Skip to content

Commit 2f4a66e

Browse files
authored
Sound Notification: Fix Node Suspend on Idle (Bluetooth battery drain) (wbolster#74)
Enabling "Sound notification" seem to cause Bluetooth battery drain. It seems the mic on/off sound state doesn't get reset after playback; audio source state is still "Running". Fix resets playback at end-of-stream, so Pipewire can auto-suspend node (e.g. Bluetooth headset). Co-authored-by: Kok-Yan Lo <[email protected]>
1 parent fdccdd3 commit 2f4a66e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

extension.js

+9
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ function init_sound(dir, name) {
127127
const sink = Gst.ElementFactory.make("pulsesink", "sink");
128128
playbin.set_property("audio-sink", sink);
129129
playbin.set_volume(GstAudio.StreamVolumeFormat.LINEAR, 0.5);
130+
131+
// Fix audio node suspend-on-idle; stop playback at end-of-stream
132+
const bus = playbin.get_bus();
133+
bus.add_signal_watch();
134+
bus.connect('message', (_bus, msg) => {
135+
if (msg.type === Gst.MessageType.EOS)
136+
playbin.set_state(Gst.State.NULL);
137+
});
138+
130139
return playbin;
131140
}
132141

0 commit comments

Comments
 (0)