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

pulseaudio: reconnect context when pulseaudio server restarts #2866

Merged
merged 2 commits into from
Jan 28, 2024
Merged

pulseaudio: reconnect context when pulseaudio server restarts #2866

merged 2 commits into from
Jan 28, 2024

Conversation

Jay-716
Copy link
Contributor

@Jay-716 Jay-716 commented Jan 25, 2024

For some reason, I sometimes restart the pulseaudio server (pipewire-pulse actually). But after restart, waybar's pulseaudio module just stop updating. The solution is to restart the whole waybar.
So I think it would be better if waybar itself could reconnect to pulseaudio server after it restarts.
The pulseaudio context connection would failed according to the documentation. So we can simply reconnect the context there.

Tested on waybar latest git version and pipewire-pulse 1.0.0

Fixes: #2619

PS: I am not so good at C++ actually. So I am sorry if I do something stupid. :)

When pulseaudio server restarts, the context is not reconnect
automatically. So the pulseaudio module will stop updating.
src/util/audio_backend.cpp Outdated Show resolved Hide resolved
@Jay-716
Copy link
Contributor Author

Jay-716 commented Jan 27, 2024

I add a connectContext() function. I hope i do it right.
Btw, I think pa_context_set_state_callback() should be called before pa_context_connect().(it's reversed in the original code) Otherwise there may be a race condition, i.e. the context may connect too fast that the callback is not yet registered and then no callbacks will be called.
And should I change the comment style from // to /**/ to match the style of existing code?
Thanks for reviewing!

@Alexays
Copy link
Owner

Alexays commented Jan 28, 2024

LGTM, thx!

@Alexays Alexays merged commit ddad6ce into Alexays:master Jan 28, 2024
@Jay-716 Jay-716 deleted the pa-reconnect branch January 29, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pulseaudio module don't reconnect au pipewire-pulse restart
2 participants