| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 void Stop() override; | 102 void Stop() override; |
| 103 void Play() override; | 103 void Play() override; |
| 104 void Pause() override; | 104 void Pause() override; |
| 105 bool SetVolume(double volume) override; | 105 bool SetVolume(double volume) override; |
| 106 OutputDeviceInfo GetOutputDeviceInfo() override; | 106 OutputDeviceInfo GetOutputDeviceInfo() override; |
| 107 | 107 |
| 108 // Methods called on IO thread ---------------------------------------------- | 108 // Methods called on IO thread ---------------------------------------------- |
| 109 // AudioOutputIPCDelegate methods. | 109 // AudioOutputIPCDelegate methods. |
| 110 void OnStateChanged(AudioOutputIPCDelegateState state) override; | 110 void OnStateChanged(AudioOutputIPCDelegateState state) override; |
| 111 void OnDeviceAuthorized(OutputDeviceStatus device_status, | 111 void OnDeviceAuthorized(OutputDeviceStatus device_status, |
| 112 const media::AudioParameters& output_params) override; | 112 const media::AudioParameters& output_params, |
| 113 const std::string& matched_device_id) override; |
| 113 void OnStreamCreated(base::SharedMemoryHandle handle, | 114 void OnStreamCreated(base::SharedMemoryHandle handle, |
| 114 base::SyncSocket::Handle socket_handle, | 115 base::SyncSocket::Handle socket_handle, |
| 115 int length) override; | 116 int length) override; |
| 116 void OnIPCClosed() override; | 117 void OnIPCClosed() override; |
| 117 | 118 |
| 118 protected: | 119 protected: |
| 119 // Magic required by ref_counted.h to avoid any code deleting the object | 120 // Magic required by ref_counted.h to avoid any code deleting the object |
| 120 // accidentally while there are references to it. | 121 // accidentally while there are references to it. |
| 121 friend class base::RefCountedThreadSafe<AudioOutputDevice>; | 122 friend class base::RefCountedThreadSafe<AudioOutputDevice>; |
| 122 ~AudioOutputDevice() override; | 123 ~AudioOutputDevice() override; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 bool play_on_start_; | 169 bool play_on_start_; |
| 169 | 170 |
| 170 // The media session ID used to identify which input device to be started. | 171 // The media session ID used to identify which input device to be started. |
| 171 // Only used by Unified IO. | 172 // Only used by Unified IO. |
| 172 int session_id_; | 173 int session_id_; |
| 173 | 174 |
| 174 // ID of hardware output device to be used (provided session_id_ is zero) | 175 // ID of hardware output device to be used (provided session_id_ is zero) |
| 175 const std::string device_id_; | 176 const std::string device_id_; |
| 176 const url::Origin security_origin_; | 177 const url::Origin security_origin_; |
| 177 | 178 |
| 179 // If |device_id_| is empty and |session_id_| is not, |matched_device_id_| is |
| 180 // received in OnDeviceAuthorized(). |
| 181 std::string matched_device_id_; |
| 182 |
| 178 // Our audio thread callback class. See source file for details. | 183 // Our audio thread callback class. See source file for details. |
| 179 class AudioThreadCallback; | 184 class AudioThreadCallback; |
| 180 | 185 |
| 181 // In order to avoid a race between OnStreamCreated and Stop(), we use this | 186 // In order to avoid a race between OnStreamCreated and Stop(), we use this |
| 182 // guard to control stopping and starting the audio thread. | 187 // guard to control stopping and starting the audio thread. |
| 183 base::Lock audio_thread_lock_; | 188 base::Lock audio_thread_lock_; |
| 184 AudioDeviceThread audio_thread_; | 189 AudioDeviceThread audio_thread_; |
| 185 scoped_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_; | 190 scoped_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_; |
| 186 | 191 |
| 187 // Temporary hack to ignore OnStreamCreated() due to the user calling Stop() | 192 // Temporary hack to ignore OnStreamCreated() due to the user calling Stop() |
| 188 // so we don't start the audio thread pointing to a potentially freed | 193 // so we don't start the audio thread pointing to a potentially freed |
| 189 // |callback_|. | 194 // |callback_|. |
| 190 // | 195 // |
| 191 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept | 196 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept |
| 192 // the callback via Start(). See http://crbug.com/151051 for details. | 197 // the callback via Start(). See http://crbug.com/151051 for details. |
| 193 bool stopping_hack_; | 198 bool stopping_hack_; |
| 194 | 199 |
| 195 base::WaitableEvent did_receive_auth_; | 200 base::WaitableEvent did_receive_auth_; |
| 196 AudioParameters output_params_; | 201 AudioParameters output_params_; |
| 197 OutputDeviceStatus device_status_; | 202 OutputDeviceStatus device_status_; |
| 198 | 203 |
| 199 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); | 204 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); |
| 200 }; | 205 }; |
| 201 | 206 |
| 202 } // namespace media | 207 } // namespace media |
| 203 | 208 |
| 204 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ | 209 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ |
| OLD | NEW |