CamillaDSP - Cross-platform IIR and FIR engine for crossovers, room correction etc.

Thanks for the tip. I just tried adding plughw to one of the devices. With this I could could get a few seconds of audio but CamillaDSP would then error out. For reference both devices share a common clock.

Here is my asound.conf.

Code:
pcm.multi_playback {
    type multi
    slaves.a.pcm plughw:ADAT
    slaves.a.channels 8
    slaves.b.pcm hw:UltraLitemk5
    slaves.b.channels 22

# bind virtual device playback channels 0-7 to ADAT 0-7
     bindings.0.slave a
     bindings.0.channel 0
     bindings.1.slave a
     bindings.1.channel 1
     bindings.2.slave a
     bindings.2.channel 2
     bindings.3.slave a
     bindings.3.channel 3
     bindings.4.slave a
     bindings.4.channel 4
     bindings.5.slave a
     bindings.5.channel 5
     bindings.6.slave a
     bindings.6.channel 6
     bindings.7.slave a
     bindings.7.channel 7
    
# bind virtual device playback channels 8-29 to UL Mk5 0-21
     bindings.8.slave b
     bindings.8.channel 0
     bindings.9.slave b
     bindings.9.channel 1
     bindings.10.slave b
     bindings.10.channel 2
     bindings.11.slave b
     bindings.11.channel 3
     bindings.12.slave b
     bindings.12.channel 4
     bindings.13.slave b
     bindings.13.channel 5
     bindings.14.slave b
     bindings.14.channel 6
     bindings.15.slave b
     bindings.15.channel 7
     bindings.16.slave b
     bindings.16.channel 8
     bindings.17.slave b
     bindings.17.channel 9
     bindings.18.slave b
     bindings.18.channel 10
     bindings.19.slave b
     bindings.19.channel 11
     bindings.20.slave b
     bindings.20.channel 12
     bindings.21.slave b
     bindings.21.channel 13
     bindings.22.slave b
     bindings.22.channel 14
     bindings.23.slave b
     bindings.23.channel 15
     bindings.24.slave b
     bindings.24.channel 16
     bindings.25.slave b
     bindings.25.channel 17
     bindings.26.slave b
     bindings.26.channel 18
     bindings.27.slave b
     bindings.27.channel 19
     bindings.28.slave b
     bindings.28.channel 20
     bindings.29.slave b
     bindings.29.channel 21
}

ctl.multi_playback {
    type hw
    card 0
}

And here is what I am seeing from CamillaDSP.

Code:
2023-07-26 14:09:20.293636 INFO [src/bin.rs:711] CamillaDSP version 1.0.3
2023-07-26 14:09:20.293894 INFO [src/bin.rs:712] Running on linux, aarch64
2023-07-26 14:09:20.294190 DEBUG [src/bin.rs:754] Read config file Some("/home/michael3/camilladsp/configs/multi.yml")
2023-07-26 14:09:20.296101 DEBUG [src/bin.rs:773] Config is valid
2023-07-26 14:09:20.296257 DEBUG [src/socketserver.rs:260] Start websocket server on 127.0.0.1:1234
2023-07-26 14:09:20.296658 DEBUG [src/bin.rs:857] Wait for config
2023-07-26 14:09:20.296808 DEBUG [src/bin.rs:890] Config ready
2023-07-26 14:09:20.297606 DEBUG [src/filters.rs:450] Build new pipeline
2023-07-26 14:09:20.297606 DEBUG [src/bin.rs:213] Using channels [true, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
2023-07-26 14:09:20.297853 DEBUG [src/processing.rs:19] build filters, waiting to start processing loop
2023-07-26 14:09:20.297854 DEBUG [src/alsadevice.rs:917] Buffer frames 2048
2023-07-26 14:09:20.302773 DEBUG [src/alsadevice.rs:413] Playback: supported channels, min: 30, max: 30, list: [30]
2023-07-26 14:09:20.302951 DEBUG [src/alsadevice.rs:414] Playback: setting channels to 30
2023-07-26 14:09:20.303531 DEBUG [src/alsadevice.rs:418] Playback: supported samplerates: Discrete([44100, 48000])
2023-07-26 14:09:20.303676 DEBUG [src/alsadevice.rs:419] Playback: setting rate to 48000
2023-07-26 14:09:20.303935 DEBUG [src/alsadevice.rs:423] Playback: supported sample formats: [S24LE3]
2023-07-26 14:09:20.304074 DEBUG [src/alsadevice.rs:424] Playback: setting format to S24LE3
2023-07-26 14:09:20.311758 DEBUG [src/alsadevice.rs:455] Opening audio device "multi_playback" with parameters: HwParams { channels: Ok(30), rate: "Ok(48000) Hz", format: Ok(S243LE), access: Ok(RWInterleaved), period_size: "Ok(256) frames", buffer_size: "Ok(2048) frames" }, SwParams(avail_min: Ok(1024) frames, start_threshold: Ok(768) frames, stop_threshold: Ok(2048) frames)
2023-07-26 14:09:20.312013 DEBUG [src/alsadevice.rs:460] Audio device "multi_playback" successfully opened
2023-07-26 14:09:20.312308 DEBUG [src/bin.rs:323] Playback thread ready to start
2023-07-26 14:09:20.313539 DEBUG [src/alsadevice.rs:413] Capture: supported channels, min: 20, max: 20, list: [20]
2023-07-26 14:09:20.313749 DEBUG [src/alsadevice.rs:414] Capture: setting channels to 20
2023-07-26 14:09:20.313925 DEBUG [src/alsadevice.rs:418] Capture: supported samplerates: Discrete([48000])
2023-07-26 14:09:20.314085 DEBUG [src/alsadevice.rs:419] Capture: setting rate to 48000
2023-07-26 14:09:20.314260 DEBUG [src/alsadevice.rs:423] Capture: supported sample formats: [S24LE3]
2023-07-26 14:09:20.314426 DEBUG [src/alsadevice.rs:424] Capture: setting format to S24LE3
2023-07-26 14:09:20.314870 DEBUG [src/alsadevice.rs:455] Opening audio device "hw:UltraLitemk5" with parameters: HwParams { channels: Ok(20), rate: "Ok(48000) Hz", format: Ok(S243LE), access: Ok(RWInterleaved), period_size: "Ok(256) frames", buffer_size: "Ok(2048) frames" }, SwParams(avail_min: Ok(1024) frames, start_threshold: Ok(0) frames, stop_threshold: Ok(2048) frames)
2023-07-26 14:09:20.315150 DEBUG [src/alsadevice.rs:460] Audio device "hw:UltraLitemk5" successfully opened
2023-07-26 14:09:20.315373 DEBUG [src/bin.rs:333] Capture thread ready to start
2023-07-26 14:09:20.315541 DEBUG [src/bin.rs:336] Both capture and playback ready, release barrier
2023-07-26 14:09:20.315723 DEBUG [src/bin.rs:338] Supervisor loop starts now!
2023-07-26 14:09:20.315748 DEBUG [src/processing.rs:21] Processing loop starts now!
2023-07-26 14:09:20.315931 DEBUG [src/alsadevice.rs:958] Starting captureloop
2023-07-26 14:09:20.316014 DEBUG [src/alsadevice.rs:863] Starting playback loop
2023-07-26 14:09:20.316920 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-07-26 14:09:20.346497 INFO [src/alsadevice.rs:161] Starting playback from Prepared state
2023-07-26 14:09:20.443489 DEBUG [/cargo/registry/src/github.com-1ecc6299db9ec823/tungstenite-0.16.0/src/handshake/server.rs:282] Server handshake done.
2023-07-26 14:09:20.447159 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetVersion)
2023-07-26 14:09:22.244844 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetState)
2023-07-26 14:09:22.245999 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureSignalRms)
2023-07-26 14:09:22.247375 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureSignalPeak)
2023-07-26 14:09:22.249103 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetPlaybackSignalRms)
2023-07-26 14:09:22.251202 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetPlaybackSignalPeak)
2023-07-26 14:09:22.252636 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureRate)
2023-07-26 14:09:22.253629 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetRateAdjust)
2023-07-26 14:09:22.254418 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetBufferLevel)
2023-07-26 14:09:22.255127 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetClippedSamples)
2023-07-26 14:09:22.273830 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetVolume)
2023-07-26 14:09:22.276200 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetMute)
2023-07-26 14:09:22.278164 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetVolume)
2023-07-26 14:09:22.280513 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetMute)
2023-07-26 14:09:22.282433 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetVolume)
2023-07-26 14:09:22.284770 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetMute)
2023-07-26 14:09:22.388705 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetState)
2023-07-26 14:09:22.389936 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureSignalRms)
2023-07-26 14:09:22.391366 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureSignalPeak)
2023-07-26 14:09:22.393064 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetPlaybackSignalRms)
2023-07-26 14:09:22.394708 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetPlaybackSignalPeak)
2023-07-26 14:09:22.519904 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetState)
2023-07-26 14:09:22.521575 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureSignalRms)
2023-07-26 14:09:22.523211 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureSignalPeak)
2023-07-26 14:09:22.524627 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetPlaybackSignalRms)
2023-07-26 14:09:22.526592 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetPlaybackSignalPeak)
2023-07-26 14:09:22.640434 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetState)
2023-07-26 14:09:22.641504 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureSignalRms)
2023-07-26 14:09:22.642690 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetCaptureSignalPeak)
2023-07-26 14:09:22.644086 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetPlaybackSignalRms)
2023-07-26 14:09:22.645539 DEBUG [src/socketserver.rs:340] parsed command: Ok(GetPlaybackSignalPeak)
2023-07-26 14:09:22.695120 WARN [src/alsadevice.rs:213] Retrying playback, error: ALSA function 'snd_pcm_writei' failed with error 'EAGAIN: Try again'
2023-07-26 14:09:22.716825 ERROR [src/bin.rs:344] Playback error: ALSA function 'snd_pcm_writei' failed with error 'EPIPE: Broken pipe'
2023-07-26 14:09:22.717116 DEBUG [src/bin.rs:352] Wait for capture thread to exit..
2023-07-26 14:09:22.719332 WARN [src/alsadevice.rs:157] Prepare playback after buffer underrun
2023-07-26 14:09:22.730102 DEBUG [src/alsadevice.rs:627] Exit message received, sending EndOfStream
2023-07-26 14:09:22.730958 DEBUG [src/bin.rs:915] Restarting with new config
2023-07-26 14:09:22.731208 DEBUG [src/bin.rs:857] Wait for config
2023-07-26 14:09:22.731432 DEBUG [src/bin.rs:860] No config and not in wait mode, exiting!

Michael
 
Good point.

I created a 30 channel test track with sox and then used aplay to play it to the multi device and it seems to work fine.

Code:
Playing WAVE '30out.wav' : Signed 24 bit Little Endian in 3bytes, Rate 48000 Hz, Channels 30
Multi PCM
  Channel bindings:
    0: slave 0, channel 0
    1: slave 0, channel 1
    2: slave 0, channel 2
    3: slave 0, channel 3
    4: slave 0, channel 4
    5: slave 0, channel 5
    6: slave 0, channel 6
    7: slave 0, channel 7
    8: slave 1, channel 0
    9: slave 1, channel 1
    10: slave 1, channel 2
    11: slave 1, channel 3
    12: slave 1, channel 4
    13: slave 1, channel 5
    14: slave 1, channel 6
    15: slave 1, channel 7
    16: slave 1, channel 8
    17: slave 1, channel 9
    18: slave 1, channel 10
    19: slave 1, channel 11
    20: slave 1, channel 12
    21: slave 1, channel 13
    22: slave 1, channel 14
    23: slave 1, channel 15
    24: slave 1, channel 16
    25: slave 1, channel 17
    26: slave 1, channel 18
    27: slave 1, channel 19
    28: slave 1, channel 20
    29: slave 1, channel 21
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S24_3LE
  subformat    : STD
  channels     : 30
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 24
  buffer_size  : 24000
  period_size  : 6000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 6000
  period_event : 0
  start_threshold  : 24000
  stop_threshold   : 24000
  silence_threshold: 0
  silence_size : 0
  boundary     : 6755399441055744000
Slave #0: Plug PCM: Linear conversion PCM (S32_LE)
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S24_3LE
  subformat    : STD
  channels     : 8
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 24
  buffer_size  : 24000
  period_size  : 6000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 6000
  period_event : 0
  start_threshold  : 24000
  stop_threshold   : 24000
  silence_threshold: 0
  silence_size : 0
  boundary     : 6755399441055744000
Slave: Hardware PCM card 2 'MCHStreamer ADAT' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S32_LE
  subformat    : STD
  channels     : 8
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 24000
  period_size  : 6000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 6000
  period_event : 0
  start_threshold  : 24000
  stop_threshold   : 24000
  silence_threshold: 0
  silence_size : 0
  boundary     : 6755399441055744000
  appl_ptr     : 0
  hw_ptr       : 0
Slave #1: Hardware PCM card 3 'UltraLite-mk5' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S24_3LE
  subformat    : STD
  channels     : 22
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 24
  buffer_size  : 24000
  period_size  : 6000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 6000
  period_event : 0
  start_threshold  : 24000
  stop_threshold   : 24000
  silence_threshold: 0
  silence_size : 0
  boundary     : 6755399441055744000
  appl_ptr     : 0
  hw_ptr       : 0

Michael
 
Right, if you want to check the same conditions in CDSP and aplay, please set buffer size and period size params to correspond to CDSP, as in the log:

Code:
Opening audio device "multi_playback" with parameters: HwParams { channels: Ok(30), rate: "Ok(48000) Hz", format: Ok(S243LE), access: Ok(RWInterleaved), period_size: "Ok(256) frames", buffer_size: "Ok(2048) frames" }

Your aplay results above have buffer size 24000 and period size 6000. The CDSP timing used is much stricter. If you set aplay --period-size=256 --buffer-size=2048, you will likely get xruns too.
 
Interestingly enough aplay seems fine with lower buffer sizes. Seems to go down to buffer size 512 and period size 256 without issue.

