diff --git a/src/clock.rs b/src/clock.rs index 194c30b..947b15f 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -407,17 +407,19 @@ impl Clock { Self::beep()?; #[cfg(feature = "sound")] { + use rodio::{Decoder, OutputStream, Sink}; trace!("playing bundled sound"); - use rodio::{source::Source, Decoder, OutputStream}; // only 30 KiB, so let's just include it in the binary and not worry about reading it // from the fs and somehow making the file be there let sound: Cursor<_> = std::io::Cursor::new(include_bytes!("../data/media/alarm.mp3")); + trace!("bundled sound: {sound:X?}"); // Get an output stream handle to the default physical sound device let (_stream, stream_handle) = OutputStream::try_default().unwrap(); let source = Decoder::new(sound).expect("could not load the included sound"); - stream_handle.play_raw(source.convert_samples())?; // the sound plays in another thread + let sink = Sink::try_new(&stream_handle).expect("could not create an audio sink"); + sink.append(source); debug!("played bundled sound"); } #[cfg(feature = "desktop")]