Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1316)

Unified Diff: content/renderer/media/audio_device.h

Issue 8477037: Simplify AudioRendererImpl by using AudioDevice. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/media/audio_device.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/audio_device.h
===================================================================
--- content/renderer/media/audio_device.h (revision 108907)
+++ content/renderer/media/audio_device.h (working copy)
@@ -25,21 +25,23 @@
//
// Start -> InitializeOnIOThread ------> AudioHostMsg_CreateStream -------->
// <- OnLowLatencyCreated <- AudioMsg_NotifyLowLatencyStreamCreated <-
-// ---> StartOnIOThread -----------> AudioHostMsg_PlayStream -------->
+// ---> PlayOnIOThread -----------> AudioHostMsg_PlayStream -------->
//
// AudioDevice::Render => audio transport on audio thread with low latency =>
// |
// Stop --> ShutDownOnIOThread --------> AudioHostMsg_CloseStream -> Close
//
-// This class utilizes three threads during its lifetime, namely:
+// This class utilizes several threads during its lifetime, namely:
// 1. Creating thread.
-// Must be the main render thread. Start and Stop should be called on
-// this thread.
-// 2. IO 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.
+// 2. IO thread (internal implementation detail - not exposed to public API)
henrika (OOO until Aug 14) 2011/11/10 11:50:24 You still have "two 2.:s". Should be 3.
// The thread within which this class receives all the IPC messages and
// IPC communications can only happen in this thread.
// 3. Audio transport thread.
-// Responsible for calling the RenderCallback and feed audio samples to
+// Responsible for calling the RenderCallback and feeding audio samples to
// the audio layer in the browser process using sync sockets and shared
// memory.
//
@@ -60,9 +62,8 @@
#include "base/shared_memory.h"
#include "base/threading/simple_thread.h"
#include "content/renderer/media/audio_message_filter.h"
+#include "media/audio/audio_parameters.h"
-struct AudioParameters;
-
class AudioDevice
: public AudioMessageFilter::Delegate,
public base::DelegateSimpleThread::Delegate,
@@ -78,18 +79,39 @@
};
// Methods called on main render thread -------------------------------------
+
+ // Minimal constructor where Initialize() must later be called.
+ explicit AudioDevice();
+
AudioDevice(size_t buffer_size,
int channels,
double sample_rate,
RenderCallback* callback);
virtual ~AudioDevice();
+ void Initialize(size_t buffer_size,
+ int channels,
+ double sample_rate,
+ AudioParameters::Format latency_format,
+ RenderCallback* callback);
+ bool IsInitialized();
+
// Starts audio playback.
void Start();
// Stops audio playback. Returns |true| on success.
bool Stop();
+ // Resumes playback if currently paused.
+ void Play();
+
+ // Pauses playback.
+ // If |flush| is true then any pending audio which is in the pipeline
+ // (has not yet reached the hardware) will be discarded. In this case,
+ // When Play() is later called, no previous pending audio will be
+ // rendered.
+ void Pause(bool flush);
+
// Sets the playback volume, with range [0.0, 1.0] inclusive.
// Returns |true| on success.
bool SetVolume(double volume);
@@ -119,7 +141,8 @@
// be executed on that thread. They interact with AudioMessageFilter and
// sends IPC messages on that thread.
void InitializeOnIOThread(const AudioParameters& params);
- void StartOnIOThread();
+ void PlayOnIOThread();
+ void PauseOnIOThread(bool flush);
void ShutDownOnIOThread(base::WaitableEvent* completion);
void SetVolumeOnIOThread(double volume);
@@ -138,6 +161,7 @@
int channels_;
int bits_per_sample_;
double sample_rate_;
+ AudioParameters::Format latency_format_;
RenderCallback* callback_;
@@ -170,8 +194,6 @@
// of sync sockets and shared memory to provide lowest possible latency.
scoped_ptr<base::SharedMemory> shared_memory_;
scoped_ptr<base::SyncSocket> socket_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice);
};
#endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_
« no previous file with comments | « no previous file | content/renderer/media/audio_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698