From 3fd927f404c52a78dfb52c60a505a277fc06933a Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sun, 4 Jan 2004 05:47:08 +0000 Subject: [PATCH] Force device to stop immediately with an SNDCTL_DSP_RESET. Otherwise, a regular close() sends SNDCTL_DSP_SYNC which can hang (and does on PPC) --- BasiliskII/src/Unix/audio_oss_esd.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BasiliskII/src/Unix/audio_oss_esd.cpp b/BasiliskII/src/Unix/audio_oss_esd.cpp index ea2c7ce2..22eac593 100644 --- a/BasiliskII/src/Unix/audio_oss_esd.cpp +++ b/BasiliskII/src/Unix/audio_oss_esd.cpp @@ -55,6 +55,7 @@ static int audio_sample_size_index = 0; static int audio_channel_count_index = 0; // Global variables +static bool is_dsp_audio = false; // Flag: is DSP audio static int audio_fd = -1; // fd of dsp or ESD static int mixer_fd = -1; // fd of mixer static sem_t audio_irq_done_sem; // Signal from interrupt to streaming thread: data block read @@ -95,6 +96,7 @@ static bool open_dsp(void) } printf("Using %s audio output\n", dsp); + is_dsp_audio = true; // Get supported sample formats if (audio_sample_sizes.empty()) { @@ -321,6 +323,11 @@ static void close_audio(void) // Close dsp or ESD socket if (audio_fd >= 0) { + if (is_dsp_audio) { + // Stop the device immediately. Otherwise, close() sends + // SNDCTL_DSP_SYNC, which may hang + ioctl(audio_fd, SNDCTL_DSP_RESET, 0); + } close(audio_fd); audio_fd = -1; }