Code:
aplay 30out.wav -D multi_playback -v --period-size=256 --buffer-size=512
Playing WAVE '30out.wav' : Signed 24 bit Little Endian in 3bytes, Rate 48000 Hz, Channels 30
Multi PCM
  Channel bindings:
    0: slave 0, channel 0
    1: slave 0, channel 1
    2: slave 0, channel 2
    3: slave 0, channel 3
    4: slave 0, channel 4
    5: slave 0, channel 5
    6: slave 0, channel 6
    7: slave 0, channel 7
    8: slave 1, channel 0
    9: slave 1, channel 1
    10: slave 1, channel 2
    11: slave 1, channel 3
    12: slave 1, channel 4
    13: slave 1, channel 5
    14: slave 1, channel 6
    15: slave 1, channel 7
    16: slave 1, channel 8
    17: slave 1, channel 9
    18: slave 1, channel 10
    19: slave 1, channel 11
    20: slave 1, channel 12
    21: slave 1, channel 13
    22: slave 1, channel 14
    23: slave 1, channel 15
    24: slave 1, channel 16
    25: slave 1, channel 17
    26: slave 1, channel 18
    27: slave 1, channel 19
    28: slave 1, channel 20
    29: slave 1, channel 21
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S24_3LE
  subformat    : STD
  channels     : 30
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 24
  buffer_size  : 512
  period_size  : 256
  period_time  : 5333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 256
  period_event : 0
  start_threshold  : 512
  stop_threshold   : 512
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
Slave #0: Plug PCM: Linear conversion PCM (S32_LE)
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S24_3LE
  subformat    : STD
  channels     : 8
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 24
  buffer_size  : 512
  period_size  : 256
  period_time  : 5333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 256
  period_event : 0
  start_threshold  : 512
  stop_threshold   : 512
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
Slave: Hardware PCM card 2 'MCHStreamer ADAT' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S32_LE
  subformat    : STD
  channels     : 8
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 512
  period_size  : 256
  period_time  : 5333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 256
  period_event : 0
  start_threshold  : 512
  stop_threshold   : 512
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
  appl_ptr     : 0
  hw_ptr       : 0
Slave #1: Hardware PCM card 3 'UltraLite-mk5' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S24_3LE
  subformat    : STD
  channels     : 22
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 24
  buffer_size  : 512
  period_size  : 256
  period_time  : 5333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 256
  period_event : 0
  start_threshold  : 512
  stop_threshold   : 512
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
  appl_ptr     : 0
  hw_ptr       : 0

Michael
 
Ah, the elusive EAGAIN decided to show up. This is a "soft" error that just means that the read or write operation could not be done right now, and should be retried.
CamilladDSP 1.0 just makes a single retry before giving up. It will be done properly in 2.0. It's already somewhat improved in the "next20" branch, but that doesn't seem enough. The problem is that the EAGAIN error basically never shows up during normal use on most systems, and it's not easy to trigger them on demand for testing.
The aplay tool shows how to handle the EAGAIN: https://git.alsa-project.org/?p=alsa-utils.git;a=blob;f=aplay/aplay.c#l2138
 
Sure, looks like it fights through a few warnings but ultimately fails. I cut out my filters from the log below so that it met the length requirements.

Code:
2023-07-26 21:13:13.537977 INFO [src/bin.rs:747] CamillaDSP version 2.0.0-alpha1
2023-07-26 21:13:13.538280 INFO [src/bin.rs:748] Running on linux, aarch64
2023-07-26 21:13:13.538540 DEBUG [src/bin.rs:792] Loaded state: None
2023-07-26 21:13:13.538633 DEBUG [src/bin.rs:822] Initial mute: [false, false, false, false, false]
2023-07-26 21:13:13.538713 DEBUG [src/bin.rs:823] Initial volume: [0.0, 0.0, 0.0, 0.0, 0.0]
2023-07-26 21:13:13.538793 DEBUG [src/bin.rs:825] Read config file Some("/home/michael4/camilladsp/configs/multi2.yml")

2023-07-26 21:13:13.544437 DEBUG [src/bin.rs:850] Config is valid
2023-07-26 21:13:13.544572 DEBUG [src/socketserver.rs:434] Start websocket server on 127.0.0.1:1234
2023-07-26 21:13:13.544841 DEBUG [src/bin.rs:963] Wait for config
2023-07-26 21:13:13.645230 DEBUG [src/bin.rs:1000] Config ready
2023-07-26 21:13:13.646313 DEBUG [src/filters.rs:464] Build new pipeline
2023-07-26 21:13:13.646314 DEBUG [src/bin.rs:211] Using channels [true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false, false, false, false, false, false]

2023-07-26 21:13:13.779226 DEBUG [src/alsadevice.rs:351] Available Capture devices: [("hw:Loopback,0,0", "Loopback, Loopback PCM, subdevice #0"), ("hw:Loopback,0,1", "Loopback, Loopback PCM, subdevice #1"), ("hw:Loopback,0,2", "Loopback, Loopback PCM, subdevice #2"), ("hw:Loopback,0,3", "Loopback, Loopback PCM, subdevice #3"), ("hw:Loopback,0,4", "Loopback, Loopback PCM, subdevice #4"), ("hw:Loopback,0,5", "Loopback, Loopback PCM, subdevice #5"), ("hw:Loopback,0,6", "Loopback, Loopback PCM, subdevice #6"), ("hw:Loopback,0,7", "Loopback, Loopback PCM, subdevice #7"), ("hw:Loopback,1,0", "Loopback, Loopback PCM, subdevice #0"), ("hw:Loopback,1,1", "Loopback, Loopback PCM, subdevice #1"), ("hw:Loopback,1,2", "Loopback, Loopback PCM, subdevice #2"), ("hw:Loopback,1,3", "Loopback, Loopback PCM, subdevice #3"), ("hw:Loopback,1,4", "Loopback, Loopback PCM, subdevice #4"), ("hw:Loopback,1,5", "Loopback, Loopback PCM, subdevice #5"), ("hw:Loopback,1,6", "Loopback, Loopback PCM, subdevice #6"), ("hw:Loopback,1,7", "Loopback, Loopback PCM, subdevice #7"), ("hw:UltraLitemk5,0,0", "UltraLite-mk5, USB Audio, subdevice #0"), ("hw:DAC8PRO,0,0", "DAC8PRO, USB Audio, subdevice #0"), ("null", "Discard all samples (playback) or generate zero samples (capture)"), ("hw:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nDirect hardware device without any conversions"), ("hw:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nDirect hardware device without any conversions"), ("plughw:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nHardware device with all software conversions"), ("plughw:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nHardware device with all software conversions"), ("default:CARD=Loopback", "Loopback, Loopback PCM\nDefault Audio Device"), ("sysdefault:CARD=Loopback", "Loopback, Loopback PCM\nDefault Audio Device"), ("front:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nFront output / input"), ("dsnoop:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nDirect sample snooping device"), ("dsnoop:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nDirect sample snooping device"), ("hw:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nDirect hardware device without any conversions"), ("plughw:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nHardware device with all software conversions"), ("default:CARD=UltraLitemk5", "UltraLite-mk5, USB Audio\nDefault Audio Device"), ("sysdefault:CARD=UltraLitemk5", "UltraLite-mk5, USB Audio\nDefault Audio Device"), ("front:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nFront output / input"), ("dsnoop:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nDirect sample snooping device"), ("hw:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nDirect hardware device without any conversions"), ("plughw:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nHardware device with all software conversions"), ("default:CARD=DAC8PRO", "DAC8PRO, USB Audio\nDefault Audio Device"), ("sysdefault:CARD=DAC8PRO", "DAC8PRO, USB Audio\nDefault Audio Device"), ("front:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nFront output / input"), ("dsnoop:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nDirect sample snooping device")]
2023-07-26 21:13:13.781949 DEBUG [src/alsadevice.rs:369] Capture: supported channels, min: 28, max: 28, list: [28]
2023-07-26 21:13:13.782090 DEBUG [src/alsadevice.rs:370] Capture: setting channels to 28
2023-07-26 21:13:13.783210 DEBUG [src/alsadevice.rs:374] Capture: supported samplerates: Discrete([44100, 48000, 88200, 96000, 176400, 192000])
2023-07-26 21:13:13.783327 DEBUG [src/alsadevice.rs:375] Capture: setting rate to 48000
2023-07-26 21:13:13.783146 DEBUG [src/alsadevice.rs:351] Available Playback devices: [("hw:Loopback,0,0", "Loopback, Loopback PCM, subdevice #0"), ("hw:Loopback,0,1", "Loopback, Loopback PCM, subdevice #1"), ("hw:Loopback,0,2", "Loopback, Loopback PCM, subdevice #2"), ("hw:Loopback,0,3", "Loopback, Loopback PCM, subdevice #3"), ("hw:Loopback,0,4", "Loopback, Loopback PCM, subdevice #4"), ("hw:Loopback,0,5", "Loopback, Loopback PCM, subdevice #5"), ("hw:Loopback,0,6", "Loopback, Loopback PCM, subdevice #6"), ("hw:Loopback,0,7", "Loopback, Loopback PCM, subdevice #7"), ("hw:Loopback,1,0", "Loopback, Loopback PCM, subdevice #0"), ("hw:Loopback,1,1", "Loopback, Loopback PCM, subdevice #1"), ("hw:Loopback,1,2", "Loopback, Loopback PCM, subdevice #2"), ("hw:Loopback,1,3", "Loopback, Loopback PCM, subdevice #3"), ("hw:Loopback,1,4", "Loopback, Loopback PCM, subdevice #4"), ("hw:Loopback,1,5", "Loopback, Loopback PCM, subdevice #5"), ("hw:Loopback,1,6", "Loopback, Loopback PCM, subdevice #6"), ("hw:Loopback,1,7", "Loopback, Loopback PCM, subdevice #7"), ("hw:Headphones,0,0", "bcm2835 Headphones, bcm2835 Headphones, subdevice #0"), ("hw:Headphones,0,1", "bcm2835 Headphones, bcm2835 Headphones, subdevice #1"), ("hw:Headphones,0,2", "bcm2835 Headphones, bcm2835 Headphones, subdevice #2"), ("hw:Headphones,0,3", "bcm2835 Headphones, bcm2835 Headphones, subdevice #3"), ("hw:Headphones,0,4", "bcm2835 Headphones, bcm2835 Headphones, subdevice #4"), ("hw:Headphones,0,5", "bcm2835 Headphones, bcm2835 Headphones, subdevice #5"), ("hw:Headphones,0,6", "bcm2835 Headphones, bcm2835 Headphones, subdevice #6"), ("hw:Headphones,0,7", "bcm2835 Headphones, bcm2835 Headphones, subdevice #7"), ("hw:UltraLitemk5,0,0", "UltraLite-mk5, USB Audio, subdevice #0"), ("hw:DAC8PRO,0,0", "DAC8PRO, USB Audio, subdevice #0"), ("null", "Discard all samples (playback) or generate zero samples (capture)"), ("hw:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nDirect hardware device without any conversions"), ("hw:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nDirect hardware device without any conversions"), ("plughw:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nHardware device with all software conversions"), ("plughw:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nHardware device with all software conversions"), ("default:CARD=Loopback", "Loopback, Loopback PCM\nDefault Audio Device"), ("sysdefault:CARD=Loopback", "Loopback, Loopback PCM\nDefault Audio Device"), ("front:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nFront output / input"), ("surround21:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n2.1 Surround output to Front and Subwoofer speakers"), ("surround40:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n4.0 Surround output to Front and Rear speakers"), ("surround41:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n4.1 Surround output to Front, Rear and Subwoofer speakers"), ("surround50:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n5.0 Surround output to Front, Center and Rear speakers"), ("surround51:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n5.1 Surround output to Front, Center, Rear and Subwoofer speakers"), ("surround71:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n7.1 Surround output to Front, Center, Side, Rear and Woofer speakers"), ("dmix:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nDirect sample mixing device"), ("dmix:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nDirect sample mixing device"), ("hw:CARD=Headphones,DEV=0", "bcm2835 Headphones, bcm2835 Headphones\nDirect hardware device without any conversions"), ("plughw:CARD=Headphones,DEV=0", "bcm2835 Headphones, bcm2835 Headphones\nHardware device with all software conversions"), ("default:CARD=Headphones", "bcm2835 Headphones, bcm2835 Headphones\nDefault Audio Device"), ("sysdefault:CARD=Headphones", "bcm2835 Headphones, bcm2835 Headphones\nDefault Audio Device"), ("dmix:CARD=Headphones,DEV=0", "bcm2835 Headphones, bcm2835 Headphones\nDirect sample mixing device"), ("hw:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nDirect hardware device without any conversions"), ("plughw:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nHardware device with all software conversions"), ("default:CARD=UltraLitemk5", "UltraLite-mk5, USB Audio\nDefault Audio Device"), ("sysdefault:CARD=UltraLitemk5", "UltraLite-mk5, USB Audio\nDefault Audio Device"), ("front:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nFront output / input"), ("surround21:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\n2.1 Surround output to Front and Subwoofer speakers"), ("surround40:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\n4.0 Surround output to Front and Rear speakers"), ("surround41:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\n4.1 Surround output to Front, Rear and Subwoofer speakers"), ("surround50:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\n5.0 Surround output to Front, Center and Rear speakers"), ("surround51:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\n5.1 Surround output to Front, Center, Rear and Subwoofer speakers"), ("surround71:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\n7.1 Surround output to Front, Center, Side, Rear and Woofer speakers"), ("iec958:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nIEC958 (S/PDIF) Digital Audio Output"), ("dmix:CARD=UltraLitemk5,DEV=0", "UltraLite-mk5, USB Audio\nDirect sample mixing device"), ("hw:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nDirect hardware device without any conversions"), ("plughw:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nHardware device with all software conversions"), ("default:CARD=DAC8PRO", "DAC8PRO, USB Audio\nDefault Audio Device"), ("sysdefault:CARD=DAC8PRO", "DAC8PRO, USB Audio\nDefault Audio Device"), ("front:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nFront output / input"), ("surround21:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\n2.1 Surround output to Front and Subwoofer speakers"), ("surround40:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\n4.0 Surround output to Front and Rear speakers"), ("surround41:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\n4.1 Surround output to Front, Rear and Subwoofer speakers"), ("surround50:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\n5.0 Surround output to Front, Center and Rear speakers"), ("surround51:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\n5.1 Surround output to Front, Center, Rear and Subwoofer speakers"), ("surround71:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\n7.1 Surround output to Front, Center, Side, Rear and Woofer speakers"), ("iec958:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nIEC958 (S/PDIF) Digital Audio Output"), ("dmix:CARD=DAC8PRO,DEV=0", "DAC8PRO, USB Audio\nDirect sample mixing device")]
2023-07-26 21:13:13.783636 DEBUG [src/alsadevice.rs:379] Capture: supported sample formats: [S16LE, S32LE]
2023-07-26 21:13:13.783745 DEBUG [src/alsadevice.rs:380] Capture: setting format to S32LE
2023-07-26 21:13:13.784119 DEBUG [src/alsadevice_buffermanager.rs:43] Setting buffer size to 2048 frames
2023-07-26 21:13:13.784540 DEBUG [src/alsadevice_buffermanager.rs:57] Device is using a buffer size of 2048 frames
2023-07-26 21:13:13.784633 DEBUG [src/alsadevice_buffermanager.rs:65] Setting period size to 256 frames
2023-07-26 21:13:13.788775 DEBUG [src/alsadevice.rs:404] Opening Capture device "multi_capture" with parameters: HwParams { channels: Ok(28), rate: "Ok(48000) Hz", format: Ok(S32LE), access: Ok(RWInterleaved), period_size: "Ok(256) frames", buffer_size: "Ok(2048) frames" }, SwParams(avail_min: Ok(1024) frames, start_threshold: Ok(0) frames, stop_threshold: Ok(2048) frames)
2023-07-26 21:13:13.788930 DEBUG [src/alsadevice.rs:409] Capture device "multi_capture" successfully opened
2023-07-26 21:13:13.789102 DEBUG [src/bin.rs:345] Capture thread ready to start
2023-07-26 21:13:13.790630 DEBUG [src/alsadevice.rs:369] Playback: supported channels, min: 30, max: 30, list: [30]
2023-07-26 21:13:13.790732 DEBUG [src/alsadevice.rs:370] Playback: setting channels to 30
2023-07-26 21:13:13.790828 DEBUG [src/alsadevice.rs:374] Playback: supported samplerates: Discrete([48000])
2023-07-26 21:13:13.790919 DEBUG [src/alsadevice.rs:375] Playback: setting rate to 48000
2023-07-26 21:13:13.791011 DEBUG [src/alsadevice.rs:379] Playback: supported sample formats: [S16LE, S32LE]
2023-07-26 21:13:13.791101 DEBUG [src/alsadevice.rs:380] Playback: setting format to S32LE
2023-07-26 21:13:13.791371 DEBUG [src/alsadevice_buffermanager.rs:43] Setting buffer size to 2048 frames
2023-07-26 21:13:13.791463 DEBUG [src/alsadevice_buffermanager.rs:57] Device is using a buffer size of 2048 frames
2023-07-26 21:13:13.791549 DEBUG [src/alsadevice_buffermanager.rs:65] Setting period size to 256 frames
2023-07-26 21:13:13.795552 DEBUG [src/alsadevice.rs:404] Opening Playback device "multi_playback" with parameters: HwParams { channels: Ok(30), rate: "Ok(48000) Hz", format: Ok(S32LE), access: Ok(RWInterleaved), period_size: "Ok(256) frames", buffer_size: "Ok(2048) frames" }, SwParams(avail_min: Ok(1024) frames, start_threshold: Ok(1) frames, stop_threshold: Ok(2048) frames)
2023-07-26 21:13:13.795726 DEBUG [src/alsadevice.rs:409] Playback device "multi_playback" successfully opened
2023-07-26 21:13:13.795899 DEBUG [src/bin.rs:335] Playback thread ready to start
2023-07-26 21:13:13.796066 DEBUG [src/bin.rs:338] Both capture and playback ready, release barrier
2023-07-26 21:13:13.796239 DEBUG [src/bin.rs:340] Supervisor loop starts now!
2023-07-26 21:13:13.796257 DEBUG [src/alsadevice.rs:1054] Starting captureloop
2023-07-26 21:13:13.796301 DEBUG [src/processing.rs:21] Processing loop starts now!
2023-07-26 21:13:13.796374 DEBUG [src/alsadevice.rs:968] Starting playback loop
2023-07-26 21:13:13.796472 DEBUG [src/alsadevice.rs:432] Playback loop uses a buffer of 1024 frames
2023-07-26 21:13:13.796623 DEBUG [src/alsadevice.rs:674] Capture loop uses a buffer of 2048 frames
2023-07-26 21:13:13.796802 DEBUG [src/alsadevice.rs:270] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-07-26 21:13:13.822679 DEBUG [src/countertimer.rs:240] Number of values changed. New 28, prev 2. Clearing history.
2023-07-26 21:13:13.822870 DEBUG [src/countertimer.rs:240] Number of values changed. New 28, prev 2. Clearing history.
2023-07-26 21:13:13.827171 INFO [src/alsadevice.rs:142] PB: Starting playback from Prepared state
2023-07-26 21:13:13.850937 DEBUG [src/countertimer.rs:240] Number of values changed. New 30, prev 2. Clearing history.
2023-07-26 21:13:13.851147 DEBUG [src/countertimer.rs:240] Number of values changed. New 30, prev 2. Clearing history.
2023-07-26 21:13:13.866837 WARN [src/alsadevice.rs:203] PB: Retrying playback, error: ALSA function 'snd_pcm_writei' failed with error 'EAGAIN: Try again'
2023-07-26 21:13:13.868257 WARN [src/alsadevice.rs:203] PB: Retrying playback, error: ALSA function 'snd_pcm_writei' failed with error 'EAGAIN: Try again'
2023-07-26 21:13:13.869804 WARN [src/alsadevice.rs:203] PB: Retrying playback, error: ALSA function 'snd_pcm_writei' failed with error 'EAGAIN: Try again'
2023-07-26 21:13:13.871133 WARN [src/alsadevice.rs:203] PB: Retrying playback, error: ALSA function 'snd_pcm_writei' failed with error 'EAGAIN: Try again'
2023-07-26 21:13:13.890133 WARN [src/alsadevice.rs:203] PB: Retrying playback, error: ALSA function 'snd_pcm_writei' failed with error 'EAGAIN: Try again'
2023-07-26 21:13:13.892457 WARN [src/alsadevice.rs:203] PB: Retrying playback, error: ALSA function 'snd_pcm_writei' failed with error 'EAGAIN: Try again'
2023-07-26 21:13:14.085215 WARN [src/alsadevice.rs:172] PB: device failed while waiting for available buffer space, error: ALSA function 'snd_pcm_wait' failed with error 'EPIPE: Broken pipe'
2023-07-26 21:13:14.085565 ERROR [src/bin.rs:356] Playback error: ALSA function 'snd_pcm_wait' failed with error 'EPIPE: Broken pipe'
2023-07-26 21:13:14.085773 DEBUG [src/bin.rs:364] Wait for capture thread to exit..
2023-07-26 21:13:14.088153 WARN [src/alsadevice.rs:138] PB: Prepare playback after buffer underrun
2023-07-26 21:13:14.099054 DEBUG [src/alsadevice.rs:705] Exit message received, sending EndOfStream
2023-07-26 21:13:14.109434 DEBUG [src/bin.rs:1008] Processing ended with status Ok(Restart)
2023-07-26 21:13:14.109628 DEBUG [src/bin.rs:1023] Restarting with new config
2023-07-26 21:13:14.109901 DEBUG [src/bin.rs:963] Wait for config
2023-07-26 21:13:14.110127 DEBUG [src/bin.rs:967] No config and not in wait mode, exiting!

