All of lore.kernel.org
 help / color / mirror / Atom feed
* XRUN happens too often.
@ 2008-04-08 10:15 Rong-Jhe
  2008-04-08 11:40 ` Rong-Jhe
  2008-04-10  6:41 ` Clemens Ladisch
  0 siblings, 2 replies; 13+ messages in thread
From: Rong-Jhe @ 2008-04-08 10:15 UTC (permalink / raw)
  To: alsa-devel

I use "default" pcm and open it in block mode.
Then, I set the this pcm to perform 16-bit, two channels, and 44100 bps 
sampling rate audio data.
The number of periods per buffer is 10.

The follows are the parameters that I read from the pcm.
sampling rate = 44100 bps
period time = 21333 us
period size = 940 frames
buffer time = 213330 us
buffer size = 9408 frames

A sample in 16-bit, two channels is 4 bytes.
I allocate a audio data of 9408x4=37632 bytes.

audio_data=malloc(buffer_size*4);

This audio_data buffer will receive audio data from the network.
If this buffer is full, I use snd_pcm_writei( ) to put the buffer into the pcm.

snd_pcm_sframes_t frames;
snd_pcm_t *handle;

while((frame=snd_pcm_writei(handle, audio_data, buffer_size))<0)
{
   if(frames==-EPIPE)
      snd_pcm_prepare(handle);
   else
      printf("snd_pcm_writei error %d\n", frames);
}

The codes states that I put the entire buffer into the pcm at each time. The 
pcm use 10 periods to perform this buffer. The program can work normally.

If the sampling rate is changed, the program will encounter XRUN frequently.

The follows are the parameters that I read from the pcm after setting sampling 
rate to 48000.
sampling rate = 48000 bps
period time = 21333 us
period size = 1024 frames
buffer time = 213330 us
buffer size = 10240 frames
audio_data=malloc(buffer_size*4); //10240x4=40960

I also put the entire buffer into the pcm at each time, but snd_pcm_writei( )
will return -PIPE frequently.

What is the problem?

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

end of thread, other threads:[~2008-04-10 12:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-08 10:15 XRUN happens too often Rong-Jhe
2008-04-08 11:40 ` Rong-Jhe
2008-04-08 15:20   ` stan
2008-04-09 12:06     ` Rong-Jhe
2008-04-09 22:28       ` stan
2008-04-10  1:01         ` Lee Revell
2008-04-10  3:29           ` Rong-Jhe
2008-04-10  4:54             ` Lee Revell
2008-04-10  7:59               ` Rong-Jhe
2008-04-10  8:20                 ` Jaroslav Kysela
2008-04-10 12:19                   ` Rong-Jhe
2008-04-10  8:24                 ` Rong-Jhe
2008-04-10  6:41 ` Clemens Ladisch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.