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

Unified Diff: media/filters/audio_renderer_base.h

Issue 160005: Implemented proper pause-then-seek behaviour for the media pipeline. (Closed)
Patch Set: yay Created 11 years, 5 months 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 | « media/base/pipeline_impl_unittest.cc ('k') | media/filters/audio_renderer_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/audio_renderer_base.h
diff --git a/media/filters/audio_renderer_base.h b/media/filters/audio_renderer_base.h
index 3d314746a4ea0874f3abf5e6f901f6b4e1274b28..fa6dba6eaa74dd64c4854d99de512051dcb83f05 100644
--- a/media/filters/audio_renderer_base.h
+++ b/media/filters/audio_renderer_base.h
@@ -30,6 +30,8 @@ namespace media {
class AudioRendererBase : public AudioRenderer {
public:
// MediaFilter implementation.
+ virtual void Play(FilterCallback* callback);
+ virtual void Pause(FilterCallback* callback);
virtual void Stop();
virtual void Seek(base::TimeDelta time, FilterCallback* callback);
@@ -54,7 +56,8 @@ class AudioRendererBase : public AudioRenderer {
// this time, such as stopping any running threads.
virtual void OnStop() = 0;
- // Called when a AudioDecoder::Read() completes.
+ // Called when a AudioDecoder::Read() completes and decrements
+ // |pending_reads_|.
virtual void OnReadComplete(Buffer* buffer_in);
// Fills the given buffer with audio data by dequeuing buffers and copying the
@@ -87,10 +90,11 @@ class AudioRendererBase : public AudioRenderer {
int* sample_bits_out);
private:
- // Helper method that schedules an asynchronous read from the decoder.
+ // Helper method that schedules an asynchronous read from the decoder and
+ // increments |pending_reads_|.
//
// Safe to call from any thread.
- void ScheduleRead();
+ void ScheduleRead_Locked();
// Audio decoder.
scoped_refptr<AudioDecoder> decoder_;
@@ -106,18 +110,31 @@ class AudioRendererBase : public AudioRenderer {
// Remembers the amount of remaining audio data for the front buffer.
size_t data_offset_;
- // Whether or not we're initialized.
- bool initialized_;
-
- // Whether or not we've stopped.
- bool stopped_;
+ // Simple state tracking variable.
+ enum State {
+ kUninitialized,
+ kPaused,
+ kSeeking,
+ kPlaying,
+ kStopped,
+ kError,
+ };
+ State state_;
+
+ // Keeps track of our pending reads. We *must* have no pending reads before
+ // executing the pause callback, otherwise we breach the contract that all
+ // filters are idling.
+ //
+ // We use size_t since we compare against std::deque::size().
+ size_t pending_reads_;
// Audio time at end of last call to FillBuffer().
// TODO(ralphl): Update this value after seeking.
base::TimeDelta last_fill_buffer_time_;
// Filter callbacks.
- scoped_ptr<FilterCallback> initialize_callback_;
+ scoped_ptr<FilterCallback> pause_callback_;
+ scoped_ptr<FilterCallback> seek_callback_;
DISALLOW_COPY_AND_ASSIGN(AudioRendererBase);
};
« no previous file with comments | « media/base/pipeline_impl_unittest.cc ('k') | media/filters/audio_renderer_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698