Advertisement
Kitomas

kit_sdl2_kmixer.c as of 2023-8-24

Aug 24th, 2023
1,022
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.55 KB | None | 0 0
  1. #include "../include/kit_sdl2/kit_kmixer.h"
  2. #include "../_private/include/_kit_privmacro.h"
  3. #include "../_private/include/_kit_kmixerPrivate.h"
  4.  
  5. struct _kit_kmixerGlobals_t _kit_kmixerGlobals;
  6.  
  7.  
  8.  
  9. int kit_kmixerInit(int deviceThreadPoolSize){
  10.   if(_kit_kmixerGlobals.init){ SDL_SetError("kmixer is already initialized!"); return 1; }
  11.   _kit_kmixerGlobals.lock=SDL_CreateMutex();
  12.   if(_kit_kmixerGlobals.lock == NULL) return -1;
  13.   if(SDL_LockMutex(_kit_kmixerGlobals.lock)<0) return -2;
  14.  
  15.   _kit_kmixerGlobals.cores=SDL_GetCPUCount();
  16.   if(deviceThreadPoolSize>0) _kit_kmixerGlobals.threadPoolSize=deviceThreadPoolSize;
  17.   else                       _kit_kmixerGlobals.threadPoolSize=_kit_kmixerGlobals.cores;
  18.  
  19.   _kit_kmixerGlobals.capabilities =SDL_HasSSE()  <<5;
  20.   _kit_kmixerGlobals.capabilities|=SDL_HasSSE2() <<4;
  21.   _kit_kmixerGlobals.capabilities|=SDL_HasSSE3() <<3;
  22.   _kit_kmixerGlobals.capabilities|=SDL_HasSSE41()<<2;
  23.   _kit_kmixerGlobals.capabilities|=SDL_HasAVX()  <<1;
  24.   _kit_kmixerGlobals.capabilities|=SDL_HasAVX2()    ;
  25.  
  26.   _kit_kmixerGlobals.init=1;
  27.   if(SDL_UnlockMutex(_kit_kmixerGlobals.lock)<0) return -999; //change this value later
  28.   return 0;
  29. }
  30.  
  31.  
  32. int kit_kmixerQuit(){
  33.   if(!_kit_kmixerGlobals.init){ SDL_SetError("kmixer is not initialized!"); return 1; }
  34.   if(SDL_LockMutex(_kit_kmixerGlobals.lock)<0) return -1;
  35.  
  36.   _kit_kmixerGlobals.init=0;
  37.   if(SDL_UnlockMutex(_kit_kmixerGlobals.lock)<0) return -999; //change this value later
  38.   SDL_DestroyMutex(_kit_kmixerGlobals.lock);
  39.   //_kit_kmixerGlobals.lock=NULL;
  40.   return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement