fix(wireplumber): reconnect when PipeWire/WirePlumber restarts
Previously the wireplumber module connected to PipeWire once in its constructor and had no handling for the connection being lost. When PipeWire or the wireplumber service restarted (or crashed), the module went stale/blank and never recovered until Waybar itself was restarted. Connect to the WpCore "disconnected" signal and, on disconnect, schedule a bounded main-loop retry (Glib::signal_timeout) that tears down the now invalid core/object-manager/mixer-api references and rebuilds the whole connection from scratch, re-running the async API and object-manager setup. Connection setup/teardown is factored into setupConnection() and teardownConnection() so startup and reconnect share one code path. The reconnect timer is cancelled in the destructor and the existing isModuleAlive() registry guard still protects in-flight async callbacks, so teardown during a pending reconnect stays safe. Fixes #2882.
This commit is contained in:
@@ -17,6 +17,11 @@ class Wireplumber : public ALabel {
|
||||
auto update() -> void override;
|
||||
|
||||
private:
|
||||
bool setupConnection();
|
||||
void teardownConnection();
|
||||
void scheduleReconnect();
|
||||
bool onReconnectTimeout();
|
||||
static void onCoreDisconnected(waybar::modules::Wireplumber* self);
|
||||
void asyncLoadRequiredApiModules();
|
||||
void prepare(waybar::modules::Wireplumber* self);
|
||||
void activatePlugins();
|
||||
@@ -66,6 +71,9 @@ class Wireplumber : public ALabel {
|
||||
bool only_physical_;
|
||||
bool resolved_physical_;
|
||||
std::string form_factor_;
|
||||
// Timer used to retry connecting to PipeWire after it goes away; disconnected in the destructor
|
||||
// so a pending attempt can't outlive the module. See #2882.
|
||||
sigc::connection reconnect_timer_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
Reference in New Issue
Block a user