mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 03:00:38 +00:00
Fences access to common resources between the possible SDL_mixer effect thread and the rest of the audio code.
git-svn-id: https://svn.eduke32.com/eduke32@1583 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4917be2439
commit
f0be341352
2 changed files with 15 additions and 8 deletions
|
@ -582,7 +582,7 @@ void grabmouse(char a)
|
||||||
if (a != mouseacquired)
|
if (a != mouseacquired)
|
||||||
{
|
{
|
||||||
// #ifndef DEBUGGINGAIDS
|
// #ifndef DEBUGGINGAIDS
|
||||||
#if 1
|
#if 0
|
||||||
SDL_GrabMode g;
|
SDL_GrabMode g;
|
||||||
|
|
||||||
g = SDL_WM_GrabInput(a ? SDL_GRAB_ON : SDL_GRAB_OFF);
|
g = SDL_WM_GrabInput(a ? SDL_GRAB_ON : SDL_GRAB_OFF);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <SDL/SDL_mixer.h>
|
#include <SDL/SDL_mixer.h>
|
||||||
|
#include <SDL/SDL_thread.h>
|
||||||
#include "driver_sdl.h"
|
#include "driver_sdl.h"
|
||||||
|
|
||||||
#ifndef UNREFERENCED_PARAMETER
|
#ifndef UNREFERENCED_PARAMETER
|
||||||
|
@ -54,7 +55,8 @@ static void ( *MixCallBack )( void ) = 0;
|
||||||
|
|
||||||
static Mix_Chunk *DummyChunk = NULL;
|
static Mix_Chunk *DummyChunk = NULL;
|
||||||
static uint8_t *DummyBuffer = NULL;
|
static uint8_t *DummyBuffer = NULL;
|
||||||
// static int32_t InterruptsDisabled = 0;
|
static int32_t InterruptsDisabled = 0;
|
||||||
|
static SDL_mutex *EffectFence;
|
||||||
|
|
||||||
static void fillData(int32_t chan, void *ptr, int32_t remaining, void *udata)
|
static void fillData(int32_t chan, void *ptr, int32_t remaining, void *udata)
|
||||||
{
|
{
|
||||||
|
@ -64,6 +66,8 @@ static void fillData(int32_t chan, void *ptr, int32_t remaining, void *udata)
|
||||||
UNREFERENCED_PARAMETER(chan);
|
UNREFERENCED_PARAMETER(chan);
|
||||||
UNREFERENCED_PARAMETER(udata);
|
UNREFERENCED_PARAMETER(udata);
|
||||||
|
|
||||||
|
SDL_LockMutex(EffectFence);
|
||||||
|
|
||||||
while (remaining > 0) {
|
while (remaining > 0) {
|
||||||
if (MixBufferUsed == MixBufferSize) {
|
if (MixBufferUsed == MixBufferSize) {
|
||||||
MixCallBack();
|
MixCallBack();
|
||||||
|
@ -90,6 +94,8 @@ static void fillData(int32_t chan, void *ptr, int32_t remaining, void *udata)
|
||||||
remaining -= len;
|
remaining -= len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_UnlockMutex(EffectFence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,6 +171,8 @@ int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *sampleb
|
||||||
|
|
||||||
//Mix_SetPostMix(fillData, NULL);
|
//Mix_SetPostMix(fillData, NULL);
|
||||||
|
|
||||||
|
EffectFence = SDL_CreateMutex();
|
||||||
|
|
||||||
// channel 0 and 1 are actual sounds
|
// channel 0 and 1 are actual sounds
|
||||||
// dummy channel 2 runs our fillData() callback as an effect
|
// dummy channel 2 runs our fillData() callback as an effect
|
||||||
Mix_RegisterEffect(2, fillData, NULL, NULL);
|
Mix_RegisterEffect(2, fillData, NULL, NULL);
|
||||||
|
@ -200,6 +208,9 @@ void SDLDrv_PCM_Shutdown(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
Mix_CloseAudio();
|
Mix_CloseAudio();
|
||||||
|
|
||||||
|
SDL_DestroyMutex(EffectFence);
|
||||||
|
|
||||||
Initialised = 0;
|
Initialised = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,21 +256,17 @@ void SDLDrv_PCM_StopPlayback(void)
|
||||||
|
|
||||||
void SDLDrv_PCM_Lock(void)
|
void SDLDrv_PCM_Lock(void)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (InterruptsDisabled++)
|
if (InterruptsDisabled++)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_LockAudio();*/
|
SDL_LockMutex(EffectFence);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLDrv_PCM_Unlock(void)
|
void SDLDrv_PCM_Unlock(void)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (--InterruptsDisabled)
|
if (--InterruptsDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_UnlockAudio();*/
|
SDL_UnlockMutex(EffectFence);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue