All of lore.kernel.org
 help / color / mirror / Atom feed
* ALSA Underrun / Silence playback
@ 2011-12-05  6:40 Irfan shaikh
  2011-12-05  9:50 ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Irfan shaikh @ 2011-12-05  6:40 UTC (permalink / raw)
  To: alsa-devel

Hello devel,

          I am trying to implement s/w params for ALSA playback device 
such that there is SILENCE playback for UNDERRUN (-32).
          To achieve above i used below s/w params API's. But still i 
observe UNDERRUN in my AUDIO Playback.
          Please correct me if i am mising somenting.
{When i do get boundry, i get some weird value 1572864000. Thus i tried 
to use alsa buffer size for threshold}

/*************************************************************************************/ 

   if (snd_pcm_sw_params_get_boundary (alsaParams->p_swparams, 
&boundary) < 0)
         {
                 printf ("Could not gete snd_pcm_sw_params_get_boundary");
                 return NULL;
         }

//      threshold = boundary;
         threshold = alsaParams->periodsize * alsaParams->no_of_periods;

         if (snd_pcm_sw_params_set_stop_threshold 
(alsaParams->pcm_handle, alsaParams->p_swparams, threshold) < 0)
         {
                 printf("Could not gete snd_pcm_sw_params_get_boundary");
                 return NULL;
         }

         if (snd_pcm_sw_params_set_silence_threshold 
(alsaParams->pcm_handle, alsaParams->p_swparams, 0) < 0 ||
                         snd_pcm_sw_params_set_silence_size 
(alsaParams->pcm_handle, alsaParams->p_swparams, boundary) < 0)      /* 
play silence on XRUN */
         {
                 printf("Could not set silence params");
                 return NULL;
         }
/*************************************************************************************/

Thanks in advance !!

Regards,

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

* Re: ALSA Underrun / Silence playback
  2011-12-05  6:40 ALSA Underrun / Silence playback Irfan shaikh
@ 2011-12-05  9:50 ` Clemens Ladisch
  2011-12-05 10:04   ` Irfan shaikh
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2011-12-05  9:50 UTC (permalink / raw)
  To: Irfan shaikh; +Cc: alsa-devel

Irfan shaikh wrote:
> When i do get boundry, i get some weird value 1572864000.

What's weird about this number?

> Thus i tried to use alsa buffer size for threshold

Use the boundary value.


Regards,
Clemens

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

* Re: ALSA Underrun / Silence playback
  2011-12-05  9:50 ` Clemens Ladisch
@ 2011-12-05 10:04   ` Irfan shaikh
  2011-12-05 10:45     ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Irfan shaikh @ 2011-12-05 10:04 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel@alsa-project.org

Hello Clemens,

             I have used my threshold as boundary value {after calling  
snd_pcm_sw_params_get_boundary() } also and checked the audio performance.
I was still getting UNDERRUN's (-32).

             if (snd_pcm_sw_params_set_stop_threshold 
(alsaParams->pcm_handle, alsaParams->p_swparams, threshold) < 0)
             {
                     printf("Could not gete 
snd_pcm_sw_params_get_boundary");
                     return NULL;
             }

What's weird about this number?

--> I set my alsa buffer size as (512 period size and 16 periods)
       As snd_pcm_sw_params_get_boundary(), returns boundary in frames.
       I was not able to get how the boundry which i get (1572864000) is 
more than the buffer size (512 X 16) which i have set.

Regards
Irfan


On 12/05/2011 03:20 PM, Clemens Ladisch wrote:
> Irfan shaikh wrote:
>> When i do get boundry, i get some weird value 1572864000.
> What's weird about this number?
>
>> Thus i tried to use alsa buffer size for threshold
> Use the boundary value.
>
>
> Regards,
> Clemens
>

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

* Re: ALSA Underrun / Silence playback
  2011-12-05 10:04   ` Irfan shaikh
@ 2011-12-05 10:45     ` Clemens Ladisch
  2011-12-05 11:56       ` Irfan shaikh
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2011-12-05 10:45 UTC (permalink / raw)
  To: Irfan shaikh; +Cc: alsa-devel@alsa-project.org

Irfan shaikh wrote:
> I have used my threshold as boundary value also and checked the audio
> performance.  I was still getting UNDERRUN's (-32).

Did you actually call snd_pcm_sw_params()?

> I was not able to get how the boundry which i get (1572864000) is more
> than the buffer size (512 X 16) which i have set.

The boundary value is a large multiple of the buffer size.


Regards,
Clemens

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

* Re: ALSA Underrun / Silence playback
  2011-12-05 10:45     ` Clemens Ladisch
@ 2011-12-05 11:56       ` Irfan shaikh
  0 siblings, 0 replies; 5+ messages in thread
From: Irfan shaikh @ 2011-12-05 11:56 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel@alsa-project.org

On 12/05/2011 04:15 PM, Clemens Ladisch wrote:
> Irfan shaikh wrote:
>> >  I have used my threshold as boundary value also and checked the audio
>> >  performance.  I was still getting UNDERRUN's (-32).
> Did you actually call snd_pcm_sw_params()?
Hi thanks a lot for hint provided by you.
It works fine now.
What threshold value is better boundary value OR alsa buffer size value 
for good performance ?

Observation :
I do lot of console operation purposely to get ALSA underrun.
After above implementation i do not see any UNDERRUN.
###### But Audio goes out of sync and playes jerky ? ########
Is there any way we can avoid above jerks ?

xfer_align function is depreciated.



Thanks and regards
Irfan

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

end of thread, other threads:[~2011-12-05 11:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-05  6:40 ALSA Underrun / Silence playback Irfan shaikh
2011-12-05  9:50 ` Clemens Ladisch
2011-12-05 10:04   ` Irfan shaikh
2011-12-05 10:45     ` Clemens Ladisch
2011-12-05 11:56       ` Irfan shaikh

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.