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:
1 parent
1641ab7c33
commit
712c7be4f7
1 file changed
+5
-1
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user