On Sat, 18 May 2013 at 13:23:41 +0100, Simon McVittie wrote: > The attached patch works as a proof-of-concept
... or it would if I'd remembered to attach it. Here it is.
>From 1af8e58d6a84c8047428b6e4e1413ad427fbf6d4 Mon Sep 17 00:00:00 2001 From: Simon McVittie <[email protected]> Date: Sat, 18 May 2013 02:02:14 +0100 Subject: [PATCH 2/2] Use atomic operations when checking whether the audio thread is enabled. Otherwise, darkplaces doesn't exit, at least with the pulseaudio backend and pulseaudio 3.0 from experimental. --- debian/changelog | 2 ++ debian/patches/atomic_int.diff | 24 ++++++++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 27 insertions(+) create mode 100644 debian/patches/atomic_int.diff diff --git a/debian/changelog b/debian/changelog index bd79df8..43d4ee5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ libsdl1.2 (1.2.15-6) UNRELEASED; urgency=low * Clean debian/tmp-udeb so the package can build twice in a row + * Use atomic operations when checking whether the audio thread is enabled. + Otherwise, darkplaces doesn't exit, at least with the pulseaudio backend. -- Simon McVittie <[email protected]> Sat, 18 May 2013 01:55:38 +0100 diff --git a/debian/patches/atomic_int.diff b/debian/patches/atomic_int.diff new file mode 100644 index 0000000..d7e2c0f --- /dev/null +++ b/debian/patches/atomic_int.diff @@ -0,0 +1,24 @@ +From: Simon McVittie <[email protected]> +Subject: Use atomic operations when checking whether the audio thread is enabled + +Otherwise, darkplaces doesn't exit, at least with the pulseaudio backend. + +--- libsdl1.2-1.2.15.orig/src/audio/SDL_audio.c ++++ libsdl1.2-1.2.15/src/audio/SDL_audio.c +@@ -175,7 +175,7 @@ int SDLCALL SDL_RunAudio(void *audiop) + #endif + + /* Loop, filling the audio buffers */ +- while ( audio->enabled ) { ++ while ( __sync_bool_compare_and_swap (&audio->enabled, 0, 0) ) { + + /* Fill the current buffer with sound */ + if ( audio->convert.needed ) { +@@ -625,6 +625,7 @@ void SDL_AudioQuit(void) + + if ( audio ) { + audio->enabled = 0; ++ __sync_synchronize (); + if ( audio->thread != NULL ) { + SDL_WaitThread(audio->thread, NULL); + } diff --git a/debian/patches/series b/debian/patches/series index 749aced..196373d 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -4,3 +4,4 @@ dont_propagate_lpthread.diff fix_build_joystick_freebsd.diff fix_window_resizing.diff fix_joystick_misc_axes.diff +atomic_int.diff -- 1.7.10.4

