On Jul 28, 12:29 pm, Diego <diego.rond...@kynetics.it> wrote:
> Next problem I get (yeah, not finished yet!) is a "buffer overflow"
> issue in AudioFlinger which prevents audio recording to succeed.
> Inspecting the code I found out that disabling the second condition of
> the if in "AudioFlinger::AudioRecordThread::threadLoop" in
> AudioFlinger.cpp makes the recording work correctly.
> You can take a look at the code at this link:http://tinyurl.com/3bbmnal
> The condition that sometimes fails is "(int)buffer.frameCount ==
> inFrameCount" because, if I have buffer size set to 2048 I sometimes
> get buffer.frameCount equal to 64.
> In particular, like in this log:http://pastebin.com/dQgDaTQL
> I get two times 2048 and one time 64 (then it starts again). I've
> tried setting buffer size to 320 as suggested in several places, which
> seems to be a proper value because ((2048 * 2) + 64) / 320 = 13, but
> it gets rounded to 256 because of this code:http://tinyurl.com/4ypemob
>
> I'm going to investigate further, but does anybody know what's the
> best solution (removing the rounding code?) and explain a bit better
> what I'm doing?

Empiric results:
- setting buffer size in "alsa_default.cpp" to 64 doesn't cause
"buffer overflow" in AudioFlinger but causes "(snd_pcm_recover)
overrun occured" in ALSA;
- setting buffer size to 320 AND removing rounding to previous power
of two seems to work fine, no "buffer overflow" nor "overrun
occurred".

So now I'm able to record correctly, but... :)
But if I try to record a second time since booting the device I get a
problem in the log:
 W/AudioFlinger( 1788): record start failed, status -17
That is because mOutput ALREADY_EXISTS (see: http://tinyurl.com/3s5joca
), which in turn is because nobody called "closeInputStream" from
AudioFlinger. I'm looking for a proper place to close the input
stream, but it's not quite clear because
"AudioRecordThread::threadLoop" can be interrupted. Again, any
suggestion?

Regards,
Diego

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting

Reply via email to