Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Pipewire audio output driver does not cleanly destroy when FluidSynth exits #1305

Closed
KynikossDragonn opened this issue Feb 14, 2024 · 4 comments
Labels
Milestone

Comments

@KynikossDragonn
Copy link

FluidSynth version

FluidSynth executable version 2.3.4
Sample type=double

Describe the bug

Various PipeWire functions related to destroying the context produce numerous errors when FluidSynth exits or otherwise wants to destroy the audio context.

*** pw_stream_destroy called from wrong context, check thread and locking: Operation not permitted
*** impl_ext_end_proxy called from wrong context, check thread and locking: Operation not permitted
*** impl_ext_end_proxy called from wrong context, check thread and locking: Operation not permitted

Occasionally, this can result in a segfault or abort.

Expected behavior

The PipeWire context should be cleanly removed, and not produce these error messages.

Steps to reproduce

Launch FluidSynth in a interactable shell with the PipeWire audio driver $ fluidsynth -a pipewire
Type quit into the shell

Additional context

The Mumble project ran into similiar pitfalls; more information here: mumble-voip/mumble#6103
https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3150#note_1862593

@derselbst
Copy link
Member

I found some time to look into this. However, I must admit that I never got pipewire working on my system and this time wasn't any different (error: PipeWire stream connection failed).

Unfortunately, I don't see what causes this error either. The audio driver is created here:

adriver = new_fluid_audio_driver(settings, synth);

and destroyed here:

delete_fluid_audio_driver(adriver);

Both is done by the main-thread. I'd welcome a PR for this.

@mawe42
Copy link
Member

mawe42 commented Mar 26, 2024

I can reproduce this on my machine with pipewire 1.0.3 and FluidSynth 2.3.4. No errors when playing a MIDI file and exiting via CTRL-C, but when I type in "quit" into the interactive shell the above mentioned errors are shown.

@mawe42
Copy link
Member

mawe42 commented Mar 26, 2024

When I add code to stop the thread loop before destroying the stream, I don't see any errors from pipewire anymore.

mawe42 added a commit that referenced this issue Mar 26, 2024
@mawe42
Copy link
Member

mawe42 commented Mar 26, 2024

Actually, the correct fix seems to be to grab the thread lock before destroying the stream. The error message even hints at that: "check thread and locking". I've updated the PR accordingly.

derselbst pushed a commit that referenced this issue Mar 26, 2024
@derselbst derselbst added this to the 2.3 milestone Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants