OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Audio rendering unit utilizing audio output stream provided by browser | 5 // Audio rendering unit utilizing audio output stream provided by browser |
6 // process through IPC. | 6 // process through IPC. |
7 // | 7 // |
8 // Relationship of classes. | 8 // Relationship of classes. |
9 // | 9 // |
10 // AudioOutputController AudioDevice | 10 // AudioOutputController AudioDevice |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #include "base/memory/scoped_ptr.h" | 69 #include "base/memory/scoped_ptr.h" |
70 #include "base/message_loop.h" | 70 #include "base/message_loop.h" |
71 #include "base/shared_memory.h" | 71 #include "base/shared_memory.h" |
72 #include "content/common/content_export.h" | 72 #include "content/common/content_export.h" |
73 #include "content/renderer/media/audio_device_thread.h" | 73 #include "content/renderer/media/audio_device_thread.h" |
74 #include "content/renderer/media/audio_message_filter.h" | 74 #include "content/renderer/media/audio_message_filter.h" |
75 #include "content/renderer/media/scoped_loop_observer.h" | 75 #include "content/renderer/media/scoped_loop_observer.h" |
76 #include "media/audio/audio_parameters.h" | 76 #include "media/audio/audio_parameters.h" |
77 #include "media/base/audio_renderer_sink.h" | 77 #include "media/base/audio_renderer_sink.h" |
78 | 78 |
79 namespace media { | |
80 class AudioParameters; | |
81 } | |
82 | |
83 class CONTENT_EXPORT AudioDevice | 79 class CONTENT_EXPORT AudioDevice |
84 : NON_EXPORTED_BASE(public media::AudioRendererSink), | 80 : NON_EXPORTED_BASE(public media::AudioRendererSink), |
85 public AudioMessageFilter::Delegate, | 81 public AudioMessageFilter::Delegate, |
86 NON_EXPORTED_BASE(public ScopedLoopObserver) { | 82 NON_EXPORTED_BASE(public ScopedLoopObserver) { |
87 public: | 83 public: |
88 // Methods called on main render thread ------------------------------------- | 84 // Methods called on main render thread ------------------------------------- |
89 | 85 |
90 // Minimal constructor where Initialize() must be called later. | 86 // Minimal constructor where Initialize() must be called later. |
91 AudioDevice(); | 87 AudioDevice(); |
92 | 88 |
93 AudioDevice(const media::AudioParameters& params, RenderCallback* callback); | 89 AudioDevice(const AudioParameters& params, RenderCallback* callback); |
94 | 90 |
95 // AudioRendererSink implementation. | 91 // AudioRendererSink implementation. |
96 | 92 |
97 virtual void Initialize(const media::AudioParameters& params, | 93 virtual void Initialize(const AudioParameters& params, |
98 RenderCallback* callback) OVERRIDE; | 94 RenderCallback* callback) OVERRIDE; |
99 // Starts audio playback. | 95 // Starts audio playback. |
100 virtual void Start() OVERRIDE; | 96 virtual void Start() OVERRIDE; |
101 | 97 |
102 // Stops audio playback. | 98 // Stops audio playback. |
103 virtual void Stop() OVERRIDE; | 99 virtual void Stop() OVERRIDE; |
104 | 100 |
105 // Resumes playback if currently paused. | 101 // Resumes playback if currently paused. |
106 virtual void Play() OVERRIDE; | 102 virtual void Play() OVERRIDE; |
107 | 103 |
(...skipping 21 matching lines...) Expand all Loading... |
129 private: | 125 private: |
130 // Magic required by ref_counted.h to avoid any code deleting the object | 126 // Magic required by ref_counted.h to avoid any code deleting the object |
131 // accidentally while there are references to it. | 127 // accidentally while there are references to it. |
132 friend class base::RefCountedThreadSafe<AudioDevice>; | 128 friend class base::RefCountedThreadSafe<AudioDevice>; |
133 virtual ~AudioDevice(); | 129 virtual ~AudioDevice(); |
134 | 130 |
135 // Methods called on IO thread ---------------------------------------------- | 131 // Methods called on IO thread ---------------------------------------------- |
136 // The following methods are tasks posted on the IO thread that needs to | 132 // The following methods are tasks posted on the IO thread that needs to |
137 // be executed on that thread. They interact with AudioMessageFilter and | 133 // be executed on that thread. They interact with AudioMessageFilter and |
138 // sends IPC messages on that thread. | 134 // sends IPC messages on that thread. |
139 void InitializeOnIOThread(const media::AudioParameters& params); | 135 void InitializeOnIOThread(const AudioParameters& params); |
140 void PlayOnIOThread(); | 136 void PlayOnIOThread(); |
141 void PauseOnIOThread(bool flush); | 137 void PauseOnIOThread(bool flush); |
142 void ShutDownOnIOThread(); | 138 void ShutDownOnIOThread(); |
143 void SetVolumeOnIOThread(double volume); | 139 void SetVolumeOnIOThread(double volume); |
144 | 140 |
145 void Send(IPC::Message* message); | 141 void Send(IPC::Message* message); |
146 | 142 |
147 // MessageLoop::DestructionObserver implementation for the IO loop. | 143 // MessageLoop::DestructionObserver implementation for the IO loop. |
148 // If the IO loop dies before we do, we shut down the audio thread from here. | 144 // If the IO loop dies before we do, we shut down the audio thread from here. |
149 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 145 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
150 | 146 |
151 media::AudioParameters audio_parameters_; | 147 AudioParameters audio_parameters_; |
152 | 148 |
153 RenderCallback* callback_; | 149 RenderCallback* callback_; |
154 | 150 |
155 // The current volume scaling [0.0, 1.0] of the audio stream. | 151 // The current volume scaling [0.0, 1.0] of the audio stream. |
156 double volume_; | 152 double volume_; |
157 | 153 |
158 // Cached audio message filter (lives on the main render thread). | 154 // Cached audio message filter (lives on the main render thread). |
159 scoped_refptr<AudioMessageFilter> filter_; | 155 scoped_refptr<AudioMessageFilter> filter_; |
160 | 156 |
161 // Our stream ID on the message filter. Only accessed on the IO thread. | 157 // Our stream ID on the message filter. Only accessed on the IO thread. |
(...skipping 16 matching lines...) Expand all Loading... |
178 // guard to control stopping and starting the audio thread. | 174 // guard to control stopping and starting the audio thread. |
179 base::Lock audio_thread_lock_; | 175 base::Lock audio_thread_lock_; |
180 AudioDeviceThread audio_thread_; | 176 AudioDeviceThread audio_thread_; |
181 scoped_ptr<AudioDevice::AudioThreadCallback> audio_callback_; | 177 scoped_ptr<AudioDevice::AudioThreadCallback> audio_callback_; |
182 | 178 |
183 | 179 |
184 DISALLOW_COPY_AND_ASSIGN(AudioDevice); | 180 DISALLOW_COPY_AND_ASSIGN(AudioDevice); |
185 }; | 181 }; |
186 | 182 |
187 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ | 183 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ |
OLD | NEW |