Chromium Code Reviews| 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 AudioOutputDevice | 10 // AudioOutputController AudioOutputDevice |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 // OnStreamCreated are deferred until OnStreamCreated, with the last valid | 37 // OnStreamCreated are deferred until OnStreamCreated, with the last valid |
| 38 // state being used) | 38 // state being used) |
| 39 // | 39 // |
| 40 // AudioOutputDevice::Render => audio transport on audio thread => | 40 // AudioOutputDevice::Render => audio transport on audio thread => |
| 41 // | | 41 // | |
| 42 // Stop --> ShutDownOnIOThread --------> CloseStream -> Close | 42 // Stop --> ShutDownOnIOThread --------> CloseStream -> Close |
| 43 // | 43 // |
| 44 // This class utilizes several threads during its lifetime, namely: | 44 // This class utilizes several threads during its lifetime, namely: |
| 45 // 1. Creating thread. | 45 // 1. Creating thread. |
| 46 // Must be the main render thread. | 46 // Must be the main render thread. |
| 47 // 2. Control thread (may be the main render thread or another thread). | 47 // 2. Control thread (may be the main render thread or another thread). |
|
Henrik Grunell
2016/03/31 09:01:37
Hmm, "Start(), Stop(), Play(), Pause(), SetVolume(
Henrik Grunell
2016/05/09 12:13:37
This comment is obsolete. For example, Pause() is
| |
| 48 // The methods: Start(), Stop(), Play(), Pause(), SetVolume() | 48 // The methods: Start(), Stop(), Play(), Pause(), SetVolume() |
| 49 // must be called on the same thread. | 49 // must be called on the same thread. |
| 50 // 3. IO thread (internal implementation detail - not exposed to public API) | 50 // 3. IO thread (internal implementation detail - not exposed to public API) |
| 51 // The thread within which this class receives all the IPC messages and | 51 // The thread within which this class receives all the IPC messages and |
| 52 // IPC communications can only happen in this thread. | 52 // IPC communications can only happen in this thread. |
| 53 // 4. Audio transport thread (See AudioDeviceThread). | 53 // 4. Audio transport thread (See AudioDeviceThread). |
| 54 // Responsible for calling the AudioThreadCallback implementation that in | 54 // Responsible for calling the AudioThreadCallback implementation that in |
| 55 // turn calls AudioRendererSink::RenderCallback which feeds audio samples to | 55 // turn calls AudioRendererSink::RenderCallback which feeds audio samples to |
| 56 // the audio layer in the browser process using sync sockets and shared | 56 // the audio layer in the browser process using sync sockets and shared |
| 57 // memory. | 57 // memory. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 73 #include "media/audio/audio_output_ipc.h" | 73 #include "media/audio/audio_output_ipc.h" |
| 74 #include "media/audio/audio_parameters.h" | 74 #include "media/audio/audio_parameters.h" |
| 75 #include "media/audio/scoped_task_runner_observer.h" | 75 #include "media/audio/scoped_task_runner_observer.h" |
| 76 #include "media/base/audio_renderer_sink.h" | 76 #include "media/base/audio_renderer_sink.h" |
| 77 #include "media/base/media_export.h" | 77 #include "media/base/media_export.h" |
| 78 #include "media/base/output_device.h" | 78 #include "media/base/output_device.h" |
| 79 | 79 |
| 80 namespace media { | 80 namespace media { |
| 81 | 81 |
| 82 class MEDIA_EXPORT AudioOutputDevice | 82 class MEDIA_EXPORT AudioOutputDevice |
| 83 : NON_EXPORTED_BASE(public AudioRendererSink), | 83 : NON_EXPORTED_BASE(public RestartableAudioRendererSink), |
| 84 NON_EXPORTED_BASE(public AudioOutputIPCDelegate), | 84 NON_EXPORTED_BASE(public AudioOutputIPCDelegate), |
| 85 NON_EXPORTED_BASE(public OutputDevice), | 85 NON_EXPORTED_BASE(public OutputDevice), |
| 86 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { | 86 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { |
| 87 public: | 87 public: |
| 88 // NOTE: Clients must call Initialize() before using. | 88 // NOTE: Clients must call Initialize() before using. |
| 89 AudioOutputDevice( | 89 AudioOutputDevice( |
| 90 scoped_ptr<AudioOutputIPC> ipc, | 90 scoped_ptr<AudioOutputIPC> ipc, |
| 91 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 91 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 92 int session_id, | 92 int session_id, |
| 93 const std::string& device_id, | 93 const std::string& device_id, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 // Unsupported OutputDevice implementation | 141 // Unsupported OutputDevice implementation |
| 142 void SwitchOutputDevice(const std::string& device_id, | 142 void SwitchOutputDevice(const std::string& device_id, |
| 143 const url::Origin& security_origin, | 143 const url::Origin& security_origin, |
| 144 const SwitchOutputDeviceCB& callback) override; | 144 const SwitchOutputDeviceCB& callback) override; |
| 145 | 145 |
| 146 // Methods called on IO thread ---------------------------------------------- | 146 // Methods called on IO thread ---------------------------------------------- |
| 147 // The following methods are tasks posted on the IO thread that need to | 147 // The following methods are tasks posted on the IO thread that need to |
| 148 // be executed on that thread. They use AudioOutputIPC to send IPC messages | 148 // be executed on that thread. They use AudioOutputIPC to send IPC messages |
| 149 // upon state changes. | 149 // upon state changes. |
| 150 void RequestDeviceAuthorizationOnIOThread(); | 150 void RequestDeviceAuthorizationOnIOThread(); |
| 151 void CreateStreamOnIOThread(const AudioParameters& params); | 151 void InitializeOnIOThread(const AudioParameters& params, |
| 152 RenderCallback* callback); | |
| 153 void CreateStreamOnIOThread(); | |
| 152 void PlayOnIOThread(); | 154 void PlayOnIOThread(); |
| 153 void PauseOnIOThread(); | 155 void PauseOnIOThread(); |
| 154 void ShutDownOnIOThread(); | 156 void StopOnIOThread(); |
| 155 void SetVolumeOnIOThread(double volume); | 157 void SetVolumeOnIOThread(double volume); |
| 156 | 158 |
| 157 // base::MessageLoop::DestructionObserver implementation for the IO loop. | 159 // base::MessageLoop::DestructionObserver implementation for the IO loop. |
| 158 // If the IO loop dies before we do, we shut down the audio thread from here. | 160 // If the IO loop dies before we do, we shut down the audio thread from here. |
| 159 void WillDestroyCurrentMessageLoop() override; | 161 void WillDestroyCurrentMessageLoop() override; |
| 160 | 162 |
| 161 AudioParameters audio_parameters_; | 163 AudioParameters audio_parameters_; |
| 162 | 164 |
| 163 RenderCallback* callback_; | 165 RenderCallback* callback_; |
| 164 | 166 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 base::WaitableEvent did_receive_auth_; | 207 base::WaitableEvent did_receive_auth_; |
| 206 media::AudioParameters output_params_; | 208 media::AudioParameters output_params_; |
| 207 OutputDeviceStatus device_status_; | 209 OutputDeviceStatus device_status_; |
| 208 | 210 |
| 209 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); | 211 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); |
| 210 }; | 212 }; |
| 211 | 213 |
| 212 } // namespace media | 214 } // namespace media |
| 213 | 215 |
| 214 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ | 216 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ |
| OLD | NEW |