summaryrefslogtreecommitdiffstats
path: root/libaudio
diff options
context:
space:
mode:
authorAnton Rogozin <ant.rogozin@samsung.com>2010-09-15 14:17:54 +0900
committerEd Heyl <edheyl@google.com>2010-09-17 16:06:10 -0700
commita8c60a91233b6ba022a862bf273a62a53d1d8813 (patch)
tree7b934114f34520d8ffa37f883e323f75fb4f9fb4 /libaudio
parentac9a9cd2cbbe20629ef08d21caeecb099035e109 (diff)
downloaddevice_samsung_crespo-a8c60a91233b6ba022a862bf273a62a53d1d8813.zip
device_samsung_crespo-a8c60a91233b6ba022a862bf273a62a53d1d8813.tar.gz
device_samsung_crespo-a8c60a91233b6ba022a862bf273a62a53d1d8813.tar.bz2
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
Diffstat (limited to 'libaudio')
-rw-r--r--libaudio/AudioHardwareALSA.cpp29
-rwxr-xr-x[-rw-r--r--]libaudio/AudioHardwareALSA.h4
2 files changed, 33 insertions, 0 deletions
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 <alsa/asoundlib.h>
#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<String16>& 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
index 9774f88..5a4b5d5 100644..100755
--- 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