From fd42e7afbe43eca5ab6835f8b2720b7e0e8302e0 Mon Sep 17 00:00:00 2001 From: Preetam Singh Ranawat Date: Thu, 23 Jul 2015 08:59:47 +0530 Subject: AVCustomizations: Enable 16 and 24 bit PCM offload. -create extended decoder and renderer -add change to pass bit width and format info to renderer. -add change for PCM conversions -add changes for time calucation Conflicts: media/libmediaplayerservice/nuplayer/NuPlayer.cpp Change-Id: I3363140fad441a7746884076c40b46e777f2e06e --- include/media/AudioTrack.h | 1 + media/libavextensions/media/AVMediaExtensions.h | 12 +++++ .../mediaplayerservice/AVNuExtensions.h | 27 ++++++++++- .../mediaplayerservice/AVNuFactory.cpp | 18 ++++++++ .../mediaplayerservice/AVNuUtils.cpp | 52 ++++++++++++++++++++++ media/libavextensions/stagefright/AVExtensions.h | 14 ++++++ media/libavextensions/stagefright/AVUtils.cpp | 27 +++++++++++ media/libmedia/AudioTrack.cpp | 31 ++++++++++--- media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 22 +++++++-- media/libmediaplayerservice/nuplayer/NuPlayer.h | 7 ++- .../nuplayer/NuPlayerDecoder.cpp | 1 + .../nuplayer/NuPlayerDecoder.h | 4 +- .../nuplayer/NuPlayerDecoderPassThrough.cpp | 2 + .../nuplayer/NuPlayerDecoderPassThrough.h | 2 +- .../nuplayer/NuPlayerRenderer.cpp | 8 +++- .../nuplayer/NuPlayerRenderer.h | 5 ++- media/libstagefright/ACodec.cpp | 2 +- media/libstagefright/Utils.cpp | 2 +- 18 files changed, 214 insertions(+), 23 deletions(-) mode change 100644 => 100755 media/libmedia/AudioTrack.cpp diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index 82d1c55..42883b5 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -624,6 +624,7 @@ private: */ status_t obtainBuffer(Buffer* audioBuffer, const struct timespec *requested, struct timespec *elapsed = NULL, size_t *nonContig = NULL); + friend struct ExtendedMediaUtils; public: /* Public API for TRANSFER_OBTAIN mode. diff --git a/media/libavextensions/media/AVMediaExtensions.h b/media/libavextensions/media/AVMediaExtensions.h index ad907a1..4338d5e 100644 --- a/media/libavextensions/media/AVMediaExtensions.h +++ b/media/libavextensions/media/AVMediaExtensions.h @@ -39,6 +39,18 @@ namespace android { */ struct AVMediaUtils { + virtual bool AudioTrackIsPcmOffloaded(const audio_format_t /*format*/) { + return false; + } + virtual status_t AudioTrackGetPosition(AudioTrack* /*track*/, + uint32_t* /*position*/) { + return NO_INIT; + } + + virtual status_t AudioTrackGetTimestamp(AudioTrack* /*track*/, + AudioTimestamp /*timestamp*/) { + return NO_INIT; + } // ----- NO TRESSPASSING BEYOND THIS LINE ------ DECLARE_LOADABLE_SINGLETON(AVMediaUtils); }; diff --git a/media/libavextensions/mediaplayerservice/AVNuExtensions.h b/media/libavextensions/mediaplayerservice/AVNuExtensions.h index cc69ecf..ccf3615 100644 --- a/media/libavextensions/mediaplayerservice/AVNuExtensions.h +++ b/media/libavextensions/mediaplayerservice/AVNuExtensions.h @@ -34,7 +34,6 @@ namespace android { struct NuPlayer; - /* * Factory to create extended NuPlayer objects */ @@ -46,6 +45,17 @@ struct AVNuFactory { const sp &source, const sp &renderer); + virtual sp createDecoder( + const sp ¬ify, + const sp &source, + pid_t pid, + const sp &renderer); + + virtual sp createRenderer( + const sp &sink, + const sp ¬ify, + uint32_t flags); + // ----- NO TRESSPASSING BEYOND THIS LINE ------ DECLARE_LOADABLE_SINGLETON(AVNuFactory); }; @@ -55,6 +65,21 @@ struct AVNuFactory { */ struct AVNuUtils { + virtual sp createPCMMetaFromSource(const sp &); + virtual bool pcmOffloadException(const sp &); + virtual bool isRAWFormat(const sp &); + virtual bool isRAWFormat(const sp &); + virtual int updateAudioBitWidth(audio_format_t audioFormat, + const sp &); + virtual audio_format_t getKeyPCMFormat(const sp &); + virtual void setKeyPCMFormat(const sp &, audio_format_t audioFormat); + virtual audio_format_t getPCMFormat(const sp &); + virtual void setPCMFormat(const sp &, audio_format_t audioFormat); + virtual void setSourcePCMFormat(const sp &); + virtual void setDecodedPCMFormat(const sp &); + virtual status_t convertToSinkFormatIfNeeded(const sp &, sp &, + audio_format_t sinkFormat, bool isOffload); + // ----- NO TRESSPASSING BEYOND THIS LINE ------ DECLARE_LOADABLE_SINGLETON(AVNuUtils); }; diff --git a/media/libavextensions/mediaplayerservice/AVNuFactory.cpp b/media/libavextensions/mediaplayerservice/AVNuFactory.cpp index 6e1f1e9..ff7c074 100644 --- a/media/libavextensions/mediaplayerservice/AVNuFactory.cpp +++ b/media/libavextensions/mediaplayerservice/AVNuFactory.cpp @@ -37,6 +37,9 @@ #include #include #include +#include +#include +#include #include #include @@ -56,6 +59,21 @@ sp AVNuFactory::createPassThruDecoder( return new NuPlayer::DecoderPassThrough(notify, source, renderer); } +sp AVNuFactory::createDecoder( + const sp ¬ify, + const sp &source, + pid_t pid, + const sp &renderer) { + return new NuPlayer::Decoder(notify, source, pid, renderer); +} + +sp AVNuFactory::createRenderer( + const sp &sink, + const sp ¬ify, + uint32_t flags) { + return new NuPlayer::Renderer(sink, notify, flags); +} + // ----- NO TRESSPASSING BEYOND THIS LINE ------ AVNuFactory::AVNuFactory() { } diff --git a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp index 563cd29..e890a61 100644 --- a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp +++ b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp @@ -44,6 +44,58 @@ namespace android { + +sp AVNuUtils::createPCMMetaFromSource(const sp &sMeta) { + return sMeta; +} + +bool AVNuUtils::pcmOffloadException(const sp &) { + return true; +} + +bool AVNuUtils::isRAWFormat(const sp &) { + return false; +} + +bool AVNuUtils::isRAWFormat(const sp &) { + return false; +} + + +int AVNuUtils::updateAudioBitWidth(audio_format_t /*audioFormat*/, + const sp &){ + return 16; +} + +audio_format_t AVNuUtils::getKeyPCMFormat(const sp &) { + return AUDIO_FORMAT_INVALID; +} + +void AVNuUtils::setKeyPCMFormat(const sp &, audio_format_t /*audioFormat*/) { + +} + +audio_format_t AVNuUtils::getPCMFormat(const sp &) { + return AUDIO_FORMAT_PCM_16_BIT; +} + +void AVNuUtils::setPCMFormat(const sp &, audio_format_t /*audioFormat*/) { + +} + +void AVNuUtils::setSourcePCMFormat(const sp &) { + +} + +void AVNuUtils::setDecodedPCMFormat(const sp &) { + +} +status_t AVNuUtils::convertToSinkFormatIfNeeded(const sp &, sp &, + audio_format_t /*sinkFormat*/, bool /*isOffload*/) { + return INVALID_OPERATION; +} + + // ----- NO TRESSPASSING BEYOND THIS LINE ------ AVNuUtils::AVNuUtils() { } diff --git a/media/libavextensions/stagefright/AVExtensions.h b/media/libavextensions/stagefright/AVExtensions.h index 29f4cbc..f9f4cf1 100644 --- a/media/libavextensions/stagefright/AVExtensions.h +++ b/media/libavextensions/stagefright/AVExtensions.h @@ -65,6 +65,20 @@ struct AVUtils { virtual sp createCustomComponentByName(const sp &looper, const char* mime, bool encoder); + + virtual bool is24bitPCMOffloadEnabled(); + virtual bool is16bitPCMOffloadEnabled(); + virtual int getPcmSampleBits(const sp &); + virtual int getPcmSampleBits(const sp &); + virtual void setPcmSampleBits(const sp &, int32_t /*bitWidth*/); + virtual void setPcmSampleBits(const sp &, int32_t /*bitWidth*/); + + virtual audio_format_t updateAudioFormat(audio_format_t audioFormat, + const sp &); + + virtual audio_format_t updateAudioFormat(audio_format_t audioFormat, + const sp &); + // ----- NO TRESSPASSING BEYOND THIS LINE ------ DECLARE_LOADABLE_SINGLETON(AVUtils); }; diff --git a/media/libavextensions/stagefright/AVUtils.cpp b/media/libavextensions/stagefright/AVUtils.cpp index d767f45..a4100c5 100644 --- a/media/libavextensions/stagefright/AVUtils.cpp +++ b/media/libavextensions/stagefright/AVUtils.cpp @@ -59,6 +59,33 @@ status_t AVUtils::sendMetaDataToHal( return OK; } +bool AVUtils::is24bitPCMOffloadEnabled() {return false;} +bool AVUtils::is16bitPCMOffloadEnabled() {return false;} + +int AVUtils::getPcmSampleBits(const sp &) { + return 16; +} + +int AVUtils::getPcmSampleBits(const sp &) { + return 16; +} + +void AVUtils::setPcmSampleBits(const sp &, int32_t /*bitWidth*/) { +} + +void AVUtils::setPcmSampleBits(const sp &, int32_t /*bitWidth*/) { +} + +audio_format_t AVUtils::updateAudioFormat(audio_format_t audioFormat, + const sp &){ + return audioFormat; +} + +audio_format_t AVUtils::updateAudioFormat(audio_format_t audioFormat, + const sp &){ + return audioFormat; +} + static bool dumbSniffer( const sp &, String8 *, float *, sp *) { diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp old mode 100644 new mode 100755 index f9eb496..fa24415 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -30,6 +30,7 @@ #include #include #include +#include "media/AVMediaExtensions.h" #define WAIT_PERIOD_MS 10 #define WAIT_STREAM_END_TIMEOUT_SEC 120 @@ -992,6 +993,10 @@ status_t AudioTrack::getPosition(uint32_t *position) return NO_ERROR; } + if (AVMediaUtils::get()->AudioTrackGetPosition(this, position) == NO_ERROR) { + return NO_ERROR; + } + if (mOutput != AUDIO_IO_HANDLE_NONE) { uint32_t halFrames; // actually unused (void) AudioSystem::getRenderPosition(mOutput, &halFrames, &dspFrames); @@ -2223,14 +2228,21 @@ status_t AudioTrack::getTimestamp(AudioTimestamp& timestamp) } } - // The presented frame count must always lag behind the consumed frame count. - // To avoid a race, read the presented frames first. This ensures that presented <= consumed. - status_t status = mAudioTrack->getTimestamp(timestamp); - if (status != NO_ERROR) { - ALOGV_IF(status != WOULD_BLOCK, "getTimestamp error:%#x", status); - return status; + status_t status = UNKNOWN_ERROR; + //do not call Timestamp if its PCM offloaded + if (!AVMediaUtils::get()->AudioTrackIsPcmOffloaded(mFormat)) { + // The presented frame count must always lag behind the consumed frame count. + // To avoid a race, read the presented frames first. This ensures that presented <= consumed. + + status = mAudioTrack->getTimestamp(timestamp); + if (status != NO_ERROR) { + ALOGV_IF(status != WOULD_BLOCK, "getTimestamp error:%#x", status); + return status; + } + } - if (isOffloadedOrDirect_l()) { + + if (isOffloadedOrDirect_l() && !AVMediaUtils::get()->AudioTrackIsPcmOffloaded(mFormat)) { if (isOffloaded_l() && (mState == STATE_PAUSED || mState == STATE_PAUSED_STOPPING)) { // use cached paused position in case another offloaded track is running. timestamp.mPosition = mPausedPosition; @@ -2288,6 +2300,11 @@ status_t AudioTrack::getTimestamp(AudioTimestamp& timestamp) } } else { // Update the mapping between local consumed (mPosition) and server consumed (mServer) + + if (AVMediaUtils::get()->AudioTrackGetTimestamp(this, timestamp) == NO_ERROR) { + return NO_ERROR; + } + (void) updateAndGetPosition_l(); // Server consumed (mServer) and presented both use the same server time base, // and server consumed is always >= presented. diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 129c8a9..3af1659 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1296,6 +1296,7 @@ void NuPlayer::onStart(int64_t startPositionUs) { } sp audioMeta = mSource->getFormatMeta(true /* audio */); + AVNuUtils::get()->setSourcePCMFormat(audioMeta); audio_stream_type_t streamType = AUDIO_STREAM_MUSIC; if (mAudioSink != NULL) { streamType = mAudioSink->getAudioStreamType(); @@ -1305,6 +1306,10 @@ void NuPlayer::onStart(int64_t startPositionUs) { mOffloadAudio = canOffloadStream(audioMeta, (videoFormat != NULL), mSource->isStreaming(), streamType); + if (!mOffloadAudio) { + mOffloadAudio = canOffloadDecodedPCMStream(audioMeta, (videoFormat != NULL), mSource->isStreaming(), streamType); + } + if (mOffloadAudio) { flags |= Renderer::FLAG_OFFLOAD_AUDIO; } @@ -1312,7 +1317,7 @@ void NuPlayer::onStart(int64_t startPositionUs) { sp notify = new AMessage(kWhatRendererNotify, this); ++mRendererGeneration; notify->setInt32("generation", mRendererGeneration); - mRenderer = new Renderer(mAudioSink, notify, flags); + mRenderer = AVNuFactory::get()->createRenderer(mAudioSink, notify, flags); mRendererLooper = new ALooper; mRendererLooper->setName("NuPlayerRenderer"); mRendererLooper->start(false, false, ANDROID_PRIORITY_AUDIO); @@ -1471,8 +1476,11 @@ void NuPlayer::determineAudioModeChange() { sp videoFormat = mSource->getFormat(false /* audio */); audio_stream_type_t streamType = mAudioSink->getAudioStreamType(); const bool hasVideo = (videoFormat != NULL); - const bool canOffload = canOffloadStream( + bool canOffload = canOffloadStream( audioMeta, hasVideo, mSource->isStreaming(), streamType); + if (!canOffload) { + canOffload = canOffloadDecodedPCMStream(audioMeta, (videoFormat != NULL), mSource->isStreaming(), streamType); + } if (canOffload) { if (!mOffloadAudio) { mRenderer->signalEnableOffloadAudio(); @@ -1484,6 +1492,7 @@ void NuPlayer::determineAudioModeChange() { if (mOffloadAudio) { mRenderer->signalDisableOffloadAudio(); mOffloadAudio = false; + setDecodedPcmOffload(false); } } } @@ -1532,12 +1541,17 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp *decoder) { notify->setInt32("generation", mAudioDecoderGeneration); determineAudioModeChange(); - if (mOffloadAudio) { + + if (AVNuUtils::get()->isRAWFormat(format)) { + AVNuUtils::get()->setPCMFormat(format, + AVNuUtils::get()->getKeyPCMFormat(mSource->getFormatMeta(true /* audio */))); + } + if (mOffloadAudio && !ifDecodedPCMOffload()) { const bool hasVideo = (mSource->getFormat(false /*audio */) != NULL); format->setInt32("has-video", hasVideo); *decoder = AVNuFactory::get()->createPassThruDecoder(notify, mSource, mRenderer); } else { - *decoder = new Decoder(notify, mSource, mPID, mRenderer); + *decoder = AVNuFactory::get()->createDecoder(notify, mSource, mPID, mRenderer); } } else { sp notify = new AMessage(kWhatVideoNotify, this); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 69ce828..7a2c73e 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -86,7 +86,10 @@ protected: virtual ~NuPlayer(); virtual void onMessageReceived(const sp &msg); - + virtual bool ifDecodedPCMOffload() {return false;} + virtual void setDecodedPcmOffload(bool /*decodePcmOffload*/) {} + virtual bool canOffloadDecodedPCMStream(const sp /*meta*/, + bool /*hasVideo*/, bool /*isStreaming*/, audio_stream_type_t /*streamType*/) {return false;} public: struct NuPlayerStreamListener; struct Source; @@ -221,7 +224,7 @@ protected: mFlushComplete[1][1] = false; } - void tryOpenAudioSinkForOffload(const sp &format, bool hasVideo); + virtual void tryOpenAudioSinkForOffload(const sp &format, bool hasVideo); void closeAudioSink(); void determineAudioModeChange(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp index aa77071..3b77bc2 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp @@ -572,6 +572,7 @@ bool NuPlayer::Decoder::handleAnOutputBuffer( buffer->setRange(offset, size); buffer->meta()->clear(); buffer->meta()->setInt64("timeUs", timeUs); + setPcmFormat(buffer->meta()); bool eos = flags & MediaCodec::BUFFER_FLAG_EOS; // we do not expect CODECCONFIG or SYNCFRAME for decoder diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h index eeb4af4..5f84a06 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h @@ -49,8 +49,8 @@ protected: virtual void onFlush(); virtual void onShutdown(bool notifyComplete); virtual bool doRequestBuffers(); + virtual void setPcmFormat(const sp & /*format*/) {} -private: enum { kWhatCodecNotify = 'cdcN', kWhatRenderBuffer = 'rndr', @@ -103,7 +103,7 @@ private: size_t size, int64_t timeUs, int32_t flags); - void handleOutputFormatChange(const sp &format); + virtual void handleOutputFormatChange(const sp &format); void releaseAndResetMediaBuffers(); void requestCodecNotification(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp index 30146c4..96e98f0 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp @@ -29,6 +29,7 @@ #include #include #include +#include "mediaplayerservice/AVNuExtensions.h" #include "ATSParser.h" @@ -201,6 +202,7 @@ sp NuPlayer::DecoderPassThrough::aggregateBuffer( if ((bigSize == 0) && smallTimestampValid) { mAggregateBuffer->meta()->setInt64("timeUs", timeUs); } + setPcmFormat(mAggregateBuffer->meta()); // Append small buffer to the bigger buffer. memcpy(mAggregateBuffer->base() + bigSize, accessUnit->data(), smallSize); bigSize += smallSize; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h index db33e87..188967a 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h @@ -43,8 +43,8 @@ protected: virtual void onFlush(); virtual void onShutdown(bool notifyComplete); virtual bool doRequestBuffers(); + virtual void setPcmFormat(const sp & /*format*/) {} -private: enum { kWhatBufferConsumed = 'bufC', }; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp index 9a33eb5..331e8ac 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp @@ -32,6 +32,8 @@ #include #include +#include "mediaplayerservice/AVNuExtensions.h" +#include "stagefright/AVExtensions.h" namespace android { @@ -1659,6 +1661,8 @@ status_t NuPlayer::Renderer::onOpenAudioSink( ALOGV("Mime \"%s\" mapped to audio_format 0x%x", mime.c_str(), audioFormat); + audioFormat = AVUtils::get()->updateAudioFormat(audioFormat, format); + int avgBitRate = -1; format->findInt32("bit-rate", &avgBitRate); @@ -1745,7 +1749,7 @@ status_t NuPlayer::Renderer::onOpenAudioSink( const PcmInfo info = { (audio_channel_mask_t)channelMask, (audio_output_flags_t)pcmFlags, - AUDIO_FORMAT_PCM_16_BIT, // TODO: change to audioFormat + AVNuUtils::get()->getPCMFormat(format), numChannels, sampleRate }; @@ -1774,7 +1778,7 @@ status_t NuPlayer::Renderer::onOpenAudioSink( sampleRate, numChannels, (audio_channel_mask_t)channelMask, - AUDIO_FORMAT_PCM_16_BIT, + AVNuUtils::get()->getPCMFormat(format), 0 /* bufferCount - unused */, mUseAudioCallback ? &NuPlayer::Renderer::AudioSinkCallback : NULL, mUseAudioCallback ? this : NULL, diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h index c83185e..85b39c0 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h @@ -73,6 +73,8 @@ struct NuPlayer::Renderer : public AHandler { status_t getCurrentPosition(int64_t *mediaUs); int64_t getVideoLateByUs(); + virtual audio_stream_type_t getAudioStreamType(){return AUDIO_STREAM_DEFAULT;} + status_t openAudioSink( const sp &format, bool offloadOnly, @@ -101,7 +103,6 @@ protected: virtual void onMessageReceived(const sp &msg); -private: enum { kWhatDrainAudioQueue = 'draA', kWhatDrainVideoQueue = 'draV', @@ -228,7 +229,7 @@ private: void prepareForMediaRenderingStart_l(); void notifyIfMediaRenderingStarted_l(); - void onQueueBuffer(const sp &msg); + virtual void onQueueBuffer(const sp &msg); void onQueueEOS(const sp &msg); void onFlush(const sp &msg); void onAudioSinkChanged(); diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 5f8453f..b4ec446 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -4201,7 +4201,7 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp ¬ify) { notify->setString("mime", MEDIA_MIMETYPE_AUDIO_RAW); notify->setInt32("channel-count", params.nChannels); notify->setInt32("sample-rate", params.nSamplingRate); - + notify->setInt32("bit-width", params.nBitPerSample); if (mChannelMaskPresent) { notify->setInt32("channel-mask", mChannelMask); } diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp index a8927ee..1ef1610 100644 --- a/media/libstagefright/Utils.cpp +++ b/media/libstagefright/Utils.cpp @@ -817,7 +817,7 @@ bool canOffloadStream(const sp& meta, bool hasVideo, } else { ALOGV("Mime type \"%s\" mapped to audio_format %d", mime, info.format); } - + info.format = AVUtils::get()->updateAudioFormat(info.format, meta); if (AUDIO_FORMAT_INVALID == info.format) { // can't offload if we don't know what the source format is ALOGE("mime type \"%s\" not a known audio format", mime); -- cgit v1.1