diff options
author | Preetam Singh Ranawat <apranawat@codeaurora.org> | 2015-07-23 08:59:47 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:24:28 -0600 |
commit | fd42e7afbe43eca5ab6835f8b2720b7e0e8302e0 (patch) | |
tree | 13b03bf4eb20ffbf7740e96078f218c63fe6652a | |
parent | ab9bb1594982ad1affed948711d6f487e1c90271 (diff) | |
download | frameworks_av-fd42e7afbe43eca5ab6835f8b2720b7e0e8302e0.zip frameworks_av-fd42e7afbe43eca5ab6835f8b2720b7e0e8302e0.tar.gz frameworks_av-fd42e7afbe43eca5ab6835f8b2720b7e0e8302e0.tar.bz2 |
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
18 files changed, 214 insertions, 23 deletions
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<NuPlayer::Source> &source, const sp<NuPlayer::Renderer> &renderer); + virtual sp<NuPlayer::DecoderBase> createDecoder( + const sp<AMessage> ¬ify, + const sp<NuPlayer::Source> &source, + pid_t pid, + const sp<NuPlayer::Renderer> &renderer); + + virtual sp<NuPlayer::Renderer> createRenderer( + const sp<MediaPlayerBase::AudioSink> &sink, + const sp<AMessage> ¬ify, + uint32_t flags); + // ----- NO TRESSPASSING BEYOND THIS LINE ------ DECLARE_LOADABLE_SINGLETON(AVNuFactory); }; @@ -55,6 +65,21 @@ struct AVNuFactory { */ struct AVNuUtils { + virtual sp<MetaData> createPCMMetaFromSource(const sp<MetaData> &); + virtual bool pcmOffloadException(const sp<MetaData> &); + virtual bool isRAWFormat(const sp<MetaData> &); + virtual bool isRAWFormat(const sp<AMessage> &); + virtual int updateAudioBitWidth(audio_format_t audioFormat, + const sp<AMessage> &); + virtual audio_format_t getKeyPCMFormat(const sp<MetaData> &); + virtual void setKeyPCMFormat(const sp<MetaData> &, audio_format_t audioFormat); + virtual audio_format_t getPCMFormat(const sp<AMessage> &); + virtual void setPCMFormat(const sp<AMessage> &, audio_format_t audioFormat); + virtual void setSourcePCMFormat(const sp<MetaData> &); + virtual void setDecodedPCMFormat(const sp<AMessage> &); + virtual status_t convertToSinkFormatIfNeeded(const sp<ABuffer> &, sp<ABuffer> &, + 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 <nuplayer/NuPlayer.h> #include <nuplayer/NuPlayerDecoderBase.h> #include <nuplayer/NuPlayerDecoderPassThrough.h> +#include <nuplayer/NuPlayerDecoder.h> +#include <nuplayer/NuPlayerCCDecoder.h> +#include <gui/Surface.h> #include <nuplayer/NuPlayerSource.h> #include <nuplayer/NuPlayerRenderer.h> @@ -56,6 +59,21 @@ sp<NuPlayer::DecoderBase> AVNuFactory::createPassThruDecoder( return new NuPlayer::DecoderPassThrough(notify, source, renderer); } +sp<NuPlayer::DecoderBase> AVNuFactory::createDecoder( + const sp<AMessage> ¬ify, + const sp<NuPlayer::Source> &source, + pid_t pid, + const sp<NuPlayer::Renderer> &renderer) { + return new NuPlayer::Decoder(notify, source, pid, renderer); +} + +sp<NuPlayer::Renderer> AVNuFactory::createRenderer( + const sp<MediaPlayerBase::AudioSink> &sink, + const sp<AMessage> ¬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<MetaData> AVNuUtils::createPCMMetaFromSource(const sp<MetaData> &sMeta) { + return sMeta; +} + +bool AVNuUtils::pcmOffloadException(const sp<MetaData> &) { + return true; +} + +bool AVNuUtils::isRAWFormat(const sp<MetaData> &) { + return false; +} + +bool AVNuUtils::isRAWFormat(const sp<AMessage> &) { + return false; +} + + +int AVNuUtils::updateAudioBitWidth(audio_format_t /*audioFormat*/, + const sp<AMessage> &){ + return 16; +} + +audio_format_t AVNuUtils::getKeyPCMFormat(const sp<MetaData> &) { + return AUDIO_FORMAT_INVALID; +} + +void AVNuUtils::setKeyPCMFormat(const sp<MetaData> &, audio_format_t /*audioFormat*/) { + +} + +audio_format_t AVNuUtils::getPCMFormat(const sp<AMessage> &) { + return AUDIO_FORMAT_PCM_16_BIT; +} + +void AVNuUtils::setPCMFormat(const sp<AMessage> &, audio_format_t /*audioFormat*/) { + +} + +void AVNuUtils::setSourcePCMFormat(const sp<MetaData> &) { + +} + +void AVNuUtils::setDecodedPCMFormat(const sp<AMessage> &) { + +} +status_t AVNuUtils::convertToSinkFormatIfNeeded(const sp<ABuffer> &, sp<ABuffer> &, + 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<MediaCodec> createCustomComponentByName(const sp<ALooper> &looper, const char* mime, bool encoder); + + virtual bool is24bitPCMOffloadEnabled(); + virtual bool is16bitPCMOffloadEnabled(); + virtual int getPcmSampleBits(const sp<MetaData> &); + virtual int getPcmSampleBits(const sp<AMessage> &); + virtual void setPcmSampleBits(const sp<MetaData> &, int32_t /*bitWidth*/); + virtual void setPcmSampleBits(const sp<AMessage> &, int32_t /*bitWidth*/); + + virtual audio_format_t updateAudioFormat(audio_format_t audioFormat, + const sp<MetaData> &); + + virtual audio_format_t updateAudioFormat(audio_format_t audioFormat, + const sp<AMessage> &); + // ----- 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<MetaData> &) { + return 16; +} + +int AVUtils::getPcmSampleBits(const sp<AMessage> &) { + return 16; +} + +void AVUtils::setPcmSampleBits(const sp<AMessage> &, int32_t /*bitWidth*/) { +} + +void AVUtils::setPcmSampleBits(const sp<MetaData> &, int32_t /*bitWidth*/) { +} + +audio_format_t AVUtils::updateAudioFormat(audio_format_t audioFormat, + const sp<MetaData> &){ + return audioFormat; +} + +audio_format_t AVUtils::updateAudioFormat(audio_format_t audioFormat, + const sp<AMessage> &){ + return audioFormat; +} + static bool dumbSniffer( const sp<DataSource> &, String8 *, float *, sp<AMessage> *) { diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index f9eb496..fa24415 100644..100755 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -30,6 +30,7 @@ #include <media/IAudioFlinger.h> #include <media/AudioPolicyHelper.h> #include <media/AudioResamplerPublic.h> +#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<MetaData> 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<AMessage> 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<AMessage> 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<DecoderBase> *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<AMessage> 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<AMessage> &msg); - + virtual bool ifDecodedPCMOffload() {return false;} + virtual void setDecodedPcmOffload(bool /*decodePcmOffload*/) {} + virtual bool canOffloadDecodedPCMStream(const sp<MetaData> /*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<AMessage> &format, bool hasVideo); + virtual void tryOpenAudioSinkForOffload(const sp<AMessage> &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<AMessage> & /*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<AMessage> &format); + virtual void handleOutputFormatChange(const sp<AMessage> &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 <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/MediaErrors.h> +#include "mediaplayerservice/AVNuExtensions.h" #include "ATSParser.h" @@ -201,6 +202,7 @@ sp<ABuffer> 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<AMessage> & /*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 <media/stagefright/VideoFrameScheduler.h> #include <inttypes.h> +#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<AMessage> &format, bool offloadOnly, @@ -101,7 +103,6 @@ protected: virtual void onMessageReceived(const sp<AMessage> &msg); -private: enum { kWhatDrainAudioQueue = 'draA', kWhatDrainVideoQueue = 'draV', @@ -228,7 +229,7 @@ private: void prepareForMediaRenderingStart_l(); void notifyIfMediaRenderingStarted_l(); - void onQueueBuffer(const sp<AMessage> &msg); + virtual void onQueueBuffer(const sp<AMessage> &msg); void onQueueEOS(const sp<AMessage> &msg); void onFlush(const sp<AMessage> &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<AMessage> ¬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<MetaData>& 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); |