All of lore.kernel.org
 help / color / mirror / Atom feed
* Broken playback
@ 2007-11-21  8:46 Gabriele Melia
  2007-11-21 11:36 ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Gabriele Melia @ 2007-11-21  8:46 UTC (permalink / raw)
  To: alsa-devel


Hi All,
 
i'm new so sorry in advance if i do any errors.
 
I have integrated my hw decoder inside ffmpeg that is working fine, but while playing through alsa the sound comes broken in the sense that it is playing for 3 seconds, stops for 1 plays again for 3 sec and stop again and so on.
 
How I can delay the palyback in order to accumulate some decoded buffers to prevent this and to not afflict the decoder when playback is stopping?
 
Thanks,
Gabriele
_________________________________________________________________
Scarica GRATIS le emoticon della tua squadra del cuore e il calendario di serie A!
http://www.emoticons-livemessenger.com/pages/msnitcalcio/index.htm

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

* Re: Broken playback
  2007-11-21  8:46 Broken playback Gabriele Melia
@ 2007-11-21 11:36 ` Clemens Ladisch
       [not found]   ` <BLU107-W5983EEB0D75DFABAC2EC60C1780@phx.gbl>
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2007-11-21 11:36 UTC (permalink / raw)
  To: Gabriele Melia, alsa-devel

Gabriele Melia wrote:
> How I can delay the palyback in order to accumulate some decoded buffers

You have to read and decode some data before you start playing.
Alternatively, you could play some silence before the first decoded data,
but this would desynchronize the audio and video streams.


HTH
Clemens

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

* Re: Broken playback
       [not found]   ` <BLU107-W5983EEB0D75DFABAC2EC60C1780@phx.gbl>
@ 2007-11-21 15:28     ` Clemens Ladisch
       [not found]       ` <BLU107-W413B1F3D204AF054EDB272C1780@phx.gbl>
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2007-11-21 15:28 UTC (permalink / raw)
  To: Gabriele Melia; +Cc: alsa-devel

Gabriele Melia wrote:
> i have already tried to read and decode some data in order to accumulate
> 1 second of data to prevent broken audio,
> but nothing change, analysing the issue i have found that broken audio
> comes when the snd_pcm_writei is called with a size that is 5000. So it
> takes time to dispach all this size.

Try non-blocking mode (see the snd_pcm_nonblock function).  In non-
blocking mode, the writei call will only write as much data as can be
written without waiting (or returns -EAGAIN if the buffer is already
full at the moment).


HTH
Clemens

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

* Re: Broken playback
       [not found]       ` <BLU107-W413B1F3D204AF054EDB272C1780@phx.gbl>
@ 2007-11-21 16:09         ` Clemens Ladisch
       [not found]           ` <BLU107-W25C7A8D036E93269A46276C1780@phx.gbl>
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2007-11-21 16:09 UTC (permalink / raw)
  To: Gabriele Melia; +Cc: alsa-devel

Gabriele Melia wrote:
> > Try non-blocking mode (see the snd_pcm_nonblock function). In non-
> > blocking mode, the writei call will only write as much data as can be
> > written without waiting (or returns -EAGAIN if the buffer is already
> > full at the moment).
> 
> I'm already in this case

Then the problem is not that the writei call takes too long.
An underrun can happen only when your code takes too much time between
two consecutive calls to writei.

> How to set the buffer size of the circular buffer in which i store the
> pcm that is then called by alsa?

snd_pcm_hw_params_set_buffer_size_near(), but the allowed values are
hardware dependent.  You might want to add your own circular buffer that
is bigger than ALSA's.


HTH
Clemens

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

* Re: Broken playback
       [not found]           ` <BLU107-W25C7A8D036E93269A46276C1780@phx.gbl>
@ 2007-11-22  8:14             ` Clemens Ladisch
  0 siblings, 0 replies; 5+ messages in thread
From: Clemens Ladisch @ 2007-11-22  8:14 UTC (permalink / raw)
  To: Gabriele Melia; +Cc: alsa-devel

Gabriele Melia wrote:
> > snd_pcm_hw_params_set_buffer_size_near(), but the allowed values are
> > hardware dependent. You might want to add your own circular buffer that
> > is bigger than ALSA's.
>  
> So your suggestion is to limit my buffer_size after decode to be same of
> ALSA's?

No; my suggestion is to use your own buffer which is big enough for your
decoder, and use this buffer to fill ALSA's buffer, whenever possible.

If one call to your decoder function needs so much time that ALSA's
buffer can become emptied, you need another thread to re-fill the ALSA
buffer in parallel with the decoding.


Regards,
Clemens

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

end of thread, other threads:[~2007-11-22  8:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-21  8:46 Broken playback Gabriele Melia
2007-11-21 11:36 ` Clemens Ladisch
     [not found]   ` <BLU107-W5983EEB0D75DFABAC2EC60C1780@phx.gbl>
2007-11-21 15:28     ` Clemens Ladisch
     [not found]       ` <BLU107-W413B1F3D204AF054EDB272C1780@phx.gbl>
2007-11-21 16:09         ` Clemens Ladisch
     [not found]           ` <BLU107-W25C7A8D036E93269A46276C1780@phx.gbl>
2007-11-22  8:14             ` 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.