Loading include/media/AudioSystem.h +1 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ public: static bool routedToA2dpOutput(audio_stream_type_t streamType); // return status NO_ERROR implies *buffSize > 0 static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, audio_channel_mask_t channelMask, size_t* buffSize); Loading media/libmedia/AudioRecord.cpp +10 −17 Original line number Diff line number Diff line Loading @@ -41,30 +41,22 @@ status_t AudioRecord::getMinFrameCount( return BAD_VALUE; } // default to 0 in case of error *frameCount = 0; size_t size = 0; size_t size; status_t status = AudioSystem::getInputBufferSize(sampleRate, format, channelMask, &size); if (status != NO_ERROR) { ALOGE("AudioSystem could not query the input buffer size; status %d", status); return NO_INIT; ALOGE("AudioSystem could not query the input buffer size for sampleRate %u, format %#x, " "channelMask %#x; status %d", sampleRate, format, channelMask, status); return status; } if (size == 0) { // We double the size of input buffer for ping pong use of record buffer. // Assumes audio_is_linear_pcm(format) if ((*frameCount = (size * 2) / (popcount(channelMask) * audio_bytes_per_sample(format))) == 0) { ALOGE("Unsupported configuration: sampleRate %u, format %#x, channelMask %#x", sampleRate, format, channelMask); return BAD_VALUE; } // We double the size of input buffer for ping pong use of record buffer. size <<= 1; // Assumes audio_is_linear_pcm(format) uint32_t channelCount = popcount(channelMask); size /= channelCount * audio_bytes_per_sample(format); *frameCount = size; return NO_ERROR; } Loading Loading @@ -215,11 +207,12 @@ status_t AudioRecord::set( mFrameSize = channelCount * audio_bytes_per_sample(format); // validate framecount size_t minFrameCount = 0; size_t minFrameCount; status_t status = AudioRecord::getMinFrameCount(&minFrameCount, sampleRate, format, channelMask); if (status != NO_ERROR) { ALOGE("getMinFrameCount() failed; status %d", status); ALOGE("getMinFrameCount() failed for sampleRate %u, format %#x, channelMask %#x; status %d", sampleRate, format, channelMask, status); return status; } ALOGV("AudioRecord::set() minFrameCount = %d", minFrameCount); Loading Loading
include/media/AudioSystem.h +1 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ public: static bool routedToA2dpOutput(audio_stream_type_t streamType); // return status NO_ERROR implies *buffSize > 0 static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, audio_channel_mask_t channelMask, size_t* buffSize); Loading
media/libmedia/AudioRecord.cpp +10 −17 Original line number Diff line number Diff line Loading @@ -41,30 +41,22 @@ status_t AudioRecord::getMinFrameCount( return BAD_VALUE; } // default to 0 in case of error *frameCount = 0; size_t size = 0; size_t size; status_t status = AudioSystem::getInputBufferSize(sampleRate, format, channelMask, &size); if (status != NO_ERROR) { ALOGE("AudioSystem could not query the input buffer size; status %d", status); return NO_INIT; ALOGE("AudioSystem could not query the input buffer size for sampleRate %u, format %#x, " "channelMask %#x; status %d", sampleRate, format, channelMask, status); return status; } if (size == 0) { // We double the size of input buffer for ping pong use of record buffer. // Assumes audio_is_linear_pcm(format) if ((*frameCount = (size * 2) / (popcount(channelMask) * audio_bytes_per_sample(format))) == 0) { ALOGE("Unsupported configuration: sampleRate %u, format %#x, channelMask %#x", sampleRate, format, channelMask); return BAD_VALUE; } // We double the size of input buffer for ping pong use of record buffer. size <<= 1; // Assumes audio_is_linear_pcm(format) uint32_t channelCount = popcount(channelMask); size /= channelCount * audio_bytes_per_sample(format); *frameCount = size; return NO_ERROR; } Loading Loading @@ -215,11 +207,12 @@ status_t AudioRecord::set( mFrameSize = channelCount * audio_bytes_per_sample(format); // validate framecount size_t minFrameCount = 0; size_t minFrameCount; status_t status = AudioRecord::getMinFrameCount(&minFrameCount, sampleRate, format, channelMask); if (status != NO_ERROR) { ALOGE("getMinFrameCount() failed; status %d", status); ALOGE("getMinFrameCount() failed for sampleRate %u, format %#x, channelMask %#x; status %d", sampleRate, format, channelMask, status); return status; } ALOGV("AudioRecord::set() minFrameCount = %d", minFrameCount); Loading