Loading media/mediaserver/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,8 @@ LOCAL_C_INCLUDES := \ frameworks/av/services/mediaresourcemanager \ $(call include-path-for, audio-utils) \ frameworks/av/services/soundtrigger \ frameworks/av/services/radio frameworks/av/services/radio \ external/sonic LOCAL_MODULE:= mediaserver LOCAL_32_BIT_ONLY := true Loading services/audioflinger/Android.mk +3 −1 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ LOCAL_SRC_FILES:= \ LOCAL_C_INCLUDES := \ $(TOPDIR)frameworks/av/services/audiopolicy \ $(TOPDIR)external/sonic \ $(call include-path-for, audio-effects) \ $(call include-path-for, audio-utils) Loading @@ -68,7 +69,8 @@ LOCAL_SHARED_LIBRARIES := \ libhardware_legacy \ libeffects \ libpowermanager \ libserviceutility libserviceutility \ libsonic LOCAL_STATIC_LIBRARIES := \ libscheduling_policy \ Loading services/audioflinger/BufferProviders.cpp +27 −11 Original line number Diff line number Diff line Loading @@ -370,16 +370,22 @@ TimestretchBufferProvider::TimestretchBufferProvider(int32_t channelCount, mPitch(pitch), mLocalBufferFrameCount(0), mLocalBufferData(NULL), mRemaining(0) mRemaining(0), mSonicStream(sonicCreateStream(sampleRate, mChannelCount)) { ALOGV("TimestretchBufferProvider(%p)(%u, %#x, %u %f %f)", this, channelCount, format, sampleRate, speed, pitch); mBuffer.frameCount = 0; LOG_ALWAYS_FATAL_IF(mSonicStream == NULL, "TimestretchBufferProvider can't allocate Sonic stream"); sonicSetSpeed(mSonicStream, speed); } TimestretchBufferProvider::~TimestretchBufferProvider() { ALOGV("~TimestretchBufferProvider(%p)", this); sonicDestroyStream(mSonicStream); if (mBuffer.frameCount != 0) { mTrackBufferProvider->releaseBuffer(&mBuffer); } Loading Loading @@ -489,6 +495,9 @@ status_t TimestretchBufferProvider::setPlaybackRate(float speed, float pitch) { mSpeed = speed; mPitch = pitch; sonicSetSpeed(mSonicStream, speed); //TODO: pitch is ignored for now return OK; } Loading @@ -506,17 +515,24 @@ void TimestretchBufferProvider::processFrames(void *dstBuffer, size_t *dstFrames *srcFrames = targetSrc + 1; } // Do the time stretch by memory copy without any local buffer. if (*dstFrames <= *srcFrames) { size_t copySize = mFrameSize * *dstFrames; memcpy(dstBuffer, srcBuffer, copySize); } else { // cyclically repeat the source. for (size_t count = 0; count < *dstFrames; count += *srcFrames) { size_t remaining = min(*srcFrames, *dstFrames - count); memcpy((uint8_t*)dstBuffer + mFrameSize * count, srcBuffer, mFrameSize * *srcFrames); switch (mFormat) { case AUDIO_FORMAT_PCM_FLOAT: if (sonicWriteFloatToStream(mSonicStream, (float*)srcBuffer, *srcFrames) != 1) { ALOGE("sonicWriteFloatToStream cannot realloc"); *srcFrames = 0; // cannot consume all of srcBuffer } *dstFrames = sonicReadFloatFromStream(mSonicStream, (float*)dstBuffer, *dstFrames); break; case AUDIO_FORMAT_PCM_16_BIT: if (sonicWriteShortToStream(mSonicStream, (short*)srcBuffer, *srcFrames) != 1) { ALOGE("sonicWriteShortToStream cannot realloc"); *srcFrames = 0; // cannot consume all of srcBuffer } *dstFrames = sonicReadShortFromStream(mSonicStream, (short*)dstBuffer, *dstFrames); break; default: // could also be caught on construction LOG_ALWAYS_FATAL("invalid format %#x for TimestretchBufferProvider", mFormat); } } Loading services/audioflinger/BufferProviders.h +2 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <hardware/audio_effect.h> #include <media/AudioBufferProvider.h> #include <system/audio.h> #include <sonic.h> namespace android { Loading Loading @@ -183,6 +184,7 @@ private: size_t mLocalBufferFrameCount; void *mLocalBufferData; size_t mRemaining; sonicStream mSonicStream; }; // ---------------------------------------------------------------------------- Loading services/audioflinger/tests/Android.mk +4 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,8 @@ LOCAL_SRC_FILES:= \ LOCAL_C_INCLUDES := \ $(call include-path-for, audio-effects) \ $(call include-path-for, audio-utils) \ frameworks/av/services/audioflinger frameworks/av/services/audioflinger \ external/sonic LOCAL_STATIC_LIBRARIES := \ libsndfile Loading @@ -58,7 +59,8 @@ LOCAL_SHARED_LIBRARIES := \ libdl \ libcutils \ libutils \ liblog liblog \ libsonic LOCAL_MODULE:= test-mixer Loading Loading
media/mediaserver/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,8 @@ LOCAL_C_INCLUDES := \ frameworks/av/services/mediaresourcemanager \ $(call include-path-for, audio-utils) \ frameworks/av/services/soundtrigger \ frameworks/av/services/radio frameworks/av/services/radio \ external/sonic LOCAL_MODULE:= mediaserver LOCAL_32_BIT_ONLY := true Loading
services/audioflinger/Android.mk +3 −1 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ LOCAL_SRC_FILES:= \ LOCAL_C_INCLUDES := \ $(TOPDIR)frameworks/av/services/audiopolicy \ $(TOPDIR)external/sonic \ $(call include-path-for, audio-effects) \ $(call include-path-for, audio-utils) Loading @@ -68,7 +69,8 @@ LOCAL_SHARED_LIBRARIES := \ libhardware_legacy \ libeffects \ libpowermanager \ libserviceutility libserviceutility \ libsonic LOCAL_STATIC_LIBRARIES := \ libscheduling_policy \ Loading
services/audioflinger/BufferProviders.cpp +27 −11 Original line number Diff line number Diff line Loading @@ -370,16 +370,22 @@ TimestretchBufferProvider::TimestretchBufferProvider(int32_t channelCount, mPitch(pitch), mLocalBufferFrameCount(0), mLocalBufferData(NULL), mRemaining(0) mRemaining(0), mSonicStream(sonicCreateStream(sampleRate, mChannelCount)) { ALOGV("TimestretchBufferProvider(%p)(%u, %#x, %u %f %f)", this, channelCount, format, sampleRate, speed, pitch); mBuffer.frameCount = 0; LOG_ALWAYS_FATAL_IF(mSonicStream == NULL, "TimestretchBufferProvider can't allocate Sonic stream"); sonicSetSpeed(mSonicStream, speed); } TimestretchBufferProvider::~TimestretchBufferProvider() { ALOGV("~TimestretchBufferProvider(%p)", this); sonicDestroyStream(mSonicStream); if (mBuffer.frameCount != 0) { mTrackBufferProvider->releaseBuffer(&mBuffer); } Loading Loading @@ -489,6 +495,9 @@ status_t TimestretchBufferProvider::setPlaybackRate(float speed, float pitch) { mSpeed = speed; mPitch = pitch; sonicSetSpeed(mSonicStream, speed); //TODO: pitch is ignored for now return OK; } Loading @@ -506,17 +515,24 @@ void TimestretchBufferProvider::processFrames(void *dstBuffer, size_t *dstFrames *srcFrames = targetSrc + 1; } // Do the time stretch by memory copy without any local buffer. if (*dstFrames <= *srcFrames) { size_t copySize = mFrameSize * *dstFrames; memcpy(dstBuffer, srcBuffer, copySize); } else { // cyclically repeat the source. for (size_t count = 0; count < *dstFrames; count += *srcFrames) { size_t remaining = min(*srcFrames, *dstFrames - count); memcpy((uint8_t*)dstBuffer + mFrameSize * count, srcBuffer, mFrameSize * *srcFrames); switch (mFormat) { case AUDIO_FORMAT_PCM_FLOAT: if (sonicWriteFloatToStream(mSonicStream, (float*)srcBuffer, *srcFrames) != 1) { ALOGE("sonicWriteFloatToStream cannot realloc"); *srcFrames = 0; // cannot consume all of srcBuffer } *dstFrames = sonicReadFloatFromStream(mSonicStream, (float*)dstBuffer, *dstFrames); break; case AUDIO_FORMAT_PCM_16_BIT: if (sonicWriteShortToStream(mSonicStream, (short*)srcBuffer, *srcFrames) != 1) { ALOGE("sonicWriteShortToStream cannot realloc"); *srcFrames = 0; // cannot consume all of srcBuffer } *dstFrames = sonicReadShortFromStream(mSonicStream, (short*)dstBuffer, *dstFrames); break; default: // could also be caught on construction LOG_ALWAYS_FATAL("invalid format %#x for TimestretchBufferProvider", mFormat); } } Loading
services/audioflinger/BufferProviders.h +2 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <hardware/audio_effect.h> #include <media/AudioBufferProvider.h> #include <system/audio.h> #include <sonic.h> namespace android { Loading Loading @@ -183,6 +184,7 @@ private: size_t mLocalBufferFrameCount; void *mLocalBufferData; size_t mRemaining; sonicStream mSonicStream; }; // ---------------------------------------------------------------------------- Loading
services/audioflinger/tests/Android.mk +4 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,8 @@ LOCAL_SRC_FILES:= \ LOCAL_C_INCLUDES := \ $(call include-path-for, audio-effects) \ $(call include-path-for, audio-utils) \ frameworks/av/services/audioflinger frameworks/av/services/audioflinger \ external/sonic LOCAL_STATIC_LIBRARIES := \ libsndfile Loading @@ -58,7 +59,8 @@ LOCAL_SHARED_LIBRARIES := \ libdl \ libcutils \ libutils \ liblog liblog \ libsonic LOCAL_MODULE:= test-mixer Loading