Chromium Code Reviews| Index: media/audio/audio_output_device.h |
| diff --git a/media/audio/audio_output_device.h b/media/audio/audio_output_device.h |
| index 532f45fe4a13eeb6b8b2884292e28652da3690f1..45235ee73e260b0ce71c0c7e2935da8b0264bc02 100644 |
| --- a/media/audio/audio_output_device.h |
| +++ b/media/audio/audio_output_device.h |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| // |
| +// TODO BEFORE COMMIT: Update documentation. |
| // Audio rendering unit utilizing audio output stream provided by browser |
| // process through IPC. |
| // |
| @@ -80,7 +81,8 @@ |
| namespace media { |
| class MEDIA_EXPORT AudioOutputDevice |
| - : NON_EXPORTED_BASE(public AudioRendererSink), |
| + : NON_EXPORTED_BASE(public RestartableAudioRendererSink), |
| + NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback), |
| NON_EXPORTED_BASE(public AudioOutputIPCDelegate), |
| NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { |
| public: |
| @@ -97,7 +99,7 @@ class MEDIA_EXPORT AudioOutputDevice |
| // AudioRendererSink implementation. |
| void Initialize(const AudioParameters& params, |
| - RenderCallback* callback) override; |
| + AudioRendererSink::RenderCallback* callback) override; |
| void Start() override; |
| void Stop() override; |
| void Play() override; |
| @@ -134,15 +136,24 @@ class MEDIA_EXPORT AudioOutputDevice |
| PLAYING, // Playing back. Can Pause()/Stop(). |
| }; |
| + // media::AudioRendererSink::RenderCallback implementation. |
| + // These two functions are called on the audio worker thread and passes calls |
| + // through to |callback_| if it exists. |
| + int Render(media::AudioBus* audio_bus, |
| + uint32_t frames_delayed, |
| + uint32_t frames_skipped) override; |
| + void OnRenderError() override; |
| + |
| // Methods called on IO thread ---------------------------------------------- |
| // The following methods are tasks posted on the IO thread that need to |
| // be executed on that thread. They use AudioOutputIPC to send IPC messages |
| // upon state changes. |
| void RequestDeviceAuthorizationOnIOThread(); |
| - void CreateStreamOnIOThread(const AudioParameters& params); |
| + void InitializeOnIOThread(const AudioParameters& params); |
| + void CreateStreamOnIOThread(); |
| void PlayOnIOThread(); |
| void PauseOnIOThread(); |
| - void ShutDownOnIOThread(); |
| + void StopOnIOThread(); |
| void SetVolumeOnIOThread(double volume); |
| // base::MessageLoop::DestructionObserver implementation for the IO loop. |
| @@ -151,7 +162,8 @@ class MEDIA_EXPORT AudioOutputDevice |
| AudioParameters audio_parameters_; |
| - RenderCallback* callback_; |
| + base::Lock callback_lock_; |
| + AudioRendererSink::RenderCallback* callback_; |
|
o1ka
2016/05/03 15:47:32
Probably store it as atomic word => get rid of the
Henrik Grunell
2016/05/04 09:05:12
We need to hold on to a lock while calling e.g. Re
|
| // A pointer to the IPC layer that takes care of sending requests over to |
| // the AudioRendererHost. Only valid when state_ != IPC_CLOSED and must only |
| @@ -183,20 +195,10 @@ class MEDIA_EXPORT AudioOutputDevice |
| // Our audio thread callback class. See source file for details. |
| class AudioThreadCallback; |
| - // In order to avoid a race between OnStreamCreated and Stop(), we use this |
| - // guard to control stopping and starting the audio thread. |
| - base::Lock audio_thread_lock_; |
| + // The audio thread implementation. |
| AudioDeviceThread audio_thread_; |
| std::unique_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_; |
|
o1ka
2016/05/03 15:47:32
Could we probably rename "callback_" into "render_
Henrik Grunell
2016/05/04 09:05:12
Good idea. Done.
|
| - // Temporary hack to ignore OnStreamCreated() due to the user calling Stop() |
| - // so we don't start the audio thread pointing to a potentially freed |
| - // |callback_|. |
| - // |
| - // TODO(scherkus): Replace this by changing AudioRendererSink to either accept |
| - // the callback via Start(). See http://crbug.com/151051 for details. |
| - bool stopping_hack_; |
| - |
| base::WaitableEvent did_receive_auth_; |
| AudioParameters output_params_; |
| OutputDeviceStatus device_status_; |