check if any sound is playing before waiting for seek result

This commit is contained in:
dvdsk 2024-05-23 13:07:09 +02:00
parent 11221a8609
commit 749a4845a2
No known key found for this signature in database
GPG key ID: 6CF9D20C5709A836

View file

@ -53,7 +53,7 @@ impl SeekOrder {
S::Item: Sample + Send,
{
let res = maybe_seekable.try_seek(self.pos);
let _ignore_reciever_dropped = self.feedback.send(res);
let _ignore_receiver_dropped = self.feedback.send(res);
}
}
@ -222,6 +222,12 @@ impl Sink {
pub fn try_seek(&self, pos: Duration) -> Result<(), SeekError> {
let (order, feedback) = SeekOrder::new(pos);
*self.controls.seek.lock().unwrap() = Some(order);
if self.sound_count.load(Ordering::Acquire) == 0 {
// No sound is playing, seek will not be performed
return Ok(())
}
match feedback.recv() {
Ok(seek_res) => seek_res,
// The feedback channel closed. Probably another seekorder was set