libobs: Add validity checks for obs objects
These functions are intended to log a warning when an obs function is called with a null object.
This commit is contained in:
parent
274780c86c
commit
ed8a06bf65
@ -48,6 +48,40 @@ struct draw_callback {
|
||||
void *param;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* validity checks */
|
||||
|
||||
static inline bool obs_object_valid(const void *obj, const char *f,
|
||||
const char *t)
|
||||
{
|
||||
if (!obj) {
|
||||
blog(LOG_WARNING, "Null %s passed to %s!", t, f);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool obs_source_valid(const obs_source_t *obj, const char *f)
|
||||
{
|
||||
return obs_object_valid(obj, f, "source");
|
||||
}
|
||||
|
||||
static inline bool obs_output_valid(const obs_output_t *obj, const char *f)
|
||||
{
|
||||
return obs_object_valid(obj, f, "output");
|
||||
}
|
||||
|
||||
static inline bool obs_encoder_valid(const obs_encoder_t *obj, const char *f)
|
||||
{
|
||||
return obs_object_valid(obj, f, "encoder");
|
||||
}
|
||||
|
||||
static inline bool obs_service_valid(const obs_service_t *obj, const char *f)
|
||||
{
|
||||
return obs_object_valid(obj, f, "service");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* modules */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user