From 427887bc50ea2d9297f2710843a7c9b5c508f0fd Mon Sep 17 00:00:00 2001 From: Vasantha Balla Date: Tue, 22 Dec 2015 17:07:21 +0530 Subject: libstagefright:Fix random memcmp crash while accessing output format. Random memcmp crash happens while checking for image-data in output format of audio buffer.Audio output format gets updated with pcm-format flag after codec formatchange in ExtendedNuUtils. Simultaneous memory check happens for image-data in FBD of MediaCodec. So crash happens. Avoid checking for image-data and crop information for audio buffers. Change-Id: I85ffcb149dc67a0f1bdb26116245627b1843d932 --- media/libstagefright/MediaCodec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index 54c57ee..5e0ee55 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -2575,7 +2575,7 @@ ssize_t MediaCodec::dequeuePortBuffer(int32_t portIndex) { info->mOwnedByClient = true; // set image-data - if (info->mFormat != NULL) { + if (info->mFormat != NULL && mIsVideo) { sp imageData; if (info->mFormat->findBuffer("image-data", &imageData)) { info->mData->meta()->setBuffer("image-data", imageData); -- cgit v1.1 From f6e8c701024f6c5dac552e794dcc61016a7f1bf7 Mon Sep 17 00:00:00 2001 From: Sharad Sangle Date: Thu, 24 Dec 2015 19:58:54 +0530 Subject: AudioMixer: delete reformatBuffer provider in proper order If mixer is creating reformatBufferProvider and downMixerBufferProvider while adding a track it first creates downMixerProvider then reformatBufferProvider. While deleting track it first deletes downMixerBufferProvider and then reformatBufferProvider, which should be in reverse order, the object created last should be deleted first. Change-Id: I844e7862280fe37c3167b31e92bbb27aa9463315 --- services/audioflinger/AudioMixer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 27a2f65..b830985 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -445,10 +445,10 @@ void AudioMixer::deleteTrackName(int name) // delete the resampler delete track.resampler; track.resampler = NULL; - // delete the downmixer - mState.tracks[name].unprepareForDownmix(); // delete the reformatter mState.tracks[name].unprepareForReformat(); + // delete the downmixer + mState.tracks[name].unprepareForDownmix(); // delete the timestretch provider delete track.mTimestretchBufferProvider; track.mTimestretchBufferProvider = NULL; -- cgit v1.1 From 617daafc1cf7580b7d80ead8a7e21bb5cbf525cf Mon Sep 17 00:00:00 2001 From: Kim Zhang Date: Tue, 29 Dec 2015 14:50:52 +0800 Subject: StagefrightMetadataRetriever: correct the status flag In case of EOS or ERROR from source, correct the status flag and clear the input index to continue to wait for output buffer from decoder. This is to fix thumbnail generation failure for some clips with one frame. CRs-Fixed: 951250 Change-Id: If9889dbcc32bf49368add408a317da026879fec8 --- media/libstagefright/StagefrightMetadataRetriever.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp index 5b96040..d39f34b 100644 --- a/media/libstagefright/StagefrightMetadataRetriever.cpp +++ b/media/libstagefright/StagefrightMetadataRetriever.cpp @@ -273,6 +273,9 @@ static VideoFrame *extractVideoFrame( if (err != OK) { ALOGW("Input Error or EOS"); haveMoreInputs = false; + //correct the status to continue to get output from decoder + err = OK; + inputIndex = -1; break; } -- cgit v1.1 From 9dae27c03dd73ca23c6aa778ed1423e4e133eb48 Mon Sep 17 00:00:00 2001 From: Santhosh Behara Date: Wed, 25 Nov 2015 19:27:22 +0530 Subject: ACodec: update native window crop rectangle In setupNativeWindowSizeFormatAndUsage, set the crop rectangle with the output port's crop value. Change-Id: I415be069d02d88dcd6b7c2460dda6df191ee7434 --- media/libstagefright/ACodec.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index ad4676f..3a08078 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -925,7 +925,7 @@ status_t ACodec::setupNativeWindowSizeFormatAndUsage( #endif ALOGV("gralloc usage: %#x(OMX) => %#x(ACodec)", omxUsage, usage); - return setNativeWindowSizeFormatAndUsage( + err = setNativeWindowSizeFormatAndUsage( nativeWindow, def.format.video.nFrameWidth, def.format.video.nFrameHeight, @@ -936,6 +936,24 @@ status_t ACodec::setupNativeWindowSizeFormatAndUsage( #endif mRotationDegrees, usage); + if (err == OK) { + OMX_CONFIG_RECTTYPE rect; + InitOMXParams(&rect); + rect.nPortIndex = kPortIndexOutput; + err = mOMX->getConfig( + mNode, OMX_IndexConfigCommonOutputCrop, &rect, sizeof(rect)); + if (err == OK) { + ALOGV("rect size = %d, %d, %d, %d", rect.nLeft, rect.nTop, rect.nWidth, rect.nHeight); + android_native_rect_t crop; + crop.left = rect.nLeft; + crop.top = rect.nTop; + crop.right = rect.nLeft + rect.nWidth - 1; + crop.bottom = rect.nTop + rect.nHeight - 1; + ALOGV("crop update (%d, %d), (%d, %d)", crop.left, crop.top, crop.right, crop.bottom); + err = native_window_set_crop(nativeWindow, &crop); + } + } + return err; } status_t ACodec::configureOutputBuffersFromNativeWindow( -- cgit v1.1 From 4486f97b6652b6b111a809827355b6ce5bf9c21e Mon Sep 17 00:00:00 2001 From: Weiyin Jiang Date: Wed, 6 Jan 2016 15:49:06 +0800 Subject: nuplayer: looping playback only if it was running Audio buffer filling in renderer is still happening, though pause was issued. As a result, EOS was reported irrespective of renderer state. If nuplayer driver receives playback complete after stopped, it will again be activated, which appears stop is not taking effect. Add a check for driver state to allow looping only if it was in running state. Change-Id: Ic9f8eac635a774cd805b3978fab640d73ae35744 CRs-Fixed: 958311 --- media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index 7c71e4e..4383fce 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -750,12 +750,19 @@ void NuPlayerDriver::notifyListener_l( } } if (mLooping || mAutoLoop) { - mPlayer->seekToAsync(0); - if (mAudioSink != NULL) { - // The renderer has stopped the sink at the end in order to play out - // the last little bit of audio. If we're looping, we need to restart it. - mAudioSink->start(); + if (mState == STATE_RUNNING) { + mPlayer->seekToAsync(0); + if (mAudioSink != NULL) { + // The renderer has stopped the sink at the end in order to play out + // the last little bit of audio. If we're looping, we need to restart it. + mAudioSink->start(); + } + } else { + mPlayer->pause(); + mState = STATE_PAUSED; + mAtEOS = true; } + // don't send completion event when looping return; } -- cgit v1.1 From e80385c9252ba5a2619378bed0bcb34d17506ba1 Mon Sep 17 00:00:00 2001 From: Preetam Singh Ranawat Date: Mon, 21 Dec 2015 16:39:11 +0530 Subject: audio: Update anchor time for offload playback post resume -AV sync is lost after multiple pasue/resume operatins. -Renderer does not update anchor time post resume and it may lead to AV sync loss after multiple pause/resume in offload playback case. -Get renderer position and update anchor time post resume for offload audio Change-Id: I2d9ba21c0e9b193ec77213de12229407cbf8dfd6 --- media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp index d959e62..2336eb7 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp @@ -1590,6 +1590,13 @@ void NuPlayer::Renderer::onResume() { ALOGD("received error :%d on resume for offload track posting TEAR_DOWN event",status); notifyAudioTearDown(); } + //Update anchor time after resuming playback. + if (offloadingAudio()) { + int64_t nowUs = ALooper::GetNowUs(); + int64_t nowMediaUs = + mAudioFirstAnchorTimeMediaUs + getPlayedOutAudioDurationUs(nowUs); + mMediaClock->updateAnchor(nowMediaUs, nowUs, INT64_MAX); + } } { -- cgit v1.1 From 7c1e4d782fec07f5b0273b7a443b6cee76357ea2 Mon Sep 17 00:00:00 2001 From: "Christopher R. Palmer" Date: Wed, 20 Jan 2016 20:31:42 -0500 Subject: av: "ACodec: update native window crop rectangle" depends on QCOM Change-Id: If0cc81468ab7ee8fa0ec374a9f23e4004e7cb212 --- media/libstagefright/ACodec.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 3a08078..4807b65 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -936,6 +936,7 @@ status_t ACodec::setupNativeWindowSizeFormatAndUsage( #endif mRotationDegrees, usage); +#ifdef QCOM_HARDWARE if (err == OK) { OMX_CONFIG_RECTTYPE rect; InitOMXParams(&rect); @@ -953,6 +954,7 @@ status_t ACodec::setupNativeWindowSizeFormatAndUsage( err = native_window_set_crop(nativeWindow, &crop); } } +#endif return err; } -- cgit v1.1 From df1c503b9dac70cd9b1c433215eea7661b5925da Mon Sep 17 00:00:00 2001 From: Keith Mok Date: Thu, 14 Jan 2016 11:36:26 -0800 Subject: Revert "Stagefright: Allow setting high-framerates in CameraSource" This reverts commit b5ccf81c19a7e9ce9b330abe734f1bae76d50796. That patch breaks "High Speed 60 FPS" and it fails in CameraSource::checkFrameRate which it compares the preview frame rate: Failed to set preview frame rate to 30 fps. The actual frame rate is 60. SAMBAR-1261 Change-Id: I6adf1432bf901e8ba37b1b86621e117e77cbf853 --- media/libstagefright/CameraSource.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index 4ee878a..e2ad924 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -325,12 +325,6 @@ status_t CameraSource::isCameraColorFormatSupported( return OK; } -static int32_t getHighSpeedFrameRate(const CameraParameters& params) { - const char* hsr = params.get("video-hsr"); - int32_t rate = (hsr != NULL && strncmp(hsr, "off", 3)) ? atoi(hsr) : 0; - return rate > 240 ? 240 : rate; -} - /* * Configure the camera to use the requested video size * (width and height) and/or frame rate. If both width and @@ -383,10 +377,6 @@ status_t CameraSource::configureCamera( params->get(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES); CHECK(supportedFrameRates != NULL); ALOGV("Supported frame rates: %s", supportedFrameRates); - if (getHighSpeedFrameRate(*params)) { - ALOGI("Use default 30fps for HighSpeed %dfps", frameRate); - frameRate = 30; - } char buf[4]; snprintf(buf, 4, "%d", frameRate); if (strstr(supportedFrameRates, buf) == NULL) { @@ -488,8 +478,6 @@ status_t CameraSource::checkFrameRate( ALOGE("Failed to retrieve preview frame rate (%d)", frameRateActual); return UNKNOWN_ERROR; } - int32_t highSpeedRate = getHighSpeedFrameRate(params); - frameRateActual = highSpeedRate ? highSpeedRate : frameRateActual; // Check the actual video frame rate against the target/requested // video frame rate. -- cgit v1.1 From dfcb22072eca593be848b762e49d4f7ab74bba13 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Fri, 22 Jan 2016 14:42:31 +0000 Subject: AVUtils: hevc: Return 0 when codec data is malformed This was returning ERROR_MALFORMED, which is a negative value, since the function prototype returns size_t, it would be converted to somewhere near 2**32 and would never fall into the actual error checking clause in AVUtils::HEVCMuxer::makeHEVCCodecSpecificData. Fixes android.mediastress.cts.HEVCR1080pAacLongPlayerTest#testPlay00 Ticket: CYNGNOS-1683 Change-Id: I13e6a76cb0ee4a6b730e1eb1023320b74a0539c7 --- media/libavextensions/stagefright/AVUtils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/media/libavextensions/stagefright/AVUtils.cpp b/media/libavextensions/stagefright/AVUtils.cpp index bdf5eb6..413026b 100644 --- a/media/libavextensions/stagefright/AVUtils.cpp +++ b/media/libavextensions/stagefright/AVUtils.cpp @@ -448,7 +448,7 @@ status_t AVUtils::HEVCMuxer::makeHEVCCodecSpecificData( List picParamSets; if ((*codecSpecificDataSize = parseHEVCCodecSpecificData(data, size, - vidParamSets, seqParamSets, picParamSets)) <= 0) { + vidParamSets, seqParamSets, picParamSets)) == 0) { ALOGE("cannot parser codec specific data, bailing out"); return ERROR_MALFORMED; } @@ -885,12 +885,12 @@ size_t AVUtils::HEVCMuxer::parseHEVCCodecSpecificData( } } else { ALOGE("Only VPS, SPS and PPS Nal units are expected"); - return ERROR_MALFORMED; + return 0; } if (nextStartCode == NULL) { ALOGE("Next start code is NULL"); - return ERROR_MALFORMED; + return 0; } // Move on to find the next parameter set -- cgit v1.1 From 214a19495ddd3d837f72ed1ee49c36d50d55fe5d Mon Sep 17 00:00:00 2001 From: Karthik Reddy Katta Date: Tue, 3 Nov 2015 16:14:27 +0530 Subject: libmedia: Add support for LHR tones Add tones to the ToneGenerator that are to be used for Local Hold Recall. Change-Id: I92cc1d63a3f6d38fc224774909b5b27d58be969c --- include/media/ToneGenerator.h | 2 ++ media/libmedia/ToneGenerator.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h index 8406ed6..0043bdc 100644 --- a/include/media/ToneGenerator.h +++ b/include/media/ToneGenerator.h @@ -148,6 +148,8 @@ public: TONE_CDMA_ABBR_ALERT, TONE_CDMA_SIGNAL_OFF, //CDMA end + TONE_HOLD_RECALL, + NUM_TONES, NUM_SUP_TONES = LAST_SUP_TONE-FIRST_SUP_TONE+1 }; diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp index d738ea7..af75e0f 100644 --- a/media/libmedia/ToneGenerator.cpp +++ b/media/libmedia/ToneGenerator.cpp @@ -698,7 +698,11 @@ const ToneGenerator::ToneDescriptor ToneGenerator::sToneDescriptors[] = { { .segments = { { .duration = 0, .waveFreq = { 0 }, 0, 0 }}, .repeatCnt = 0, .repeatSegment = 0 }, // TONE_CDMA_SIGNAL_OFF - + { .segments = { { .duration = 15000, .waveFreq = { 0 }, 0, 0 }, + { .duration = 500, .waveFreq = { 450, 0 }, 0, 0 }, + { .duration = 0 , .waveFreq = { 0 }, 0, 0}}, + .repeatCnt = ToneGenerator::TONEGEN_INF, + .repeatSegment = 0 }, // TONE_HOLD_RECALL { .segments = { { .duration = ToneGenerator::TONEGEN_INF, .waveFreq = { 350, 440, 0 }, 0, 0 }, { .duration = 0 , .waveFreq = { 0 }, 0, 0}}, .repeatCnt = ToneGenerator::TONEGEN_INF, -- cgit v1.1 From 554bc677837d05f5052592044f77e4de78520a04 Mon Sep 17 00:00:00 2001 From: Gabriele M Date: Sat, 23 Jan 2016 00:06:41 +0100 Subject: Revert "Audio Effects are not processing first buffer" This causes a short and loud noise when turning off effects while an audio track is playing or when an audio track is started with audio effects enabled. The noise appears to be non-existent if the volume level is set to its maximum. This reverts commit d15a8bd157cb531716bd3e15561f557e74588801. Change-Id: I2b8dd3447d673b4b98018710bc10c1eeb282598e --- services/audioflinger/Effects.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp index fb1e80c..879b6c9 100644 --- a/services/audioflinger/Effects.cpp +++ b/services/audioflinger/Effects.cpp @@ -1466,14 +1466,14 @@ void AudioFlinger::EffectChain::process_l() } size_t size = mEffects.size(); - for (size_t i = 0; i < size; i++) { - mEffects[i]->updateState(); - } if (doProcess) { for (size_t i = 0; i < size; i++) { mEffects[i]->process(); } } + for (size_t i = 0; i < size; i++) { + mEffects[i]->updateState(); + } } // addEffect_l() must be called with PlaybackThread::mLock held -- cgit v1.1 From 96985edf1dd51dcf4a3bebbb2f7f2169bc619497 Mon Sep 17 00:00:00 2001 From: jinamdar Date: Wed, 9 Dec 2015 12:38:43 -0800 Subject: Combine 'DTS Sound (TruMedia) Postpro support in frameworks/av for Android 6.0' as a single patch. Signed-off-by: jinamdar (cherry picked from commit d3668da66643d4cc39058fb65c8db0742748f70f) Conflicts: services/audioflinger/AudioFlinger.cpp services/audioflinger/Threads.cpp Change-Id: I67e3ba100ff40058919ba827b806aea7bdbaf4bb --- services/audioflinger/Android.mk | 25 +++++++++++++ services/audioflinger/AudioFlinger.cpp | 38 ++++++++++++++++++++ services/audioflinger/Threads.cpp | 66 ++++++++++++++++++++++++++++++++-- services/audioflinger/Threads.h | 20 ++++++++++- 4 files changed, 146 insertions(+), 3 deletions(-) diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk index 474fb46..0dd2af6 100644 --- a/services/audioflinger/Android.mk +++ b/services/audioflinger/Android.mk @@ -1,3 +1,23 @@ +# +# This file was modified by DTS, Inc. The portions of the +# code that are surrounded by "DTS..." are copyrighted and +# licensed separately, as follows: +# +# (C) 2015 DTS, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) @@ -86,6 +106,11 @@ LOCAL_SRC_FILES += \ LOCAL_CFLAGS += -DSTATE_QUEUE_INSTANTIATIONS='"StateQueueInstantiations.cpp"' LOCAL_CFLAGS += -fvisibility=hidden +ifeq ($(strip $(BOARD_USES_SRS_TRUEMEDIA)),true) +LOCAL_SHARED_LIBRARIES += libsrsprocessing +LOCAL_CFLAGS += -DSRS_PROCESSING +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-effects +endif include $(BUILD_SHARED_LIBRARY) diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 1acfaad..fdedabb 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -13,6 +13,25 @@ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. +** +** This file was modified by DTS, Inc. The portions of the +** code that are surrounded by "DTS..." are copyrighted and +** licensed separately, as follows: +** +** (C) 2015 DTS, Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +** */ @@ -64,6 +83,9 @@ #include #include #include +#ifdef SRS_PROCESSING +#include "postpro_patch.h" +#endif // ---------------------------------------------------------------------------- @@ -1051,6 +1073,13 @@ status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8& if (ioHandle == AUDIO_IO_HANDLE_NONE) { Mutex::Autolock _l(mLock); status_t final_result = NO_ERROR; +#ifdef SRS_PROCESSING + POSTPRO_PATCH_PARAMS_SET(keyValuePairs); + for (size_t i = 0; i < mPlaybackThreads.size(); i++) { + PlaybackThread *thread = mPlaybackThreads.valueAt(i).get(); + thread->setPostPro(); + } +#endif { AutoMutex lock(mHardwareLock); mHardwareStatus = AUDIO_HW_SET_PARAMETER; @@ -1145,6 +1174,9 @@ String8 AudioFlinger::getParameters(audio_io_handle_t ioHandle, const String8& k if (ioHandle == AUDIO_IO_HANDLE_NONE) { String8 out_s8; +#ifdef SRS_PROCESSING + POSTPRO_PATCH_PARAMS_GET(keys, out_s8); +#endif for (size_t i = 0; i < mAudioHwDevs.size(); i++) { char *s; @@ -1370,6 +1402,12 @@ sp AudioFlinger::getEffectThread_l(int sessionId, +void AudioFlinger::PlaybackThread::setPostPro() +{ + Mutex::Autolock _l(mLock); + if (mType == OFFLOAD) + broadcast_l(); +} // ---------------------------------------------------------------------------- AudioFlinger::Client::Client(const sp& audioFlinger, pid_t pid) diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 8c59282..1f60924 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -13,6 +13,25 @@ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. +** +** This file was modified by DTS, Inc. The portions of the +** code that are surrounded by "DTS..." are copyrighted and +** licensed separately, as follows: +** +** (C) 2015 DTS, Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +** */ @@ -72,6 +91,9 @@ #include #endif +#ifdef SRS_PROCESSING +#include "postpro_patch.h" +#endif // ---------------------------------------------------------------------------- // Note: the following macro is used for extremely verbose logging message. In @@ -2727,6 +2749,19 @@ bool AudioFlinger::PlaybackThread::threadLoop() const String8 myName(String8::format("thread %p type %d TID %d", this, mType, gettid())); acquireWakeLock(); +#ifdef SRS_PROCESSING + String8 bt_param = String8("bluetooth_enabled=0"); + POSTPRO_PATCH_PARAMS_SET(bt_param); + if (mType == MIXER) { + POSTPRO_PATCH_OUTPROC_PLAY_INIT(this, myName); + } else if (mType == OFFLOAD) { + POSTPRO_PATCH_OUTPROC_DIRECT_INIT(this, myName); + POSTPRO_PATCH_OUTPROC_PLAY_ROUTE_BY_VALUE(this, mOutDevice); + } else if (mType == DIRECT) { + POSTPRO_PATCH_OUTPROC_DIRECT_INIT(this, myName); + POSTPRO_PATCH_OUTPROC_PLAY_ROUTE_BY_VALUE(this, mOutDevice); + } +#endif // mNBLogWriter->log can only be called while thread mutex mLock is held. // So if you need to log when mutex is unlocked, set logString to a non-NULL string, @@ -2918,7 +2953,13 @@ bool AudioFlinger::PlaybackThread::threadLoop() effectChains[i]->process_l(); } } - +#ifdef SRS_PROCESSING + // Offload thread + if (mType == OFFLOAD) { + char buffer[2]; + POSTPRO_PATCH_OUTPROC_DIRECT_SAMPLES(this, AUDIO_FORMAT_PCM_16_BIT, (int16_t *) buffer, 2, 48000, 2); + } +#endif // Only if the Effects buffer is enabled and there is data in the // Effects buffer (buffer valid), we need to // copy into the sink buffer. @@ -2936,6 +2977,11 @@ bool AudioFlinger::PlaybackThread::threadLoop() // mSleepTimeUs == 0 means we must write to audio hardware if (mSleepTimeUs == 0) { ssize_t ret = 0; +#ifdef SRS_PROCESSING + if (mType == MIXER && mMixerStatus == MIXER_TRACKS_READY) { + POSTPRO_PATCH_OUTPROC_PLAY_SAMPLES(this, mFormat, mSinkBuffer, mSinkBufferSize, mSampleRate, mChannelCount); + } +#endif if (mBytesRemaining) { ret = threadLoop_write(); if (ret < 0) { @@ -3032,7 +3078,15 @@ bool AudioFlinger::PlaybackThread::threadLoop() threadLoop_standby(); mStandby = true; } - +#ifdef SRS_PROCESSING + if (mType == MIXER) { + POSTPRO_PATCH_OUTPROC_PLAY_EXIT(this, myName); + } else if (mType == OFFLOAD) { + POSTPRO_PATCH_OUTPROC_DIRECT_EXIT(this, myName); + } else if (mType == DIRECT) { + POSTPRO_PATCH_OUTPROC_DIRECT_EXIT(this, myName); + } +#endif releaseWakeLock(); mWakeLockUids.clear(); mActiveTracksGeneration++; @@ -3126,6 +3180,10 @@ status_t AudioFlinger::PlaybackThread::createAudioPatch_l(const struct audio_pat type |= patch->sinks[i].ext.device.type; } +#ifdef SRS_PROCESSING + POSTPRO_PATCH_OUTPROC_PLAY_ROUTE_BY_VALUE(this, type); +#endif + #ifdef ADD_BATTERY_DATA // when changing the audio output device, call addBatteryData to notify // the change @@ -4281,6 +4339,9 @@ bool AudioFlinger::MixerThread::checkForNewParameter_l(const String8& keyValuePa AudioParameter param = AudioParameter(keyValuePair); int value; +#ifdef SRS_PROCESSING + POSTPRO_PATCH_OUTPROC_PLAY_ROUTE(this, param, value); +#endif if (param.getInt(String8(AudioParameter::keySamplingRate), value) == NO_ERROR) { reconfig = true; } @@ -4821,6 +4882,7 @@ bool AudioFlinger::DirectOutputThread::checkForNewParameter_l(const String8& key AudioParameter param = AudioParameter(keyValuePair); int value; + if (param.getInt(String8(AudioParameter::keyRouting), value) == NO_ERROR) { // forward device change to effects that have requested to be // aware of attached audio device. diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index 6182364..48ff77d 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -13,6 +13,24 @@ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. +** +** This file was modified by DTS, Inc. The portions of the +** code that are surrounded by "DTS..." are copyrighted and +** licensed separately, as follows: +** +** (C) 2015 DTS, Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. */ #ifndef INCLUDING_FROM_AUDIOFLINGER_H @@ -537,7 +555,7 @@ public: void setMasterVolume(float value); void setMasterMute(bool muted); - + void setPostPro(); void setStreamVolume(audio_stream_type_t stream, float value); void setStreamMute(audio_stream_type_t stream, bool muted); -- cgit v1.1 From 0276a2fa56d6d8074e88940a4d21caa3e54f4972 Mon Sep 17 00:00:00 2001 From: Leena Winterrowd Date: Wed, 23 Dec 2015 12:22:18 -0800 Subject: audioflinger: Enable TEE_SINK compilation Change CHECK to ALOG_ASSERT to allow compilation of the TEE_SINK dump feature. Change-Id: I1114a9d185cfd24cdbdda51c526f48be7fd009f9 --- services/audioflinger/AudioFlinger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index fdedabb..23215dd 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -3029,7 +3029,7 @@ void AudioFlinger::dumpTee(int fd, const sp& source, audio_io_hand bool firstRead = true; #define TEE_SINK_READ 1024 // frames per I/O operation void *buffer = malloc(TEE_SINK_READ * frameSize); - CHECK (buffer != NULL); + ALOG_ASSERT(buffer != NULL); for (;;) { size_t count = TEE_SINK_READ; ssize_t actual = teeSource->read(buffer, count, -- cgit v1.1 From da6f52df74ff57a79ab5c338b6f7b4124b47e133 Mon Sep 17 00:00:00 2001 From: Ashish Jain Date: Tue, 27 Oct 2015 12:11:18 +0530 Subject: AudioMixer: Clear bufferProviders in correct order Issue: While switching between clips with different track properties, when earlier track is cleared, postDownMixerBufferProvider tries to release a buffer to serverProxy instead of the original owner i.e. downMixBufferProvider. This illegal releaseBuffer call to serverProxy results in an assert in AudioTrackShared. -In issue scenario, data flow path in AudioMixer is, ServerProxy-->-->DownMixer-->PostDownMixer-->Resampler, - Clear for downMixerBufferProvider ensures that all serverproxy buffers are returned back. -This also causes the postDownMixer to get connected with serverProxy. -Hence on delete of postDownMixer illegal releaseBuffer for serverProxy gets executed. Fix: Clear PostDownMixerBufferProvider before clearing DownMixerBufferProvider to ensure that buffers are release to right owners. Change-Id: I982366660d0a1e04be8cca6dabe758221dedf9b1 --- services/audioflinger/AudioMixer.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index b830985..bc062e6 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -308,6 +308,11 @@ bool AudioMixer::setChannelMasks(int name, void AudioMixer::track_t::unprepareForDownmix() { ALOGV("AudioMixer::unprepareForDownmix(%p)", this); + if (mPostDownmixReformatBufferProvider != NULL) { + delete mPostDownmixReformatBufferProvider; + mPostDownmixReformatBufferProvider = NULL; + reconfigureBufferProviders(); + } mDownmixRequiresFormat = AUDIO_FORMAT_INVALID; if (downmixerBufferProvider != NULL) { // this track had previously been configured with a downmixer, delete it @@ -363,18 +368,9 @@ status_t AudioMixer::track_t::prepareForDownmix() void AudioMixer::track_t::unprepareForReformat() { ALOGV("AudioMixer::unprepareForReformat(%p)", this); - bool requiresReconfigure = false; if (mReformatBufferProvider != NULL) { delete mReformatBufferProvider; mReformatBufferProvider = NULL; - requiresReconfigure = true; - } - if (mPostDownmixReformatBufferProvider != NULL) { - delete mPostDownmixReformatBufferProvider; - mPostDownmixReformatBufferProvider = NULL; - requiresReconfigure = true; - } - if (requiresReconfigure) { reconfigureBufferProviders(); } } -- cgit v1.1 From fda1413978cabfafdf184c02aa20d2fd8c095616 Mon Sep 17 00:00:00 2001 From: Ashish Jain Date: Tue, 19 Jan 2016 17:32:00 +0530 Subject: Revert "AudioMixer: delete reformatBuffer provider in proper order" This reverts commit 415bcac8afac7aef3e9853cfe4a0f2a0eb2f04ad. Change-Id: Ibbc35f16ef8cd17ead72498178c3e7bca1dff3cc --- services/audioflinger/AudioMixer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index bc062e6..806eaf1 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -441,10 +441,10 @@ void AudioMixer::deleteTrackName(int name) // delete the resampler delete track.resampler; track.resampler = NULL; - // delete the reformatter - mState.tracks[name].unprepareForReformat(); // delete the downmixer mState.tracks[name].unprepareForDownmix(); + // delete the reformatter + mState.tracks[name].unprepareForReformat(); // delete the timestretch provider delete track.mTimestretchBufferProvider; track.mTimestretchBufferProvider = NULL; -- cgit v1.1