Skip to content
Snippets Groups Projects
Commit d5ff6e92 authored by deuce's avatar deuce
Browse files

Use SDL_LockAudio/SDL_UnlockAudio as suggested by the docs.

(Shouldn't actually be necessary, but oh well).
parent e9c8bda4
Branches
Tags
No related merge requests found
......@@ -56,6 +56,8 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
sdlf->OpenAudio=SDL_OpenAudio;
sdlf->CloseAudio=SDL_CloseAudio;
sdlf->PauseAudio=SDL_PauseAudio;
sdlf->LockAudio=SDL_LockAudio;
sdlf->UnlockAudio=SDL_UnlockAudio;
sdlf->gotfuncs=1;
sdl_funcs_loaded=1;
return(0);
......@@ -211,6 +213,14 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
FreeLibrary(sdl_dll);
return(-1);
}
if((sdlf->LockAudio=GetProcAddress(sdl_dll, "SDL_LockAudio"))==NULL) {
FreeLibrary(sdl_dll);
return(-1);
}
if((sdlf->UnlockAudio=GetProcAddress(sdl_dll, "SDL_UnlockAudio"))==NULL) {
FreeLibrary(sdl_dll);
return(-1);
}
sdlf->gotfuncs=1;
sdl_funcs_loaded=1;
return(0);
......@@ -360,6 +370,14 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
dlclose(sdl_dll);
return(-1);
}
if((sdlf->LockAudio=dlsym(sdl_dll, "SDL_LockAudio"))==NULL) {
dlclose(sdl_dll);
return(-1);
}
if((sdlf->UnlockAudio=dlsym(sdl_dll, "SDL_UnlockAudio"))==NULL) {
dlclose(sdl_dll);
return(-1);
}
sdlf->gotfuncs=1;
sdl_funcs_loaded=1;
return(0);
......
......@@ -42,6 +42,8 @@ struct sdlfuncs {
void (*QuitSubSystem)(Uint32 flags);
int (*OpenAudio)(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
void (*CloseAudio)(void);
void (*LockAudio)(void);
void (*UnlockAudio)(void);
void (*PauseAudio)(int pause_on);
int gotfuncs;
};
......
......@@ -427,11 +427,13 @@ BOOL DLLCALL xptone(double freq, DWORD duration, enum WAVE_SHAPE shape)
#ifdef WITH_SDL
if(handle_type==SOUND_DEVICE_SDL) {
sdl.LockAudio();
sdl_audio_buf_pos=0;
sdl_audio_buf_len=S_RATE*duration/1000;
if(sdl_audio_buf_len<=S_RATE/freq*2)
sdl_audio_buf_len=S_RATE/freq*2;
makewave(freq,swave,sdl_audio_buf_len,shape);
sdl.UnlockAudio();
sdl.PauseAudio(FALSE);
sdl.SemWait(sdlToneDone);
sdl.PauseAudio(TRUE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment