From a8c60a91233b6ba022a862bf273a62a53d1d8813 Mon Sep 17 00:00:00 2001 From: Anton Rogozin Date: Wed, 15 Sep 2010 14:17:54 +0900 Subject: libaudio: updating supported recording sample rates getInputBufferSize() function was added to AudioHardwareALSA for supporting of other sample rates in addition to 8 kHz Change-Id: I0bb7aa333f7c51135a3bc8b65c5e5528946c48d3 --- libaudio/AudioHardwareALSA.cpp | 29 +++++++++++++++++++++++++++++ libaudio/AudioHardwareALSA.h | 4 ++++ 2 files changed, 33 insertions(+) mode change 100644 => 100755 libaudio/AudioHardwareALSA.h (limited to 'libaudio') diff --git a/libaudio/AudioHardwareALSA.cpp b/libaudio/AudioHardwareALSA.cpp index bb6a8fc..88598b7 100644 --- a/libaudio/AudioHardwareALSA.cpp +++ b/libaudio/AudioHardwareALSA.cpp @@ -33,6 +33,8 @@ #include #include "AudioHardwareALSA.h" +#define READ_FRAME_SIZE 2080 +#define READ_FRAME_SIZE_STANDARD 4160 #if defined SEC_IPC // sangsu fix : headers for IPC @@ -670,6 +672,33 @@ status_t AudioHardwareALSA::dump(int fd, const Vector& args) return NO_ERROR; } + +size_t AudioHardwareALSA::getInputBufferSize(uint32_t sampleRate, int format, int channelCount) +{ + if (sampleRate != 8000 && sampleRate != 11025 && sampleRate != 16000 && sampleRate != 22050 && + sampleRate != 24000 && sampleRate != 32000 && sampleRate != 44100 && sampleRate != 48000) { + LOGW("getInputBufferSize bad sampling rate: %d", sampleRate); + return 0; + } + if (format != AudioSystem::PCM_16_BIT) { + LOGW("getInputBufferSize bad format: %d", format); + return 0; + } + if (channelCount != 1) { + LOGW("getInputBufferSize bad channel count: %d", channelCount); + return 0; + } + +#if defined SEC_SWP_SOUND + if (sampleRate == 32000 || sampleRate == 44100 || sampleRate == 48000) + return READ_FRAME_SIZE_STANDARD; + else + return READ_FRAME_SIZE; +#else /* SEC_SWP_SOUND */ + return 320; +#endif /* SEC_SWP_SOUND */ +} + // ---------------------------------------------------------------------------- ALSAStreamOps::ALSAStreamOps() : diff --git a/libaudio/AudioHardwareALSA.h b/libaudio/AudioHardwareALSA.h old mode 100644 new mode 100755 index 9774f88..5a4b5d5 --- a/libaudio/AudioHardwareALSA.h +++ b/libaudio/AudioHardwareALSA.h @@ -347,6 +347,10 @@ namespace android // mic mute virtual status_t setMicMute(bool state); virtual status_t getMicMute(bool* state); + virtual size_t getInputBufferSize( + uint32_t sampleRate, + int format, + int channelCount); #if defined TURN_ON_DEVICE_ONLY_USE virtual int setMicStatus(int on); // To deliver status of input stream(activated or not). If it's activated, doesn't turn off codec. #endif -- cgit v1.1