summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKrishnankutty Kolathappilly <kkolat@codeaurora.org>2012-08-22 19:24:48 -0700
committerSteve Kondik <shade@chemlab.org>2013-06-18 19:17:54 -0700
commit1216ed8d00080619bb04c398bb0072945c58511b (patch)
tree82b758f07572e1cd2c4af8b50fecd777937fbe1f /services
parenteaa35b4fdd81af7dd6ad35a10d9eb27ff9758739 (diff)
downloadframeworks_av-1216ed8d00080619bb04c398bb0072945c58511b.zip
frameworks_av-1216ed8d00080619bb04c398bb0072945c58511b.tar.gz
frameworks_av-1216ed8d00080619bb04c398bb0072945c58511b.tar.bz2
Squashed commit of A/V changes from CodeAurora
* Brings us current with AU_LINUX_ANDROID_JB_2.5.04.02.02.040.367 Camera: Fix deadlock due to mLock in pcb and takepicture In non-zsl case of takepicture, we do streamoff for preview stream which is waiting on preview callback thread to exit. By that time the lock has already been acquired by takePicture. So preivew callback will not exit until it acquires lock and takePicture cannot continue until PCB call back is returned. Fix: Avoid the mLock at services when both Preview cb & Compressed cb are enabled. Change-Id: I6c264928bf1540c7b51f1add65f9c3e968506e15 CRs-fixed: 479419 audioflinger: Fix the LPA-AudioEffects crash issue - Issue:crash is observed during LPA playback on enabling effects followed by plug-out->plug-in of wired headset - Rootcause: while deleteing the effectchain in deleteEffect EffctChain is being unlocked after clearing the chain which leads to accessing the lock which might already deleted. - Fix: first unlock the effectChain and then call clear CRs-Fixed: 491774 Change-Id: I518ff086c5ad71486cd29142563145137ebc15b6 libstagefright: Fix for crash in sound recorder during device switch -Crash seen in sound recorder during frequent insertion and removal of wired headset -During device switch some time Codec's input buffers are too small to accomodate buffer read from source. Omx codec doesn't read the fix size buffer from source, during device switch scenario sometime buffer read from source exceeds input buffer size so it goes in error state which leads to crash. -Increasing the input buffer size fix this issue Change-Id: Id15378670880d0c3c0bd4408841b28be963549a0 CRs-Fixed: 488449 libstagefright: Fix for FPS drop issue during A-V playback. Issues: -The AAC decoder was not updating the timestamp when EOS is reached. -Logic to smoothen the real time update in AudioPlayer uses system time. This introduces corrupt timestamp during EOS. Fix: -Update the timestamp in AAC decoder when EOS is reached. -Extrapolate realtime using system time in AudioPlayer when EOS is reached. Cap the value to realtime if extrapolated time becomes greater than realtime. CRs-Fixed: 384183 Change-Id: Ice54501436431d2527fcd3d710d65d9732fcffdd libstagefright: Reset buffer size value with SurfaceTexture - OMXCodec explicitly sets the decoder output buffer size using the native window perform API. (to accomodate extra-data) - This size is reset only when the SurfaceTexture is destroyed. - Unless reset, this size will be assumed for all output buffers if the SurfaceTexture is re-used. CRs-Fixed: 337660, 432309 Change-Id: I28aed12ad02adeac61caffbb00e3082640a5f6d4 audio: Add support for tunnel mode recording - Add support for tunnel mode recording. Change-Id: I95cdfff729affd784141487521c9f2f714221d11 audio: Add support for non-pcm VOIP vocoders - Add support for non-pcm VOIP vocoders - non-pcm vocoders use AUDIO_SOURCE_VOICE_COMMUNICATION as inputSource. Add check to verify inputSource and then configure framecount accordingly Change-Id: Ia38da4f6ba0ee40c794d3c97325327cdb7dcb32a CRs-Fixed: 467850 frameworks/av: Add metadata mode changes to LPAPlayer -Seek to EOS was causing playback to hang for 3 seconds before switching to the next clip. -This is because the lpa driver works on period size. Partial buffers are not handled. -Add support for metadata mode changes to LPAPlayer to support partial frames. CRs-Fixed: 458904 Change-Id: I8673756b54ae7bca18855d326c85ae1064652514 libstagefright: Add support for WMA in ACodec - WMA support is not there in ACodec - In the case of wma format, since not getting the complete information of wma version so instead of allocating the component in onAllocateComponent function it will create in onConfigureCompoenent function. bitspersample is find as "bsps" from AMessage while configuring the WMA10PRO and WMALOSSLESS format CRs-Fixed: 453951 Change-Id: I98baa701dbf8a5c012f4be5e83831c0be2111dcc libstagefright: Flush the pending buffers when EOS is received For the use case where the first frame in the buffer is EOS, decode the aac config frame buffer to update the sample rate and channel mode and flush out the buffer. Change-Id: I0354802cdbf61ac1ba0fecbbdf616705806b0f4a CRs-Fixed: 459334 audio: Fix The Linux Foundation copyright - Fix copyright format based on The Linux Foundation copyright template Change-Id: I100a5c86302d1a1a3d79543d95e242734daae746 media, audioflinger: check for divide by zero possibilities and err When output stream is not available to audioflinger due to any reason , sampleRate and frameCount have zero values when trying to create new Audiotrack. This might result in divide by 0 situation. Change-Id: Ic13cb51facb8497e68ab596abb027b44f496b907 CRs-Fixed: 478480 framewroks/av:Fix ANR at the end of video recording - While doing video recording, when the recording ends ANR observed while doing stress test for many hours - When the recording is stopped, audio HAL receives error from driver and audio HAL propagates this error to AudioFlinger. But AudioFlinger is not sending error status to audio source to stop recording. Because of this audiorecord thread keeps on waiting for buffers which is resulting in ANR. - To avoid indefinite wait, a timeout of 1 sec is set for buffer in audioSource and after timeout, -ETIMEDOUT is returned to recorder thread. CRs-Fixed: 479968 Change-Id: I91aba6922086e711992d9d991dea9c35d33eaee9 audioflinger: Integrate SRS TruMedia Change-Id: If61ae91556120ddd5f5ebcc6dbbfe6583c7df67d audioflinger: Fix apply SRS effects if tones diabled in tunnel mode For the use case of SRS post processing in Tunnel mode, the API's of SRS are called only from write. With the huge buffering for tunnel mode, once EOS is received there would not be further write. With system tone enabled, the SRS API's are called during the check for Parameters change through normal mixer thread. With system tones disabled, SRS will not be applied after EOS as no write and mixer thread would not be active. Fix the issue by adding the Effects Thread for SRS in Tunnel mode. Fix the compilation issue with ALOGV messages enabled Change-Id: Ic7e62894840f786119dfe8ae471c5d24812917d7 audioflinger: Enhance LPA-effect logic to handle rapid config. -Issue:Rapid Config events cause pops/glitches, raw data playback. -Rootcause1:Raw data leakage to DSP: applyEffectsOn() applies effects chunk by chunk in a loop, if effects change during this time the loop exits and this results in creation of a buffer in which part of it is effects processed and rest raw, this causes raw data to leak to DSP. -RootCause2:Effectsthread directly works on the DSP buffers, while DSP is rendering from there, so that effect application is instantaneous and for this it gives the DSP buffers as output to effects chain, this means that all the effects in the chain update the DSP buffers one after the other, this can create unpredictable rendering patterns. RootCause1 and 2 combined seem to fragment memory with parts of it with effects and parts with raw data etc. -Fix1:Dont update DSP mem unless the effects are applied completely on a buffer. -Fix2:Effectschain will work on a temp scrath buffer instead of DSP mem and when effects are applied completely on this scrath buffer, memcpy this to DSP mem with this DSP mem is updated in one shot. -Remove repetetive logs which clutter the logcat if msgs are enabled in audioflinger. Change-Id: I9051e7b8531aa5c8cb3dcfafe0be3136a2cf0f9d CRs-Fixed: 463880 frameworks/av: Update framecount and buffersize values -framecount should be calculated based on mMaxBufferSize returned from HAL -update the buffersize with the value returned from HAL CRs-Fixed: 482744 Change-Id: I90dd9c3ebbbc8a9f1f2f92c5347ae9cb01719e13 audioflinger: Fix the LPA-AudioEffects dead lock issue. - Issue:Deadlock occurs when the LPA clips are subjected to rapid next from BT device and simultaneously on/off the audio effects. - Rootcause:some times flinger thread processing LPAPlayer/directtrack next deadlocks with the thread working on effect configuration as both of them contend for the audioflinger::mlock and effectmodule::mlock. - Fix1:AudioFlinger::deleteEffectSession() not to acquire audioflinger:mLock instead take the mLPAEffectChain.mlock. - Fix2:ThreadBase::effectConfigChanged() not to acquire audioflinger::mlock. Change-Id: I056c8297802f81644fa1371836db42bdbd3825fd CRs-Fixed: 477511 libstagefright: Add support for High Frame Rate Encoding - Based on kkeyhfr key value from meta data, add support in OMXCodec and MPEG4Writer for HFR mode - Assume normal mode recording if kKeyHfr is absent - Increase bit rate for high frame rate (HFR) recording feature to reflect the corresponding increase in frame rate Change-Id: I0a69f8d9322a768677781d08dd910dc5772c5292 libstagefright: Support some userdefine properties - support property to disable audio - support property to change recorder profile mode - support b frame encoding Change-Id: I175decec83f6027cbd7988caf680f7fec2836f83 CRs-Fixed: 443327 libstagefright: Add support for H/W AAC decoder - Currently, only software AAC decoding is supported. - Add support for H/W AAC decoding by including it in the list of available decoders and use it for decoding only if the property 'media.aaccodectype' is set to 0. Change-Id: I4bb9df1bd10bd8ee91e63dadd6c473fc4e29813a CRs-Fixed: 449145 libstagefright: Move checks for creating new extractor to ExtendedExtractor - Move all the checks and creation of the extended extractor into ExtendedExtractor. - Restrict creation of new extractor to the following conditions o default extractor is NULL o default extractor says the content is video only or has an unrecognized audio stream o the audio stream is a amr-wb (plus). - This change is being added to avoid unnecessary creation of two extractors thereby improving the startup latency. CRs-Fixed: 462087 Change-Id: Ia87eca73c4f81d37697fa85fd4f7c8cc8d406104 [StageFright] Enable 4 channel support This patches enables 4 channel WAV audio support and fixes invalid data size in WAV header field if it exceeds the actual source size. This patch is needed to support WebAudio in WebKit as some of the chrome demos use 4 channel WAV audio and bogus header information. Change-Id: I307026107ab4e4342b1c0d7bb64761a416fb2c65 audioflinger: Fix crash on LPA shutdown * Decrement the refcount after unlocking the mutex Change-Id: Ic3210700e0aaf5e8df78f85f501621a455058e24 libstagefright: Accept vendor specific NV12 colorformat from component - Accept OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m color format which is NV12 + 32 aligned stride and slice. - This is different from vanilla NV12 which is 16 aligned. Change-Id: I6de2ec3a78215dbcc28a6006b746e3e0afe69c3c libstagefright: various fixes for avc_utils - skip seq_scaling_matrix_present_flag assertion if checking for interlaced property. - correct interlace check to outside of if-block Change-Id: Ia5854110feb1c56ddc86b312d2ba2dbb73d37804 CRs-Fixed: 445527, 445692 libstagefright: print stats at end of playback - prints statistics before reset at the end of playback onto logcat - print statistics after each pause and seek Change-Id: I68edcc3153a04209e7382e4d3fba0bf734f3e33f CRs-Fixed: 457926, 447109 frameworks/base : Fix to play a specific Mp4 clip due to SYNCH_LOST_ERROR. -Unable to play a Specific Mp4 clip. -Mp3 playback is stopped if the Decoder errors out with SYNCH_LOST_ERROR. -Ignore the frame with SYNCH_LOST_ERROR and play silence instead. Change-Id: I6b94a83cf89e8bc6792d8ee3804042d629aa505b Add checks before removing an active buffer in OMXNodeInstance With this change, OMXNodeInstance will remove a buffer from it's active list only if OMX_FreeBuffer returns successfully. Change-Id: I685b39ac7ba762a2fc1b64d7f6c1efd391513598 libstagefright: Add interlaced video support - Adds call to set output buffer size on the native window Change-Id: If4a67b3f877bef557c46bb67b29d1e7051553335 audio: fix for AMRWB param overwritten issue - Overwrite AMRWB params with default value only when setParameters is not invoked CRs-Fixed: 456459 Change-Id: I3fa6b56101ca408ed5b5b82707c6dc75a9d9f17b audio: fix encoder parameters for AMRWB format - AMRWB encoder only accepts SampleRate 16k and channel count 1. Always overwrite AMRWB SampleRate and channel count to default values. - AMRWB encoder accepts BitRate from 6.6k to 23.85k, only overwrite AMRWB BitRate to default(23.85k)if setParameters() is not invoked Change-Id: I75a96b54ef04bc59dab9074ec112071e62fd51aa CRs-Fixed: 460931 stagefright: Add QCOM_BSP ifdefs for interlaced video handling Change-Id: I856ae4a97f1bf13ab18d386b3486e742a4804b2a Camera : Changes to support camcorder profiles. Change-Id: I9c4bf14f273839fd36d5f52db0f215873e8291a0 av: Ifdef all the things! Change-Id: If9dd6c6442e9d2ac9e55e48369f2da85f5f951f7 Camera: Add profiles for camcorder. Change-Id: Icdaf1fae0018de1fb04f41125cfbe34a91b5eda7 libvideoeditor: use vWidth and vHeight for buffer allocation - video editor detects crop information from decoder, crop width and height will override metadata width and height. - decoder is capable of sending crop information where crop width and height are smaller than actual resolution. - use actual metadata width and height for calculating buffer size. Change-Id: Id1d77c316e3892e6d51a00418052f256629f495f CRs-Fixed: 452511 Add ifdefs around enhanced media types Change-Id: I64b8853660ac4fe90ddb218b237f63b635cdb47b
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/Android.mk8
-rw-r--r--services/audioflinger/AudioFlinger.cpp405
-rw-r--r--services/audioflinger/AudioFlinger.h19
-rw-r--r--services/camera/libcameraservice/CameraClient.cpp6
4 files changed, 396 insertions, 42 deletions
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index a14c205..771b8c9 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -51,6 +51,14 @@ LOCAL_SHARED_LIBRARIES := \
libdl \
libpowermanager
+# SRS Processing
+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
+# SRS Processing
+
LOCAL_STATIC_LIBRARIES := \
libscheduling_policy \
libcpustats \
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 3c04c1c..0c3cb14 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -88,6 +88,10 @@
#include <media/nbaio/SourceAudioBufferProvider.h>
#include "SchedulingPolicyService.h"
+#ifdef SRS_PROCESSING
+#include "srs_processing.h"
+#include "postpro_patch_ics.h"
+#endif
// ----------------------------------------------------------------------------
@@ -125,7 +129,7 @@ static const int8_t kMaxTrackStartupRetries = 50;
// allow less retry attempts on direct output thread.
// direct outputs can be a scarce resource in audio hardware and should
// be released as quickly as possible.
-static const int8_t kMaxTrackRetriesDirect = 2;
+static const int8_t kMaxTrackRetriesDirect = 5;
static const int kDumpLockRetries = 50;
static const int kDumpLockSleepUs = 20000;
@@ -667,11 +671,11 @@ Exit:
void AudioFlinger::deleteEffectSession()
{
- Mutex::Autolock _l(mLock);
ALOGV("deleteSession");
// -2 is invalid session ID
mLPASessionId = -2;
if (mLPAEffectChain != NULL) {
+ mLPAEffectChain->lock();
mLPAEffectChain->setLPAFlag(false);
size_t i, numEffects = mLPAEffectChain->getNumEffects();
for(i = 0; i < numEffects; i++) {
@@ -684,6 +688,7 @@ void AudioFlinger::deleteEffectSession()
}
effect->configure();
}
+ mLPAEffectChain->unlock();
mLPAEffectChain.clear();
mLPAEffectChain = NULL;
}
@@ -691,7 +696,8 @@ void AudioFlinger::deleteEffectSession()
// ToDo: Should we go ahead with this frameCount?
#define DEAFULT_FRAME_COUNT 1200
-void AudioFlinger::applyEffectsOn(void *token, int16_t *inBuffer, int16_t *outBuffer, int size)
+bool AudioFlinger::applyEffectsOn(void *token, int16_t *inBuffer,
+ int16_t *outBuffer, int size, bool force)
{
ALOGV("applyEffectsOn: inBuf %p outBuf %p size %d token %p", inBuffer, outBuffer, size, token);
// This might be the first buffer to apply effects after effect config change
@@ -699,6 +705,12 @@ void AudioFlinger::applyEffectsOn(void *token, int16_t *inBuffer, int16_t *outBu
mIsEffectConfigChanged = false;
volatile size_t numEffects = 0;
+
+#ifdef SRS_PROCESSING
+ POSTPRO_PATCH_ICS_OUTPROC_DIRECT_SAMPLES(token, AUDIO_FORMAT_PCM_16_BIT, outBuffer, size,
+ mLPASampleRate, mLPANumChannels);
+#endif
+
if(mLPAEffectChain != NULL) {
numEffects = mLPAEffectChain->getNumEffects();
}
@@ -729,16 +741,17 @@ void AudioFlinger::applyEffectsOn(void *token, int16_t *inBuffer, int16_t *outBu
bool isEffectEnabled = false;
for(i = 0; i < numEffects; i++) {
// If effect configuration is changed while applying effects do not process further
- if(mIsEffectConfigChanged) {
+
+ if(mIsEffectConfigChanged && !force) {
mLPAEffectChain->unlock();
- ALOGV("applyEffectsOn: mIsEffectConfigChanged is set - no further processing");
- return;
+ ALOGV("applyEffectsOn: mIsEffectConfigChanged is set - no further processing %d",frameCount);
+ return false;
}
sp<EffectModule> effect = mLPAEffectChain->getEffectFromIndex_l(i);
if(effect == NULL) {
ALOGE("getEffectFromIndex_l(%d) returned NULL ptr", i);
mLPAEffectChain->unlock();
- return;
+ return false;
}
if(i == 0) {
// For the first set input and output buffers different
@@ -773,13 +786,14 @@ void AudioFlinger::applyEffectsOn(void *token, int16_t *inBuffer, int16_t *outBu
}
}
- if (!numEffects) {
+ if (!numEffects && !force) {
ALOGV("applyEffectsOn: There are no effects to be applied");
if(inBuffer != outBuffer) {
// No effect applied so just copy input buffer to output buffer
memcpy(outBuffer, inBuffer, size);
}
}
+ return true;
}
#endif
@@ -1154,6 +1168,11 @@ status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8&
// ioHandle == 0 means the parameters are global to the audio hardware interface
if (ioHandle == 0) {
Mutex::Autolock _l(mLock);
+#ifdef SRS_PROCESSING
+ POSTPRO_PATCH_ICS_PARAMS_SET(keyValuePairs);
+ if (!mDirectAudioTracks.isEmpty())
+ audioConfigChanged_l(AudioSystem::EFFECT_CONFIG_CHANGED, 0, NULL);
+#endif
status_t final_result = NO_ERROR;
{
AutoMutex lock(mHardwareLock);
@@ -1232,6 +1251,12 @@ status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8&
String8 key = String8(AudioParameter::keyRouting);
int device;
if (param.getInt(key, device) == NO_ERROR) {
+
+#ifdef SRS_PROCESSING
+ ALOGV("setParameters:: routing change to device %d", device);
+ desc->device = (audio_devices_t)device;
+ POSTPRO_PATCH_ICS_OUTPROC_MIX_ROUTE(desc->trackRefPtr, param, device);
+#endif
if(mLPAEffectChain != NULL){
mLPAEffectChain->setDevice_l(device);
audioConfigChanged_l(AudioSystem::EFFECT_CONFIG_CHANGED, 0, NULL);
@@ -1281,6 +1306,9 @@ String8 AudioFlinger::getParameters(audio_io_handle_t ioHandle, const String8& k
if (ioHandle == 0) {
String8 out_s8;
+#ifdef SRS_PROCESSING
+ POSTPRO_PATCH_ICS_PARAMS_GET(keys, out_s8);
+#endif
for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
char *s;
{
@@ -1596,10 +1624,8 @@ status_t AudioFlinger::ThreadBase::setParameters(const String8& keyValuePairs)
#ifdef QCOM_HARDWARE
void AudioFlinger::ThreadBase::effectConfigChanged() {
- mAudioFlinger->mLock.lock();
ALOGV("New effect is being added to LPA chain, Notifying LPA Direct Track");
mAudioFlinger->audioConfigChanged_l(AudioSystem::EFFECT_CONFIG_CHANGED, 0, NULL);
- mAudioFlinger->mLock.unlock();
}
#endif
@@ -2176,7 +2202,9 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
// This is probably too conservative, but legacy application code may depend on it.
// If you change this calculation, also review the start threshold which is related.
uint32_t latencyMs = mOutput->stream->get_latency(mOutput->stream);
- uint32_t minBufCount = latencyMs / ((1000 * mNormalFrameCount) / mSampleRate);
+ uint32_t minBufCount = 0;
+ if(mSampleRate)
+ minBufCount = latencyMs / ((1000 * mNormalFrameCount) / mSampleRate);
if (minBufCount < 2) {
minBufCount = 2;
}
@@ -2188,7 +2216,17 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
}
if (mType == DIRECT) {
- if ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM) {
+#ifdef QCOM_ENHANCED_AUDIO
+ if (((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM)
+ ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AMR_NB)
+ ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AMR_WB)
+ ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRC)
+ ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRCB)
+ ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRCWB))
+#else
+ if ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM)
+#endif
+ {
if (sampleRate != mSampleRate || format != mFormat || channelMask != mChannelMask) {
ALOGE("createTrack_l() Bad parameter: sampleRate %d format %d, channelMask 0x%08x \""
"for output %p with format %d",
@@ -2274,7 +2312,10 @@ uint32_t AudioFlinger::MixerThread::correctLatency(uint32_t latency) const
{
if (mFastMixer != NULL) {
MonoPipe *pipe = (MonoPipe *)mPipeSink.get();
- latency += (pipe->getAvgFrames() * 1000) / mSampleRate;
+ if(mSampleRate)
+ latency += (pipe->getAvgFrames() * 1000) / mSampleRate;
+ else
+ ALOGW("SampleRate is 0");
}
return latency;
}
@@ -2950,6 +2991,13 @@ bool AudioFlinger::PlaybackThread::threadLoop()
standbyTime = systemTime();
+#ifdef SRS_PROCESSING
+if (mType == MIXER) {
+ POSTPRO_PATCH_ICS_OUTPROC_MIX_INIT(this, gettid());
+ } else if (mType == DUPLICATING) {
+ POSTPRO_PATCH_ICS_OUTPROC_DUPE_INIT(this, gettid());
+ }
+#endif
// MIXER
nsecs_t lastWarning = 0;
@@ -3064,6 +3112,15 @@ bool AudioFlinger::PlaybackThread::threadLoop()
// sleepTime == 0 means we must write to audio hardware
if (sleepTime == 0) {
+#ifdef SRS_PROCESSING
+ if (mType == MIXER) {
+ POSTPRO_PATCH_ICS_OUTPROC_MIX_SAMPLES(this, mFormat, mMixBuffer,
+ mixBufferSize, mSampleRate, mChannelCount);
+ } else if (mType == DUPLICATING) {
+ POSTPRO_PATCH_ICS_OUTPROC_DUPE_SAMPLES(this, mFormat, mMixBuffer,
+ mixBufferSize, mSampleRate, mChannelCount);
+ }
+#endif
threadLoop_write();
if (mType == MIXER) {
@@ -3115,6 +3172,13 @@ if (mType == MIXER) {
}
}
+#ifdef SRS_PROCESSING
+ if (mType == MIXER) {
+ POSTPRO_PATCH_ICS_OUTPROC_MIX_EXIT(this, gettid());
+ } else if (mType == DUPLICATING) {
+ POSTPRO_PATCH_ICS_OUTPROC_DUPE_EXIT(this, gettid());
+ }
+#endif
releaseWakeLock();
ALOGV("Thread %p type %d exiting", this, mType);
@@ -3516,7 +3580,12 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac
minFrames = mNormalFrameCount;
} else {
// +1 for rounding and +1 for additional sample needed for interpolation
- minFrames = (mNormalFrameCount * t->sampleRate()) / mSampleRate + 1 + 1;
+ if(mSampleRate)
+ minFrames = (mNormalFrameCount * t->sampleRate()) / mSampleRate + 1 + 1;
+ else {
+ minFrames = 2;
+ ALOGW("SampleRate is 0");
+ }
// add frames already consumed but not yet released by the resampler
// because cblk->framesReady() will include these frames
minFrames += mAudioMixer->getUnreleasedFrames(track->name());
@@ -3873,6 +3942,9 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
String8 keyValuePair = mNewParameters[0];
AudioParameter param = AudioParameter(keyValuePair);
int value;
+#ifdef SRS_PROCESSING
+ POSTPRO_PATCH_ICS_OUTPROC_MIX_ROUTE(this, param, value);
+#endif
if (param.getInt(String8(AudioParameter::keySamplingRate), value) == NO_ERROR) {
reconfig = true;
@@ -4462,7 +4534,10 @@ void AudioFlinger::DuplicatingThread::addOutputTrack(MixerThread *thread)
{
Mutex::Autolock _l(mLock);
// FIXME explain this formula
- int frameCount = (3 * mNormalFrameCount * mSampleRate) / thread->sampleRate();
+ int sampleRate = thread->sampleRate();
+ int frameCount = 0;
+ if (sampleRate)
+ frameCount = (3 * mNormalFrameCount * mSampleRate) / sampleRate;
OutputTrack *outputTrack = new OutputTrack(thread,
this,
mSampleRate,
@@ -4548,6 +4623,9 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase(
audio_format_t format,
audio_channel_mask_t channelMask,
int frameCount,
+#ifdef QCOM_ENHANCED_AUDIO
+ uint32_t flags,
+#endif
const sp<IMemory>& sharedBuffer,
int sessionId)
: RefBase(),
@@ -4561,6 +4639,9 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase(
mSampleRate(sampleRate),
mFormat(format),
mStepServerFailed(false),
+#ifdef QCOM_ENHANCED_AUDIO
+ mFlags(0),
+#endif
mSessionId(sessionId)
// mChannelCount
// mChannelMask
@@ -4570,7 +4651,40 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase(
// ALOGD("Creating track with %d buffers @ %d bytes", bufferCount, bufferSize);
size_t size = sizeof(audio_track_cblk_t);
uint8_t channelCount = popcount(channelMask);
+#ifdef QCOM_ENHANCED_AUDIO
+ size_t bufferSize = 0;
+ if ((int16_t)flags == 0x1) {
+ bufferSize = frameCount*channelCount*sizeof(int16_t);
+ } else {
+ if ( (format == AUDIO_FORMAT_PCM_16_BIT) ||
+ (format == AUDIO_FORMAT_PCM_8_BIT))
+ {
+ bufferSize = frameCount*channelCount*sizeof(int16_t);
+ }
+ else if (format == AUDIO_FORMAT_AMR_NB)
+ {
+ bufferSize = frameCount*channelCount*32; // full rate frame size
+ }
+ else if (format == AUDIO_FORMAT_EVRC)
+ {
+ bufferSize = frameCount*channelCount*23; // full rate frame size
+ }
+ else if (format == AUDIO_FORMAT_QCELP)
+ {
+ bufferSize = frameCount*channelCount*35; // full rate frame size
+ }
+ else if (format == AUDIO_FORMAT_AAC)
+ {
+ bufferSize = frameCount*2048; // full rate frame size
+ }
+ else if (format == AUDIO_FORMAT_AMR_WB)
+ {
+ bufferSize = frameCount*channelCount*61; // full rate frame size
+ }
+ }
+#else
size_t bufferSize = frameCount*channelCount*sizeof(int16_t);
+#endif
if (sharedBuffer == 0) {
size += bufferSize;
}
@@ -4593,7 +4707,39 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase(
mChannelMask = channelMask;
if (sharedBuffer == 0) {
mBuffer = (char*)mCblk + sizeof(audio_track_cblk_t);
+#ifdef QCOM_ENHANCED_AUDIO
+ if ((int16_t)flags == 0x1) {
+ bufferSize = frameCount*channelCount*sizeof(int16_t);
+ } else {
+ if ((format == AUDIO_FORMAT_PCM_16_BIT) ||
+ (format == AUDIO_FORMAT_PCM_8_BIT))
+ {
+ memset(mBuffer, 0, frameCount*channelCount*sizeof(int16_t));
+ }
+ else if (format == AUDIO_FORMAT_AMR_NB)
+ {
+ memset(mBuffer, 0, frameCount*channelCount*32); // full rate frame size
+ }
+ else if (format == AUDIO_FORMAT_EVRC)
+ {
+ memset(mBuffer, 0, frameCount*channelCount*23); // full rate frame size
+ }
+ else if (format == AUDIO_FORMAT_QCELP)
+ {
+ memset(mBuffer, 0, frameCount*channelCount*35); // full rate frame size
+ }
+ else if (format == AUDIO_FORMAT_AAC)
+ {
+ memset(mBuffer, 0, frameCount*2048); // full rate frame size
+ }
+ else if (format == AUDIO_FORMAT_AMR_WB)
+ {
+ memset(mBuffer, 0, frameCount*channelCount*61); // full rate frame size
+ }
+ }
+#else
memset(mBuffer, 0, frameCount*channelCount*sizeof(int16_t));
+#endif
// Force underrun condition to avoid false underrun callback until first data is
// written to buffer (other flags are cleared)
mCblk->flags = CBLK_UNDERRUN_ON;
@@ -4696,13 +4842,21 @@ void* AudioFlinger::ThreadBase::TrackBase::getBuffer(uint32_t offset, uint32_t f
int8_t *bufferEnd = bufferStart + frames * frameSize;
// Check validity of returned pointer in case the track control block would have been corrupted.
+#ifdef QCOM_ENHANCED_AUDIO
+ if (bufferStart < mBuffer || bufferStart > bufferEnd || bufferEnd > mBufferEnd){
+ ALOGE("TrackBase::getBuffer buffer out of range:\n start: %p, end %p , mBuffer %p mBufferEnd %p\n \
+ server %u, serverBase %u, user %u, userBase %u",
+ bufferStart, bufferEnd, mBuffer, mBufferEnd,
+ cblk->server, cblk->serverBase, cblk->user, cblk->userBase);
+ return 0;
+ }
+#else
ALOG_ASSERT(!(bufferStart < mBuffer || bufferStart > bufferEnd || bufferEnd > mBufferEnd),
"TrackBase::getBuffer buffer out of range:\n"
" start: %p, end %p , mBuffer %p mBufferEnd %p\n"
" server %u, serverBase %u, user %u, userBase %u, frameSize %d",
- bufferStart, bufferEnd, mBuffer, mBufferEnd,
cblk->server, cblk->serverBase, cblk->user, cblk->userBase, frameSize);
-
+#endif
return bufferStart;
}
@@ -4726,7 +4880,11 @@ AudioFlinger::PlaybackThread::Track::Track(
const sp<IMemory>& sharedBuffer,
int sessionId,
IAudioFlinger::track_flags_t flags)
- : TrackBase(thread, client, sampleRate, format, channelMask, frameCount, sharedBuffer, sessionId),
+ : TrackBase(thread, client, sampleRate, format, channelMask, frameCount,
+#ifdef QCOM_ENHANCED_AUDIO
+ ((audio_stream_type_t)streamType == AUDIO_STREAM_VOICE_CALL)?0x1:0x0,
+#endif
+ sharedBuffer, sessionId),
mMute(false),
mFillingUpStatus(FS_INVALID),
// mRetryCount initialized later when needed
@@ -4745,7 +4903,12 @@ AudioFlinger::PlaybackThread::Track::Track(
if (mCblk != NULL) {
// NOTE: audio_track_cblk_t::frameSize for 8 bit PCM data is based on a sample size of
// 16 bit because data is converted to 16 bit before being stored in buffer by AudioTrack
- mCblk->frameSize = audio_is_linear_pcm(format) ? mChannelCount * sizeof(int16_t) : sizeof(uint8_t);
+#ifdef QCOM_ENHANCED_AUDIO
+ if ((audio_stream_type_t)streamType == AUDIO_STREAM_VOICE_CALL)
+ mCblk->frameSize = mChannelCount * sizeof(int16_t);
+ else
+#endif
+ mCblk->frameSize = audio_is_linear_pcm(format) ? mChannelCount * sizeof(int16_t) : sizeof(uint8_t);
// to avoid leaking a track name, do not allocate one unless there is an mCblk
mName = thread->getTrackName_l(channelMask, sessionId);
mCblk->mName = mName;
@@ -5776,12 +5939,44 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
audio_format_t format,
audio_channel_mask_t channelMask,
int frameCount,
+#ifdef QCOM_ENHANCED_AUDIO
+ uint32_t flags,
+#endif
int sessionId)
- : TrackBase(thread, client, sampleRate, format,
- channelMask, frameCount, 0 /*sharedBuffer*/, sessionId),
+ : TrackBase(thread, client, sampleRate, format,channelMask,frameCount,
+#ifdef QCOM_ENHANCED_AUDIO
+ ((audio_source_t)((int16_t)flags) == AUDIO_SOURCE_VOICE_COMMUNICATION) ?
+ ((flags & 0xffff0000)| 0x1) : ((flags & 0xffff0000)),
+#endif
+ 0 /*sharedBuffer*/, sessionId),
mOverflow(false)
{
+ uint8_t channelCount = popcount(channelMask);
if (mCblk != NULL) {
+#ifdef QCOM_ENHANCED_AUDIO
+ ALOGV("RecordTrack constructor, size %d flags %d", (int)mBufferEnd - (int)mBuffer,flags);
+ if ((audio_source_t)((int16_t)flags) == AUDIO_SOURCE_VOICE_COMMUNICATION) {
+ mCblk->frameSize = mChannelCount * sizeof(int16_t);
+ } else {
+ if (format == AUDIO_FORMAT_AMR_NB) {
+ mCblk->frameSize = channelCount * 32;
+ } else if (format == AUDIO_FORMAT_EVRC) {
+ mCblk->frameSize = channelCount * 23;
+ } else if (format == AUDIO_FORMAT_QCELP) {
+ mCblk->frameSize = channelCount * 35;
+ } else if (format == AUDIO_FORMAT_AAC) {
+ mCblk->frameSize = 2048;
+ } else if (format == AUDIO_FORMAT_PCM_16_BIT) {
+ mCblk->frameSize = mChannelCount * sizeof(int16_t);
+ } else if (format == AUDIO_FORMAT_PCM_8_BIT) {
+ mCblk->frameSize = mChannelCount * sizeof(int8_t);
+ } else if (format == AUDIO_FORMAT_AMR_WB) {
+ mCblk->frameSize = channelCount * 61;
+ } else {
+ mCblk->frameSize = sizeof(int8_t);
+ }
+ }
+#else
ALOGV("RecordTrack constructor, size %d", (int)mBufferEnd - (int)mBuffer);
if (format == AUDIO_FORMAT_PCM_16_BIT) {
mCblk->frameSize = mChannelCount * sizeof(int16_t);
@@ -5790,6 +5985,7 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
} else {
mCblk->frameSize = sizeof(int8_t);
}
+#endif
}
}
@@ -6200,8 +6396,14 @@ AudioFlinger::DirectAudioTrack::DirectAudioTrack(const sp<AudioFlinger>& audioFl
int output, AudioSessionDescriptor *outputDesc,
IDirectTrackClient* client, audio_output_flags_t outflag)
: BnDirectTrack(), mIsPaused(false), mAudioFlinger(audioFlinger), mOutput(output), mOutputDesc(outputDesc),
- mClient(client), mEffectConfigChanged(false), mKillEffectsThread(false), mFlag(outflag)
+ mClient(client), mEffectConfigChanged(false), mKillEffectsThread(false), mFlag(outflag),
+ mEffectsThreadScratchBuffer(NULL)
{
+#ifdef SRS_PROCESSING
+ ALOGD("SRS_Processing - DirectAudioTrack - OutNotify_Init: %p TID %d\n", this, gettid());
+ POSTPRO_PATCH_ICS_OUTPROC_DIRECT_INIT(this, gettid());
+ SRS_Processing::ProcessOutRoute(SRS_Processing::AUTO, this, outputDesc->device);
+#endif
if (mFlag & AUDIO_OUTPUT_FLAG_LPA) {
createEffectThread();
@@ -6209,6 +6411,13 @@ AudioFlinger::DirectAudioTrack::DirectAudioTrack(const sp<AudioFlinger>& audioFl
mAudioFlinger->registerClient(mAudioFlingerClient);
allocateBufPool();
+#ifdef SRS_PROCESSING
+ } else if (mFlag & AUDIO_OUTPUT_FLAG_TUNNEL) {
+ ALOGV("create effects thread for TUNNEL");
+ createEffectThread();
+ mAudioFlingerClient = new AudioFlingerDirectTrackClient(this);
+ mAudioFlinger->registerClient(mAudioFlingerClient);
+#endif
}
outputDesc->mVolumeScale = 1.0;
mDeathRecipient = new PMDeathRecipient(this);
@@ -6216,11 +6425,21 @@ AudioFlinger::DirectAudioTrack::DirectAudioTrack(const sp<AudioFlinger>& audioFl
}
AudioFlinger::DirectAudioTrack::~DirectAudioTrack() {
+#ifdef SRS_PROCESSING
+ ALOGD("SRS_Processing - DirectAudioTrack - OutNotify_Init: %p TID %d\n", this, gettid());
+ POSTPRO_PATCH_ICS_OUTPROC_DIRECT_EXIT(this, gettid());
+#endif
if (mFlag & AUDIO_OUTPUT_FLAG_LPA) {
requestAndWaitForEffectsThreadExit();
mAudioFlinger->deregisterClient(mAudioFlingerClient);
mAudioFlinger->deleteEffectSession();
deallocateBufPool();
+#ifdef SRS_PROCESSING
+ } else if (mFlag & AUDIO_OUTPUT_FLAG_TUNNEL) {
+ requestAndWaitForEffectsThreadExit();
+ mAudioFlinger->deregisterClient(mAudioFlingerClient);
+ mAudioFlinger->deleteEffectSession();
+#endif
}
AudioSystem::releaseOutput(mOutput);
releaseWakeLock();
@@ -6276,9 +6495,11 @@ ssize_t AudioFlinger::DirectAudioTrack::write(const void *buffer, size_t size) {
memcpy((char *) buf.localBuf, (char *)buffer, size);
buf.bytesToWrite = size;
mEffectsPool.push_back(buf);
- mAudioFlinger->applyEffectsOn(static_cast<void *>(this), (int16_t*)buf.localBuf,(int16_t*)buffer,(int)size);
+ mAudioFlinger->applyEffectsOn(static_cast<void *>(this),
+ (int16_t*)buf.localBuf, (int16_t*)buffer, (int)size, true);
mEffectLock.unlock();
}
+ ALOGV("out of Writing to AudioSessionOut");
return mOutputDesc->stream->write(mOutputDesc->stream, buffer, size);
}
@@ -6352,6 +6573,10 @@ void AudioFlinger::DirectAudioTrack::allocateBufPool() {
ALOGV("The MEM that is allocated buffer is %x, size %d",(unsigned int)dsp_buf,nSize);
}
+
+ mEffectsThreadScratchBuffer = malloc(nSize);
+ ALOGV("effectsThreadScratchBuffer = %x",mEffectsThreadScratchBuffer);
+
free(buf);
}
@@ -6370,6 +6595,9 @@ void AudioFlinger::DirectAudioTrack::deallocateBufPool() {
ALOGV("Removing from bufpool");
mBufPool.erase(it);
}
+
+ free(mEffectsThreadScratchBuffer);
+ mEffectsThreadScratchBuffer = NULL;
}
status_t AudioFlinger::DirectAudioTrack::onTransact(
@@ -6397,18 +6625,40 @@ void AudioFlinger::DirectAudioTrack::EffectsThreadEntry() {
if (mEffectConfigChanged) {
mEffectConfigChanged = false;
- for ( List<BufferInfo>::iterator it = mEffectsPool.begin();
- it != mEffectsPool.end(); it++) {
- ALOGV("Apply effects on the buffer dspbuf %p, mEffectsPool.size() %d",it->dspBuf,mEffectsPool.size());
- mAudioFlinger->applyEffectsOn(static_cast<void *>(this),
- (int16_t *)it->localBuf,
- (int16_t *)it->dspBuf,
- it->bytesToWrite);
- if (mEffectConfigChanged) {
- break;
- }
- }
+ if (mFlag & AUDIO_OUTPUT_FLAG_LPA) {
+ for ( List<BufferInfo>::iterator it = mEffectsPool.begin();
+ it != mEffectsPool.end(); it++) {
+ ALOGV("ete: calling applyEffectsOn buff %x",it->localBuf);
+ bool isEffectsApplied = mAudioFlinger->applyEffectsOn(
+ static_cast<void *>(this),
+ (int16_t *)it->localBuf,
+ (int16_t *)mEffectsThreadScratchBuffer,
+ it->bytesToWrite,
+ false);
+ if (isEffectsApplied == true){
+ ALOGV("ete:dsp updated for local buf %x",it->localBuf);
+ memcpy(it->dspBuf, mEffectsThreadScratchBuffer, it->bytesToWrite);
+ }
+ else
+ ALOGV("ete:dsp updated for local buf %x SKIPPED",it->localBuf);
+ if (mEffectConfigChanged) {
+ ALOGE("ete:effects changed, abort effects application");
+ break;
+ }
+ }
+#ifdef SRS_PROCESSING
+ } else if (mFlag & AUDIO_OUTPUT_FLAG_TUNNEL) {
+ ALOGV("applying effects for TUNNEL");
+ char buffer[2];
+ //dummy buffer to ensure the SRS processing takes place
+ // The API mandates Sample rate and channel mode. Hence
+ // defaulted the sample rate channel mode to 48000 and 2 respectively
+ POSTPRO_PATCH_ICS_OUTPROC_DIRECT_SAMPLES(static_cast<void *>(this),
+ AUDIO_FORMAT_PCM_16_BIT,
+ (int16_t*)buffer, 2, 48000, 2);
+#endif
+ }
}
mEffectLock.unlock();
}
@@ -6614,6 +6864,10 @@ sp<IAudioRecord> AudioFlinger::openRecord(
sp<RecordThread::RecordTrack> recordTrack;
sp<RecordHandle> recordHandle;
sp<Client> client;
+#ifdef QCOM_ENHANCED_AUDIO
+ size_t inputBufferSize = 0;
+ uint32_t channelCount = popcount(channelMask);
+#endif
status_t lStatus;
RecordThread *thread;
size_t inFrameCount;
@@ -6625,6 +6879,15 @@ sp<IAudioRecord> AudioFlinger::openRecord(
goto Exit;
}
+#ifdef QCOM_ENHANCED_AUDIO
+ // Check that audio input stream accepts requested audio parameters
+ inputBufferSize = getInputBufferSize(sampleRate, format, channelCount);
+ if (inputBufferSize == 0) {
+ lStatus = BAD_VALUE;
+ ALOGE("Bad audio input parameters: sampling rate %u, format %d, channels %d", sampleRate, format, channelCount);
+ goto Exit;
+ }
+#endif
// add client to list
{ // scope for mLock
Mutex::Autolock _l(mLock);
@@ -6645,6 +6908,41 @@ sp<IAudioRecord> AudioFlinger::openRecord(
*sessionId = lSessionId;
}
}
+#ifdef QCOM_ENHANCED_AUDIO
+ // frameCount must be a multiple of input buffer size
+ // Change for Codec type
+ uint8_t channelCount = popcount(channelMask);
+ if ((audio_source_t)((int16_t)flags) == AUDIO_SOURCE_VOICE_COMMUNICATION) {
+ inFrameCount = inputBufferSize/channelCount/sizeof(short);
+ } else {
+ if ((format == AUDIO_FORMAT_PCM_16_BIT) ||
+ (format == AUDIO_FORMAT_PCM_8_BIT))
+ {
+ inFrameCount = inputBufferSize/channelCount/sizeof(short);
+ }
+ else if (format == AUDIO_FORMAT_AMR_NB)
+ {
+ inFrameCount = inputBufferSize/channelCount/32;
+ }
+ else if (format == AUDIO_FORMAT_EVRC)
+ {
+ inFrameCount = inputBufferSize/channelCount/23;
+ }
+ else if (format == AUDIO_FORMAT_QCELP)
+ {
+ inFrameCount = inputBufferSize/channelCount/35;
+ }
+ else if (format == AUDIO_FORMAT_AAC)
+ {
+ inFrameCount = inputBufferSize/2048;
+ }
+ else if (format == AUDIO_FORMAT_AMR_WB)
+ {
+ inFrameCount = inputBufferSize/channelCount/61;
+ }
+ }
+ frameCount = ((frameCount - 1)/inFrameCount + 1) * inFrameCount;
+#endif
// create new record track. The record track uses one track in mHardwareMixerThread by convention.
recordTrack = thread->createRecordTrack_l(client, sampleRate, format, channelMask,
frameCount, lSessionId, flags, tid, &lStatus);
@@ -6849,9 +7147,30 @@ bool AudioFlinger::RecordThread::threadLoop()
}
}
if (framesOut && mFrameCount == mRsmpInIndex) {
+#ifdef QCOM_ENHANCED_AUDIO
+ if (((int) framesOut != mFrameCount) &&
+ ((mFormat != AUDIO_FORMAT_PCM_16_BIT)&&
+ ((audio_source_t)mInputSource != AUDIO_SOURCE_VOICE_COMMUNICATION))) {
+ mBytesRead = mInput->stream->read(mInput->stream, buffer.raw,
+ buffer.frameCount * mFrameSize);
+ ALOGV("IR mBytesRead = %d",mBytesRead);
+ if(mBytesRead >= 0 ){
+ buffer.frameCount = mBytesRead/mFrameSize;
+ }
+ framesOut = 0;
+ } else
+#endif
if (framesOut == mFrameCount &&
+#ifdef QCOM_ENHANCED_AUDIO
+ ((audio_source_t)mInputSource != AUDIO_SOURCE_VOICE_COMMUNICATION) &&
+#endif
((int)mChannelCount == mReqChannelCount || mFormat != AUDIO_FORMAT_PCM_16_BIT)) {
mBytesRead = mInput->stream->read(mInput->stream, buffer.raw, mInputBytes);
+#ifdef QCOM_ENHANCED_AUDIO
+ if( mBytesRead >= 0 ){
+ buffer.frameCount = mBytesRead/mFrameSize;
+ }
+#endif
framesOut = 0;
} else {
mBytesRead = mInput->stream->read(mInput->stream, mRsmpInBuffer, mInputBytes);
@@ -6988,7 +7307,11 @@ sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createR
Mutex::Autolock _l(mLock);
track = new RecordTrack(this, client, sampleRate,
- format, channelMask, frameCount, sessionId);
+ format, channelMask, frameCount,
+#ifdef QCOM_ENHANCED_AUDIO
+ flags,
+#endif
+ sessionId);
if (track->getCblk() == 0) {
lStatus = NO_MEMORY;
@@ -7796,6 +8119,10 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,
ALOGI("Using module %d has the primary audio interface", module);
mPrimaryHardwareDev = outHwDev;
+#ifdef SRS_PROCESSING
+ SRS_Processing::RawDataSet(NULL, "qdsp hook", &mPrimaryHardwareDev,
+ sizeof(&mPrimaryHardwareDev));
+#endif
AutoMutex lock(mHardwareLock);
mHardwareStatus = AUDIO_HW_SET_MODE;
hwDevHal->set_mode(hwDevHal, mMode);
@@ -9289,7 +9616,7 @@ status_t AudioFlinger::EffectModule::configure(bool isForLPA, int sampleRate, in
} else {
channels = AUDIO_CHANNEL_OUT_STEREO;
}
- ALOGV("%s: LPA ON - channels %d", __func__, channels);
+// ALOGV("%s: LPA ON - channels %d", __func__, channels);
} else {
if (thread->channelCount() == 1) {
channels = AUDIO_CHANNEL_OUT_MONO;
@@ -9347,8 +9674,8 @@ status_t AudioFlinger::EffectModule::configure(bool isForLPA, int sampleRate, in
mConfig.inputCfg.buffer.frameCount = thread->frameCount();
mConfig.outputCfg.buffer.frameCount = mConfig.inputCfg.buffer.frameCount;
- ALOGV("configure() %p thread %p buffer %p framecount %d",
- this, thread.get(), mConfig.inputCfg.buffer.raw, mConfig.inputCfg.buffer.frameCount);
+// ALOGV("configure() %p thread %p buffer %p framecount %d",
+// this, thread.get(), mConfig.inputCfg.buffer.raw, mConfig.inputCfg.buffer.frameCount);
status_t cmdStatus;
uint32_t size = sizeof(int);
@@ -10037,7 +10364,7 @@ status_t AudioFlinger::EffectHandle::command(uint32_t cmdCode,
(cmdCode == EFFECT_CMD_SET_VOLUME) || (cmdCode == EFFECT_CMD_SET_AUDIO_MODE)) ) {
// Notify Direct track for the change in Effect module
// TODO: check if it is required to send mLPAHandle
- ALOGV("Notifying Direct Track for the change in effect config");
+ ALOGV("Notifying Direct Track for the change in effect config %d", cmdCode);
mClient->audioFlinger()->audioConfigChanged_l(AudioSystem::EFFECT_CONFIG_CHANGED, 0, NULL);
}
#endif
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index d6a3815..5b718d7 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -245,10 +245,11 @@ public:
uint32_t flags);
#ifdef QCOM_HARDWARE
- void applyEffectsOn(void *token,
+ bool applyEffectsOn(void *token,
int16_t *buffer1,
int16_t *buffer2,
- int size);
+ int size,
+ bool force);
#endif
// end of IAudioFlinger interface
@@ -427,6 +428,9 @@ private:
audio_format_t format,
audio_channel_mask_t channelMask,
int frameCount,
+#ifdef QCOM_ENHANCED_AUDIO
+ uint32_t flags,
+#endif
const sp<IMemory>& sharedBuffer,
int sessionId);
virtual ~TrackBase();
@@ -506,6 +510,9 @@ private:
// support dynamic rates, the current value is in control block
const audio_format_t mFormat;
bool mStepServerFailed;
+#ifdef QCOM_ENHANCED_AUDIO
+ uint32_t mFlags;
+#endif
const int mSessionId;
uint8_t mChannelCount;
audio_channel_mask_t mChannelMask;
@@ -1483,6 +1490,7 @@ private:
};
List<BufferInfo> mBufPool;
List<BufferInfo> mEffectsPool;
+ void *mEffectsThreadScratchBuffer;
void allocateBufPool();
void deallocateBufPool();
@@ -1521,7 +1529,8 @@ private:
sp<AudioFlinger> mAudioFlinger;
sp<AudioFlingerDirectTrackClient> mAudioFlingerClient;
- void clearPowerManager();
+ void clearPowerManager();
+
class PMDeathRecipient : public IBinder::DeathRecipient {
public:
PMDeathRecipient(void *obj){parentClass = (DirectAudioTrack *)obj;}
@@ -1592,6 +1601,9 @@ private:
audio_format_t format,
audio_channel_mask_t channelMask,
int frameCount,
+#ifdef QCOM_ENHANCED_AUDIO
+ uint32_t flags,
+#endif
int sessionId);
virtual ~RecordTrack();
@@ -1722,6 +1734,7 @@ private:
// when < 0, maximum frames to drop before starting capture even if sync event is
// not received
ssize_t mFramestoDrop;
+ int16_t mInputSource;
};
// server side of the client's IAudioRecord
diff --git a/services/camera/libcameraservice/CameraClient.cpp b/services/camera/libcameraservice/CameraClient.cpp
index 967562d..1254962 100644
--- a/services/camera/libcameraservice/CameraClient.cpp
+++ b/services/camera/libcameraservice/CameraClient.cpp
@@ -697,6 +697,12 @@ void CameraClient::disableMsgType(int32_t msgType) {
bool CameraClient::lockIfMessageWanted(int32_t msgType) {
int sleepCount = 0;
while (mMsgEnabled & msgType) {
+ if ((msgType == CAMERA_MSG_PREVIEW_FRAME) &&
+ (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE)) {
+ LOG1("lockIfMessageWanted(%d): Don't try to acquire mlock if "
+ "both Preview and Compressed are enabled", msgType);
+ return false;
+ }
if (mLock.tryLock() == NO_ERROR) {
if (sleepCount > 0) {
LOG1("lockIfMessageWanted(%d): waited for %d ms",