Check for duplicate sources/outputs/encoders/etc

With the recent change to module handling by BtbN, I felt that having
this information might be useful in case someone is actually using make
install to set up their libraries.
master
jp9000 2014-07-28 16:08:56 -07:00
parent cd2c75a05d
commit 53aa0a60d5
6 changed files with 48 additions and 17 deletions

View File

@ -18,7 +18,7 @@
#include "obs.h"
#include "obs-internal.h"
static inline struct obs_encoder_info *find_encoder(const char *id)
struct obs_encoder_info *find_encoder(const char *id)
{
for (size_t i = 0; i < obs->encoder_types.num; i++) {
struct obs_encoder_info *info = obs->encoder_types.array+i;

View File

@ -363,6 +363,8 @@ struct obs_source {
bool rendering_filter;
};
extern const struct obs_source_info *find_source(struct darray *list,
const char *id);
extern bool obs_source_init_context(struct obs_source *source,
obs_data_t settings, const char *name);
extern bool obs_source_init(struct obs_source *source,
@ -422,6 +424,8 @@ struct obs_output {
bool valid;
};
extern const struct obs_output_info *find_output(const char *id);
extern void obs_output_remove_encoder(struct obs_output *output,
struct obs_encoder *encoder);
@ -475,6 +479,8 @@ struct obs_encoder {
DARRAY(struct encoder_callback) callbacks;
};
extern struct obs_encoder_info *find_encoder(const char *id);
extern bool obs_encoder_initialize(obs_encoder_t encoder);
extern void obs_encoder_start(obs_encoder_t encoder,
@ -501,6 +507,8 @@ struct obs_service {
struct obs_output *output;
};
extern const struct obs_service_info *find_service(const char *id);
extern void obs_service_activate(struct obs_service *service);
extern void obs_service_deactivate(struct obs_service *service, bool remove);
extern bool obs_service_initialize(struct obs_service *service,

View File

@ -432,6 +432,24 @@ void obs_register_source_s(const struct obs_source_info *info, size_t size)
struct obs_source_info data = {0};
struct darray *array;
if (info->type == OBS_SOURCE_TYPE_INPUT) {
array = &obs->input_types.da;
} else if (info->type == OBS_SOURCE_TYPE_FILTER) {
array = &obs->filter_types.da;
} else if (info->type == OBS_SOURCE_TYPE_TRANSITION) {
array = &obs->transition_types.da;
} else {
blog(LOG_ERROR, "Tried to register unknown source type: %u",
info->type);
return;
}
if (find_source(array, info->id)) {
blog(LOG_WARNING, "Source d '%s' already exists! "
"Duplicate library?", info->id);
return;
}
CHECK_REQUIRED_VAL(info, getname, obs_register_source);
CHECK_REQUIRED_VAL(info, create, obs_register_source);
CHECK_REQUIRED_VAL(info, destroy, obs_register_source);
@ -445,23 +463,17 @@ void obs_register_source_s(const struct obs_source_info *info, size_t size)
memcpy(&data, info, size);
if (info->type == OBS_SOURCE_TYPE_INPUT) {
array = &obs->input_types.da;
} else if (info->type == OBS_SOURCE_TYPE_FILTER) {
array = &obs->filter_types.da;
} else if (info->type == OBS_SOURCE_TYPE_TRANSITION) {
array = &obs->transition_types.da;
} else {
blog(LOG_ERROR, "Tried to register unknown source type: %u",
info->type);
return;
}
darray_push_back(sizeof(struct obs_source_info), array, &data);
}
void obs_register_output_s(const struct obs_output_info *info, size_t size)
{
if (find_output(info->id)) {
blog(LOG_WARNING, "Output id '%s' already exists! "
"Duplicate library?", info->id);
return;
}
CHECK_REQUIRED_VAL(info, getname, obs_register_output);
CHECK_REQUIRED_VAL(info, create, obs_register_output);
CHECK_REQUIRED_VAL(info, destroy, obs_register_output);
@ -485,6 +497,12 @@ void obs_register_output_s(const struct obs_output_info *info, size_t size)
void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size)
{
if (find_encoder(info->id)) {
blog(LOG_WARNING, "Encoder id '%s' already exists! "
"Duplicate library?", info->id);
return;
}
CHECK_REQUIRED_VAL(info, getname, obs_register_encoder);
CHECK_REQUIRED_VAL(info, create, obs_register_encoder);
CHECK_REQUIRED_VAL(info, destroy, obs_register_encoder);
@ -498,6 +516,12 @@ void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size)
void obs_register_service_s(const struct obs_service_info *info, size_t size)
{
if (find_service(info->id)) {
blog(LOG_WARNING, "Service id '%s' already exists! "
"Duplicate library?", info->id);
return;
}
CHECK_REQUIRED_VAL(info, getname, obs_register_service);
CHECK_REQUIRED_VAL(info, create, obs_register_service);
CHECK_REQUIRED_VAL(info, destroy, obs_register_service);

View File

@ -21,7 +21,7 @@
static inline void signal_stop(struct obs_output *output, int code);
static inline const struct obs_output_info *find_output(const char *id)
const struct obs_output_info *find_output(const char *id)
{
size_t i;
for (i = 0; i < obs->output_types.num; i++)

View File

@ -17,7 +17,7 @@
#include "obs-internal.h"
static inline const struct obs_service_info *find_service(const char *id)
const struct obs_service_info *find_service(const char *id)
{
size_t i;
for (i = 0; i < obs->service_types.num; i++)

View File

@ -34,8 +34,7 @@ static inline bool source_valid(struct obs_source *source)
return source && source->context.data;
}
static inline const struct obs_source_info *find_source(struct darray *list,
const char *id)
const struct obs_source_info *find_source(struct darray *list, const char *id)
{
size_t i;
struct obs_source_info *array = list->array;