Commit Graph

14 Commits (47aa56b3e9362c6867bd8e988b9dd752f9a7166f)

Author SHA1 Message Date
jp9000 92bbb8e8b1 libobs/callback: Allow ability to use calldata_t with stack
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.
2016-01-25 17:29:08 -08:00
jp9000 d1f225e2e8 libobs/callback: Set default return values to 0/NULL
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.
2015-12-15 01:11:10 -08:00
Palana c680b3e115 libobs/calldata: Fix unaligned loads/stores
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"
2015-05-31 04:45:54 +02:00
jp9000 41fad2d1a4 (API Change) Use const params where applicable
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.
2014-09-26 17:23:07 -07:00
jp9000 c9df41c1e2 (API Change) Remove pointers from all typedefs
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.
2014-09-25 21:48:11 -07:00
jp9000 50ec8b0d55 (API Change) libobs/callback: Unsquish names
Renamed:                  To:
-------------------------------------------------
calldata_getdata          calldata_get_data
calldata_getint           calldata_get_int
calldata_getfloat         calldata_get_float
calldata_getbool          calldata_get_bool
calldata_getptr           calldata_get_ptr
calldata_getstring        calldata_get_string
calldata_setdata          calldata_set_data
calldata_setint           calldata_set_int
calldata_setfloat         calldata_set_float
calldata_setbool          calldata_set_bool
calldata_setptr           calldata_set_ptr
calldata_setstring        calldata_set_string
2014-08-09 11:57:38 -07:00
jp9000 e9342143a7 Simplify and extend callback/signalling system
- 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)
2014-03-01 05:54:55 -07:00
jp9000 966b943d5b Remove majority of warnings
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.
2014-02-14 15:13:36 -07:00
jp9000 968f5fed32 Added some return-style functions to calldata.h
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.
2014-01-04 13:28:27 -07:00
jp9000 78eb116cc8 add 'static' to inline functions in callback/calldata.h 2013-12-30 11:09:32 -07:00
jp9000 72633e40a3 also include bmem.h in the header, minor oversight 2013-12-30 10:14:28 -07:00
jp9000 6ac6256ac5 fill in rest of signal/callback/proc 2013-12-26 04:26:17 -07:00
jp9000 a136748bd3 don't hide calldata structure, no reason to, and forced an unnecessary allocation which is bad 2013-12-26 02:02:24 -07:00
jp9000 e9ded173f1 add my signal/callback interface from another project, also update license of utility files to ISC 1.3 2013-12-25 22:40:33 -07:00