Re: [alsa-devel] Playback - Overwrite buffer with silence
Nilhcraiv wrote:
To set the Buffer size and Periord size I have use the snd_pcm_hw_params_set_period_size_near() and snd_pcm_hw_params_set_buffer_size_near() functions. If I do not use the ...near() functions, I return errors.
The allowed values of the hardware parameters depend on the hardware's capabilities.
Regards, Clemens
Clemens wrote:
The allowed values of the hardware parameters depend on the hardware's capabilities.
OK but, overwrite the buffer with silence depend of software, no? Why the buffer is not overwrite with silence with this pcm setup? It is as documentation.
PCM:
ALSA <-> PulseAudio PCM I/O Plugin Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 1 rate : 48000 exact rate : 48000 (48000/1) msbits : 16 buffer_size : 720 period_size : 240 period_time : 5000 tstamp_mode : NONE period_step : 1 avail_min : 240 period_event : 0 start_threshold : 240 stop_threshold : 720 silence_threshold: 0 silence_size : 6485183463413514240 boundary : 6485183463413514240
Regards,
Nilhcraiv wrote:
Why the buffer is not overwrite with silence with this pcm setup?
ALSA <-> PulseAudio PCM I/O Plugin Its setup is: silence_threshold: 0 silence_size : 6485183463413514240 boundary : 6485183463413514240
I guess PulseAudio does not handle the silencing correctly.
Regards, Clemens
The allowed values of the hardware parameters depend on the hardware's capabilities.
OK but, overwrite the buffer with silence depend of software, no? Why the
buffer is not overwrite with silence with this pcm setup? It is as documentation.
PCM:
ALSA <-> PulseAudio PCM I/O Plugin Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 1 rate : 48000 exact rate : 48000 (48000/1) msbits : 16 buffer_size : 720 period_size : 240 period_time : 5000 tstamp_mode : NONE period_step : 1 avail_min : 240 period_event : 0 start_threshold : 240 stop_threshold : 720 silence_threshold: 0 silence_size : 6485183463413514240 boundary : 6485183463413514240
Pulse plugin 's minimum periods is three.
len = decoder(&decoded_data,t_data);
pcmreturn = snd_pcm_writei(pcm_handle, decoded_data, len);/*In most cases there are UNDERRUN...*/
If len > 720 (buffer_size), you need to write three periods, start playback, receive data, peform decode while waiting for the sound card/plugin playback one period and write another period
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
Raymind wrote:
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
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?
I have set the snd_pcm_sw_params_set_stop_threshold() to the boundary value also, but the under-run occurs
My Playback PCM now:
INFO: Using "default" device. ALSA <-> PulseAudio PCM I/O Plugin Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 48000 exact rate : 48000 (48000/1) msbits : 16 buffer_size : 720 period_size : 240 period_time : 5000 tstamp_mode : NONE period_step : 1 avail_min : 240 period_event : 0 start_threshold : 720 stop_threshold : 6485183463413514240 silence_threshold: 0 silence_size : 6485183463413514240 boundary : 6485183463413514240
Regards,
participants (3)
-
Clemens Ladisch
-
Nilhcraiv
-
Raymond Yau