Commit e784ba70e016eed3203e403256f87b34dd6ef48b
1 parent
af3a9031
Ensure signals are properly masked for new SDL Audio threads, by Andrzej
Zaborowski. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3069 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
18 additions
and
0 deletions
audio/sdlaudio.c
| @@ -25,6 +25,13 @@ | @@ -25,6 +25,13 @@ | ||
| 25 | #include <SDL_thread.h> | 25 | #include <SDL_thread.h> |
| 26 | #include "vl.h" | 26 | #include "vl.h" |
| 27 | 27 | ||
| 28 | +#ifndef _WIN32 | ||
| 29 | +#ifdef __sun__ | ||
| 30 | +#define _POSIX_PTHREAD_SEMANTICS 1 | ||
| 31 | +#endif | ||
| 32 | +#include <signal.h> | ||
| 33 | +#endif | ||
| 34 | + | ||
| 28 | #define AUDIO_CAP "sdl" | 35 | #define AUDIO_CAP "sdl" |
| 29 | #include "audio_int.h" | 36 | #include "audio_int.h" |
| 30 | 37 | ||
| @@ -177,11 +184,22 @@ static int sdl_to_audfmt (int sdlfmt, audfmt_e *fmt, int *endianess) | @@ -177,11 +184,22 @@ static int sdl_to_audfmt (int sdlfmt, audfmt_e *fmt, int *endianess) | ||
| 177 | static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt) | 184 | static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt) |
| 178 | { | 185 | { |
| 179 | int status; | 186 | int status; |
| 187 | +#ifndef _WIN32 | ||
| 188 | + sigset_t new, old; | ||
| 189 | + | ||
| 190 | + /* Make sure potential threads created by SDL don't hog signals. */ | ||
| 191 | + sigfillset (&new); | ||
| 192 | + pthread_sigmask (SIG_BLOCK, &new, &old); | ||
| 193 | +#endif | ||
| 180 | 194 | ||
| 181 | status = SDL_OpenAudio (req, obt); | 195 | status = SDL_OpenAudio (req, obt); |
| 182 | if (status) { | 196 | if (status) { |
| 183 | sdl_logerr ("SDL_OpenAudio failed\n"); | 197 | sdl_logerr ("SDL_OpenAudio failed\n"); |
| 184 | } | 198 | } |
| 199 | + | ||
| 200 | +#ifndef _WIN32 | ||
| 201 | + pthread_sigmask (SIG_SETMASK, &old, 0); | ||
| 202 | +#endif | ||
| 185 | return status; | 203 | return status; |
| 186 | } | 204 | } |
| 187 | 205 |