Update Rodio and neatly call play/pause

This commit is contained in:
Roderick van Domburg 2022-01-26 22:54:04 +01:00
parent cb1cfddb74
commit 827b815da9
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451
3 changed files with 12 additions and 3 deletions

4
Cargo.lock generated
View file

@ -2350,9 +2350,9 @@ dependencies = [
[[package]] [[package]]
name = "rodio" name = "rodio"
version = "0.14.0" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d98f5e557b61525057e2bc142c8cd7f0e70d75dc32852309bec440e6e046bf9" checksum = "ec0939e9f626e6c6f1989adb6226a039c855ca483053f0ee7c98b90e41cf731e"
dependencies = [ dependencies = [
"cpal", "cpal",
] ]

View file

@ -39,7 +39,7 @@ gstreamer-app = { version = "0.17", optional = true }
glib = { version = "0.14", optional = true } glib = { version = "0.14", optional = true }
# Rodio dependencies # 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 } cpal = { version = "0.13", optional = true }
# Container and audio decoder # Container and audio decoder

View file

@ -186,6 +186,15 @@ pub fn open(host: cpal::Host, device: Option<String>, format: AudioFormat) -> Ro
} }
impl Sink for RodioSink { 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<()> { fn write(&mut self, packet: AudioPacket, converter: &mut Converter) -> SinkResult<()> {
let samples = packet let samples = packet
.samples() .samples()