Commit 5471aec7 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Workaround to prevent "Out of memory" error when creating AudioTrack.

On some devices (eg. LG Optimus 5) the call to
AudioTrack::getMinFrameCount() returns a weird value. If this is the
case do not use it, take the value returned by
AudioRecord::getMinFrameCount() instead.
parent 70aaa23d
......@@ -522,6 +522,13 @@ static void android_snd_write_preprocess(MSFilter *obj){
if (AudioTrack::getMinFrameCount(&play_buf_size,ad->stype,ad->rate)==0){
if (play_buf_size > 10000) {
ms_message("AudioTrack: getMinFrameCount() returned a weird result, use AudioRecord::getMinFrameCount() instead");
if (AudioRecord::getMinFrameCount(&play_buf_size, ad->rate, AUDIO_FORMAT_PCM_16_BIT, 1) != 0) {
ms_error("AudioTrack: Fallback to AudioRecord::getMinFrameCount() failed");
ms_message("AudioTrack: min frame count is %i",play_buf_size);
ms_error("AudioTrack::getMinFrameCount() error");
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment