Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "../include/kit_sdl2/kit_kmixer.h"
- #include "../_private/include/_kit_privmacro.h"
- #include "../_private/include/_kit_coreAllPrivate.h"
- #include "../_private/include/_kit_kmixerAllPrivate.h"
- #if defined(_KIT_KMIXER_DEBUG) || defined(_KIT_ALL_DEBUG)
- const SDL_bool kit_kmixerIsDebug=SDL_TRUE;
- #else
- const SDL_bool kit_kmixerIsDebug=SDL_FALSE;
- #endif
- struct _kit_kmixerGlobals_t _kit_kmixerGlobals;
- int kit_kmixerInit(int numDeviceThreads){
- if(!_kit_coreGlobals.init){ SDL_SetError("core not initialized!"); return -1; }
- if(_kit_kmixerGlobals.init){ SDL_SetError("kmixer is initialized!"); return 1; }
- if(SDL_InitSubSystem(SDL_INIT_AUDIO)<0) return -2;
- _kit_kmixerGlobals.lock=SDL_CreateMutex();
- if(_kit_kmixerGlobals.lock == NULL) return -3;
- if(SDL_LockMutex(_kit_kmixerGlobals.lock)<0) return -4;
- if(numDeviceThreads>0) _kit_kmixerGlobals.numDeviceThreads = numDeviceThreads;
- else { //MAX is used here so 0 is functionally identical to -1
- int fraction = MAX(SDL_abs(numDeviceThreads),1);
- _kit_kmixerGlobals.numDeviceThreads = MAX(_kit_coreGlobals.cores/fraction,1);
- }
- _kit_kmixerGlobals.init = 1;
- if(SDL_UnlockMutex(_kit_kmixerGlobals.lock)<0) return -5;
- return 0;
- }
- int kit_kmixerQuit(){
- if(!_kit_kmixerGlobals.init){ SDL_SetError("kmixer not initialized!"); return 1; }
- if(SDL_LockMutex(_kit_kmixerGlobals.lock)<0) return -1;
- _kit_kmixerGlobals.init=0;
- if(SDL_UnlockMutex(_kit_kmixerGlobals.lock)<0) return -2;
- SDL_DestroyMutex(_kit_kmixerGlobals.lock);
- SDL_QuitSubSystem(SDL_INIT_AUDIO);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement