mozilla / cubeb

Cross platform audio library
ISC License
434 stars 123 forks source link

sndio backend fails unless sndiod (daemon) is started on FreeBSD #746

Open jbeich opened 1 year ago

jbeich commented 1 year ago

Regressed by #743. Affects cubeb-test but not test_audio. CC @ratchov Found via RPCS3/Yuzu/Citra which unlike Firefox (see media.cubeb.backend) don't expose a way to force a specific cubeb backend.

$ pkg install cmake ninja googletest sndio
$ export CFLAGS="-isystem/usr/local/include" CXXFLAGS="-isystem/usr/local/include" LDFLAGS="-L/usr/local/lib"
$ cmake -G Ninja -B /tmp/cubeb_build
$ cmake --build /tmp/cubeb_build

$ /tmp/cubeb_build/cubeb-test
Log level is DISABLED
Init cubeb backend: sndio
collection device type is UNKNOWN
cubeb.c:625:DeviceID: "default" (PREFERRED)
        Name:   "default"
        Group:  "default"
        Vendor: "(null)"
        Type:   output
        State:  enabled
        Maximum channels:       8
        Format: S16LE (0x10) (default: S16LE)
        Rate:   [4000, 192000] (default: 48000)
        Latency: lo 480 frames, hi 9600 frames
Found 1 output devices. Choose one:
# 0
        name: system default device
# 1  (PREFERRED)
        name: default
        device id: default
        max channels: 8
        state: enabled
Enter device number: 0
Could not open the stream
stream_init failed
Abort trap
ratchov commented 1 year ago

It seems that FreeBSD doesn't support LSB-aligned samples. FWIW, the current cubeb_sndio encoding is the native sndiod one, which avoids conversions on the sndiod side. Here's a quick diff to use the more common MSB-aligned encoding:

https://github.com/ratchov/cubeb/commit/8ec312d3c0fdcc57d9be452e8bf51803d588ec46

Does it work for you?

jbeich commented 1 year ago

https://github.com/ratchov/cubeb/commit/8ec312d3c0fdcc57d9be452e8bf51803d588ec46 doesn't help:

$ git fetch https://github.com/ratchov/cubeb sndio_s24_msb
$ git merge FETCH_HEAD
$ cmake --build /tmp/cubeb_build
$ /tmp/cubeb_build/cubeb-test
Log level is DISABLED
Init cubeb backend: sndio
collection device type is UNKNOWN
cubeb.c:625:DeviceID: "default" (PREFERRED)
        Name:   "default"
        Group:  "default"
        Vendor: "(null)"
        Type:   output
        State:  enabled
        Maximum channels:       8
        Format: S16LE (0x10) (default: S16LE)
        Rate:   [4000, 192000] (default: 48000)
        Latency: lo 480 frames, hi 9600 frames
Found 1 output devices. Choose one:
# 0
        name: system default device
# 1  (PREFERRED)
        name: default
        device id: default
        max channels: 8
        state: enabled
Enter device number: 0
Could not open the stream
stream_init failed
Abort trap