am 17bc4f65: Merge "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." into gingerbread
Merge commit '17bc4f65324a823598e7671256c815bf32ddcc95' into gingerbread-plus-aosp * commit '17bc4f65324a823598e7671256c815bf32ddcc95': 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.
This commit is contained in:
@@ -49,11 +49,9 @@ public:
|
|||||||
|
|
||||||
status_t start(bool sourceAlreadyStarted = false);
|
status_t start(bool sourceAlreadyStarted = false);
|
||||||
|
|
||||||
void pause();
|
void pause(bool playPendingSamples = false);
|
||||||
void resume();
|
void resume();
|
||||||
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
// Returns the timestamp of the last buffer played (in us).
|
// Returns the timestamp of the last buffer played (in us).
|
||||||
int64_t getMediaTimeUs();
|
int64_t getMediaTimeUs();
|
||||||
|
|
||||||
@@ -107,6 +105,8 @@ private:
|
|||||||
|
|
||||||
int64_t getRealTimeUsLocked() const;
|
int64_t getRealTimeUsLocked() const;
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
AudioPlayer(const AudioPlayer &);
|
AudioPlayer(const AudioPlayer &);
|
||||||
AudioPlayer &operator=(const AudioPlayer &);
|
AudioPlayer &operator=(const AudioPlayer &);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ AudioPlayer::AudioPlayer(
|
|||||||
|
|
||||||
AudioPlayer::~AudioPlayer() {
|
AudioPlayer::~AudioPlayer() {
|
||||||
if (mStarted) {
|
if (mStarted) {
|
||||||
stop();
|
reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,13 +165,21 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioPlayer::pause() {
|
void AudioPlayer::pause(bool playPendingSamples) {
|
||||||
CHECK(mStarted);
|
CHECK(mStarted);
|
||||||
|
|
||||||
if (mAudioSink.get() != NULL) {
|
if (playPendingSamples) {
|
||||||
mAudioSink->pause();
|
if (mAudioSink.get() != NULL) {
|
||||||
|
mAudioSink->stop();
|
||||||
|
} else {
|
||||||
|
mAudioTrack->stop();
|
||||||
|
}
|
||||||
} else {
|
} 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);
|
CHECK(mStarted);
|
||||||
|
|
||||||
if (mAudioSink.get() != NULL) {
|
if (mAudioSink.get() != NULL) {
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ void AwesomePlayer::onStreamDone() {
|
|||||||
notifyListener_l(
|
notifyListener_l(
|
||||||
MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, mStreamDoneStatus);
|
MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, mStreamDoneStatus);
|
||||||
|
|
||||||
pause_l();
|
pause_l(true /* at eos */);
|
||||||
|
|
||||||
mFlags |= AT_EOS;
|
mFlags |= AT_EOS;
|
||||||
return;
|
return;
|
||||||
@@ -600,7 +600,7 @@ void AwesomePlayer::onStreamDone() {
|
|||||||
LOGV("MEDIA_PLAYBACK_COMPLETE");
|
LOGV("MEDIA_PLAYBACK_COMPLETE");
|
||||||
notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
|
notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
|
||||||
|
|
||||||
pause_l();
|
pause_l(true /* at eos */);
|
||||||
|
|
||||||
mFlags |= AT_EOS;
|
mFlags |= AT_EOS;
|
||||||
}
|
}
|
||||||
@@ -738,7 +738,7 @@ status_t AwesomePlayer::pause() {
|
|||||||
return pause_l();
|
return pause_l();
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t AwesomePlayer::pause_l() {
|
status_t AwesomePlayer::pause_l(bool at_eos) {
|
||||||
if (!(mFlags & PLAYING)) {
|
if (!(mFlags & PLAYING)) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -746,7 +746,14 @@ status_t AwesomePlayer::pause_l() {
|
|||||||
cancelPlayerEvents(true /* keepBufferingGoing */);
|
cancelPlayerEvents(true /* keepBufferingGoing */);
|
||||||
|
|
||||||
if (mAudioPlayer != NULL) {
|
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;
|
mFlags &= ~PLAYING;
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ private:
|
|||||||
status_t setDataSource_l(const sp<MediaExtractor> &extractor);
|
status_t setDataSource_l(const sp<MediaExtractor> &extractor);
|
||||||
void reset_l();
|
void reset_l();
|
||||||
status_t seekTo_l(int64_t timeUs);
|
status_t seekTo_l(int64_t timeUs);
|
||||||
status_t pause_l();
|
status_t pause_l(bool at_eos = false);
|
||||||
void initRenderer_l();
|
void initRenderer_l();
|
||||||
void seekAudioIfNecessary_l();
|
void seekAudioIfNecessary_l();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user