[alsa-devel] Warning/error from ALSA’s pcm_min.c example. Possible problem?

Jaroslav Kysela perex at perex.cz
Fri Oct 29 09:19:55 CEST 2010


On Fri, 29 Oct 2010, Raymond Yau wrote:

>>> On Sat, 30 Jan 2010, Louise Hoffman wrote:
>
>>> Dear ALSA developers,
>>>
>>> When I compile ALSA's pcm_min.c[0] example with
>>>
>>> gcc -Wall -lasound pcm_min.c -o pcm_min
>>>
>>> Everything is fine, but running it, I get the white noise as expected,
>>> but I also get this warning/error:
>>>
>>> Short write (expected 16384, wrote 7616)
>
>> It was a bug in alsa-lib. I fixed it in patch bellow. Thank you for your
>> report.
>
>> http://git.alsa-project.org/?p=alsa-lib.git;a=commitdiff;h=2e48439ad93f6c8d99a2d72928ac71285b5211bb <http://git.alsa-project.org/?p=alsa-lib.git;a=commitdiff;h=2e48439ad93f6c8d99a2d72928ac71285b5211bb>
>
> Add snd_pcm_dump() after call snd_pcm_set_params in pcm_min.c
>
> The start threshold is equal to buffer size , so there should be a
> short write at the second write since
> 16384 + 7616 = 24000  ( start threshold )
>
> your patch had changed the behaviour

The pcm_min uses the blocked mode, so all layers tries to queue all given 
samples and wait for the ring buffer.

>  buffer_size  : 24000
>  start_threshold  : 24000

> state = 2
> write 16384 frames
> state = 2
> write 16384 frames
> state = 3

This looks correct.

 					Jaroslav


-----
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.



More information about the Alsa-devel mailing list