summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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