From 827b815da9ffe8bc77f554bda638658a4ecec758 Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Wed, 26 Jan 2022 22:54:04 +0100 Subject: [PATCH] Update Rodio and neatly call play/pause --- Cargo.lock | 4 ++-- playback/Cargo.toml | 2 +- playback/src/audio_backend/rodio.rs | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59e0d652..675bc9e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2350,9 +2350,9 @@ dependencies = [ [[package]] name = "rodio" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d98f5e557b61525057e2bc142c8cd7f0e70d75dc32852309bec440e6e046bf9" +checksum = "ec0939e9f626e6c6f1989adb6226a039c855ca483053f0ee7c98b90e41cf731e" dependencies = [ "cpal", ] diff --git a/playback/Cargo.toml b/playback/Cargo.toml index 60304507..cd09641a 100644 --- a/playback/Cargo.toml +++ b/playback/Cargo.toml @@ -39,7 +39,7 @@ gstreamer-app = { version = "0.17", optional = true } glib = { version = "0.14", optional = true } # Rodio dependencies -rodio = { version = "0.14", optional = true, default-features = false } +rodio = { version = "0.15", optional = true, default-features = false } cpal = { version = "0.13", optional = true } # Container and audio decoder diff --git a/playback/src/audio_backend/rodio.rs b/playback/src/audio_backend/rodio.rs index bbc5de1a..3827a8da 100644 --- a/playback/src/audio_backend/rodio.rs +++ b/playback/src/audio_backend/rodio.rs @@ -186,6 +186,15 @@ pub fn open(host: cpal::Host, device: Option, format: AudioFormat) -> Ro } impl Sink for RodioSink { + fn start(&mut self) -> SinkResult<()> { + Ok(self.rodio_sink.play()) + } + + fn stop(&mut self) -> SinkResult<()> { + self.rodio_sink.sleep_until_end(); + Ok(self.rodio_sink.pause()) + } + fn write(&mut self, packet: AudioPacket, converter: &mut Converter) -> SinkResult<()> { let samples = packet .samples()