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

Add more SDL functions to support audio.

parent 44a79bf3
Branches
Tags
No related merge requests found
#include <stdio.h> /* NULL */
#include "gen_defs.h"
#undef main
#include "sdlfuncs.h"
#ifndef _WIN32
......@@ -34,6 +35,7 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
sdlf->BlitSurface=SDL_UpperBlit;
sdlf->UpdateRects=SDL_UpdateRects;
sdlf->SDL_CreateSemaphore=SDL_CreateSemaphore;
sdlf->SDL_DestroySemaphore=SDL_DestroySemaphore;
sdlf->SDL_CreateMutex=SDL_CreateMutex;
sdlf->CreateThread=SDL_CreateThread;
sdlf->WaitEvent=SDL_WaitEvent;
......@@ -48,6 +50,9 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
sdlf->GetError=SDL_GetError;
sdlf->InitSubSystem=SDL_InitSubSystem;
sdlf->QuitSubSystem=SDL_QuitSubSystem;
sdlf->OpenAudio=SDL_OpenAudio;
sdlf->CloseAudio=SDL_CloseAudio;
sdlf->PauseAudio=SDL_PauseAudio;
sdlf->gotfuncs=1;
sdl_funcs_loaded=1;
return(0);
......@@ -131,6 +136,10 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
FreeLibrary(sdl_dll);
return(-1);
}
if((sdlf->SDL_DestroySemaphore=GetProcAddress(sdl_dll, "SDL_DestroySemaphore"))==NULL) {
FreeLibrary(sdl_dll);
return(-1);
}
if((sdlf->SDL_CreateMutex=GetProcAddress(sdl_dll, "SDL_CreateMutex"))==NULL) {
FreeLibrary(sdl_dll);
return(-1);
......@@ -187,6 +196,18 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
FreeLibrary(sdl_dll);
return(-1);
}
if((sdlf->OpenAudio=GetProcAddress(sdl_dll, "SDL_OpenAudio"))==NULL) {
FreeLibrary(sdl_dll);
return(-1);
}
if((sdlf->CloseAudio=GetProcAddress(sdl_dll, "SDL_CloseAudio"))==NULL) {
FreeLibrary(sdl_dll);
return(-1);
}
if((sdlf->PauseAudio=GetProcAddress(sdl_dll, "SDL_PauseAudio"))==NULL) {
FreeLibrary(sdl_dll);
return(-1);
}
sdlf->gotfuncs=1;
sdl_funcs_loaded=1;
return(0);
......@@ -264,6 +285,10 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
dlclose(sdl_dll);
return(-1);
}
if((sdlf->SDL_DestroySemaphore=dlsym(sdl_dll, "SDL_DestroySemaphore"))==NULL) {
dlclose(sdl_dll);
return(-1);
}
if((sdlf->SDL_CreateMutex=dlsym(sdl_dll, "SDL_CreateMutex"))==NULL) {
dlclose(sdl_dll);
return(-1);
......
......@@ -25,6 +25,7 @@ struct sdlfuncs {
SDL_Surface *dst, SDL_Rect *dstrect);
void (*UpdateRects) (SDL_Surface *screen, int numrects, SDL_Rect *rects);
SDL_sem *(*SDL_CreateSemaphore) (Uint32 initial_value);
void (*SDL_DestroySemaphore) (SDL_sem *semaphore);
SDL_mutex *(*SDL_CreateMutex) (void);
struct SDL_Thread *(*CreateThread) (int (*fn)(void *), void *data);
int (*WaitEvent) (SDL_Event *event);
......@@ -39,6 +40,9 @@ struct sdlfuncs {
char *(*GetError) (void);
int (*InitSubSystem)(Uint32 flags);
void (*QuitSubSystem)(Uint32 flags);
int (*OpenAudio)(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
void (*CloseAudio)(void);
void (*PauseAudio)(int pause_on);
int gotfuncs;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment