Skip to content

Commit 1356160

Browse files
theandi666Android (Google) Code Review
authored andcommitted
Merge "Audio player must not be used as a timesource before it's started."
2 parents ab90899 + 8458447 commit 1356160

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

media/libstagefright/AudioPlayer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
#include <binder/IPCThreadState.h>
2222
#include <media/AudioTrack.h>
23+
#include <media/stagefright/foundation/ADebug.h>
2324
#include <media/stagefright/AudioPlayer.h>
24-
#include <media/stagefright/MediaDebug.h>
2525
#include <media/stagefright/MediaDefs.h>
2626
#include <media/stagefright/MediaErrors.h>
2727
#include <media/stagefright/MediaSource.h>
@@ -60,7 +60,7 @@ AudioPlayer::~AudioPlayer() {
6060
}
6161

6262
void AudioPlayer::setSource(const sp<MediaSource> &source) {
63-
CHECK_EQ(mSource, NULL);
63+
CHECK(mSource == NULL);
6464
mSource = source;
6565
}
6666

@@ -466,6 +466,8 @@ int64_t AudioPlayer::getRealTimeUs() {
466466
}
467467

468468
int64_t AudioPlayer::getRealTimeUsLocked() const {
469+
CHECK(mStarted);
470+
CHECK_NE(mSampleRate, 0);
469471
return -mLatencyUs + (mNumFramesPlayed * 1000000) / mSampleRate;
470472
}
471473

media/libstagefright/AwesomePlayer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,9 @@ void AwesomePlayer::onVideoEvent() {
17361736
modifyFlags(TEXT_RUNNING, SET);
17371737
}
17381738

1739-
TimeSource *ts = (mFlags & AUDIO_AT_EOS) ? &mSystemTimeSource : mTimeSource;
1739+
TimeSource *ts =
1740+
((mFlags & AUDIO_AT_EOS) || !(mFlags & AUDIOPLAYER_STARTED))
1741+
? &mSystemTimeSource : mTimeSource;
17401742

17411743
if (mFlags & FIRST_FRAME) {
17421744
modifyFlags(FIRST_FRAME, CLEAR);

0 commit comments

Comments
 (0)