alsa-project/alsa-utils issue #85 was opened from philipp-fischer:
## Behaviour alsaloop crashes with a bus error (SIGBUS) immediately
``` pi@pi-snapserver:~ $ alsaloop -C hw:2,0 -P hw:3,0 Bus error ```
## Analysis and debugging
Very verbose output: ``` pi@pi-snapserver:~ $ alsaloop -C hw:2,0 -P hw:3,0 -vvvvvvvvvvvvvvvvv !!!Scheduler set to Round Robin with priority 99 FAILED! playback hw:3,0: buffer_size=1920 playback hw:3,0: period_size=240 capture hw:2,0: buffer_size=1920 capture hw:2,0: period_size=240 playback hw:3,0: avail_min2=1560 capture hw:2,0: avail_min2=120 Hardware PCM card 3 'ICUSBAUDIO7D' device 0 subdevice 0 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 : 1920 period_size : 240 period_time : 5000 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 1560 period_event : 0 start_threshold : 2147483647 stop_threshold : 1920 silence_threshold: 0 silence_size : 0 boundary : 2013265920 appl_ptr : 0 hw_ptr : 0 Hardware PCM card 2 'ICUSBAUDIO7D' device 0 subdevice 0 Its setup is: stream : CAPTURE access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 48000 exact rate : 48000 (48000/1) msbits : 16 buffer_size : 1920 period_size : 240 period_time : 5000 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 240 period_event : 0 start_threshold : 2147483647 stop_threshold : 1920 silence_threshold: 0 silence_size : 0 boundary : 2013265920 appl_ptr : 0 hw_ptr : 0 Latency 480 frames, 10000.000us, 10.000000ms (100.0000Hz) playback hw:3,0/capture hw:2,0 sync type: SAMPLERATE (SRC_SINC_FASTEST) playback hw:3,0/capture hw:2,0: capt->buffer_size = 3840, play->buffer_size = 3840 playback hw:3,0/capture hw:2,0: Samplerate src_ratio update1: 1.00000000 New pitch for playback hw:3,0/capture hw:2,0: 1.00000000 (min/max samples = 0/0) playback hw:3,0/capture hw:2,0: silence queued 480 samples pool took 3074us playback hw:3,0/capture hw:2,0: pollfds handle playback hw:3,0: delay 480 / 3840 / 0 capture hw:2,0: delay 0 / 3840 / 0 playback hw:3,0/capture hw:2,0: prevents = 0x4, crevents = 0x0 playback hw:3,0/capture hw:2,0: queued 480/0 samples playback hw:3,0: end delay 480 / 3840 / 0 capture hw:2,0: end delay 0 / 3840 / 0 playback hw:3,0/capture hw:2,0: processing time 59us pool took 13us [...] playback hw:3,0/capture hw:2,0: pollfds handle playback hw:3,0: delay 323 / 3840 / 0 capture hw:2,0: delay 0 / 3840 / 0 playback hw:3,0/capture hw:2,0: prevents = 0x4, crevents = 0x0 playback hw:3,0/capture hw:2,0: queued 323/0 samples playback hw:3,0: end delay 323 / 3840 / 0 capture hw:2,0: end delay 0 / 3840 / 0 playback hw:3,0/capture hw:2,0: processing time 212us pool took 5us playback hw:3,0/capture hw:2,0: pollfds handle playback hw:3,0: delay 323 / 3840 / 0 capture hw:2,0: delay 48 / 3840 / 0 playback hw:3,0/capture hw:2,0: prevents = 0x4, crevents = 0x0 Bus error ```
Debugging with backtrace (binary without dbg symbols): ``` [...] Program received signal SIGBUS, Bus error. 0xb6dbd394 in src_short_to_float_array () from /lib/arm-linux-gnueabihf/libsamplerate.so.0 (gdb) bt #0 0xb6dbd394 in src_short_to_float_array () from /lib/arm-linux-gnueabihf/libsamplerate.so.0 #1 0x00016a20 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) ```
So the error seems to happen in `libsamplerate.so`
Switching the sync method to "SIMPLE" prevents the error from happening as alsaloop doesn't seem to make use of libsamplerate in this case. The following modes run without failing but don't give the desired results:
``` pi@pi-snapserver:~ $ alsaloop -C hw:2,0 -P hw:3,0 -S 0 # SYNC_TYPE_NONE pi@pi-snapserver:~ $ alsaloop -C hw:2,0 -P hw:3,0 -S 1 # SYNC_TYPE_SIMPLE pi@pi-snapserver:~ $ alsaloop -C hw:2,0 -P hw:3,0 -S 2 # SYNC_TYPE_CAPTRATESHIFT pi@pi-snapserver:~ $ alsaloop -C hw:2,0 -P hw:3,0 -S 3 # SYNC_TYPE_PLAYRATESHIFT ```
Only `SYNC_TYPE_SAMPLERATE` and `SYNC_TYPE_AUTO` (which selects SYNC_TYPE_SAMPLERATE) fail.
The modes `SYNC_TYPE_NONE` and `SYNC_TYPE_SIMPLE` don't crash for me, but they don't work and result in increasing latency until the fifos reset. (Which is another issue I guess)
Issue URL : https://github.com/alsa-project/alsa-utils/issues/85 Repository URL: https://github.com/alsa-project/alsa-utils