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

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') | content/renderer/media/audio_device.cc » ('J')
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 107169)
+++ content/renderer/media/audio_device.h (working copy)
@@ -25,21 +25,23 @@
//
// Start -> InitializeOnIOThread ------> AudioHostMsg_CreateStream -------->
henrika (OOO until Aug 14) 2011/11/09 17:05:22 Care to add similar sequence for Play/Resume to cl
Chris Rogers 2011/11/15 22:48:29 Good idea - DONE On 2011/11/09 17:05:22, henrika1
// <- 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)
acolwell GONE FROM CHROMIUM 2011/11/08 21:44:20 Change the second 2. to a 3. and update the 3. bel
Chris Rogers 2011/11/15 22:48:29 Done.
// 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,38 @@
};
// Methods called on main render thread -------------------------------------
+
+ // Minimal constructor where Initialize() must later be called.
+ explicit AudioDevice(RenderCallback* callback);
acolwell GONE FROM CHROMIUM 2011/11/08 21:44:20 Why not pass this callback in Initialize()? Is it
Chris Rogers 2011/11/15 22:48:29 Done.
+
AudioDevice(size_t buffer_size,
acolwell GONE FROM CHROMIUM 2011/11/08 21:44:20 How about we remove this constructor so all AudioD
Chris Rogers 2011/11/10 02:17:22 Henrik any thoughts here? My feeling is that in t
acolwell GONE FROM CHROMIUM 2011/11/10 21:58:15 I guess I'm looking for consistency between use ca
Chris Rogers 2011/11/15 22:48:29 I definitely agree that it would be nice to defer
int channels,
double sample_rate,
RenderCallback* callback);
virtual ~AudioDevice();
+ void Initialize(size_t buffer_size,
acolwell GONE FROM CHROMIUM 2011/11/08 21:44:20 Any reason we can't just make this an int?
Chris Rogers 2011/11/10 02:17:22 I'm just following the type we are currently using
+ int channels,
+ double sample_rate,
+ AudioParameters::Format latency_format);
+ bool IsInitialized();
+
// Starts audio playback.
void Start();
// Stops audio playback. Returns |true| on success.
bool Stop();
+ // Resumes playback if currently paused.
+ void Play();
acolwell GONE FROM CHROMIUM 2011/11/08 21:44:20 Why do we need Start()/Stop() AND Play()/Pause()?
henrika (OOO until Aug 14) 2011/11/09 17:05:22 If it is intended to resume, then why not call it
Chris Rogers 2011/11/10 02:17:22 The intention is to closely follow the existing lo
henrika (OOO until Aug 14) 2011/11/10 11:45:07 I am fine with trying to mimic the existing AudioR
Chris Rogers 2011/11/15 22:48:29 I've added a TODO(crogers) for Play()/Pause() desc
+
+ // 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 +140,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 +160,7 @@
int channels_;
int bits_per_sample_;
double sample_rate_;
+ AudioParameters::Format latency_format_;
RenderCallback* callback_;
« no previous file with comments | « no previous file | content/renderer/media/audio_device.cc » ('j') | content/renderer/media/audio_device.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698