Advertisement
Kitomas

kit_sdl2_kmixer.c as of 2023-10-05

Oct 6th, 2023
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.48 KB | None | 0 0
  1. #include "../include/kit_sdl2/kit_kmixer.h"
  2. #include "../_private/include/_kit_privmacro.h"
  3. #include "../_private/include/_kit_coreAllPrivate.h"
  4. #include "../_private/include/_kit_kmixerAllPrivate.h"
  5.  
  6.  
  7.  
  8.  
  9. #if defined(_KIT_KMIXER_DEBUG) || defined(_KIT_ALL_DEBUG)
  10. const SDL_bool kit_kmixerIsDebug=SDL_TRUE;
  11. #else
  12. const SDL_bool kit_kmixerIsDebug=SDL_FALSE;
  13. #endif
  14.  
  15.  
  16.  
  17.  
  18. struct _kit_kmixerGlobals_t _kit_kmixerGlobals;
  19.  
  20.  
  21.  
  22.  
  23. int kit_kmixerInit(int deviceThreadPoolSize){
  24.   if(!_kit_coreGlobals.init){ SDL_SetError("core not initialized!"); return -1; }
  25.  
  26.   if(_kit_kmixerGlobals.init){ SDL_SetError("kmixer is initialized!"); return 1; }
  27.   if(SDL_InitSubSystem(SDL_INIT_AUDIO)<0) return -2;
  28.  
  29.   _kit_kmixerGlobals.lock=SDL_CreateMutex();
  30.   if(_kit_kmixerGlobals.lock == NULL) return -3;
  31.   if(SDL_LockMutex(_kit_kmixerGlobals.lock)<0) return -4;
  32.  
  33.   if(deviceThreadPoolSize>0) _kit_kmixerGlobals.threadPoolSize=deviceThreadPoolSize;
  34.   else                       _kit_kmixerGlobals.threadPoolSize=_kit_coreGlobals.cores;
  35.  
  36.   _kit_kmixerGlobals.init=1;
  37.   if(SDL_UnlockMutex(_kit_kmixerGlobals.lock)<0) return -5;
  38.   return 0;
  39. }
  40.  
  41.  
  42.  
  43. int kit_kmixerQuit(){
  44.   if(!_kit_kmixerGlobals.init){ SDL_SetError("kmixer not initialized!"); return 1; }
  45.   if(SDL_LockMutex(_kit_kmixerGlobals.lock)<0) return -1;
  46.  
  47.   _kit_kmixerGlobals.init=0;
  48.   if(SDL_UnlockMutex(_kit_kmixerGlobals.lock)<0) return -2;
  49.   SDL_DestroyMutex(_kit_kmixerGlobals.lock);
  50.   SDL_QuitSubSystem(SDL_INIT_AUDIO);
  51.   return 0;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement