This source file includes following definitions.
- SDLOUT_InitSDL
- SDLOUT_CloseSDL
- QueryInterfaces
- LoadInterface
- ShutdownInterface
#include "sdl_out.h"
static Bool is_init = GF_FALSE;
static u32 num_users = 0;
#if (defined(WIN32) || defined(_WIN32_WCE)) && !defined(__GNUC__)
#if SDL_VERSION_ATLEAST(2,0,0)
#pragma comment(lib, "SDL2")
#else
#pragma comment(lib, "SDL")
#endif
#endif
Bool SDLOUT_InitSDL()
{
if (is_init) {
num_users++;
return GF_TRUE;
}
if (SDL_Init(0) < 0) return GF_FALSE;
is_init = GF_TRUE;
num_users++;
return GF_TRUE;
}
void SDLOUT_CloseSDL()
{
if (!is_init) return;
assert(num_users);
num_users--;
if (!num_users) SDL_Quit();
return;
}
GPAC_MODULE_EXPORT
const u32 *QueryInterfaces()
{
static u32 si [] = {
GF_VIDEO_OUTPUT_INTERFACE,
GF_AUDIO_OUTPUT_INTERFACE,
0
};
return si;
}
GPAC_MODULE_EXPORT
GF_BaseInterface *LoadInterface(u32 InterfaceType)
{
if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface*)SDL_NewVideo();
if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return (GF_BaseInterface*)SDL_NewAudio();
return NULL;
}
GPAC_MODULE_EXPORT
void ShutdownInterface(GF_BaseInterface *ifce)
{
switch (ifce->InterfaceType) {
case GF_VIDEO_OUTPUT_INTERFACE:
SDL_DeleteVideo(ifce);
break;
case GF_AUDIO_OUTPUT_INTERFACE:
SDL_DeleteAudio(ifce);
break;
}
}
GPAC_MODULE_STATIC_DECLARATION( sdl_out )