Open muni-corn opened 4 years ago
Any update on this issue? I also want to know how to pause or stop a playing music running on another thread. thanks
I have been investigating high CPU usage on low-power devices (e.g. Raspberry Pi Zero W), over in librespot-org/librespot#567; I suspect it may be this problem (or a related problem). At idle, Rodio consumes 12-13% of a 1GHz ARMv6 core.
I saw 100% cpu usage on my machine when it was loaded but idle. Not the best solution but works for me in the mean time:
pub fn sleep_and_unload(&mut self) {
if let Some(sink) = &self.sink {
sink.sleep_until_end();
self.sink = None;
self.stream_handle = None;
self._stream = None;
}
}
Drops CPU back to 0
After using
play_once
orplay_raw
on a sound and audio device (both local variables), the playback stream still shows up inpavucontrol
:The thread also still exists when I inspect htop, and the thread is using around 3% CPU:
Code I'm using currently:
I would expect the thread to stop after
audio_device
andsink
are dropped (oraudio_device
andsource
if usingplay_raw
), but the thread still runs. Is there a way to stop rodio's background thread after playing a sound?