| Index: media/audio/audio_output_device.h
|
| diff --git a/media/audio/audio_output_device.h b/media/audio/audio_output_device.h
|
| index c0faacd11517fab6c80e168a0c433b627dfb5561..4d49fd0a654c694f149f9118af69741cd3437f7d 100644
|
| --- a/media/audio/audio_output_device.h
|
| +++ b/media/audio/audio_output_device.h
|
| @@ -45,8 +45,8 @@
|
| // 1. Creating thread.
|
| // Must be the main render thread.
|
| // 2. Control thread (may be the main render thread or another thread).
|
| -// The methods: Start(), Stop(), Play(), Pause(), SetVolume()
|
| -// must be called on the same thread.
|
| +// The methods Initialize(), Start(), and Stop() must be called on the same
|
| +// thread.
|
| // 3. IO thread (internal implementation detail - not exposed to public API)
|
| // The thread within which this class receives all the IPC messages and
|
| // IPC communications can only happen in this thread.
|
| @@ -56,8 +56,7 @@
|
| // the audio layer in the browser process using sync sockets and shared
|
| // memory.
|
| //
|
| -// Implementation notes:
|
| -// - The user must call Stop() before deleting the class instance.
|
| +// NOTE: The user must call Stop() before deleting the class instance.
|
|
|
| #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_
|
| #define MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_
|
| @@ -69,6 +68,7 @@
|
| #include "base/macros.h"
|
| #include "base/memory/shared_memory.h"
|
| #include "base/synchronization/waitable_event.h"
|
| +#include "base/threading/thread_checker.h"
|
| #include "media/audio/audio_device_thread.h"
|
| #include "media/audio/audio_output_ipc.h"
|
| #include "media/audio/scoped_task_runner_observer.h"
|
| @@ -84,7 +84,7 @@ class OneShotTimer;
|
| namespace media {
|
|
|
| class MEDIA_EXPORT AudioOutputDevice
|
| - : NON_EXPORTED_BASE(public AudioRendererSink),
|
| + : NON_EXPORTED_BASE(public RestartableAudioRendererSink),
|
| NON_EXPORTED_BASE(public AudioOutputIPCDelegate),
|
| NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) {
|
| public:
|
| @@ -102,7 +102,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;
|
| @@ -144,10 +144,10 @@ class MEDIA_EXPORT AudioOutputDevice
|
| // be executed on that thread. They use AudioOutputIPC to send IPC messages
|
| // upon state changes.
|
| void RequestDeviceAuthorizationOnIOThread();
|
| - void CreateStreamOnIOThread(const AudioParameters& params);
|
| + void CreateStreamOnIOThread();
|
| void PlayOnIOThread();
|
| void PauseOnIOThread();
|
| - void ShutDownOnIOThread();
|
| + void StopOnIOThread();
|
| void SetVolumeOnIOThread(double volume);
|
|
|
| // Process device authorization result on the IO thread.
|
| @@ -161,9 +161,10 @@ class MEDIA_EXPORT AudioOutputDevice
|
| // If the IO loop dies before we do, we shut down the audio thread from here.
|
| void WillDestroyCurrentMessageLoop() override;
|
|
|
| - AudioParameters audio_parameters_;
|
| + // Reports error to |render_callback_|.
|
| + void ReportRenderError();
|
|
|
| - RenderCallback* callback_;
|
| + AudioParameters audio_parameters_;
|
|
|
| // 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
|
| @@ -195,11 +196,17 @@ 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_;
|
| + // This lock is used in order to:
|
| + // (1) Avoid a race between OnStreamCreated() and Stop(). We use this guard to
|
| + // control stopping and starting the audio thread.
|
| + // (2) Protect |render_callback_|.
|
| + base::Lock lock_;
|
| +
|
| AudioDeviceThread audio_thread_;
|
| - std::unique_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_;
|
| + std::unique_ptr<AudioOutputDevice::AudioThreadCallback>
|
| + audio_thread_callback_;
|
| +
|
| + RenderCallback* render_callback_;
|
|
|
| // Temporary hack to ignore OnStreamCreated() due to the user calling Stop()
|
| // so we don't start the audio thread pointing to a potentially freed
|
| @@ -216,6 +223,8 @@ class MEDIA_EXPORT AudioOutputDevice
|
| const base::TimeDelta auth_timeout_;
|
| std::unique_ptr<base::OneShotTimer> auth_timeout_action_;
|
|
|
| + base::ThreadChecker control_thread_checker_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice);
|
| };
|
|
|
|
|