From 8b63533e6aaff121378878998925c57dbe9a9e16 Mon Sep 17 00:00:00 2001 From: Haynes Mathew George Date: Mon, 30 Mar 2015 17:59:47 -0700 Subject: nuplayer: Has video hint for offload Send a hint indicating whether the clip being played has a video stream from NuPlayer to NuPlayerDecoderPassThrough. This hint is used to open the audio sink with the correct offload config. Currently, NuPlayerDecoderPassthrough always calls openAudioSink with hasVideo set to false causing an unnecessary recreation of AudioTrack. Change-Id: I7bc6c73818b65f9237a6e606721b7d48e1d807b9 CRs-Fixed: 811510 --- media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 2 ++ media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'media') diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index f4d3794..2f9f33c 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1239,6 +1239,8 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp *decoder) { notify->setInt32("generation", mAudioDecoderGeneration); if (mOffloadAudio) { + const bool hasVideo = (mSource->getFormat(false /*audio */) != NULL); + format->setInt32("has-video", hasVideo); *decoder = new DecoderPassThrough(notify, mSource, mRenderer); } else { *decoder = new Decoder(notify, mSource, mRenderer); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp index 29b4c26..563de5e 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp @@ -74,11 +74,14 @@ void NuPlayer::DecoderPassThrough::onConfigure(const sp &format) { onRequestInputBuffers(); + int32_t hasVideo = 0; + format->findInt32("has-video", &hasVideo); + // The audio sink is already opened before the PassThrough decoder is created. // Opening again might be relevant if decoder is instantiated after shutdown and // format is different. status_t err = mRenderer->openAudioSink( - format, true /* offloadOnly */, false /* hasVideo */, + format, true /* offloadOnly */, hasVideo, AUDIO_OUTPUT_FLAG_NONE /* flags */, NULL /* isOffloaded */); if (err != OK) { handleError(err); -- cgit v1.1