fix: re-apply clock.force-rate after stream creation on resume (#165)

When PipeWire drops the stream during pause, the graph reverts to the
DAC's default rate (e.g. 44100Hz). The pre-stream force-rate metadata
can be ignored when no streams are active. Re-applying after the stream
is connected forces PipeWire to reconfigure the graph at the correct
sample rate.

Also fix unused import warning for MusicBrainzSharedState in commands_v2
by using the import instead of the full path in factory_reset.
This commit is contained in:
vicrodh committed 2026-03-11 13:32:42 -06:00
1 parent 728c867c1b
commit b1424c8b68
2 files changed
+14 -1

No files matched your search

+13
View File
@@ -504,6 +504,19 @@ impl AudioBackend for PipeWireBackend {
log::info!("[PipeWire Backend] Output stream created successfully at {}Hz", effective_rate);
// Re-apply clock.force-rate AFTER stream creation.
// When resuming after PipeWire dropped the stream during pause,
// the graph may have reverted to the DAC's default rate (e.g. 44100).
// The pre-stream force-rate can be ignored if no streams were active.
// Re-applying now that the stream exists forces PipeWire to reconfigure
// the graph at the correct rate.
if effective_rate != 44100 && effective_rate != 48000 {
let _ = Command::new("pw-metadata")
.args(["-n", "settings", "0", "clock.force-rate", &effective_rate.to_string()])
.output();
log::info!("[PipeWire Backend] Re-applied clock.force-rate={}Hz after stream creation", effective_rate);
}
Ok(mixer_sink)
}