diff options
author | Eric Laurent <elaurent@google.com> | 2011-06-17 16:56:16 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2011-07-11 12:00:31 -0700 |
commit | ff63d56af99e917981df535b96bac4c2a5fc622f (patch) | |
tree | 4803fbbfef8755932bb9e4e332da97e8a995299f | |
parent | a85e358bd9450bc4148b2673ae5403d54fcc61bf (diff) | |
download | device_samsung_crespo-ff63d56af99e917981df535b96bac4c2a5fc622f.zip device_samsung_crespo-ff63d56af99e917981df535b96bac4c2a5fc622f.tar.gz device_samsung_crespo-ff63d56af99e917981df535b96bac4c2a5fc622f.tar.bz2 |
Audio HAL: added interface for audio preprocessing
Change-Id: I0fcfbbddc9716e5c39b3d78032222c7babaa46bd
-rw-r--r-- | libaudio/AudioHardware.cpp | 64 | ||||
-rw-r--r-- | libaudio/AudioHardware.h | 3 |
2 files changed, 41 insertions, 26 deletions
diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp index 4bbe7d6..601a591 100644 --- a/libaudio/AudioHardware.cpp +++ b/libaudio/AudioHardware.cpp @@ -1703,38 +1703,17 @@ String8 AudioHardware::AudioStreamInALSA::getParameters(const String8& keys) return param.toString(); } -status_t AudioHardware::AudioStreamInALSA::getNextBuffer(AudioHardware::BufferProvider::Buffer* buffer) +status_t AudioHardware::AudioStreamInALSA::addAudioEffect(effect_handle_t effect) { - if (mPcm == NULL) { - buffer->raw = NULL; - buffer->frameCount = 0; - mReadStatus = NO_INIT; - return NO_INIT; - } - - if (mInPcmInBuf == 0) { - TRACE_DRIVER_IN(DRV_PCM_READ) - mReadStatus = pcm_read(mPcm,(void*) mPcmIn, AUDIO_HW_IN_PERIOD_SZ * frameSize()); - TRACE_DRIVER_OUT - if (mReadStatus != 0) { - buffer->raw = NULL; - buffer->frameCount = 0; - return mReadStatus; - } - mInPcmInBuf = AUDIO_HW_IN_PERIOD_SZ; - } - - buffer->frameCount = (buffer->frameCount > mInPcmInBuf) ? mInPcmInBuf : buffer->frameCount; - buffer->i16 = mPcmIn + (AUDIO_HW_IN_PERIOD_SZ - mInPcmInBuf) * mChannelCount; - - return mReadStatus; + return NO_ERROR; } -void AudioHardware::AudioStreamInALSA::releaseBuffer(Buffer* buffer) +status_t AudioHardware::AudioStreamInALSA::removeAudioEffect(effect_handle_t effect) { - mInPcmInBuf -= buffer->frameCount; + return NO_ERROR; } + size_t AudioHardware::AudioStreamInALSA::getBufferSize(uint32_t sampleRate, int channelCount) { size_t i; @@ -1770,6 +1749,39 @@ void AudioHardware::AudioStreamInALSA::unlock() { mLock.unlock(); } +//--- BufferProvider +status_t AudioHardware::AudioStreamInALSA::getNextBuffer(AudioHardware::BufferProvider::Buffer* buffer) +{ + if (mPcm == NULL) { + buffer->raw = NULL; + buffer->frameCount = 0; + mReadStatus = NO_INIT; + return NO_INIT; + } + + if (mInPcmInBuf == 0) { + TRACE_DRIVER_IN(DRV_PCM_READ) + mReadStatus = pcm_read(mPcm,(void*) mPcmIn, AUDIO_HW_IN_PERIOD_SZ * frameSize()); + TRACE_DRIVER_OUT + if (mReadStatus != 0) { + buffer->raw = NULL; + buffer->frameCount = 0; + return mReadStatus; + } + mInPcmInBuf = AUDIO_HW_IN_PERIOD_SZ; + } + + buffer->frameCount = (buffer->frameCount > mInPcmInBuf) ? mInPcmInBuf : buffer->frameCount; + buffer->i16 = mPcmIn + (AUDIO_HW_IN_PERIOD_SZ - mInPcmInBuf) * mChannelCount; + + return mReadStatus; +} + +void AudioHardware::AudioStreamInALSA::releaseBuffer(Buffer* buffer) +{ + mInPcmInBuf -= buffer->frameCount; +} + //------------------------------------------------------------------------------ // speex based resampler //------------------------------------------------------------------------------ diff --git a/libaudio/AudioHardware.h b/libaudio/AudioHardware.h index c791f37..abc2e08 100644 --- a/libaudio/AudioHardware.h +++ b/libaudio/AudioHardware.h @@ -329,6 +329,9 @@ private: virtual status_t setParameters(const String8& keyValuePairs); virtual String8 getParameters(const String8& keys); virtual unsigned int getInputFramesLost() const { return 0; } + virtual status_t addAudioEffect(effect_handle_t effect); + virtual status_t removeAudioEffect(effect_handle_t effect); + uint32_t device() { return mDevices; } void doStandby_l(); void close_l(); |