fix: 🐛 system level audio buffer overflow while stopping
This commit is contained in:
parent
6dbfd57072
commit
14c84d2f40
3 changed files with 16 additions and 37 deletions
|
@ -46,14 +46,16 @@ pub async fn play(
|
|||
|
||||
let output_data_fn = move |data: &mut [f32], _: &cpal::OutputCallbackInfo| {
|
||||
for sample in data {
|
||||
let single = match decoded_to_playing_receiver.blocking_recv() {
|
||||
Ok(single) => single,
|
||||
Err(_) => 0.0,
|
||||
};
|
||||
if audio_stream_sender.receiver_count() > 0 {
|
||||
let _ = audio_stream_sender.send(single);
|
||||
if decoded_to_playing_receiver.len() > 0 {
|
||||
let single = match decoded_to_playing_receiver.blocking_recv() {
|
||||
Ok(single) => single,
|
||||
Err(_) => 0.0,
|
||||
};
|
||||
if audio_stream_sender.receiver_count() > 0 {
|
||||
let _ = audio_stream_sender.send(single);
|
||||
}
|
||||
*sample = single;
|
||||
}
|
||||
*sample = single;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue