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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 #include "base/memory/shared_memory.h" | 70 #include "base/memory/shared_memory.h" |
71 #include "base/synchronization/waitable_event.h" | 71 #include "base/synchronization/waitable_event.h" |
72 #include "media/audio/audio_device_thread.h" | 72 #include "media/audio/audio_device_thread.h" |
73 #include "media/audio/audio_output_ipc.h" | 73 #include "media/audio/audio_output_ipc.h" |
74 #include "media/audio/scoped_task_runner_observer.h" | 74 #include "media/audio/scoped_task_runner_observer.h" |
75 #include "media/base/audio_parameters.h" | 75 #include "media/base/audio_parameters.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_info.h" | 78 #include "media/base/output_device_info.h" |
79 | 79 |
| 80 namespace base { |
| 81 class OneShotTimer; |
| 82 } |
| 83 |
80 namespace media { | 84 namespace media { |
81 | 85 |
82 class MEDIA_EXPORT AudioOutputDevice | 86 class MEDIA_EXPORT AudioOutputDevice |
83 : NON_EXPORTED_BASE(public AudioRendererSink), | 87 : NON_EXPORTED_BASE(public AudioRendererSink), |
84 NON_EXPORTED_BASE(public AudioOutputIPCDelegate), | 88 NON_EXPORTED_BASE(public AudioOutputIPCDelegate), |
85 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { | 89 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { |
86 public: | 90 public: |
87 // NOTE: Clients must call Initialize() before using. | 91 // NOTE: Clients must call Initialize() before using. |
88 AudioOutputDevice( | 92 AudioOutputDevice( |
89 std::unique_ptr<AudioOutputIPC> ipc, | 93 std::unique_ptr<AudioOutputIPC> ipc, |
90 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 94 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
91 int session_id, | 95 int session_id, |
92 const std::string& device_id, | 96 const std::string& device_id, |
93 const url::Origin& security_origin); | 97 const url::Origin& security_origin, |
| 98 base::TimeDelta authorization_timeout); |
94 | 99 |
95 // Request authorization to use the device specified in the constructor. | 100 // Request authorization to use the device specified in the constructor. |
96 void RequestDeviceAuthorization(); | 101 void RequestDeviceAuthorization(); |
97 | 102 |
98 // AudioRendererSink implementation. | 103 // AudioRendererSink implementation. |
99 void Initialize(const AudioParameters& params, | 104 void Initialize(const AudioParameters& params, |
100 RenderCallback* callback) override; | 105 RenderCallback* callback) override; |
101 void Start() override; | 106 void Start() override; |
102 void Stop() override; | 107 void Stop() override; |
103 void Play() override; | 108 void Play() override; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // The following methods are tasks posted on the IO thread that need to | 143 // The following methods are tasks posted on the IO thread that need to |
139 // be executed on that thread. They use AudioOutputIPC to send IPC messages | 144 // be executed on that thread. They use AudioOutputIPC to send IPC messages |
140 // upon state changes. | 145 // upon state changes. |
141 void RequestDeviceAuthorizationOnIOThread(); | 146 void RequestDeviceAuthorizationOnIOThread(); |
142 void CreateStreamOnIOThread(const AudioParameters& params); | 147 void CreateStreamOnIOThread(const AudioParameters& params); |
143 void PlayOnIOThread(); | 148 void PlayOnIOThread(); |
144 void PauseOnIOThread(); | 149 void PauseOnIOThread(); |
145 void ShutDownOnIOThread(); | 150 void ShutDownOnIOThread(); |
146 void SetVolumeOnIOThread(double volume); | 151 void SetVolumeOnIOThread(double volume); |
147 | 152 |
| 153 // Process device authorization result on the IO thread. |
| 154 void ProcessDeviceAuthorizationOnIOThread( |
| 155 OutputDeviceStatus device_status, |
| 156 const media::AudioParameters& output_params, |
| 157 const std::string& matched_device_id, |
| 158 bool timed_out); |
| 159 |
148 // base::MessageLoop::DestructionObserver implementation for the IO loop. | 160 // base::MessageLoop::DestructionObserver implementation for the IO loop. |
149 // If the IO loop dies before we do, we shut down the audio thread from here. | 161 // If the IO loop dies before we do, we shut down the audio thread from here. |
150 void WillDestroyCurrentMessageLoop() override; | 162 void WillDestroyCurrentMessageLoop() override; |
151 | 163 |
152 AudioParameters audio_parameters_; | 164 AudioParameters audio_parameters_; |
153 | 165 |
154 RenderCallback* callback_; | 166 RenderCallback* callback_; |
155 | 167 |
156 // A pointer to the IPC layer that takes care of sending requests over to | 168 // A pointer to the IPC layer that takes care of sending requests over to |
157 // the AudioRendererHost. Only valid when state_ != IPC_CLOSED and must only | 169 // the AudioRendererHost. Only valid when state_ != IPC_CLOSED and must only |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // |callback_|. | 206 // |callback_|. |
195 // | 207 // |
196 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept | 208 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept |
197 // the callback via Start(). See http://crbug.com/151051 for details. | 209 // the callback via Start(). See http://crbug.com/151051 for details. |
198 bool stopping_hack_; | 210 bool stopping_hack_; |
199 | 211 |
200 base::WaitableEvent did_receive_auth_; | 212 base::WaitableEvent did_receive_auth_; |
201 AudioParameters output_params_; | 213 AudioParameters output_params_; |
202 OutputDeviceStatus device_status_; | 214 OutputDeviceStatus device_status_; |
203 | 215 |
| 216 const base::TimeDelta auth_timeout_; |
| 217 std::unique_ptr<base::OneShotTimer> auth_timeout_action_; |
| 218 |
204 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); | 219 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); |
205 }; | 220 }; |
206 | 221 |
207 } // namespace media | 222 } // namespace media |
208 | 223 |
209 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ | 224 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ |
OLD | NEW |