Advertisement
Kitomas

kit_kmixer.h as of 8-18-23

Aug 18th, 2023
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.71 KB | None | 0 0
  1. /**
  2.  * \file kit_kmixer.h
  3.  * \brief Header file for KIT SDL2's KMixer module
  4.  */
  5. #ifndef _KIT_KMIXER_H
  6. #define _KIT_KMIXER_H
  7. #ifndef _KIT_SDL2_KMIXER_H
  8. #define _KIT_SDL2_KMIXER_H
  9.  
  10.  
  11. //#include <SDL2/SDL.h>
  12. #include "./kit_core.h"
  13.  
  14.  
  15.  
  16. /* +kit_kmixer+ */
  17. extern int kit_kmixerInit(int deviceThreadPoolSize);
  18. extern int kit_kmixerQuit();
  19. /* -kit_kmixer- */
  20.  
  21.  
  22. /* +kit_kmixerVoice+ */
  23. /**
  24.  * PCM Audio Voice Callback
  25.  * This type of function is called when added as a voice to a KMixer audio device.
  26.  * Unless it's a capture (recording) type, you can add multiple voices or returns to a KMixer device.
  27.  * While each voice's callback is given its own threadpool task (and should be thread-safe),
  28.  * the overall speed is determined by device's slowest voice or return chain (processing-wise).
  29.  * For a capture-type device, the given audio buffer must be completely read before returning.
  30.  * For a rendering (playback) device, the buffer must be completely filled before returning.
  31.  * \param[in] userdata A user-defined pointer passed to the voice callback.
  32.  * \param[in] _stream  A pointer to the audio data buffer.
  33.  * \param[in] len      The length of that buffer in samples (number of sample *frames* is len/<# of channels>).
  34.  */
  35. typedef void (*kit_kmixerVoiceCallback) (void* userdata, void* _stream, int len);
  36. /* -kit_kmixerVoice- */
  37.  
  38.  
  39.  
  40. /* +kit_kmixerDevice+ */
  41. /**
  42.  * \brief This struct contains all info related to a an audio device and its voice chain
  43.  */
  44. typedef struct {
  45.   union {
  46.     char           str[8]; ///< \brief String portion of struct ID ("kmxrDev\x00").
  47.     Uint64            num; ///< \brief Integer portion of struct ID (0x0076654472786D6B).
  48.   } /* ---------- */ _magic; ///< \brief Struct ID number; union of Uint64 and char[8].
  49.   SDL_AudioSpec        spec; ///< \brief Audio specification of the device.
  50.   SDL_mutex*          _lock; ///< \brief Mutex for device access (lock unnecessary for accessing some members).
  51.   struct {
  52.     SDL_cond*        cond; ///< \brief < TBD >
  53.     kit_coreVector* queue; ///< \brief Circular buffer that contains currently queued voice tasks.
  54.     kit_coreVector*  pool; ///< \brief The thread pool for voice tasks
  55.   } /* --------- */ _thread; ///< \brief The device's thread pool voice task queue.
  56.   struct {
  57.     kit_coreVector*   raw; ///< \brief 1D array of all registered voices and their information.
  58.     kit_coreVector*   ord; ///< \brief 2D array of voices and their info, ordered by number of input voices.
  59.   } /* --------- */ _voices; ///< \brief The device's registered voices
  60.   SDL_AudioDeviceID  _devID; ///< \brief The device ID number that SDL uses.
  61. } kit_kmixerDevice;
  62. /* -kit_kmixerDevice- */
  63.  
  64.  
  65.  
  66. #endif /* _KIT_SDL2_KMIXER_H */
  67. #endif /* _KIT_KMIXER_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement