alsa-project/alsa-lib issue #428 was opened from nnamera:
I am using the ALSA open-source library to read and write audio data for my project. To write audio data, I am calling the snd_pcm_writei function. Initially, it works as expected, but after writing 2-3 frames, the function starts taking significantly more time (around 1 second) to complete.
Normally, snd_pcm_writei should execute within 1-3 ms, but this delay is affecting my application's overall performance, causing audio chopping issues.
Here are the details of my setup:
Frame size: ~8000 bytes (writing 8000 bytes per call)
Plug PCM: Route conversion PCM (sformat=S16_LE) Transformation table: 0 <- 0 1 <- 0 Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 1 rate : 8000 exact rate : 8000 (8000/1) msbits : 16 buffer_size : 4000 period_size : 1000 period_time : 125000 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 1000 period_event : 0 start_threshold : 4000 stop_threshold : 4000 silence_threshold: 0 silence_size : 0 boundary : 9007199254740992000 Slave: Soft volume PCM Control: amba-playback min_dB: -20 max_dB: 20 resolution: 256 Its setup is: stream : PLAYBACK access : MMAP_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 8000 exact rate : 8000 (8000/1) msbits : 16 buffer_size : 4000 period_size : 1000 period_time : 125000 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 1000 period_event : 0 start_threshold : 4000 stop_threshold : 4000 silence_threshold: 0 silence_size : 0 boundary : 9007199254740992000 Slave: Hardware PCM card 0 'es8389' device 0 subdevice 0 Its setup is: stream : PLAYBACK access : MMAP_INTERLEAV[ 22.206911] ambarella-i2c e400a000.i2c: No ACK from address 0x6c, 0:0! ED format [ 22.214533] os04c10: probe of 2-0001 failed with error -5 : S16_LE subformat : STD channels : 2 rate : 8000 exact rate : 8000 (8000/1) msbits : 16 buffer_size : 4000 period_size : 1000 period_time : 125000 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 1000 period_event : 0 start_threshold : 4000 stop_threshold : 4000 silence_threshold: 0 silence_size : 0 boundary : 9007199254740992000 appl_ptr : 0 hw_ptr : 0
I would appreciate any guidance or suggestions on why this delay is happening and how I can resolve it. Let me know if you need any additional details or logs.
Issue URL : https://github.com/alsa-project/alsa-lib/issues/428 Repository URL: https://github.com/alsa-project/alsa-lib