summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiogo Ferreira <defer@cyngn.com>2014-11-04 14:30:04 +0000
committerRicardo Cerqueira <ricardo@cyngn.com>2014-12-16 18:14:46 +0000
commit0cdb003d8b05e994ba45cd13e44f1d811980a0d7 (patch)
treef3ec388bb2ce7be87a94cda9e163e6b3fec77696
parentc15cc06ff331bef564789dcd872233e79272c531 (diff)
downloadframeworks_av-0cdb003d8b05e994ba45cd13e44f1d811980a0d7.tar.gz
frameworks_av-0cdb003d8b05e994ba45cd13e44f1d811980a0d7.tar.bz2
frameworks_av-0cdb003d8b05e994ba45cd13e44f1d811980a0d7.zip
mediatek: Use the MTK resampler
Change-Id: Id690f22ad0a2357d592271ba7a7718ec3bd1fbad
-rw-r--r--services/audioflinger/Android.mk12
-rw-r--r--services/audioflinger/AudioResampler.cpp21
-rw-r--r--services/audioflinger/AudioResampler.h3
-rw-r--r--services/audioflinger/Threads.cpp18
4 files changed, 54 insertions, 0 deletions
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index d0b712d9f7..85938413eb 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -82,6 +82,12 @@ LOCAL_STATIC_LIBRARIES := \
libcpustats \
libmedia_helper
+ifeq ($(BOARD_HAS_MTK_HARDWARE),true)
+ LOCAL_STATIC_LIBRARIES += libstagefright_audioresamplermtk
+ LOCAL_C_INCLUDES += $(TOP)/hardware/mediatek/media/include
+ LOCAL_SHARED_LIBRARIES += libblisrc
+endif
+
LOCAL_MODULE:= libaudioflinger
LOCAL_SRC_FILES += FastMixer.cpp FastMixerState.cpp AudioWatchdog.cpp
@@ -133,6 +139,12 @@ LOCAL_SHARED_LIBRARIES := \
libutils \
liblog
+ifeq ($(BOARD_HAS_MTK_HARDWARE),true)
+ LOCAL_STATIC_LIBRARIES += libstagefright_audioresamplermtk
+ LOCAL_C_INCLUDES += $(TOP)/hardware/mediatek/media/include
+ LOCAL_SHARED_LIBRARIES += libblisrc
+endif
+
LOCAL_MODULE:= test-resample
LOCAL_MODULE_TAGS := optional
diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp
index ebbdb33f43..6b7d782a93 100644
--- a/services/audioflinger/AudioResampler.cpp
+++ b/services/audioflinger/AudioResampler.cpp
@@ -25,6 +25,9 @@
#include "AudioResampler.h"
#include "AudioResamplerSinc.h"
#include "AudioResamplerCubic.h"
+#ifdef MTK_HARDWARE
+#include "audioresampler/AudioResamplerMtkWrapper.h"
+#endif
#ifdef QTI_RESAMPLER
#include "AudioResamplerQTI.h"
@@ -93,6 +96,9 @@ bool AudioResampler::qualityIsSupported(src_quality quality)
#ifdef QTI_RESAMPLER
case QTI_QUALITY:
#endif
+#ifdef MTK_HARDWARE
+ case MTK_QUALITY:
+#endif
return true;
default:
return false;
@@ -115,6 +121,8 @@ void AudioResampler::init_routine()
ALOGD("forcing AudioResampler quality to %d", defaultQuality);
#ifdef QTI_RESAMPLER
if (defaultQuality < DEFAULT_QUALITY || defaultQuality > QTI_QUALITY) {
+#elif defined(MTK_HARDWARE)
+ if (defaultQuality < DEFAULT_QUALITY || defaultQuality > MTK_QUALITY) {
#else
if (defaultQuality < DEFAULT_QUALITY || defaultQuality > VERY_HIGH_QUALITY) {
#endif
@@ -135,6 +143,10 @@ uint32_t AudioResampler::qualityMHz(src_quality quality)
return 6;
case HIGH_QUALITY:
return 20;
+#ifdef MTK_HARDWARE
+ case MTK_QUALITY:
+ return 28;
+#endif
case VERY_HIGH_QUALITY:
#ifdef QTI_RESAMPLER
case QTI_QUALITY: //for QTI_QUALITY, currently assuming same as VHQ
@@ -179,6 +191,9 @@ AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount,
default:
case DEFAULT_QUALITY:
case LOW_QUALITY:
+#ifdef MTK_HARDWARE
+ case MTK_QUALITY:
+#endif
atFinalQuality = true;
break;
case MED_QUALITY:
@@ -197,6 +212,7 @@ AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount,
#endif
}
}
+
pthread_mutex_unlock(&mutex);
AudioResampler* resampler;
@@ -226,6 +242,11 @@ AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount,
resampler = new AudioResamplerQTI(bitDepth, inChannelCount, sampleRate);
break;
#endif
+#ifdef MTK_HARDWARE
+ case MTK_QUALITY:
+ resampler = new AudioResamplerMtkWrapper(bitDepth, inChannelCount, (int32_t)sampleRate);
+ break;
+#endif
}
// initialize resampler
diff --git a/services/audioflinger/AudioResampler.h b/services/audioflinger/AudioResampler.h
index 5af70fb36c..74016c3637 100644
--- a/services/audioflinger/AudioResampler.h
+++ b/services/audioflinger/AudioResampler.h
@@ -44,6 +44,9 @@ public:
#ifdef QTI_RESAMPLER
QTI_QUALITY=5,
#endif
+#ifdef MTK_HARDWARE
+ MTK_QUALITY=5,
+#endif
};
static AudioResampler* create(int bitDepth, int inChannelCount,
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index f93bd1dada..ae46e5dbd6 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -87,6 +87,10 @@
#include "postpro_patch.h"
#endif
+#ifdef MTK_HARDWARE
+#include "audioresampler/AudioResamplerMtkWrapper.h"
+#endif
+
// ----------------------------------------------------------------------------
// Note: the following macro is used for extremely verbose logging message. In
@@ -4944,8 +4948,13 @@ bool AudioFlinger::RecordThread::threadLoop()
upmix_to_stereo_i16_from_mono_i16((int16_t *)dst,
(int16_t *)src, framesIn);
} else {
+#if MTK_HARDWARE
+ MTK_downmix_to_mono_i16_from_stereo_i16((int16_t *)dst,
+ (int16_t *)src, framesIn);
+#else
downmix_to_mono_i16_from_stereo_i16((int16_t *)dst,
(int16_t *)src, framesIn);
+#endif
}
}
}
@@ -5028,8 +5037,13 @@ bool AudioFlinger::RecordThread::threadLoop()
ditherAndClamp(mRsmpOutBuffer, mRsmpOutBuffer, framesOut);
// the resampler always outputs stereo samples:
// do post stereo to mono conversion
+#ifdef MTK_HARDWARE
+ MTK_downmix_to_mono_i16_from_stereo_i16(buffer.i16, (int16_t *)mRsmpOutBuffer,
+ framesOut);
+#else
downmix_to_mono_i16_from_stereo_i16(buffer.i16, (int16_t *)mRsmpOutBuffer,
framesOut);
+#endif
} else {
ditherAndClamp((int32_t *)buffer.raw, mRsmpOutBuffer, framesOut);
}
@@ -5708,7 +5722,11 @@ void AudioFlinger::RecordThread::readInputParameters()
} else {
channelCount = 2;
}
+#ifdef MTK_HARDWARE
+ mResampler = AudioResampler::create(16, channelCount, mReqSampleRate, AudioResampler::MTK_QUALITY);
+#else
mResampler = AudioResampler::create(16, channelCount, mReqSampleRate);
+#endif
mResampler->setSampleRate(mSampleRate);
mResampler->setVolume(AudioMixer::UNITY_GAIN, AudioMixer::UNITY_GAIN);
mRsmpOutBuffer = new int32_t[mFrameCount * FCC_2];