<p><br>
>><br>
>> Pulseaudio is a sound server which mix several playback streams, silence size may has no effect since the alsa sink may use different period size/buffer size or disable period wakeup when using timer scheduling <br>
><br>
> Then, How I can avoid under-run? I mean, If I attempt to write data in a buffer and the under-run occurs, It takes a long time to recover the pcm and the data must be lost. ¿how I can put silence in buffer instead of lost data?</p>
<p>Did your program work when using alsa hw device instead of pulse plugin ?</p>
<p>Did you get back the period size after snd_pcm_hw_params()?</p>
<p>You need to keep at least one period of data in alsa buffer at any time if the sound card just increment hwptr by one period when interrupt occur</p>
<p>It look like bug in your decode and write loop since alsa-pulse plugin won't report underrun by default</p>
<p><a href="http://git.alsa-project.org/?p=alsa-plugins.git;a=commit;h=c20d516e229620129ee20175d8fee8511cc3a4bd">http://git.alsa-project.org/?p=alsa-plugins.git;a=commit;h=c20d516e229620129ee20175d8fee8511cc3a4bd</a></p>
<p>Do you mean your input source always provide data less than the specified rate ?</p>
<p>> I have set the snd_pcm_sw_params_set_stop_threshold() to the boundary value also, but the under-run occurs<br>
><br>
> My Playback PCM now:<br>
><br>
> INFO: Using "default" device.<br>
><br>
> ALSA <-> PulseAudio PCM I/O Plugin<br>
> Its setup is:<br>
> stream : PLAYBACK<br>
> access : RW_INTERLEAVED<br>
> format : S16_LE<br>
> subformat : STD<br>
> channels : 2<br>
> rate : 48000<br>
> exact rate : 48000 (48000/1)<br>
> msbits : 16<br>
> buffer_size : 720<br>
> period_size : 240<br>
> period_time : 5000<br>
> tstamp_mode : NONE<br>
> period_step : 1<br>
> avail_min : 240<br>
> period_event : 0<br>
> start_threshold : 720<br>
> stop_threshold : 6485183463413514240<br>
><br>
> silence_threshold: 0<br>
> silence_size : 6485183463413514240<br>
> boundary : 6485183463413514240<br>
><br>
></p>