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

Unified Diff: media/audio/android/opensles_output.cc

Issue 2142403002: Pick up starting position from OpenSLES getPosition(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/android/opensles_output.cc
diff --git a/media/audio/android/opensles_output.cc b/media/audio/android/opensles_output.cc
index 87daa9c6f8fbb690a8b20bc443c11cc272147b1f..5dc916ae03a565994736814dfee7d47ba2fc332d 100644
--- a/media/audio/android/opensles_output.cc
+++ b/media/audio/android/opensles_output.cc
@@ -87,13 +87,11 @@ void OpenSLESOutputStream::Start(AudioSourceCallback* callback) {
base::AutoLock lock(lock_);
DCHECK(!callback_);
callback_ = callback;
- delay_calculator_.SetBaseTimestamp(base::TimeDelta());
// Fill audio data with silence to avoid start-up glitches. Don't use
// FillBufferQueueNoLock() since it can trigger recursive entry if an error
// occurs while writing into the stream. See http://crbug.com/624877.
memset(audio_data_[active_buffer_index_], 0, buffer_size_bytes_);
- delay_calculator_.AddFrames(audio_bus_->frames());
LOG_ON_FAILURE_AND_RETURN((*simple_buffer_queue_)
->Enqueue(simple_buffer_queue_,
audio_data_[active_buffer_index_],
@@ -106,6 +104,15 @@ void OpenSLESOutputStream::Start(AudioSourceCallback* callback) {
LOG_ON_FAILURE_AND_RETURN(
(*player_)->SetPlayState(player_, SL_PLAYSTATE_PLAYING));
+ // On older version of Android, the position may not be reset even though we
+ // call Clear() during Stop(), in this case the best we can do is assume that
+ // we're continuing on from this previous position.
+ uint32_t position_in_ms = 0;
+ LOG_ON_FAILURE_AND_RETURN((*player_)->GetPosition(player_, &position_in_ms));
+ delay_calculator_.SetBaseTimestamp(
+ base::TimeDelta::FromMilliseconds(position_in_ms));
+ delay_calculator_.AddFrames(audio_bus_->frames());
+
started_ = true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698