Michael
 
The log seems OK. Since the device is opened in non-blocking mode, the first call to snd_pcm_writei returns EAGAIN (i.e. the buffer is full). Upon that, snd_pcm_wait is being called https://github.com/HEnquist/camilladsp/blob/next20/src/alsadevice.rs#L209 which succeeds (this wait time is not traced in the log). Upon that another snd_pcm_writei is called again https://github.com/HEnquist/camilladsp/blob/next20/src/alsadevice.rs#L221 which succeeds and breaks the loop.

But the second writei does not track the return value - i.e. how many frames were actually written, does not update the buffer for the written samples, and does not run the loop again, unlike in the case of the first writei https://github.com/HEnquist/camilladsp/blob/next20/src/alsadevice.rs#L197

Maybe here is the problem?

The aplay example uses only one writei call, always checks if all bytes were written https://git.alsa-project.org/?p=alsa-utils.git;a=blob;f=aplay/aplay.c#l2138 , and always updates the data buffer for the frames written https://git.alsa-project.org/?p=alsa-utils.git;a=blob;f=aplay/aplay.c#l2154
 
  • Like
Reactions: 1 user
Just using the multi plugin doesn't give any EAGAINs, but I came up with a weird config that gives plenty of them. I capture from the loopback, while at the same time playing back on a multi plugin that also includes the loopback. This spits out lots and lots of EAGAIN!
So now finally I can test this. @mdsimon2 could you try the branch "eagain"? This runs ok in my weird test environment.
 
Just using the multi plugin doesn't give any EAGAINs, but I came up with a weird config that gives plenty of them. I capture from the loopback, while at the same time playing back on a multi plugin that also includes the loopback. This spits out lots and lots of EAGAIN!
So now finally I can test this. @mdsimon2 could you try the branch "eagain"? This runs ok in my weird test environment.

See attached log. Still get an error. Should say I've only seen this when using devices with different sample formats.

Michael
 

Attachments

  • log_eagain.txt
    1.1 MB · Views: 32
  • Like
Reactions: 1 user
Good evening

I hope to kindly ask for some guidance in setting up CamillaDSP for the first time. My main struggle is to figure out details of devices for capture and playback, and what to configure in Alsa, Pipewire etc.

My setup:
- Intel NUC
- Topping DM7 8-channel DAC
- Linux Mint Mate 21.2 / Kernel 5.15
Intended use:
- Media use, mostly spotify streaming, Videostreaming etc.
- Active speaker crossover duty, room correction

Tried following instructions on GitHub, but get easily confused due to lack of skills and experience. I did the modprobe aloop thing, and got loopback option in alsamixer, then I did the Pipewire thing to make MySink witch turned up as option for input and output in pavucontrol, but after reboot those went away. Do I need to do something to make them stick?

Instructions mention under Pipewire that you can also set up Alsa loopback, but do I need both? My understanding for my use-case is I should set up a MySink, so that all media on my machine can be directed to sink and on to CamillaDSP and on to usb DAC