Open ckcr4lyf opened 1 year ago
Could you try running the application with debug logging enabled? (--log-level debug
)
Also worth noting that I haven't properly tested this with pipewire yet, so it's possible that some further changes are needed.
With debug logging:
$ ./target/debug/bardcast -d pulse -m peek --log-level debug
==================================
bardcast v0.1.1
(c) Paul Bonnen <hal7df@gmail.com>
==================================
2023-07-02T18:36:44.974+08:00 DEBUG [bardcast] Initializing async runtime...
2023-07-02T18:36:44.980+08:00 DEBUG [bardcast] Async runtime initialized
2023-07-02T18:36:44.980+08:00 DEBUG [bardcast] Setting up application shutdown notification channel
2023-07-02T18:36:44.980+08:00 DEBUG [bardcast] Starting audio driver
2023-07-02T18:36:44.981+08:00 INFO [bardcast::snd] Configured sound drivers: pulse
2023-07-02T18:36:44.989+08:00 DEBUG [bardcast::snd::pulse::context] Connecting to PulseAudio server
2023-07-02T18:36:44.989+08:00 DEBUG [bardcast::snd::pulse::context] Mainloop started
2023-07-02T18:36:44.997+08:00 DEBUG [bardcast::snd::pulse::context] PulseAudio context ready
2023-07-02T18:36:44.998+08:00 INFO [bardcast::snd::pulse] Connected to PulseAudio server
2023-07-02T18:36:44.998+08:00 DEBUG [bardcast::snd::pulse::context] Task queue closed, terminating context handler
2023-07-02T18:36:44.998+08:00 DEBUG [bardcast::snd::pulse::context] Context handler shutting down
2023-07-02T18:36:45.001+08:00 DEBUG [bardcast::snd::pulse::context] Mainloop exiting
2023-07-02T18:36:45.001+08:00 DEBUG [bardcast::snd::pulse::context] Context handler shut down
Runtime error: Sound driver failed to initialize: PulseAudio driver failed to initialize (PulseAudio error: Bad state)
$ ./target/debug/bardcast -d pulse -m monitor --log-level debug
==================================
bardcast v0.1.1
(c) Paul Bonnen <hal7df@gmail.com>
==================================
2023-07-02T18:36:59.890+08:00 DEBUG [bardcast] Initializing async runtime...
2023-07-02T18:36:59.893+08:00 DEBUG [bardcast] Async runtime initialized
2023-07-02T18:36:59.893+08:00 DEBUG [bardcast] Setting up application shutdown notification channel
2023-07-02T18:36:59.893+08:00 DEBUG [bardcast] Starting audio driver
2023-07-02T18:36:59.893+08:00 INFO [bardcast::snd] Configured sound drivers: pulse
2023-07-02T18:36:59.900+08:00 DEBUG [bardcast::snd::pulse::context] Connecting to PulseAudio server
2023-07-02T18:36:59.900+08:00 DEBUG [bardcast::snd::pulse::context] Mainloop started
2023-07-02T18:36:59.905+08:00 DEBUG [bardcast::snd::pulse::context] PulseAudio context ready
2023-07-02T18:36:59.905+08:00 INFO [bardcast::snd::pulse] Connected to PulseAudio server
2023-07-02T18:36:59.926+08:00 INFO [bardcast::snd] Started application using driver 'pulse'
Segmentation fault (core dumped)
P.S. I may be using it incorrectly, just happened to stumble across this project when looking for references to songbird/serenity so decided to try it out.
Ah, I do see one issue: peek
and capture
modes require you to specify -E
, since they target specific applications, rather than just capturing all system audio (as monitor
does).
For example, if you wanted to capture audio from Firefox:
./target/debug/bardcast -E firefox -m capture ...
I thought there was a clearer error message for that, but maybe not.
Not sure why monitor mode is segfaulting, but I'm guessing that might have to do with differences between pipewire and pulseaudio.
Looking a bit more closely at the error message you posted, it looks like it manages to successfully set up the sound driver, and segfaults shortly thereafter. I'm guessing it is probably still something in the libpulse
C library (all of the segfaults I've encountered with this application so far have been from libpulse
) failing, possibly because Pipewire implemented the API slightly differently. It's still a little weird, though, because at the point where it segfaults, the application shouldn't be doing much with libpulse
...
Once you run it with -E
, do you see the same behavior with capture
or peek
modes?
Running with -E
to specify the app, seems it can run into different kind of errors.
SEGFAULT:
$ ltrace ./target/debug/bardcast -E firefox -m capture --log-level debug
==================================
bardcast v0.1.1
(c) Paul Bonnen <hal7df@gmail.com>
==================================
2023-07-03T10:35:05.167+08:00 DEBUG [bardcast] Initializing async runtime...
2023-07-03T10:35:05.168+08:00 DEBUG [bardcast] Async runtime initialized
2023-07-03T10:35:05.168+08:00 DEBUG [bardcast] Setting up application shutdown notification channel
2023-07-03T10:35:05.168+08:00 DEBUG [bardcast] Starting audio driver
2023-07-03T10:35:05.168+08:00 INFO [bardcast::snd] Configured sound drivers: pulse
2023-07-03T10:35:05.171+08:00 DEBUG [bardcast::snd::pulse::context] Connecting to PulseAudio server
2023-07-03T10:35:05.171+08:00 DEBUG [bardcast::snd::pulse::context] Mainloop started
2023-07-03T10:35:05.189+08:00 DEBUG [bardcast::snd::pulse::context] PulseAudio context ready
2023-07-03T10:35:05.189+08:00 INFO [bardcast::snd::pulse] Connected to PulseAudio server
2023-07-03T10:35:05.190+08:00 INFO [bardcast::snd::pulse] Matching applications against pattern 'firefox' on properties: application.process.binary,application.name
2023-07-03T10:35:05.199+08:00 DEBUG [bardcast::snd::pulse::event::factory] Set server entity subscription.
2023-07-03T10:35:05.211+08:00 DEBUG [bardcast::snd::pulse] Establishing event listener for application stream intercept
2023-07-03T10:35:05.212+08:00 INFO [bardcast::snd::pulse] Intercepting matched applications using mode: Capture
2023-07-03T10:35:05.226+08:00 DEBUG [bardcast::snd::pulse::intercept] Creating audio capture sink with name 'bardcast-12344_rec-0'
2023-07-03T10:35:05.243+08:00 DEBUG [bardcast::snd::pulse::intercept] Audio capture module loaded (index 536870945)
2023-07-03T10:35:05.264+08:00 DEBUG [bardcast::snd::pulse::intercept] Created rec sink at index 1051
2023-07-03T10:35:05.264+08:00 DEBUG [bardcast::snd::pulse] Starting application stream intercept task
2023-07-03T10:35:05.265+08:00 INFO [bardcast::snd::pulse] Intercepting matching application 'Firefox' (index 355)
2023-07-03T10:35:05.351+08:00 INFO [bardcast::snd] Started application using driver 'pulse'
--- SIGSEGV (Segmentation fault) ---
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++
SIGABRT (malloc error)
==================================
bardcast v0.1.1
(c) Paul Bonnen <hal7df@gmail.com>
==================================
2023-07-03T10:35:06.296+08:00 DEBUG [bardcast] Initializing async runtime...
2023-07-03T10:35:06.297+08:00 DEBUG [bardcast] Async runtime initialized
2023-07-03T10:35:06.297+08:00 DEBUG [bardcast] Setting up application shutdown notification channel
2023-07-03T10:35:06.297+08:00 DEBUG [bardcast] Starting audio driver
2023-07-03T10:35:06.297+08:00 INFO [bardcast::snd] Configured sound drivers: pulse
2023-07-03T10:35:06.299+08:00 DEBUG [bardcast::snd::pulse::context] Connecting to PulseAudio server
2023-07-03T10:35:06.300+08:00 DEBUG [bardcast::snd::pulse::context] Mainloop started
2023-07-03T10:35:06.315+08:00 DEBUG [bardcast::snd::pulse::context] PulseAudio context ready
2023-07-03T10:35:06.315+08:00 INFO [bardcast::snd::pulse] Connected to PulseAudio server
2023-07-03T10:35:06.315+08:00 INFO [bardcast::snd::pulse] Matching applications against pattern 'firefox' on properties: application.name,application.process.binary
2023-07-03T10:35:06.322+08:00 DEBUG [bardcast::snd::pulse::event::factory] Set server entity subscription.
2023-07-03T10:35:06.333+08:00 DEBUG [bardcast::snd::pulse] Establishing event listener for application stream intercept
2023-07-03T10:35:06.333+08:00 INFO [bardcast::snd::pulse] Intercepting matched applications using mode: Capture
2023-07-03T10:35:06.346+08:00 DEBUG [bardcast::snd::pulse::intercept] Creating audio capture sink with name 'bardcast-12381_rec-0'
2023-07-03T10:35:06.361+08:00 DEBUG [bardcast::snd::pulse::intercept] Audio capture module loaded (index 536870946)
2023-07-03T10:35:06.380+08:00 DEBUG [bardcast::snd::pulse::intercept] Created rec sink at index 1074
2023-07-03T10:35:06.380+08:00 DEBUG [bardcast::snd::pulse] Starting application stream intercept task
2023-07-03T10:35:06.380+08:00 INFO [bardcast::snd::pulse] Intercepting matching application 'Firefox' (index 355)
2023-07-03T10:35:06.543+08:00 INFO [bardcast::snd] Started application using driver 'pulse'
malloc(): unsorted double linked list corrupted
--- SIGABRT (Aborted) ---
+++ killed by SIGABRT +++
SIGABRT (Wfree error)
==================================
bardcast v0.1.1
(c) Paul Bonnen <hal7df@gmail.com>
==================================
2023-07-03T10:37:12.145+08:00 DEBUG [bardcast] Initializing async runtime...
2023-07-03T10:37:12.146+08:00 DEBUG [bardcast] Async runtime initialized
2023-07-03T10:37:12.146+08:00 DEBUG [bardcast] Setting up application shutdown notification channel
2023-07-03T10:37:12.146+08:00 DEBUG [bardcast] Starting audio driver
2023-07-03T10:37:12.146+08:00 INFO [bardcast::snd] Configured sound drivers: pulse
2023-07-03T10:37:12.148+08:00 DEBUG [bardcast::snd::pulse::context] Connecting to PulseAudio server
2023-07-03T10:37:12.149+08:00 DEBUG [bardcast::snd::pulse::context] Mainloop started
2023-07-03T10:37:12.164+08:00 DEBUG [bardcast::snd::pulse::context] PulseAudio context ready
2023-07-03T10:37:12.164+08:00 INFO [bardcast::snd::pulse] Connected to PulseAudio server
2023-07-03T10:37:12.164+08:00 INFO [bardcast::snd::pulse] Matching applications against pattern 'firefox' on properties: application.process.binary,application.name
2023-07-03T10:37:12.175+08:00 DEBUG [bardcast::snd::pulse::event::factory] Set server entity subscription.
2023-07-03T10:37:12.188+08:00 DEBUG [bardcast::snd::pulse] Establishing event listener for application stream intercept
2023-07-03T10:37:12.188+08:00 INFO [bardcast::snd::pulse] Intercepting matched applications using mode: Capture
2023-07-03T10:37:12.205+08:00 DEBUG [bardcast::snd::pulse::intercept] Creating audio capture sink with name 'bardcast-12509_rec-0'
2023-07-03T10:37:12.223+08:00 DEBUG [bardcast::snd::pulse::intercept] Audio capture module loaded (index 536870949)
2023-07-03T10:37:12.245+08:00 DEBUG [bardcast::snd::pulse::intercept] Created rec sink at index 1152
2023-07-03T10:37:12.245+08:00 DEBUG [bardcast::snd::pulse] Starting application stream intercept task
2023-07-03T10:37:12.245+08:00 INFO [bardcast::snd::pulse] Intercepting matching application 'Firefox' (index 355)
2023-07-03T10:37:12.331+08:00 INFO [bardcast::snd] Started application using driver 'pulse'
Wfree(): corrupted unsorted chunks
--- SIGABRT (Aborted) ---
+++ killed by SIGABRT +++
Could be related to either the binding or the pipewire shim, but if it's hard for you to reproduce don't worry, just something I noticed so thought I'd share.
Interesting, thanks for the info. bardcast does have some fairly complex interactions with pulseaudio, so I'm not entirely surprised that pipewire would struggle with it.
I'm running on a Ubuntu 22.04 derivative, which is still using pulseaudio by default, so I don't have a test setup ready for this. But, adding a native pipewire implementation (#4) is fairly high on my priority list, likely after fixing up the pulseaudio error messages and adding metadata tracking. I'm inclined to leave this issue open for the time being in order to document the issue, and in case myself or anyone else who comes across this wants to take a stab at debugging this before I can get around to adding native support.
In the meantime, if you're just looking to see it run, maybe you can spin up bardcast and (original) pulseaudio in a VM or container? I think it should work without any normal audio sinks if you use capture
mode.
Thanks for the reply. I am working on a different program so was just looking for some tips to interface with songbird.
Trying to make a program that will take input from stdin and stream it to discord. Very very early stage but the repo is at https://github.com/ckcr4lyf/stdinman
I would probably recommend looking at the impl
block for theConnectedClient
type here: https://github.com/hal7df/bardcast/blob/main/src/discord/mod.rs#L73
I am on Arch Linux, trying to use this with pulse. I am getting errors if I try and use it (though I am technically on pipewire).
System:
Tried via:
Let me know if there's anything I can do to help.