Convenience function that allows removing the current signal handler
callback within the callback without having to use
signal_handler_disconnect with all of its required parameters.
Allows the ability to use fixed stack memory to construct a calldata_t
structure rather than having to allocate each time. This is fine to do
for certain signals where the calldata never goes above a specific size.
If by some chance the size is insufficient, it will output a log
message.
These functions created stack variables but never actually initialized
them. If the calldata variable is invalid, the return values will be
the uninitialized stack value.
It's possible for one signal handler to disconnect another during signal_handler_signal, which could result in crashes when the disconnected signal handler is called with a potentially freed data pointer due to other cleanup.
Found via UBSan, actual errors (addresses not pruned for illustrative purposes):
"runtime error: store to misaligned address 0x7f9a9178e84c for type
'size_t' (aka 'unsigned long'), which requires 8 byte alignment"
"runtime error: load of misaligned address 0x7f9a9140f2cf for type
'size_t' (aka 'unsigned long'), which requires 8 byte alignment"
This Fixes a minor flaw with the API where data had to always be mutable
to be usable by the API.
Functions that do not modify the fundamental underlying data of a
structure should be marked as constant, both for safety and to signify
that the parameter is input only and will not be modified by the
function using it.
Typedef pointers are unsafe. If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data. I admit this was a fundamental mistake that must
be corrected.
All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.
This does not break ABI though, which is pretty nice.
I encountered a situation where I wanted to delete a callback for a
signal while inside of that signal. However it would hard lock, and
even after that, it would mess up the loop for the callback list.
So, change the mutex of the individual signals to a recursive-style
mutex, and then if a callback of a signal is deleted while currently in
that signal, just mark it for deletion, which will happen after the
signal is complete.
When a source/output/etc has a property of a 'list' type, there was no
way to get the names associated with its values. That, and it only
supported lists of either text, or enums (0..[value] only).
Now, you can associate translated names with those values, and use
integer, float, or string values. Put it all in to one function as well
to simplify its usage.
I plan on using this to help get enumerations from devices/etc for
certain types of sources. For example, if I get the properties of an
audio source, I'd like to have a list of available devices with it as
well.
- Signals and dynamic callbacks now require declarations to be made
before being used. What this does is allows us to get information
about the functions dynamically which can be relayed to the user and
plugins for future extended usage (this should have big implications
later for scripting in particular, hopefully).
- Reduced the number of types calldata uses from "everything I could
think of" to simply integer, float, bool, pointer/object, string.
Integer data is now stored as long long. Floats are now stored as
doubles (check em).
- Use a more consistent naming scheme for lexer error/warning macros.
- Fixed a rather nasty bug where switching to an existing scene would
cause it to increment sourceSceneRefs, which would mean that it would
never end up never properly removing the source when the user clicks
removed (stayed in limbo, obs_source_remove never got called)
There were a *lot* of warnings, managed to remove most of them.
Also, put warning flags before C_FLAGS and CXX_FLAGS, rather than after,
as -Wall -Wextra was overwriting flags that came before it.
When using signal callbacks, there is rarely a need to check to see if
the callback paramters are actually validl; in those cases, if they are
invalid, then the signal is being used incorrectly. The calldata_get*
functions are meant to be used more for when using dynamic function
calls rather than when using signals. The calldata_get* functions made
it so that you have to declare your varaibles, and then call that
function to assign that value to those variables, which was slightly
annoying to constantly have to do over and over.
Therefore I created a few extra functions for returning the value
without having to check for validity. Although you would think this
would be an issue for maintaining, keep in mind that these functions
return base types. Admittedly, these functions are merely for
convenience.