summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_output_controller.h
diff options
context:
space:
mode:
authorvrk@chromium.org <vrk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 23:18:18 +0000
committervrk@chromium.org <vrk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 23:18:18 +0000
commitce31e94ba19b780f10466802d2467d5c179f470f (patch)
tree2d62a9535852c12544d4286b9b87252c83f6c401 /media/audio/audio_output_controller.h
parent1d79d09d3711a1cdd77ec5beef8d0ae304d73e50 (diff)
downloadchromium_src-ce31e94ba19b780f10466802d2467d5c179f470f.zip
chromium_src-ce31e94ba19b780f10466802d2467d5c179f470f.tar.gz
chromium_src-ce31e94ba19b780f10466802d2467d5c179f470f.tar.bz2
Remove "high"-latency audio code path
Chrome only uses the low-latency code path. This CL removes the unused, alternative "high"-latency code path. player_x11 and player_wtl use the high-latency code path, so sound is disabled from those players for now. BUG=NONE TEST=builds; content_unittests Review URL: http://codereview.chromium.org/9121062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120436 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_output_controller.h')
-rw-r--r--media/audio/audio_output_controller.h85
1 files changed, 24 insertions, 61 deletions
diff --git a/media/audio/audio_output_controller.h b/media/audio/audio_output_controller.h
index f6e5722..4105e15 100644
--- a/media/audio/audio_output_controller.h
+++ b/media/audio/audio_output_controller.h
@@ -25,14 +25,12 @@ class MessageLoop;
// An AudioOutputController controls an AudioOutputStream and provides data
// to this output stream. It has an important function that it executes
// audio operations like play, pause, stop, etc. on a separate thread,
-// namely the audio controller thread.
+// namely the audio manager thread.
//
// All the public methods of AudioOutputController are non-blocking.
-// The actual operations are performed on the audio thread.
+// The actual operations are performed on the audio manager thread.
//
-// Here is a state diagram for the AudioOutputController for default low
-// latency mode; in normal latency mode there is no "starting" or "paused when
-// starting" states, "created" immediately switches to "playing":
+// Here is a state diagram for the AudioOutputController:
//
// .-----------------------> [ Closed / Error ] <------.
// | ^ |
@@ -48,25 +46,20 @@ class MessageLoop;
//
// * Initial state
//
-// There are two modes of buffering operations supported by this class.
+// The AudioOutputStream can request data from the AudioOutputController via the
+// AudioSourceCallback interface. AudioOutputController uses the SyncReader
+// passed to it via construction to synchronously fulfill this read request.
//
-// Regular latency mode:
-// In this mode we receive signals from AudioOutputController and then we
-// enqueue data into it.
-//
-// Low latency mode:
-// In this mode a DataSource object is given to the AudioOutputController
-// and AudioOutputController reads from it synchronously.
-//
-// The audio thread itself is owned by the AudioManager that the
-// AudioOutputController holds a reference to. When performing tasks on the
-// audio thread, the controller must not add or release references to the
+// The audio manager thread is owned by the AudioManager that the
+// AudioOutputController holds a reference to. When performing tasks on this
+// thread, the controller must not add or release references to the
// AudioManager or itself (since it in turn holds a reference to the manager),
// for delayed tasks as it can slow down or even prevent normal shut down.
// So, for tasks on the audio thread, the controller uses WeakPtr which enables
// us to safely cancel pending polling tasks.
-// The owner of the audio thread, AudioManager, will take care of properly
-// shutting it down.
+//
+// AudioManager will take care of properly shutting down the audio manager
+// thread.
//
#include "media/base/media_export.h"
@@ -81,7 +74,7 @@ class MEDIA_EXPORT AudioOutputController
static const int kPauseMark;
// An event handler that receives events from the AudioOutputController. The
- // following methods are called on the audio controller thread.
+ // following methods are called on the audio manager thread.
class MEDIA_EXPORT EventHandler {
public:
virtual ~EventHandler() {}
@@ -89,12 +82,6 @@ class MEDIA_EXPORT AudioOutputController
virtual void OnPlaying(AudioOutputController* controller) = 0;
virtual void OnPaused(AudioOutputController* controller) = 0;
virtual void OnError(AudioOutputController* controller, int error_code) = 0;
-
- // Audio controller asks for more data.
- // |pending_bytes| is the number of bytes still on the controller.
- // |timestamp| is then time when |pending_bytes| is recorded.
- virtual void OnMoreData(AudioOutputController* controller,
- AudioBuffersState buffers_state) = 0;
};
// A synchronous reader interface used by AudioOutputController for
@@ -124,22 +111,13 @@ class MEDIA_EXPORT AudioOutputController
};
// Factory method for creating an AudioOutputController.
- // If successful, an audio controller thread is created. The audio device
- // will be created on the audio controller thread and when that is done
- // event handler will receive a OnCreated() call.
+ // This also creates and opens an AudioOutputStream on the audio manager
+ // thread, and if this is successful, the |event_handler| will receive an
+ // OnCreated() call from the same audio manager thread.
static scoped_refptr<AudioOutputController> Create(
AudioManager* audio_manager,
EventHandler* event_handler,
const AudioParameters& params,
- // Soft limit for buffer capacity in this controller. This parameter
- // is used only in regular latency mode.
- uint32 buffer_capacity);
-
- // Factory method for creating a low latency audio stream.
- static scoped_refptr<AudioOutputController> CreateLowLatency(
- AudioManager* audio_manager,
- EventHandler* event_handler,
- const AudioParameters& params,
// External synchronous reader for audio controller.
SyncReader* sync_reader);
@@ -156,7 +134,7 @@ class MEDIA_EXPORT AudioOutputController
void Flush();
// Closes the audio output stream. The state is changed and the resources
- // are freed on the audio thread. closed_task is executed after that.
+ // are freed on the audio manager thread. closed_task is executed after that.
// Callbacks (EventHandler and SyncReader) must exist until closed_task is
// called.
//
@@ -167,13 +145,6 @@ class MEDIA_EXPORT AudioOutputController
// Sets the volume of the audio output stream.
void SetVolume(double volume);
- // Enqueue audio |data| into the controller. This method is used only in
- // the regular latency mode and it is illegal to call this method when
- // SyncReader is present.
- void EnqueueData(const uint8* data, uint32 size);
-
- bool LowLatencyMode() const { return sync_reader_ != NULL; }
-
///////////////////////////////////////////////////////////////////////////
// AudioSourceCallback methods.
virtual uint32 OnMoreData(AudioOutputStream* stream,
@@ -206,9 +177,9 @@ class MEDIA_EXPORT AudioOutputController
AudioOutputController(AudioManager* audio_manager,
EventHandler* handler,
- uint32 capacity, SyncReader* sync_reader);
+ SyncReader* sync_reader);
- // The following methods are executed on the audio controller thread.
+ // The following methods are executed on the audio manager thread.
void DoCreate(const AudioParameters& params);
void DoPlay();
void PollAndStartIfDataReady();
@@ -218,9 +189,6 @@ class MEDIA_EXPORT AudioOutputController
void DoSetVolume(double volume);
void DoReportError(int code);
- // Helper method to submit a OnMoreData() call to the event handler.
- void SubmitOnMoreData_Locked();
-
// Helper method that starts physical stream.
void StartStream();
@@ -236,24 +204,19 @@ class MEDIA_EXPORT AudioOutputController
// The current volume of the audio stream.
double volume_;
- // |state_| is written on the audio controller thread and is read on the
+ // |state_| is written on the audio manager thread and is read on the
// hardware audio thread. These operations need to be locked. But lock
- // is not required for reading on the audio controller thread.
+ // is not required for reading on the audio manager thread.
State state_;
- AudioBuffersState buffers_state_;
-
- // The |lock_| must be acquired whenever we access |buffer_|.
+ // The |lock_| must be acquired whenever we access |state_| from a thread
+ // other than the audio manager thread.
base::Lock lock_;
- media::SeekableBuffer buffer_;
-
- bool pending_request_;
-
// SyncReader is used only in low latency mode for synchronous reading.
SyncReader* sync_reader_;
- // The message loop of audio thread that this object runs on.
+ // The message loop of audio manager thread that this object runs on.
scoped_refptr<base::MessageLoopProxy> message_loop_;
// When starting stream we wait for data to become available.