Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\include\kit\_misc_fileio.hpp":
- #ifndef _INC__MISC_FILEIO_HPP
- #define _INC__MISC_FILEIO_HPP
- #include "commondef.hpp"
- namespace kit {
- union BinaryData_magic {
- u8 n8;
- u16 n16;
- u32 n32;
- u64 n64;
- char str[8];
- //(str may not be null-terminated!)
- };
- class BinaryData {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- char* _data = nullptr;
- size_t _data_len = 0;
- public:
- //wacky
- BinaryData_magic** const magic =
- (BinaryData_magic**)&this->_data;
- BinaryData(const char* filePath);
- //this will allocate dataSize bytes for _data, before copying data to _data
- //(it is safe to pass nullptr to data, though that would make the class
- // instance sorta equivalent to a garbage collected memory::alloc())
- BinaryData(const void* data, size_t data_len);
- ~BinaryData();
- inline bool isValid() { return _valid; }
- inline bool isConstructing(){ return _constructing; }
- char* getData(){ return _data; }
- size_t getSize(){ return _data_len; }
- };
- #define KIT_FILE_SEEK_SET 0
- #define KIT_FILE_SEEK_CUR 1
- #define KIT_FILE_SEEK_END 2
- class File { //16B
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- bool _closed = false;
- bool _zombie = false;
- GenOpqPtr _file = nullptr;
- public:
- File(const char* filePath, const char* mode);
- ~File();
- inline bool isValid() { return _valid; }
- inline bool isConstructing(){ return _constructing; }
- inline bool isClosed() { return _closed; }
- //WARNING: make sure to call clearSysError() before starting any
- //string of calls to read(), otherwise an error might be thrown
- //if the thread's previously set error was equal to "Error"
- //returns number of elements read (or 0 if EOF)
- size_t read(void* elements, size_t elementSize, size_t elements_len);
- //returns number of bytes read (or 0 if EOF)
- inline size_t read(void* data, size_t dataSize){ return read(data, 1, dataSize); }
- void write(const void* elements, size_t elementSize, size_t elements_len);
- inline void write(const void* data, size_t dataSize){ write(data, 1, dataSize); }
- //seek to offset relative of whence (one of KIT_FILE_SEEK_<SET/CUR/END>)
- //returns new absolute offset of data stream
- size_t seek(s64 offset, u32 whence);
- //returns current file offset
- inline size_t tell(){ return seek(0, KIT_FILE_SEEK_CUR); }
- //closes file handle
- //(file is considered invalid after this point!)
- void close();
- //returns size of file, in bytes
- size_t size();
- };
- namespace fileio {
- bool exists(const char* filePath);
- size_t size(const char* filePath);
- void remove(const char* filePath);
- //heap memory is allocated here,
- //and should be freed with memory::free()
- //(also, while *dataSize_p won't be populated with resulting
- // filesize if dataSize_p is nullptr, it won't actually error)
- void* readAll(const char* filePath, size_t* dataSize_p);
- //writes to a binary file from a buffer
- void writeAll(const char* filePath, const void* data,
- size_t dataSize, bool append = false);
- }; /* namespace fileio */
- }; /* namespace kit */
- #endif /* _INC__MISC_FILEIO_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\include\kit\_misc_func.hpp":
- #ifndef _INC__MISC_FUNC_HPP
- #define _INC__MISC_FUNC_HPP
- #include "commondef.hpp"
- namespace kit {
- enum InitFlagsEnum {
- KINIT_TIMER = 0x01,
- KINIT_AUDIO = 0x02,
- KINIT_VIDEO = 0x04,
- KINIT_JOYSTICK = 0x08,
- KINIT_GAMECONTROLLER = 0x10,
- KINIT_EVENTS = 0x20,
- KINIT_EVERYTHING = 0x3F,
- };
- #define KIT_INIT_ALL() (kit::initSubsystems(KINIT_EVERYTHING))
- #define KIT_QUIT_ALL() (kit::quitSubsystems(KINIT_EVERYTHING))
- //these should only be called from the main thread, only after
- //guaranteeing that no other threads are currently running
- void initSubsystems(u32 flags);
- void quitSubsystems(u32 flags);
- //(quitting with KINIT_EVERYTHING is allowed even if
- //there are no currently active subsystems)
- //(len_max does not include null-terminator!)
- //(if !len_max, call is analogous to str(not n)len)
- size_t strnLen(const char* str, size_t len_max = 0);
- //(mostly) yoinked from stackoverflow :D
- //(len_max does not include null-terminator!)
- //(if !len_max, call is analogous to str(not n)cmp)
- s32 strnCmp(const char* str_a, const char* str_b, size_t len_max = 0);
- const char* getLastSysError();
- void clearSysError();
- //this must be called whenever a const char* exception is caught,
- //only after that Error has been handled by the user
- //(as in, the pointer should be considered invalid after exiting this function!)
- //also, a call of quitSubsystem(KINIT_EVERYTHING)
- //will free all thread errors automatically
- //also also, mixups might occur if another thread error is pushed before
- //a call to freeThreadError() has the chance to free the previous one
- //on the same thread, resulting in the wrong reference (not an invalid
- //error string, just not the right one) being accessed
- void freeThreadError();
- u32 getNumLogicalCPUCores(); //(might be > core count if hyperthreading is enabled)
- u32 getCPUCacheLineSize(); //in bytes (L1 cache specifically)
- enum MessageBoxFlagsEnum {
- MSGBOX_ERROR = 0x0010,
- MSGBOX_WARNING = 0x0020,
- MSGBOX_INFO = 0x0040,
- MSGBOX_BTNS_L2R = 0x0080, //buttons placed left-to-right (showMsgBoxEx only)
- MSGBOX_BTNS_R2L = 0x0100, //buttons placed right-to-left (showMsgBoxEx only)
- };
- class Window; //forward declaration
- void showMsgBox(const char* text = nullptr, const char* title = nullptr,
- u32 flags = MSGBOX_INFO, Window* win = nullptr);
- //showMsgBoxEx is TBD (i don't want to deal with SDL's message boxes right now)
- union Event; //forward declaration
- //returns false if there were no events in queue
- //(if event_p is left as nullptr, the next event will not be dequeued)
- //(also, only call this function in the thread that set the video mode,
- // which is usually the main thread!)
- bool pollEvent(Event* event_p = nullptr); //requires events subsystem
- const char* getEventText(u32 type); //only useful in debug build
- //(clipboard text uses utf-8 encoding)
- bool clipboardHasText();
- char* clipboardGetText(); //(allocates memory; returned ptr must be memory::free'd)
- void clipboardSetText(const char* txt);
- bool showCursor(s32 toggle); //boolean, or -1 to query state without changing
- void warpMouseGlobal(s32 x, s32 y);
- }; /* namespace kit */
- #endif /* _INC__MISC_FUNC_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\include\kit\_misc_memory.hpp":
- #ifndef _INC__MISC_MEMORY_HPP
- #define _INC__MISC_MEMORY_HPP
- #include "commondef.hpp"
- namespace kit {
- namespace memory {
- void* alloc(size_t size);
- //this version of free is especially useful, because it's safe to pass nullptr to!
- //this rule goes for both ptr_p and *ptr_p
- void free(void* ptr_p);
- void* realloc(void* ptr_p, size_t newSize);
- //^^(for both free and realloc, a void** declared in function as void*,
- // so you don't need to explicitly cast it to void**)
- //same as alloc and free, now with exception throwing!
- void* alloc2(size_t size);
- void free2(void* ptr_p); //(unlike free, this will throw if nullptr is given)
- void* realloc2(void* ptr_p, size_t newSize);
- size_t getNumAllocations();
- void* set(void* ptr, s32 value, size_t size);
- //throws exceptions, unlike set
- void* set2(void* ptr, s32 value, size_t size);
- void* copy(void* destination, const void* source, size_t size);
- //throws exceptions, unlike copy
- void* copy2(void* destination, const void* source, size_t size);
- }; /* namespace memory */
- }; /* namespace kit */
- #endif /* _INC__MISC_MEMORY_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\include\kit\_misc_Mutex.hpp":
- #ifndef _INC__MISC_MUTEX_HPP
- #define _INC__MISC_MUTEX_HPP
- #include "commondef.hpp"
- namespace kit {
- //this mutex is non-blocking within the same thread!
- //(that means you can lock multiple times in one thread
- // as long as you unlock it the same number of times)
- class Mutex { //16B; does not require an active subsystem
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- GenOpqPtr _mutex_p = nullptr;
- public:
- Mutex();
- ~Mutex();
- inline bool isValid() { return _valid; }
- inline bool isConstructing(){ return _constructing; }
- void lock(bool locked = true);
- inline void unlock(){ lock(false); }
- bool tryLock(); //returns true if locked successfully
- };
- }; /* namespace kit */
- #endif /* _INC__MISC_MUTEX_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\include\kit\_misc_Thread.hpp":
- #ifndef _INC__MISC_THREAD_HPP
- #define _INC__MISC_THREAD_HPP
- #include "commondef.hpp"
- namespace kit {
- enum ThreadPriorityEnum {
- THREAD_LOW = -1,
- THREAD_NORMAL = 0,
- THREAD_HIGH = 1,
- THREAD_HIGHEST = 2, //for time critical tasks
- };
- //if a thread function throws an unhandled exception,
- //it will be outputted to stdout and/or stderr
- typedef s32 (*ThreadFunction)(void* userdata);
- //returns whether or not priority of current thread was successfully set
- //may fail if setting priority requires elevated privileges (or at least when
- //setting a higher priority), if it's even allowed at all
- bool Thread_setPriority(s32 priority, bool throwOnFailure = false);
- class Thread { //16B; does not require an active subsystem
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- bool _waitInDestructor = false; //otherwise thread auto-detaches
- bool _detached = false;
- GenOpqPtr _thread = nullptr;
- //(real opaque is separate from Thread object and is very temporary)
- public:
- //if waitInDestructor is false, the Thread object will not
- //wait for func to return inside the Thread's destructor
- //(stackSize = 0 to use whatever default stack size is)
- Thread(ThreadFunction func, void* userdata = nullptr,
- bool waitInDestructor = false, size_t stackSize = 0,
- const char* threadName = nullptr);
- //(threadName should be UTF-8 string if not nullptr)
- ~Thread();
- inline bool isValid() { return _valid; }
- inline bool isConstructing(){ return _constructing; }
- inline bool isDetached() { return _detached; }
- u32 getID();
- //returns UTF-8 string, or nullptr if thread doesn't have a name
- const char* getName();
- //returns result of func (if detached, returns 0 immediately)
- //(afaik, SDL_WaitThread doesn't time out, so be careful!)
- s32 waitUntilDone();
- //make thread automatically clean up after returning
- //(otherwise, you'll need to call waitUntilDone() to do that)
- void detach();
- };
- }; /* namespace kit */
- #endif /* _INC__MISC_THREAD_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\include\kit\_misc_time.hpp":
- #ifndef _INC__MISC_TIME_HPP
- #define _INC__MISC_TIME_HPP
- #include "commondef.hpp"
- namespace kit {
- /* from the SDL2 wiki: "
- The callback function is passed the current timer interval
- and returns the next timer interval. If the returned value
- is the same as the one passed in, the periodic alarm continues,
- otherwise a new alarm is scheduled. If the callback returns 0,
- the periodic alarm is cancelled. "*/
- typedef u32 (*timerCallback)(u32 interval_ms, void* userdata);
- typedef s32 timerID;
- //(these 2 functions require the timer subsystem)
- timerID timerAdd(timerCallback func, u32 interval_ms, void* userdata = nullptr);
- void timerRemove(timerID id);
- namespace time {
- //returns current tick count, and how
- //many ticks are in a second, respectively
- u64 getTicks();
- u64 getTicksPerSecond();
- //returns # of milliseconds since init
- u64 getMS();
- u32 getMS_32();
- //returns # of seconds since init
- //(uses integer milliseconds internally;
- // do "(f64)getTicks()/getTicksPerSecond()"
- // if more accuracy is needed)
- f64 getSeconds();
- //will wait AT LEAST the given number
- //of milliseconds (possibly longer)
- void sleep(u32 milliseconds);
- }; /* namespace time */
- }; /* namespace kit */
- #endif /* _INC__MISC_TIME_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\include\kit\_video_Window.hpp":
- #ifndef _INC__VIDEO_WINDOW_HPP
- #define _INC__VIDEO_WINDOW_HPP
- #include "commondef.hpp"
- #include "_misc_Mutex.hpp"
- namespace kit {
- enum WindowPositionEnum {
- WINPOS_UNDEFINED = 0x1FFF0000u,
- WINPOS_CENTERED = 0x2FFF0000u,
- };
- enum WindowFlagEnum {
- WINFLAG_FULLSCREEN = 0x00000001, //fullscreen window
- WINFLAG_OPENGL = 0x00000002, //window usable with an opengl context
- WINFLAG_HIDDEN = 0x00000008, //window is not visible
- WINFLAG_BORDERLESS = 0x00000010, //no window decoration
- WINFLAG_RESIZABLE = 0x00000020, //window can be resized
- WINFLAG_MINIMIZED = 0x00000040, //window is minimized
- WINFLAG_MAXIMIZED = 0x00000080, //window is maximized
- WINFLAG_INPUT_GRABBED = 0x00000100, //window has grabbed input focus
- WINFLAG_FULLSCREEN_DESKTOP = 0x00001000|WINFLAG_FULLSCREEN, //fs window at desktop resolution
- WINFLAG_VULKAN = 0x10000000, //window usable with a vulkan instance
- };
- struct DisplayMode { //16B
- u32 pixelFmt;
- s32 w, h;
- s32 refreshRate;
- };
- class Window { //32B (16B+_lock)
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- GenOpqPtr _win = nullptr;
- Mutex _lock;
- public:
- Window(const char* winTitle,
- s32 winWidth, s32 winHeight,
- u32 winFlags = 0,
- s32 winX = WINPOS_UNDEFINED,
- s32 winY = WINPOS_UNDEFINED);
- ~Window();
- inline bool isValid() { return _valid; }
- inline bool isConstructing(){ return _constructing; }
- inline void lock(bool locked = true){ _lock.lock(locked); }
- inline void unlock() { _lock.lock(false ); }
- bool hasSurface();
- u32 getPixelFormat(); //returns pixel format used by window's surface
- u32 getID();
- u32 getDisplayIndex();
- void* getUserdata(const char* name);
- DisplayMode getDisplayMode(); //get display mode when visible at fullscreen
- const char* getTitle();
- shape::point getSize();
- u32 getFlags();
- f32 getOpacity();
- shape::point getMinSize();
- shape::point getMaxSize();
- shape::point getPosition();
- bool getGrab();
- bool getKeyboardGrab();
- bool getMouseGrab();
- shape::rect getMouseGrabRect();
- f32 getBrightness(); //the window's gamma multiplier, specifically
- //returns previous userdata pointer; name "Window class" is forbidden (used internally)
- void* setUserdata(const char* name, void* userdata);
- void setDisplayMode(const DisplayMode* mode); //nullptr to use win's dims & desktop's fmt & refresh rate
- void setTitle(const char* title);
- void setSize(s32 width, s32 height);
- void setVisibility(bool visible);
- void setFullscreen(u32 mode); //0,1,2 = disabled, enabled, enabled @ desktop resolution
- void setResizable(bool enable);
- void setBordered(bool enable);
- void setAlwaysOnTop(bool enable);
- void setOpacity(f32 opacity); //0.0f -> 1.0f
- void setMinSize(s32 minWidth, s32 minHeight);
- void setMaxSize(s32 maxWidth, s32 maxHeight);
- void setPosition(s32 x, s32 y);
- void setGrab(bool enable); //also includes keyboard if SDL_HINT_GRAB_KEYBOARD is set (tbd: replace macro)
- void setKeyboardGrab(bool enable);
- void setMouseGrab(bool enable); //confines mouse cursor to window
- void setMouseGrabRect(const shape::rect* rect = nullptr); //nullptr to use entire window
- void setBrightness(f32 brightness); //gamma multiplier; 0.0f -> 1.0f
- void warpMouse(s32 x, s32 y); //relative to and inside the window's bounds
- void minimize();
- void maximize();
- void restore();
- void raise(); //also makes window have input focus
- };
- //returns window if input is grabbed; nullptr otherwise
- Window* getGrabbedWindow();
- }; /* namespace kit */
- #endif /* _INC__VIDEO_WINDOW_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\src\kit_sdl2\_kit_common.hpp":
- #ifndef _SRC__KIT_COMMON_HPP
- #define _SRC__KIT_COMMON_HPP
- /* notes/todo:
- use fstr to give more coherent error throws
- throw if trying to create object using an uninitialized subsystem
- specify which functions/methods can throw exceptions
- when throwing in a constructor, make sure to deallocate any memory
- SDL_AddEventWatch
- SDL_DelEventWatch
- SDL_FlushEvent/Events
- SDL_HasEvent/Events
- SDL_JoystickEventState
- SDL_PeepEvents
- SDL_PushEvent
- SDL_RegisterEvents
- SDL_WaitEvent/EventTimeout
- SDL_StartTextInput (??)
- what's going on with lodepng's encoder's file stuff?
- maybe put a mutex on numAllocations
- allow people to disable zeroing out audio buffers
- */
- #include <SDL2/SDL.h>
- #ifdef _DEBUG
- #define _log(...) SDL_Log(__VA_ARGS__)
- #define loghere SDL_Log("line %4i: (%s)",__LINE__,__FILE__);
- #define _getnumallocs SDL_Log("%4i: # OF ALLOCATIONS = %u", __LINE__, (u32)memory::getNumAllocations());
- #else
- #define _log(...)
- #define loghere
- #define _getnumallocs
- #endif
- /*
- #define DISABLE_WARNING(_name) _Pragma(#_name)
- #define DISABLE_WARNING_PUSH(_name) _Pragma("GCC diagnostic push") DISABLE_WARNING(_name)
- #define DISABLE_WARNING_POP _Pragma("GCC diagnostic pop")
- */
- #include <kit/all.hpp>
- int snprintf(char*, size_t, const char*, ...); //only used by fstr
- int remove(const char *); //only used by fileio::remove
- //class type ID macros
- #define KIT_OPAQUE_PRESENT (0x80000000)
- #define KIT_IS_OPAQUE_PRESENT(_type) ( ((_type)&KIT_OPAQUE_PRESENT) != 0 )
- #define KIT_CLASSTYPE_NULL (0x0000 )
- #define KIT_CLASSTYPE_MUTEX (0x0001 | KIT_OPAQUE_PRESENT)
- #define KIT_CLASSTYPE_THREAD (0x0002 | KIT_OPAQUE_PRESENT)
- #define KIT_CLASSTYPE_BINARYDATA (0x0003 )
- #define KIT_CLASSTYPE_FILE (0x0004 | KIT_OPAQUE_PRESENT)
- #define KIT_CLASSTYPE_WINDOW (0x0005 | KIT_OPAQUE_PRESENT)
- //#define KIT_CLASSTYPE_SURFACE (0x0006 | KIT_OPAQUE_PRESENT)
- //#define KIT_CLASSTYPE_TEXTURE (0x0007 | KIT_OPAQUE_PRESENT)
- #define KIT_CLASSTYPE_AUDIODEVICE (0x0008 | KIT_OPAQUE_PRESENT)
- #define KIT_CLASSTYPE_AUDIOSTREAM (0x0009 | KIT_OPAQUE_PRESENT)
- namespace kit {
- #define KIT_GET_CLASS_TYPE(_ptr) ( ((kit::_commonClassValues*)(_ptr))->type )
- #define KIT_GET_CLASS_VALID(_ptr) ( ((kit::_commonClassValues*)(_ptr))->valid )
- #define KIT_GET_CLASS_CONSTRUCTING(_ptr) ( ((kit::_commonClassValues*)(_ptr))->constructing )
- #define KIT_GET_CLASS_DATA(_ptr) ( ((kit::_commonClassValues*)(_ptr))->data )
- #define KIT_GET_CLASS_OPAQUE(_ptr) ( ((kit::_commonClassValues*)(_ptr))->opq )
- #define KIT_IS_CLASS_TYPE(_ptr,_type) ( KIT_GET_CLASS_TYPE(_ptr) == (_type) )
- #define KIT_IS_CLASS_VALID(_ptr) ( KIT_GET_CLASS_VALID(_ptr) != 0 )
- #define KIT_IS_CLASS_CONSTRUCTING(_ptr) ( KIT_GET_CLASS_CONSTRUCTING(_ptr) != 0 )
- struct _commonClassValues { //8-16B (depending on KIT_OPAQUE_PRESENT)
- u32 type;
- bool valid; //'is object fully and successfully constructed?'
- bool constructing; //'is object currently inside constructor?'
- //^^this is useful for if public class functions are called inside the
- //constructor itself, but the valid flag is not set to true yet
- u16 data; //purpose varies by class type; unused by some (or it's split into 2 u8)
- GenOpqPtr opq; //nonexistent if type lacks the KIT_OPAQUE_PRESENT flag
- };
- union Error { //16B
- struct {
- const char* _txt;
- u32 _thread_id;
- bool _heap;
- u8 _padding8;
- u16 _padding16;
- };
- struct { u64 _0, _1; };
- Error() : _txt(nullptr), _thread_id(0), _heap(false) {}
- Error(const char* txt, bool heap = false)
- : _txt(txt), _thread_id(SDL_GetThreadID(nullptr)), _heap(heap) {}
- inline const char* text(){
- return (_txt != nullptr) ? _txt : "(ERROR TEXT IS NULLPTR)"; }
- };
- #define FSTR_LEN ((size_t)1024)
- struct _globalStates {
- //(make sure to not call fstr from more than 2 threads at once!)
- char fstr_str[2][FSTR_LEN];
- s32 fstr_which = 0;
- //normally, the user is warned if the SDL version's patch level
- //is <= the one kit_sdl2 was made for, but this can be disabled
- bool patch_warning_disabled;
- char _[3];
- u64 performanceFreq = 0; //how many performance counter units per second
- //(haptic & sensor subsystems are not included)
- union {
- u64 init_value;
- struct {
- bool timer;
- bool audio;
- bool video; //auto-inits events
- bool gamecontroller; //auto-inits joystick
- bool joystick; //auto-inits events
- bool events;
- bool joystick_sdl; //same as events_sdl, except with the joystick subsystem
- bool events_sdl; //'were events EXPLICITLY initialized? (as in, not auto-init)'
- } init;
- };
- Error* errors = nullptr;
- size_t errors_len = 0;
- SDL_mutex* lock = nullptr;
- };
- //found in "kit_func_init-quit.cpp"
- extern _globalStates _gl; //gl as in global, not opengl
- extern const char _fstr_failure[]; // = "(FSTR FAILED)"
- //(will complain about undefined sequencing if you put fstr in a call to fstr,
- //due to the of the "^=" assignment operator)
- #define fstr(...) ( \
- (snprintf(_gl.fstr_str[_gl.fstr_which^=1],FSTR_LEN,__VA_ARGS__)>=0) \
- ? (const char*)_gl.fstr_str[_gl.fstr_which] : _fstr_failure \
- )
- #define LOCK_GLOBALS() { if(_gl.lock != nullptr) SDL_LockMutex( _gl.lock); }
- #define UNLOCK_GLOBALS() { if(_gl.lock != nullptr) SDL_UnlockMutex(_gl.lock); }
- //in _kit_private.cpp:
- const char* _pushError(const char* errortext);
- void _freeError(u32 thread_id = 0);
- void _freeErrors(); //also frees _gl.errors entirely
- #define PUSH_ERROR(_txt) _pushError(_txt)
- #define PUSH_ERRORF(...) _pushError( fstr(__VA_ARGS__) )
- extern size_t numAllocations;
- //100ms
- #define FADETOTAL_SEC (0.100f)
- //linearly fade over the course of 10ms
- #define FADEDELTA_SEC (0.010f)
- //the most common audio clipping ends at 10-11ms after unpausing,
- //but i've seen clipping as far as ~450ms after unpausing
- #define FADEDELAY_SEC (FADETOTAL_SEC - FADEDELTA_SEC)
- }; /* namespace kit */
- #include "_kit_opaques.hpp"
- #endif /* _SRC__KIT_COMMON_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"ksdl2\src\kit_sdl2\_kit_opaques.hpp":
- #ifndef _SRC__KIT_OPAQUES_HPP
- #define _SRC__KIT_OPAQUES_HPP
- //THIS FILE IS NOT TO BE INCLUDED ON ITS OWN,
- //RATHER AS A PART OF "_kit_common.hpp"!!
- /*
- Opaques are included as follows: (classes without opaques are omitted)
- [ ] Mutex
- [ ] Thread
- [ ] File
- [ ] Window
- [*] AudioDevice
- */
- namespace kit {
- struct _AudioDeviceOpaque {
- AudioDeviceInfo* info_p;
- void* buffer;
- u32 buffer_size;
- f32 fadeDelta;
- f32 fadeVolume;
- u32 fadeDelay;
- bool fadeOut; //fade-in otherwise
- bool noFadeDelay;
- bool playing;
- u8 _0;
- u32 _1;
- };
- }; /* namespace kit */
- #endif /* _SRC__KIT_OPAQUES_HPP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement