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); 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) Ok(mixer_sink)
} }
+1 -1
View File
@@ -10871,7 +10871,7 @@ pub async fn v2_factory_reset(
offline: State<'_, crate::offline::OfflineState>, offline: State<'_, crate::offline::OfflineState>,
offline_cache: State<'_, crate::offline_cache::OfflineCacheState>, offline_cache: State<'_, crate::offline_cache::OfflineCacheState>,
lyrics: State<'_, crate::lyrics::LyricsState>, lyrics: State<'_, crate::lyrics::LyricsState>,
musicbrainz: State<'_, crate::musicbrainz::MusicBrainzSharedState>, musicbrainz: State<'_, MusicBrainzSharedState>,
listenbrainz: State<'_, crate::listenbrainz::ListenBrainzSharedState>, listenbrainz: State<'_, crate::listenbrainz::ListenBrainzSharedState>,
listenbrainz_v2: State<'_, ListenBrainzV2State>, listenbrainz_v2: State<'_, ListenBrainzV2State>,
musicbrainz_v2: State<'_, MusicBrainzV2State>, musicbrainz_v2: State<'_, MusicBrainzV2State>,