summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_output_controller.h
diff options
context:
space:
mode:
Diffstat (limited to 'media/audio/audio_output_controller.h')
-rw-r--r--media/audio/audio_output_controller.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/media/audio/audio_output_controller.h b/media/audio/audio_output_controller.h
index 88c4e06..2c2246b 100644
--- a/media/audio/audio_output_controller.h
+++ b/media/audio/audio_output_controller.h
@@ -103,6 +103,13 @@ class MEDIA_EXPORT AudioOutputController
// Close this synchronous reader.
virtual void Close() = 0;
+
+ // Poll if data is ready.
+ // Not reliable, as there is no guarantee that renderer is "new-style"
+ // renderer that writes metadata into buffer. After several unsuccessful
+ // attempts caller should assume the data is ready even if that function
+ // returns false.
+ virtual bool DataReady() = 0;
};
virtual ~AudioOutputController();
@@ -163,12 +170,17 @@ class MEDIA_EXPORT AudioOutputController
virtual void OnError(AudioOutputStream* stream, int code);
private:
+ // We are polling sync reader if data became available.
+ static const int kPollNumAttempts;
+ static const int kPollPauseInMilliseconds;
+
AudioOutputController(EventHandler* handler,
uint32 capacity, SyncReader* sync_reader);
// The following methods are executed on the audio controller thread.
void DoCreate(const AudioParameters& params);
void DoPlay();
+ void PollAndStartIfDataReady();
void DoPause();
void DoFlush();
void DoClose(const base::Closure& closed_task);
@@ -178,6 +190,9 @@ class MEDIA_EXPORT AudioOutputController
// Helper method to submit a OnMoreData() call to the event handler.
void SubmitOnMoreData_Locked();
+ // Helper method that starts physical stream.
+ void StartStream();
+
// |handler_| may be called only if |state_| is not kClosed.
EventHandler* handler_;
AudioOutputStream* stream_;
@@ -205,6 +220,10 @@ class MEDIA_EXPORT AudioOutputController
// The message loop of audio thread that this object runs on.
MessageLoop* message_loop_;
+ // When starting stream we wait for data to become available.
+ // Number of times left.
+ int number_polling_attempts_left_;
+
DISALLOW_COPY_AND_ASSIGN(AudioOutputController);
};