fix(player): add delay after engine stop to prevent sink contention

Add 50ms delay after stopping the previous playback engine to allow
the rodio Sink to fully release its reference to the OutputStreamHandle.
This prevents "resource busy" errors when rapidly switching tracks,
especially when selecting from search while radio is playing.
This commit is contained in:
vicrodh committed 2026-01-23 10:17:58 -06:00
1 parent 1641ab7c33
commit 712c7be4f7
1 file changed
+5 -1
+5 -1
View File
@@ -944,9 +944,13 @@ impl Player {
return;
};
// Stop previous engine
// Stop previous engine and wait for sink to release resources
if let Some(engine) = current_engine.take() {
engine.stop();
// Small delay to allow the audio sink to fully release its
// reference to the OutputStreamHandle before creating a new sink.
// This prevents "resource busy" errors on rapid track switches.
std::thread::sleep(Duration::from_millis(50));
}
*current_audio_data = Some(data.clone());