alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* arecord: strange --duration behaviour with some sample rates
@ 2015-01-20 20:38 Daniel Drake
  2015-01-20 20:51 ` Jaroslav Kysela
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Drake @ 2015-01-20 20:38 UTC (permalink / raw)
  To: alsa-devel

Hi,

With alsa-utils-1.0.28, we're seeing some strange behaviour when running:
 arecord -t wav -r 44100 -d 1 out.wav

After recording 1 second of data to out.wav, a load of extra files are
created like out-01.wav, out-02.wav, out-03.wav, etc. These extra
files are 44 bytes in length. arecord seems to continue  like this
forever rather than exiting after the 1 second recording.

The problem is somehow linked to the sample-rate. At 48000 or 8000,
things work fine, just 44100 is bad.

Tracing some values in the source:
count is 44100, and rest is initialized to the same.

In each iteration of the /* capture */ loop, f has value 5512, i.e.
5512 bytes are read.
So rest decreases through values 38588, 33076, 27564, 22052, 16540, 11028, 5516.

Now we read another 5512 bytes, rest is decreased to 4.
So we now call pcm_read(audiobuf, f) where f has value 4.
pcm_read adjusts that to 5512 and returns 5512.

Now we hit:
    if (pcm_read(audiobuf, f) != f)
        break;

We break out of that inner loop, count still has value 4 so we reach
the end of the outer loop, and loop again, which causes a new file to
be opened, etc.

Sorry that I'm not quite up-to-scratch with pcm basics to suggest a
quick fix, but hopefully this diagnosis is useful at least.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-20 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-20 20:38 arecord: strange --duration behaviour with some sample rates Daniel Drake
2015-01-20 20:51 ` Jaroslav Kysela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).