alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Warning/error from ALSA’s pcm_min.c example. Possible problem?
@ 2010-01-30 19:51 Louise Hoffman
  2010-01-31  4:43 ` Raymond Yau
  2010-01-31  8:46 ` Jaroslav Kysela
  0 siblings, 2 replies; 7+ messages in thread
From: Louise Hoffman @ 2010-01-30 19:51 UTC (permalink / raw)
  To: alsa-devel

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)

Which comes from the last if-statement.

One bug is in this line

                frames = snd_pcm_writei(handle, buffer, sizeof(buffer));

where "sizeof(buffer)" should be "number of frames in the buffer".

But there are still some strange things going on. I still get those
errors, and if I remove the for-loop, nothing is played.

Here is my code. [1]

Can someone see what's wrong?

Hugs,
Louise


[0] http://www.google.com/codesearch/p?hl=en&sa=N&cd=1&ct=rc#4FSOSMZ6Pxc/distfiles/alsa-lib-1.0.14rc2.tar.bz2|ZScnKi-LryE/alsa-lib-1.0.14rc2/test/pcm_min.c&q=pcm_min.c

[1] http://pastebin.com/m2f28b578

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Warning/error from ALSA’s pcm_min.c example. Possible problem?
@ 2010-10-29  3:49 Raymond Yau
  2010-10-29  7:19 ` Jaroslav Kysela
  0 siblings, 1 reply; 7+ messages in thread
From: Raymond Yau @ 2010-10-29  3:49 UTC (permalink / raw)
  To: ALSA Development Mailing List

>> 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


 ./pcm_min
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : U8
  subformat    : STD
  channels     : 1
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 8
  buffer_size  : 24000
  period_size  : 6000
  period_time  : 125000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 6000
  period_event : 0
  start_threshold  : 24000
  stop_threshold   : 24000
  silence_threshold: 0
  silence_size : 0
  boundary     : 1572864000
state = 2
write 16384 frames
state = 2
write 16384 frames
state = 3
write 16384 frames
state = 3
write 16384 frames
state = 3

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

end of thread, other threads:[~2010-10-29  7:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-30 19:51 Warning/error from ALSA’s pcm_min.c example. Possible problem? Louise Hoffman
2010-01-31  4:43 ` Raymond Yau
2010-01-31 20:53   ` Louise Hoffman
2010-01-31  8:46 ` Jaroslav Kysela
2010-01-31 20:41   ` Louise Hoffman
  -- strict thread matches above, loose matches on Subject: below --
2010-10-29  3:49 Raymond Yau
2010-10-29  7:19 ` 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).