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