| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after 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, |
| 94 const url::Origin& security_origin); | 94 const url::Origin& security_origin); |
| 95 | 95 |
| 96 // Request authorization to use the device specified in the constructor. | 96 // RestartableAudioRendererSink implementation. |
| 97 void RequestDeviceAuthorization(); | |
| 98 | |
| 99 // AudioRendererSink implementation. | |
| 100 void Initialize(const AudioParameters& params, | 97 void Initialize(const AudioParameters& params, |
| 101 RenderCallback* callback) override; | 98 RenderCallback* callback) override; |
| 102 void Start() override; | 99 void Start() override; |
| 103 void Stop() override; | 100 void Stop() override; |
| 104 void Play() override; | 101 void Play() override; |
| 105 void Pause() override; | 102 void Pause() override; |
| 106 bool SetVolume(double volume) override; | 103 bool SetVolume(double volume) override; |
| 107 OutputDevice* GetOutputDevice() override; | 104 OutputDevice* GetOutputDevice() override; |
| 108 | 105 |
| 109 // OutputDevice implementation | 106 // OutputDevice implementation |
| 110 AudioParameters GetOutputParameters() override; | 107 AudioParameters GetOutputParameters() override; |
| 111 OutputDeviceStatus GetDeviceStatus() override; | 108 OutputDeviceStatus GetDeviceStatus() override; |
| 112 | 109 |
| 110 // Request authorization to use the device specified in the constructor. |
| 111 void RequestDeviceAuthorization(); |
| 112 |
| 113 // Methods called on IO thread ---------------------------------------------- | 113 // Methods called on IO thread ---------------------------------------------- |
| 114 // AudioOutputIPCDelegate methods. | 114 // AudioOutputIPCDelegate methods. |
| 115 void OnStateChanged(AudioOutputIPCDelegateState state) override; | 115 void OnStateChanged(AudioOutputIPCDelegateState state) override; |
| 116 void OnDeviceAuthorized(OutputDeviceStatus device_status, | 116 void OnDeviceAuthorized(OutputDeviceStatus device_status, |
| 117 const media::AudioParameters& output_params) override; | 117 const media::AudioParameters& output_params) override; |
| 118 void OnStreamCreated(base::SharedMemoryHandle handle, | 118 void OnStreamCreated(base::SharedMemoryHandle handle, |
| 119 base::SyncSocket::Handle socket_handle, | 119 base::SyncSocket::Handle socket_handle, |
| 120 int length) override; | 120 int length) override; |
| 121 void OnIPCClosed() override; | 121 void OnIPCClosed() override; |
| 122 | 122 |
| (...skipping 18 matching lines...) Expand all 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 |