From 1a3a8956e410beffcd3fce0ce296509d51e828d1 Mon Sep 17 00:00:00 2001 From: Andre-Philippe Paquet Date: Wed, 12 Sep 2018 07:13:13 -0400 Subject: [PATCH] WASPI - Fix stream start after destroy (#241) * waspi - Fix stream start after destroy * Fix stream name --- src/wasapi/stream.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/wasapi/stream.rs b/src/wasapi/stream.rs index 1b30c97..49d154c 100644 --- a/src/wasapi/stream.rs +++ b/src/wasapi/stream.rs @@ -449,21 +449,27 @@ impl EventLoop { } }, Command::PlayStream(stream_id) => { - if let Some(v) = run_context.streams.get_mut(stream_id.0) { - if !v.playing { - let hresult = (*v.audio_client).Start(); - check_result(hresult).unwrap(); - v.playing = true; + match run_context.streams.iter_mut().find(|v| v.id == stream_id) { + None => continue, + Some(stream) => { + if !stream.playing { + let hresult = (*stream.audio_client).Start(); + check_result(hresult).unwrap(); + stream.playing = true; + } } } }, Command::PauseStream(stream_id) => { - if let Some(v) = run_context.streams.get_mut(stream_id.0) { - if v.playing { - let hresult = (*v.audio_client).Stop(); - check_result(hresult).unwrap(); - v.playing = false; - } + match run_context.streams.iter_mut().find(|v| v.id == stream_id) { + None => continue, + Some(stream) => { + if stream.playing { + let hresult = (*stream.audio_client).Stop(); + check_result(hresult).unwrap(); + stream.playing = false; + } + }, } }, }