Skip to content

Commit 551aeac

Browse files
committed
Make sure we can properly shutdown even if
a) one of the two decoders has a pending discontinuity b) the renderer holds on to all output buffers for that decoder c) the renderer is paused if all three conditions are met the decoder won't ask for more input data and therefore never see the discontinuity. To avoid this we briefly resume the renderer just before shutting down. Change-Id: I9e08af2a1eb4298d1cd00497d6aa33f4ad184e9a related-to-bug: 5655016
1 parent e35581a commit 551aeac

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

media/libmediaplayerservice/nuplayer/NuPlayer.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,24 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
462462
{
463463
LOGV("kWhatReset");
464464

465+
if (mRenderer != NULL) {
466+
// There's an edge case where the renderer owns all output
467+
// buffers and is paused, therefore the decoder will not read
468+
// more input data and will never encounter the matching
469+
// discontinuity. To avoid this, we resume the renderer.
470+
471+
if (mFlushingAudio == AWAITING_DISCONTINUITY
472+
|| mFlushingVideo == AWAITING_DISCONTINUITY) {
473+
mRenderer->resume();
474+
}
475+
}
476+
465477
if (mFlushingAudio != NONE || mFlushingVideo != NONE) {
466478
// We're currently flushing, postpone the reset until that's
467479
// completed.
468480

469-
LOGV("postponing reset");
481+
LOGV("postponing reset mFlushingAudio=%d, mFlushingVideo=%d",
482+
mFlushingAudio, mFlushingVideo);
470483

471484
mResetPostponed = true;
472485
break;

media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,16 @@ void NuPlayer::Renderer::onPause() {
628628
mAudioSink->pause();
629629
}
630630

631+
LOGV("now paused audio queue has %d entries, video has %d entries",
632+
mAudioQueue.size(), mVideoQueue.size());
633+
631634
mPaused = true;
632635
}
633636

634637
void NuPlayer::Renderer::onResume() {
635-
CHECK(mPaused);
638+
if (!mPaused) {
639+
return;
640+
}
636641

637642
if (mHasAudio) {
638643
mAudioSink->start();

0 commit comments

Comments
 (0)