From 79be96a22d7f6094a683ca22622f2de52755ac5b Mon Sep 17 00:00:00 2001 From: Praveen Chavan Date: Tue, 29 Sep 2015 02:25:47 -0700 Subject: AudioSystem: Fix race condition in accessing ioDescriptors The vector mIoDescriptors can be simultaneouly modified and accessed by 2 threads. Acquire a lock while wrapping the ioDescriptor in a sp<> Change-Id: I73c79ef8eca092b500a7ead3a5ebd0bcf75f9920 --- media/libmedia/AudioSystem.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'media') diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp index 3bfb09a..9d645f0 100644 --- a/media/libmedia/AudioSystem.cpp +++ b/media/libmedia/AudioSystem.cpp @@ -476,7 +476,7 @@ void AudioSystem::AudioFlingerClient::ioConfigChanged(audio_io_config_event even switch (event) { case AUDIO_OUTPUT_OPENED: case AUDIO_INPUT_OPENED: { - sp oldDesc = getIoDescriptor(ioDesc->mIoHandle); + sp oldDesc = getIoDescriptor_l(ioDesc->mIoHandle); if (oldDesc == 0) { mIoDescriptors.add(ioDesc->mIoHandle, ioDesc); } else { @@ -498,7 +498,7 @@ void AudioSystem::AudioFlingerClient::ioConfigChanged(audio_io_config_event even } break; case AUDIO_OUTPUT_CLOSED: case AUDIO_INPUT_CLOSED: { - if (getIoDescriptor(ioDesc->mIoHandle) == 0) { + if (getIoDescriptor_l(ioDesc->mIoHandle) == 0) { ALOGW("ioConfigChanged() closing unknown %s %d", event == AUDIO_OUTPUT_CLOSED ? "output" : "input", ioDesc->mIoHandle); break; @@ -512,7 +512,7 @@ void AudioSystem::AudioFlingerClient::ioConfigChanged(audio_io_config_event even case AUDIO_OUTPUT_CONFIG_CHANGED: case AUDIO_INPUT_CONFIG_CHANGED: { - sp oldDesc = getIoDescriptor(ioDesc->mIoHandle); + sp oldDesc = getIoDescriptor_l(ioDesc->mIoHandle); if (oldDesc == 0) { ALOGW("ioConfigChanged() modifying unknown output! %d", ioDesc->mIoHandle); break; @@ -575,7 +575,7 @@ status_t AudioSystem::AudioFlingerClient::getInputBufferSize( return NO_ERROR; } -sp AudioSystem::AudioFlingerClient::getIoDescriptor(audio_io_handle_t ioHandle) +sp AudioSystem::AudioFlingerClient::getIoDescriptor_l(audio_io_handle_t ioHandle) { sp desc; ssize_t index = mIoDescriptors.indexOfKey(ioHandle); @@ -585,6 +585,12 @@ sp AudioSystem::AudioFlingerClient::getIoDescriptor(audio_io_ return desc; } +sp AudioSystem::AudioFlingerClient::getIoDescriptor(audio_io_handle_t ioHandle) +{ + Mutex::Autolock _l(mLock); + return getIoDescriptor_l(ioHandle); +} + status_t AudioSystem::AudioFlingerClient::addAudioDeviceCallback( const sp& callback, audio_io_handle_t audioIo) { -- cgit v1.1 From 43a345e28b64d6eb63f4d5bb1fa5b7d67c5ce26f Mon Sep 17 00:00:00 2001 From: Satya Krishna Pindiproli Date: Wed, 30 Sep 2015 16:32:12 +0530 Subject: libmedia: return error if getRenderPosition fails Currently, if the call getRenderPosition() fails, no error is propagated to the caller. As the handling is already present in NuPlayerRenderer, return an error if the call fails. CRs-Fixed: 912730 Change-Id: I01e3348ffd696ce781287451b9a9478b50037ade --- media/libmedia/AudioTrack.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'media') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index f46b66e..2d9fcf7 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -999,14 +999,18 @@ status_t AudioTrack::getPosition(uint32_t *position) return NO_ERROR; } - if (AVMediaUtils::get()->AudioTrackGetPosition(this, position) == NO_ERROR) { + if (AVMediaUtils::get()->AudioTrackIsPcmOffloaded(mFormat) && + 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); - // FIXME: on getRenderPosition() error, we return OK with frame position 0. + status_t status = AudioSystem::getRenderPosition(mOutput, &halFrames, &dspFrames); + if (status != NO_ERROR) { + ALOGW("failed to getRenderPosition for offload session status %d", status); + return INVALID_OPERATION; + } } // FIXME: dspFrames may not be zero in (mState == STATE_STOPPED || mState == STATE_FLUSHED) // due to hardware latency. We leave this behavior for now. -- cgit v1.1 From 427d20a12115dbb35c6391f014f68e5283b3e6a2 Mon Sep 17 00:00:00 2001 From: Santhosh Behara Date: Mon, 14 Sep 2015 12:16:49 +0530 Subject: NuPlayer: Use ".m3u8" in substring search to determine HLS URL In IsHTTPLiveURL(), "m3u8" is being used in sub-string comparison to determine if the given URL is HTTPLiveURL or not. This can lead to false results incase if the given URL has "m3u8" as part of it. Hence use ".m3u8" in strstr() instead of "m3u8". Change-Id: I7f4a3c641d831b3ef77d166701f3e3edabdaebc0 --- media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'media') diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 86c35e2..91c2e6f 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -226,7 +226,7 @@ bool NuPlayer::IsHTTPLiveURL(const char *url) { return true; } - if (strstr(url,"m3u8")) { + if (strstr(url,".m3u8")) { return true; } } -- cgit v1.1 From 906e4fdbc8c5882c371abf84fbeedda2b54f67fc Mon Sep 17 00:00:00 2001 From: Santhosh Behara Date: Mon, 28 Sep 2015 16:03:55 +0530 Subject: httplive: Ignore seek request for livestreaming Check added in HTTPLiveSource to throw error if seek is called in live streaming usecase. Change-Id: I1d478ea506734bd9b6bbfba4f04649be398f3c7a --- media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'media') diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp index 6683481..a57fdc1 100644 --- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp +++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp @@ -212,7 +212,11 @@ status_t NuPlayer::HTTPLiveSource::selectTrack(size_t trackIndex, bool select, i } status_t NuPlayer::HTTPLiveSource::seekTo(int64_t seekTimeUs) { - return mLiveSession->seekTo(seekTimeUs); + if (mLiveSession->isSeekable()) { + return mLiveSession->seekTo(seekTimeUs); + } else { + return INVALID_OPERATION; + } } void NuPlayer::HTTPLiveSource::pollForRawData( -- cgit v1.1 From 26e6ce2197669040095a225b55b04d41dbd4e4b0 Mon Sep 17 00:00:00 2001 From: Surajit Podder Date: Fri, 25 Sep 2015 19:03:35 +0530 Subject: Revert "Revert "mediaplayer: make frame-accurate avsync configurable"" This reverts commit e17afa888040eb5fbd31249305efd88ee03bb5bc. Change-Id: I7afb6a055d3efb08fdbdff19f0bbad01934614e8 --- .../nuplayer/NuPlayerRenderer.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'media') diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp index aa993a9..9d2f134 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp @@ -83,6 +83,16 @@ const NuPlayer::Renderer::PcmInfo NuPlayer::Renderer::AUDIO_PCMINFO_INITIALIZER // static const int64_t NuPlayer::Renderer::kMinPositionUpdateDelayUs = 100000ll; +static bool sFrameAccurateAVsync = false; + +static void readProperties() { + char value[PROPERTY_VALUE_MAX]; + if (property_get("persist.sys.media.avsync", value, NULL)) { + sFrameAccurateAVsync = + !strcmp("1", value) || !strcasecmp("true", value); + } +} + NuPlayer::Renderer::Renderer( const sp &sink, const sp ¬ify, @@ -124,6 +134,7 @@ NuPlayer::Renderer::Renderer( mMediaClock = new MediaClock; mPlaybackRate = mPlaybackSettings.mSpeed; mMediaClock->setPlaybackRate(mPlaybackRate); + readProperties(); } NuPlayer::Renderer::~Renderer() { @@ -1065,6 +1076,11 @@ void NuPlayer::Renderer::postDrainVideoQueue() { ALOGW_IF(delayUs > 500000, "unusually high delayUs: %" PRId64, delayUs); // post 2 display refreshes before rendering is due + // FIXME currently this increases power consumption, so unless frame-accurate + // AV sync is requested, post closer to required render time (at 0.63 vsyncs) + if (!sFrameAccurateAVsync) { + twoVsyncsUs >>= 4; + } msg->post(delayUs > twoVsyncsUs ? delayUs - twoVsyncsUs : 0); mDrainVideoQueuePending = true; @@ -1477,6 +1493,8 @@ void NuPlayer::Renderer::onPause() { } void NuPlayer::Renderer::onResume() { + readProperties(); + if (!mPaused) { return; } -- cgit v1.1 From fc7a0312dd2a9dfc0c084e70b5898438875958f0 Mon Sep 17 00:00:00 2001 From: Praveen Chavan Date: Thu, 1 Oct 2015 19:05:19 -0700 Subject: Stagefright: add a NULL check before accessing camera params Camera may return NULL params if the remote object is dead. Check for NULL and report error rather than crash. Change-Id: Id1fcd04dc187aadf00ca4ec5e48fb495c3369c92 CRs-Fixed: 906099 --- media/libstagefright/CameraSource.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'media') diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index 41513fb..27a6086 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -100,6 +100,11 @@ void CameraSourceListener::postDataTimestamp( } static int32_t getColorFormat(const char* colorFormat) { + if (!colorFormat) { + ALOGE("Invalid color format"); + return -1; + } + if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV420P)) { return OMX_COLOR_FormatYUV420Planar; } -- cgit v1.1 From a9961f6786d048c247cd41363e2b784e1a5aeab4 Mon Sep 17 00:00:00 2001 From: Manikanta Kanamarlapudi Date: Mon, 28 Sep 2015 16:03:17 +0530 Subject: libstagefright: Set Intra period set intra period for HEVC encoder Change-Id: Id2b3e71b746eaaed76118126d44ad83458d68520 --- media/libavextensions/stagefright/AVExtensions.h | 5 +++++ media/libavextensions/stagefright/AVUtils.cpp | 6 ++++++ media/libstagefright/ACodec.cpp | 4 ++++ 3 files changed, 15 insertions(+) (limited to 'media') diff --git a/media/libavextensions/stagefright/AVExtensions.h b/media/libavextensions/stagefright/AVExtensions.h index 832fc28..fc04df1 100644 --- a/media/libavextensions/stagefright/AVExtensions.h +++ b/media/libavextensions/stagefright/AVExtensions.h @@ -34,6 +34,7 @@ #include #include #include +#include namespace android { @@ -183,6 +184,10 @@ struct AVUtils { virtual void cacheCaptureBuffers(sp camera, video_encoder encoder); virtual const char *getCustomCodecsLocation(); + virtual void setIntraPeriod( + int nPFrames, int nBFrames, const sp OMXhandle, + IOMX::node_id nodeID); + private: HEVCMuxer mHEVCMuxer; // ----- NO TRESSPASSING BEYOND THIS LINE ------ diff --git a/media/libavextensions/stagefright/AVUtils.cpp b/media/libavextensions/stagefright/AVUtils.cpp index 9219fc2..324ff9b 100644 --- a/media/libavextensions/stagefright/AVUtils.cpp +++ b/media/libavextensions/stagefright/AVUtils.cpp @@ -169,6 +169,12 @@ const char *AVUtils::getCustomCodecsLocation() { return "/etc/media_codecs.xml"; } +void AVUtils::setIntraPeriod( + int, int, const sp, + IOMX::node_id) { + return; +} + // ----- NO TRESSPASSING BEYOND THIS LINE ------ AVUtils::AVUtils() {} diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 43006f3..78ab3db 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -54,6 +54,8 @@ #include "include/avc_utils.h" +#include + namespace android { // OMX errors are directly mapped into status_t range if @@ -3510,6 +3512,8 @@ status_t ACodec::setupHEVCEncoderParameters(const sp &msg) { frameRate = (float)tmp; } + AVUtils::get()->setIntraPeriod(setPFramesSpacing(iFrameInterval, frameRate), 0, mOMX, mNode); + OMX_VIDEO_PARAM_HEVCTYPE hevcType; InitOMXParams(&hevcType); hevcType.nPortIndex = kPortIndexOutput; -- cgit v1.1 From d33b158b5ed85a6e43bf79c646cac72adce3c04f Mon Sep 17 00:00:00 2001 From: Praveen Chavan Date: Thu, 8 Oct 2015 13:43:12 -0700 Subject: Stagefright: Transition to uninitialized state after freeing node If the component is force-released after timeout, there could be a race condition where component posted a message just before it was released. This posted message will cause ACodec to wrongly invoke OMX API on the component which was freed already. Move ACodec to uninitialized state where all component messages will be safely ignored. Change-Id: I71da7c7d021210fd6bed44761740161a5d8894e7 CRs-Fixed: 884165 --- media/libstagefright/ACodec.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'media') diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 43006f3..8f814d8 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -4611,6 +4611,7 @@ bool ACodec::BaseState::onMessageReceived(const sp &msg) { ALOGI("[%s] forcing the release of codec", mCodec->mComponentName.c_str()); status_t err = mCodec->mOMX->freeNode(mCodec->mNode); + mCodec->changeState(mCodec->mUninitializedState); ALOGE_IF("[%s] failed to release codec instance: err=%d", mCodec->mComponentName.c_str(), err); sp notify = mCodec->mNotify->dup(); -- cgit v1.1 From b8a89c8c3cdcaa95706897b18bff35098df0c817 Mon Sep 17 00:00:00 2001 From: Deva Ramasubramanian Date: Thu, 17 Sep 2015 12:48:59 -0700 Subject: libstagefright: Allow for CameraSourceTimeLapse to be extended Add in hooks to route CameraSourceTimeLapse creation to AVFactory so that we can add our customizations. Change-Id: I309a247ba6e3c5626cfba096677a6dbfeae543f3 --- media/libavextensions/stagefright/AVExtensions.h | 15 ++++++++++++++- media/libavextensions/stagefright/AVFactory.cpp | 18 +++++++++++++++++- media/libmediaplayerservice/StagefrightRecorder.cpp | 4 ++-- 3 files changed, 33 insertions(+), 4 deletions(-) (limited to 'media') diff --git a/media/libavextensions/stagefright/AVExtensions.h b/media/libavextensions/stagefright/AVExtensions.h index fc04df1..9c712e4 100644 --- a/media/libavextensions/stagefright/AVExtensions.h +++ b/media/libavextensions/stagefright/AVExtensions.h @@ -54,6 +54,7 @@ class CameraParameters; class MediaBuffer; struct AudioSource; class CameraSource; +class CameraSourceTimeLapse; class ICamera; class ICameraRecordingProxy; class String16; @@ -85,7 +86,7 @@ struct AVFactory { uint32_t channels, uint32_t outSampleRate = 0); - virtual CameraSource *CreateFromCamera( + virtual CameraSource *CreateCameraSourceFromCamera( const sp &camera, const sp &proxy, int32_t cameraId, @@ -95,6 +96,18 @@ struct AVFactory { int32_t frameRate, const sp& surface, bool storeMetaDataInVideoBuffers = true); + + virtual CameraSourceTimeLapse *CreateCameraSourceTimeLapseFromCamera( + const sp &camera, + const sp &proxy, + int32_t cameraId, + const String16& clientName, + uid_t clientUid, + Size videoSize, + int32_t videoFrameRate, + const sp& surface, + int64_t timeBetweenFrameCaptureUs, + bool storeMetaDataInVideoBuffers = true); // ----- NO TRESSPASSING BEYOND THIS LINE ------ DECLARE_LOADABLE_SINGLETON(AVFactory); }; diff --git a/media/libavextensions/stagefright/AVFactory.cpp b/media/libavextensions/stagefright/AVFactory.cpp index 19977e9..90ac7b2 100644 --- a/media/libavextensions/stagefright/AVFactory.cpp +++ b/media/libavextensions/stagefright/AVFactory.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include "common/ExtensionsLoader.hpp" @@ -88,7 +89,7 @@ AudioSource* AVFactory::createAudioSource( channels, outSampleRate); } -CameraSource* AVFactory::CreateFromCamera( +CameraSource* AVFactory::CreateCameraSourceFromCamera( const sp &camera, const sp &proxy, int32_t cameraId, @@ -103,6 +104,21 @@ CameraSource* AVFactory::CreateFromCamera( storeMetaDataInVideoBuffers); } +CameraSourceTimeLapse* AVFactory::CreateCameraSourceTimeLapseFromCamera( + const sp &camera, + const sp &proxy, + int32_t cameraId, + const String16& clientName, + uid_t clientUid, + Size videoSize, + int32_t videoFrameRate, + const sp& surface, + int64_t timeBetweenFrameCaptureUs, + bool storeMetaDataInVideoBuffers) { + return CameraSourceTimeLapse::CreateFromCamera(camera, proxy, cameraId, + clientName, clientUid, videoSize, videoFrameRate, surface, + timeBetweenFrameCaptureUs, storeMetaDataInVideoBuffers); +} // ----- NO TRESSPASSING BEYOND THIS LINE ------ AVFactory::AVFactory() { } diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 136e6cf..80d5ac2 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -1465,13 +1465,13 @@ status_t StagefrightRecorder::setupCameraSource( return BAD_VALUE; } - mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera( + mCameraSourceTimeLapse = AVFactory::get()->CreateCameraSourceTimeLapseFromCamera( mCamera, mCameraProxy, mCameraId, mClientName, mClientUid, videoSize, mFrameRate, mPreviewSurface, mTimeBetweenCaptureUs); *cameraSource = mCameraSourceTimeLapse; } else { - *cameraSource = AVFactory::get()->CreateFromCamera( + *cameraSource = AVFactory::get()->CreateCameraSourceFromCamera( mCamera, mCameraProxy, mCameraId, mClientName, mClientUid, videoSize, mFrameRate, mPreviewSurface); -- cgit v1.1 From 2860671de710281c35df163d343f2ab2ec9bf736 Mon Sep 17 00:00:00 2001 From: Aravind Asam Date: Fri, 25 Sep 2015 14:02:11 -0700 Subject: Opt out of clang till issues are fixed Needed for moving to clang Change-Id: I984ce0d452bcd9025d743c0f081bb0d22587b106 --- media/libavextensions/Android.mk | 3 +++ media/libstagefright/codecs/amrnb/dec/Android.mk | 1 + 2 files changed, 4 insertions(+) (limited to 'media') diff --git a/media/libavextensions/Android.mk b/media/libavextensions/Android.mk index 0bc886d..0380135 100644 --- a/media/libavextensions/Android.mk +++ b/media/libavextensions/Android.mk @@ -22,6 +22,7 @@ ifeq ($(TARGET_ENABLE_QC_AV_ENHANCEMENTS),true) endif LOCAL_MODULE:= libavextensions +LOCAL_CLANG := false LOCAL_MODULE_TAGS := optional @@ -49,6 +50,7 @@ ifeq ($(TARGET_ENABLE_QC_AV_ENHANCEMENTS),true) endif LOCAL_MODULE:= libavmediaextentions +LOCAL_CLANG := false LOCAL_MODULE_TAGS := optional @@ -82,6 +84,7 @@ ifeq ($(TARGET_ENABLE_QC_AV_ENHANCEMENTS),true) endif LOCAL_MODULE:= libavmediaserviceextensions +LOCAL_CLANG := false LOCAL_MODULE_TAGS := optional diff --git a/media/libstagefright/codecs/amrnb/dec/Android.mk b/media/libstagefright/codecs/amrnb/dec/Android.mk index 3750e2e..415702e 100644 --- a/media/libstagefright/codecs/amrnb/dec/Android.mk +++ b/media/libstagefright/codecs/amrnb/dec/Android.mk @@ -80,6 +80,7 @@ LOCAL_SHARED_LIBRARIES := \ libstagefright_amrnb_common LOCAL_MODULE := libstagefright_soft_amrdec +LOCAL_CLANG := false LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) -- cgit v1.1 From 3684ae89c9baa229f5a988406d27a5931a5e0556 Mon Sep 17 00:00:00 2001 From: Shalaj Jain Date: Fri, 9 Oct 2015 17:32:58 -0700 Subject: nuplayer: handle error from MediaCodec in Decoder handleAnOutputBuffer MediaCodec could send out message of output buffer available right before it hits an error and clears its buffers. Change-Id: I1b11c88cdcb3fca7ddd6103c6d3d28642304f079 --- media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'media') diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp index 27650d7..f83eaf6 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp @@ -565,6 +565,11 @@ bool NuPlayer::Decoder::handleAnOutputBuffer( sp buffer; mCodec->getOutputBuffer(index, &buffer); + if (buffer == NULL) { + handleError(UNKNOWN_ERROR); + return false; + } + if (index >= mOutputBuffers.size()) { for (size_t i = mOutputBuffers.size(); i <= index; ++i) { mOutputBuffers.add(); -- cgit v1.1 From 380d397b261d7a12d7d1be10756dc93670aeb017 Mon Sep 17 00:00:00 2001 From: Preetam Singh Ranawat Date: Thu, 30 Apr 2015 16:56:51 +0530 Subject: NuPlayer: Fix for PCM offload fallback on BT -Start the Decoded PCM offload playback on speaker or headset and connect BT, audio is not played on BT. -During tear down event on BT connection, instantiation of decoder is initated before actual shut down of decoder completes.So decoder is not getting instantiated again after tear down event. It is a race condition between instantiation of Decoder and shut down of decoder. -Defer the instantiation of decoder in intermediate state CRs-Fixed: 916643, 829392 Change-Id: Ic346cb7bb7b1babe21618daa8f8746c00f4b61b3 --- media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 17 +++++++++++++++++ media/libmediaplayerservice/nuplayer/NuPlayer.h | 1 + 2 files changed, 18 insertions(+) (limited to 'media') diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 86c35e2..aaf6b9e 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -131,6 +131,23 @@ private: DISALLOW_EVIL_CONSTRUCTORS(FlushDecoderAction); }; +struct NuPlayer::InstantiateDecoderAction : public Action { + InstantiateDecoderAction(bool audio, sp *decoder) + : mAudio(audio), + mdecoder(decoder) { + } + + virtual void execute(NuPlayer *player) { + player->instantiateDecoder(mAudio, mdecoder); + } + +private: + bool mAudio; + sp *mdecoder; + + DISALLOW_EVIL_CONSTRUCTORS(InstantiateDecoderAction); +}; + struct NuPlayer::PostMessageAction : public Action { PostMessageAction(const sp &msg) : mMessage(msg) { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 4ed3079..53d1f06 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -109,6 +109,7 @@ public: struct SetSurfaceAction; struct ResumeDecoderAction; struct FlushDecoderAction; + struct InstantiateDecoderAction; struct PostMessageAction; struct SimpleAction; -- cgit v1.1 From 00208bc4c6d725ea9ce0795a897d42b5a32360c3 Mon Sep 17 00:00:00 2001 From: Haynes Mathew George Date: Wed, 30 Sep 2015 16:11:11 -0700 Subject: NuPlayer: Teardown sequence for pcm offload On a teardown event, follow proper shutdown sequence if the decoder instance type is not passthrough. This is needed to ensure NuPlayerDecoder, MediaCodec do not enter an invalid state due to forced clear while handling a teardown event. CRs-Fixed: 916643 Change-Id: Ied5df07dc8567974ef02e3a0bb415795f31f2ed2 --- media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 47 +++++++++++++++++++++++ media/libmediaplayerservice/nuplayer/NuPlayer.h | 2 + 2 files changed, 49 insertions(+) (limited to 'media') diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index aaf6b9e..f9d1bee 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1110,6 +1110,12 @@ void NuPlayer::onMessageReceived(const sp &msg) { int32_t reason; CHECK(msg->findInt32("reason", &reason)); ALOGV("Tear down audio with reason %d.", reason); + + if (ifDecodedPCMOffload()) { + tearDownPCMOffload(msg); + break; + } + mAudioDecoder.clear(); ++mAudioDecoderGeneration; bool needsToCreateAudioDecoder = true; @@ -2401,4 +2407,45 @@ void NuPlayer::Source::onMessageReceived(const sp & /* msg */) { TRESPASS(); } +void NuPlayer::tearDownPCMOffload(const sp &msg) { + int32_t reason; + CHECK(msg->findInt32("reason", &reason)); + + if (mAudioDecoder != NULL) { + switch (mFlushingAudio) { + case NONE: + case FLUSHING_DECODER: + mDeferredActions.push_back( + new FlushDecoderAction(FLUSH_CMD_SHUTDOWN /* audio */, + FLUSH_CMD_NONE /* video */)); + + if (reason == Renderer::kDueToError) { + mDeferredActions.push_back( + new InstantiateDecoderAction(true /* audio */, &mAudioDecoder)); + } + + int64_t positionUs; + if (!msg->findInt64("positionUs", &positionUs)) { + positionUs = mPreviousSeekTimeUs; + } + mDeferredActions.push_back(new SeekAction(positionUs)); + break; + default: + ALOGW("tearDownPCMOffload while flushing audio in %d", mFlushingAudio); + break; + } + } + + if (mRenderer != NULL) { + closeAudioSink(); + mRenderer->flush( + true /* audio */, false /* notifyComplete */); + if (mVideoDecoder != NULL) { + mRenderer->flush( + false /* audio */, false /* notifyComplete */); + } + } + processDeferredActions(); +} + } // namespace android diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 53d1f06..c0aa782 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -280,6 +280,8 @@ protected: void writeTrackInfo(Parcel* reply, const sp format) const; + void tearDownPCMOffload(const sp &msg); + DISALLOW_EVIL_CONSTRUCTORS(NuPlayer); }; -- cgit v1.1 From 97850dba0c3393126501991b8fa7431b7f130062 Mon Sep 17 00:00:00 2001 From: Santhosh Behara Date: Tue, 29 Sep 2015 11:24:21 +0530 Subject: httplive: Add default implementation in HLS for custom changes Add getSeqNumberInLiveStreaming() function in PlayListFetcher Make getBandwidthIndex() function to be virtual. Change-Id: I5e2bc7a42e0d4a16d5b5ea5f2ec3d78a7d019ad3 --- media/libstagefright/httplive/LiveSession.h | 2 +- media/libstagefright/httplive/PlaylistFetcher.cpp | 4 +++- media/libstagefright/httplive/PlaylistFetcher.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'media') diff --git a/media/libstagefright/httplive/LiveSession.h b/media/libstagefright/httplive/LiveSession.h index 4667c71..0d504e4 100644 --- a/media/libstagefright/httplive/LiveSession.h +++ b/media/libstagefright/httplive/LiveSession.h @@ -276,7 +276,7 @@ protected: float getAbortThreshold( ssize_t currentBWIndex, ssize_t targetBWIndex) const; void addBandwidthMeasurement(size_t numBytes, int64_t delayUs); - size_t getBandwidthIndex(int32_t bandwidthBps); + virtual size_t getBandwidthIndex(int32_t bandwidthBps); ssize_t getLowestValidBandwidthIndex() const; HLSTime latestMediaSegmentStartTime() const; diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp index 5ad29c3..023de93 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.cpp +++ b/media/libstagefright/httplive/PlaylistFetcher.cpp @@ -975,7 +975,9 @@ bool PlaylistFetcher::initDownloadState( if (mSegmentStartTimeUs < 0) { if (!mPlaylist->isComplete() && !mPlaylist->isEvent()) { // If this is a live session, start 3 segments from the end on connect - mSeqNumber = lastSeqNumberInPlaylist - 3; + if (!getSeqNumberInLiveStreaming()) { + mSeqNumber = lastSeqNumberInPlaylist - 3; + } if (mSeqNumber < firstSeqNumberInPlaylist) { mSeqNumber = firstSeqNumberInPlaylist; } diff --git a/media/libstagefright/httplive/PlaylistFetcher.h b/media/libstagefright/httplive/PlaylistFetcher.h index 74cc0dd..6b60b65 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.h +++ b/media/libstagefright/httplive/PlaylistFetcher.h @@ -249,6 +249,7 @@ protected: void updateDuration(); void updateTargetDuration(); virtual bool checkSwitchBandwidth() { return false; } + virtual bool getSeqNumberInLiveStreaming() { return false; } DISALLOW_EVIL_CONSTRUCTORS(PlaylistFetcher); }; -- cgit v1.1 From 6d1bfe5b18dbb745da83540c6011e1c557996f5c Mon Sep 17 00:00:00 2001 From: Sharad Sangle Date: Thu, 8 Oct 2015 23:59:08 +0530 Subject: audio: use QTI flac decoder based on flag While setting up the component for flac, current design is if encoder then don't use QTI flac component otherwise use QTI flac component, so if QTI flac is not being used then this might be wrong. So enhance the design to use QTI flac component only when it is enabled, otherwise use default flac component Change-Id: I57454841611885ae7cdf75896f8297ef8132292e CRs-Fixed: 916650 --- media/libstagefright/ACodec.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'media') diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index a132637..18d221b 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -2073,7 +2073,11 @@ status_t ACodec::configureCodec( } err = setupG711Codec(encoder, sampleRate, numChannels); } +#ifdef QTI_FLAC_DECODER } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC) && encoder) { +#else + } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { +#endif int32_t numChannels = 0, sampleRate = 0, compressionLevel = -1; if (encoder && (!msg->findInt32("channel-count", &numChannels) -- cgit v1.1 From cfec88d5a7806381da0dd1aadc3545727a3e79be Mon Sep 17 00:00:00 2001 From: Manoj Kumar AVM Date: Thu, 30 Apr 2015 10:24:11 -0700 Subject: stagefright: Add null check before passing meta data buffer Add necessary null checks to GraphicBuffer before passing it onto Metadatabuffer. Change-Id: I5cf09da4bd316e5c1733023746aa54960a36d8c9 --- media/libstagefright/SurfaceMediaSource.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'media') diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp index e8abf48..7da5a9f 100644 --- a/media/libstagefright/SurfaceMediaSource.cpp +++ b/media/libstagefright/SurfaceMediaSource.cpp @@ -360,7 +360,11 @@ status_t SurfaceMediaSource::read( mNumFramesEncoded++; // Pass the data to the MediaBuffer. Pass in only the metadata - + if (mSlots[mCurrentSlot].mGraphicBuffer == NULL) { + ALOGV("Read: SurfaceMediaSource mGraphicBuffer is null. Returning" + "ERROR_END_OF_STREAM."); + return ERROR_END_OF_STREAM; + } passMetadataBuffer(buffer, mSlots[mCurrentSlot].mGraphicBuffer->handle); (*buffer)->setObserver(this); -- cgit v1.1