Fix NuPlayer assertion on failure to create AudioTrack
Under heavy media load or monkey/stress testing, more than
32 AudioTracks may be created or memory resources may be scarce.
Remove the assertion on failure to create AudioTrack
and signal MEDIA_ERROR.
Bug: 17319843
Change-Id: I5d4e200b5f50d800046851a33e035cdc6ff10075
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 012d33e..6ad28b5 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -44,7 +44,7 @@
const sp<Renderer> &renderer,
const sp<NativeWindowWrapper> &nativeWindow,
const sp<CCDecoder> &ccDecoder)
- : mNotify(notify),
+ : DecoderBase(notify),
mNativeWindow(nativeWindow),
mSource(source),
mRenderer(renderer),
@@ -56,7 +56,6 @@
mIsVideoAVC(false),
mIsSecure(false),
mFormatChangePending(false),
- mBufferGeneration(0),
mPaused(true),
mResumePending(false),
mComponentName("decoder") {
@@ -336,20 +335,6 @@
}
}
-void NuPlayer::Decoder::handleError(int32_t err)
-{
- // We cannot immediately release the codec due to buffers still outstanding
- // in the renderer. We signal to the player the error so it can shutdown/release the
- // decoder after flushing and increment the generation to discard unnecessary messages.
-
- ++mBufferGeneration;
-
- sp<AMessage> notify = mNotify->dup();
- notify->setInt32("what", kWhatError);
- notify->setInt32("err", err);
- notify->post();
-}
-
bool NuPlayer::Decoder::handleAnInputBuffer() {
if (mFormatChangePending) {
return false;
@@ -462,8 +447,14 @@
flags = AUDIO_OUTPUT_FLAG_NONE;
}
- mRenderer->openAudioSink(
- format, false /* offloadOnly */, hasVideo, flags);
+ res = mRenderer->openAudioSink(
+ format, false /* offloadOnly */, hasVideo, flags, NULL /* isOffloaded */);
+ if (res != OK) {
+ ALOGE("Failed to open AudioSink on format change for %s (err=%d)",
+ mComponentName.c_str(), res);
+ handleError(res);
+ return false;
+ }
}
return true;
} else if (res == INFO_DISCONTINUITY) {