summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-10-05 10:25:34 -0700
committerAndreas Huber <andih@google.com>2010-10-05 13:53:39 -0700
commitb2e3954c94717e43b3dc9b880564f166cfbbc0a2 (patch)
tree3ebd2a7b944856cd2048a05aec0c11b4e639a9ee /media
parent50817931e4cb4ae0019fd13c831a2839349834c5 (diff)
downloadframeworks_av-b2e3954c94717e43b3dc9b880564f166cfbbc0a2.zip
frameworks_av-b2e3954c94717e43b3dc9b880564f166cfbbc0a2.tar.gz
frameworks_av-b2e3954c94717e43b3dc9b880564f166cfbbc0a2.tar.bz2
Make sure to call AudioTrack::stop() instead of AudioTrack::pause() after submitting all samples to AudioTrack to make sure those remaining samples are actually played out.
Change-Id: Id574a0203efcb5e565f1b0fe77869fc33b9a9d56
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/AudioPlayer.cpp20
-rw-r--r--media/libstagefright/AwesomePlayer.cpp15
-rw-r--r--media/libstagefright/include/AwesomePlayer.h2
3 files changed, 26 insertions, 11 deletions
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index b314114..5ff934d 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -55,7 +55,7 @@ AudioPlayer::AudioPlayer(
AudioPlayer::~AudioPlayer() {
if (mStarted) {
- stop();
+ reset();
}
}
@@ -165,13 +165,21 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
return OK;
}
-void AudioPlayer::pause() {
+void AudioPlayer::pause(bool playPendingSamples) {
CHECK(mStarted);
- if (mAudioSink.get() != NULL) {
- mAudioSink->pause();
+ if (playPendingSamples) {
+ if (mAudioSink.get() != NULL) {
+ mAudioSink->stop();
+ } else {
+ mAudioTrack->stop();
+ }
} else {
- mAudioTrack->stop();
+ if (mAudioSink.get() != NULL) {
+ mAudioSink->pause();
+ } else {
+ mAudioTrack->pause();
+ }
}
}
@@ -185,7 +193,7 @@ void AudioPlayer::resume() {
}
}
-void AudioPlayer::stop() {
+void AudioPlayer::reset() {
CHECK(mStarted);
if (mAudioSink.get() != NULL) {
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 040e27d..bfc23d4 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -576,7 +576,7 @@ void AwesomePlayer::onStreamDone() {
notifyListener_l(
MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, mStreamDoneStatus);
- pause_l();
+ pause_l(true /* at eos */);
mFlags |= AT_EOS;
return;
@@ -600,7 +600,7 @@ void AwesomePlayer::onStreamDone() {
LOGV("MEDIA_PLAYBACK_COMPLETE");
notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
- pause_l();
+ pause_l(true /* at eos */);
mFlags |= AT_EOS;
}
@@ -738,7 +738,7 @@ status_t AwesomePlayer::pause() {
return pause_l();
}
-status_t AwesomePlayer::pause_l() {
+status_t AwesomePlayer::pause_l(bool at_eos) {
if (!(mFlags & PLAYING)) {
return OK;
}
@@ -746,7 +746,14 @@ status_t AwesomePlayer::pause_l() {
cancelPlayerEvents(true /* keepBufferingGoing */);
if (mAudioPlayer != NULL) {
- mAudioPlayer->pause();
+ if (at_eos) {
+ // If we played the audio stream to completion we
+ // want to make sure that all samples remaining in the audio
+ // track's queue are played out.
+ mAudioPlayer->pause(true /* playPendingSamples */);
+ } else {
+ mAudioPlayer->pause();
+ }
}
mFlags &= ~PLAYING;
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 600faca..40ea37d 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -221,7 +221,7 @@ private:
status_t setDataSource_l(const sp<MediaExtractor> &extractor);
void reset_l();
status_t seekTo_l(int64_t timeUs);
- status_t pause_l();
+ status_t pause_l(bool at_eos = false);
void initRenderer_l();
void seekAudioIfNecessary_l();