fix SDL2 audio thread hanging on close
This commit is contained in:
parent
12b879ac9f
commit
d156c04a04
|
@ -392,7 +392,7 @@ impl AudioCallback for MySdlAudio {
|
|||
|
||||
fn callback(&mut self, out: &mut [Self::Channel]) {
|
||||
if self.audio_spec.format == AudioFormat::S16LSB {
|
||||
if let Ok(samples) = self.audio_receiver.recv() {
|
||||
if let Ok(samples) = self.audio_receiver.recv_timeout(Duration::from_millis(500)) {
|
||||
out.copy_from_slice(&samples[..out.len()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,7 @@ use std::io::Read;
|
|||
pub struct RetroComponentBase {
|
||||
retro: LibretroWrapper,
|
||||
libretro_path: PathBuf,
|
||||
// TODO: control when things get added to this.
|
||||
// probably shouldn't be after load_game?
|
||||
// unless we invent a way to play back the latest set_pixel_format etc. metadata required.
|
||||
// TODO: control when things get added to this with lifetime constraints defined by implementers
|
||||
components: Vec<Box<dyn RetroComponent>>,
|
||||
|
||||
// replaying env calls for late-added components
|
||||
|
|
|
@ -284,7 +284,7 @@ impl AudioCallback for MySdlAudio {
|
|||
|
||||
fn callback(&mut self, out: &mut [Self::Channel]) {
|
||||
if self.audio_spec.format == AudioFormat::S16LSB {
|
||||
if let Ok(samples) = self.audio_receiver.recv() {
|
||||
if let Ok(samples) = self.audio_receiver.recv_timeout(Duration::from_millis(500)) {
|
||||
out.copy_from_slice(&samples[..out.len()]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue