0

I've got a dedicated thread that caputures audio from Alsa through snd_pcm_readi(). Recording happens fine for some 30 mins (each file of one minute duration), After that file size gradually decreases and results in "read from audio interface failed err = -32"

if ((err = snd_pcm_readi(capture_handle, buffer, buffer_frames)) != buffer_frames)

{

        fprintf (stderr, "read from audio interface failed (%s)\n",err, snd_strerror (err));
            audio_outbuf_size = (err * snd_pcm_format_width(AUDIO_FORMAT)/ 8 * 2);
}

Any helps are apperciated. Thank you.

MrSmile
  • 1,217
  • 2
  • 12
  • 20
bala
  • 1
  • 1
  • -32 is -EPIPE, which would indicate an overrun. What should happen in that case? – CL. Jul 13 '18 at 12:34
  • i am recording videos continuously(of each one minute duration), after this error "read from audio interface failed err = -32", video file size gradually decreases, and then files results in 1kb or 2kb files which is non playable. please suggest me how to overcome "overrun error". – bala Jul 16 '18 at 04:59
  • An overrun means that your program did not read samples fast enough, so some were lost. What should happen in this case? – CL. Jul 16 '18 at 05:12
  • how can i achieve this in the right way..? – bala Jul 16 '18 at 06:18
  • What should happen when some samples are lost? Abort? Restart? Replace with zeros? – CL. Jul 16 '18 at 06:45
  • No, i should not miss any samples. i need all the data to be fine. – bala Jul 16 '18 at 09:39
  • ALSA uses a ring buffer. If you do not read samples in time, they are lost. – CL. Jul 16 '18 at 10:23

1 Answers1

1

To reduce the chances of an overrun, increase the buffer size. For best results, make it as large as possible.

As long as the period size stays the same, latency will not change.

CL.
  • 173,858
  • 17
  • 217
  • 259