diff options
Diffstat (limited to 'chromium/media/audio/audio_output_device.h')
-rw-r--r-- | chromium/media/audio/audio_output_device.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/chromium/media/audio/audio_output_device.h b/chromium/media/audio/audio_output_device.h index 43f95ae46f2..fd42339c084 100644 --- a/chromium/media/audio/audio_output_device.h +++ b/chromium/media/audio/audio_output_device.h @@ -17,7 +17,8 @@ // is done by using shared memory in combination with a sync socket pair // to generate a low latency transport. The AudioOutputDevice user registers an // AudioOutputDevice::RenderCallback at construction and will be polled by the -// AudioOutputDevice for audio to be played out by the underlying audio layers. +// AudioOutputController for audio to be played out by the underlying audio +// layers. // // State sequences. // @@ -51,10 +52,10 @@ // The thread within which this class receives all the IPC messages and // IPC communications can only happen in this thread. // 4. Audio transport thread (See AudioDeviceThread). -// Responsible for calling the AudioThreadCallback implementation that in -// turn calls AudioRendererSink::RenderCallback which feeds audio samples to -// the audio layer in the browser process using sync sockets and shared -// memory. +// Responsible for calling the AudioOutputDeviceThreadCallback +// implementation that in turn calls AudioRendererSink::RenderCallback +// which feeds audio samples to 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. @@ -67,7 +68,7 @@ #include "base/bind.h" #include "base/macros.h" -#include "base/memory/shared_memory.h" +#include "base/memory/unsafe_shared_memory_region.h" #include "base/synchronization/waitable_event.h" #include "base/time/time.h" #include "media/audio/audio_device_thread.h" @@ -83,6 +84,7 @@ class SingleThreadTaskRunner; } namespace media { +class AudioOutputDeviceThreadCallback; class MEDIA_EXPORT AudioOutputDevice : public AudioRendererSink, public AudioOutputIPCDelegate { @@ -114,9 +116,9 @@ class MEDIA_EXPORT AudioOutputDevice : public AudioRendererSink, // AudioOutputIPCDelegate methods. void OnError() override; void OnDeviceAuthorized(OutputDeviceStatus device_status, - const media::AudioParameters& output_params, + const AudioParameters& output_params, const std::string& matched_device_id) override; - void OnStreamCreated(base::SharedMemoryHandle handle, + void OnStreamCreated(base::UnsafeSharedMemoryRegion shared_memory_region, base::SyncSocket::Handle socket_handle, bool play_automatically) override; void OnIPCClosed() override; @@ -136,6 +138,16 @@ class MEDIA_EXPORT AudioOutputDevice : public AudioRendererSink, // request. Can Play()/Pause()/Stop(). }; + // This enum is used for UMA, so the only allowed operation on this definition + // is to add new states to the bottom, update kMaxValue, and update the + // histogram "Media.Audio.Render.StreamCallbackError2". + enum Error { + kNoError = 0, + kErrorDuringCreation = 1, + kErrorDuringRendering = 2, + kMaxValue = kErrorDuringRendering + }; + // 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 @@ -152,7 +164,7 @@ class MEDIA_EXPORT AudioOutputDevice : public AudioRendererSink, // Process device authorization result on the IO thread. void ProcessDeviceAuthorizationOnIOThread( OutputDeviceStatus device_status, - const media::AudioParameters& output_params, + const AudioParameters& output_params, const std::string& matched_device_id, bool timed_out); @@ -173,7 +185,7 @@ class MEDIA_EXPORT AudioOutputDevice : public AudioRendererSink, StartupState state_; // For UMA stats. May only be accessed on the IO thread. - bool had_callback_error_ = false; + Error had_error_ = kNoError; // Last set volume. double volume_ = 1.0; @@ -189,13 +201,10 @@ class MEDIA_EXPORT AudioOutputDevice : public AudioRendererSink, // received in OnDeviceAuthorized(). std::string matched_device_id_; - // 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_; - std::unique_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_; + std::unique_ptr<AudioOutputDeviceThreadCallback> audio_callback_; std::unique_ptr<AudioDeviceThread> audio_thread_; // Temporary hack to ignore OnStreamCreated() due to the user calling Stop() |