Advertisement
Kitomas

kit_sdl2_kmixerAsync.c as of 2023-10-12

Oct 12th, 2023
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.59 KB | None | 0 0
  1. #include "../include/kit_sdl2/kit_kmixer.h"
  2. #include "../_private/include/_kit_privmacro.h"
  3. #include "../_private/include/_kit_kmixerAllPrivate.h"
  4. //todo: include mutexes where they should be
  5.  
  6.  
  7.  
  8. typedef struct _kit_kmixerAsyncTrack {
  9.   kit_acodecPCM* pcm;
  10.   //double
  11.   Uint64     position;
  12.   Uint32        index;
  13.   Uint32    timeStamp;
  14.   SDL_bool stopOnMute;
  15.   Uint32     _padding;
  16. } _kit_kmixerAsyncTrack;
  17.  
  18.  
  19.  
  20. //this should be contiguous with the AsyncTrack(s)
  21. typedef struct _kit_kmixerAsyncUserdata {
  22.   kit_kmixerVoiceSpec vspec;
  23.   Uint32 numTracks;
  24.   Uint32 padding;
  25.  
  26.   _kit_kmixerAsyncTrack* tracks;
  27. } _kit_kmixerAsyncUserdata;
  28.  
  29.  
  30.  
  31. void _kit_kmixerAsyncRemoveCallback(void* userdata){  if(userdata != NULL) SDL_free(userdata);  }
  32.  
  33.  
  34.  
  35. void _kit_kmixerAsyncTrackCallback(void* userdata, void* _stream, int size, SDL_bool hasInput){
  36. }
  37.  
  38.  
  39.  
  40. void _kit_kmixerAsyncVoiceCallback(void* userdata, void* _stream, int size, SDL_bool hasInput){
  41. }
  42.  
  43.  
  44.  
  45.  
  46. Uint32 kit_kmixerAsyncAdd(kit_kmixerDevice* device, kit_kmixerVoiceSpec* vspec,
  47.                           Uint32 outputVoiceID, Uint32 numTracks)
  48. {
  49.   Uint32 newIndex = 0; //0 for error by default
  50.   _DEVICE_VALIDITY_CHECK(0)
  51.   _IF_SDLERR(outputVoiceID>=device->_raw->x,;,"outputVoiceID out of bounds")
  52.   _IF_SDLERR(numTracks==0,;,"!numTracks")
  53.  
  54.   _IF_SDLERR(vspec==NULL,;,"!vspec")
  55.   vspec->remove   = _kit_kmixerAsyncRemoveCallback;
  56.   vspec->callback = _kit_kmixerAsyncVoiceCallback;
  57.  
  58.   //(then do userdata stuff here)
  59.  
  60.   newIndex = kit_kmixerVoiceAdd(device,vspec,outputVoiceID);
  61.  
  62.   _noerr_:
  63.   _error_:
  64.   return newIndex;
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement