Merge "Revert "Do not stop audio track when the buffer queue is empty."" into sc-dev
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp
index cd1a36d..a324b4a 100644
--- a/src/android/AudioPlayer_to_android.cpp
+++ b/src/android/AudioPlayer_to_android.cpp
@@ -1318,8 +1318,8 @@
}
}
- // The track will fall into underrun status when the queue is empty.
- // The track will be automatically started when the next available buffer is enqueued.
+ // stop the track so it restarts playing faster when new data is enqueued
+ ap->mTrackPlayer->stop();
}
interface_unlock_exclusive(&ap->mBufferQueue);
@@ -2483,6 +2483,16 @@
//-----------------------------------------------------------------------------
void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *ap) {
+ // the AudioTrack associated with the AudioPlayer receiving audio from a PCM buffer
+ // queue was stopped when the queue become empty, we restart as soon as a new buffer
+ // has been enqueued since we're in playing state
+ if (ap->mTrackPlayer->mAudioTrack != 0) {
+ ap->mTrackPlayer->reportEvent(android::PLAYER_STATE_STARTED,
+ ap->mTrackPlayer->mAudioTrack->getRoutedDeviceId());
+ // instead of ap->mTrackPlayer->mAudioTrack->start();
+ ap->mDeferredStart = true;
+ }
+
// when the queue became empty, an underflow on the prefetch status itf was sent. Now the queue
// has received new data, signal it has sufficient data
if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {