(API Change) libobs: Pass type data to get_name callbacks

API changed from:
obs_source_info::get_name(void)
obs_output_info::get_name(void)
obs_encoder_info::get_name(void)
obs_service_info::get_name(void)

API changed to:
obs_source_info::get_name(void *type_data)
obs_output_info::get_name(void *type_data)
obs_encoder_info::get_name(void *type_data)
obs_service_info::get_name(void *type_data)

This allows the type data to be used when getting the name of the
object (useful for plugin wrappers primarily).

NOTE: Though a parameter was added, this is backward-compatible with
older plugins due to calling convention.  The new parameter will simply
be ignored by older plugins, and the stack (if used) will be cleaned up
by the caller.
This commit is contained in:
jp9000
2015-09-16 01:30:51 -07:00
parent 0ed913a136
commit 6285a47726
52 changed files with 98 additions and 58 deletions

View File

@@ -33,7 +33,7 @@ struct obs_encoder_info *find_encoder(const char *id)
const char *obs_encoder_get_display_name(const char *id)
{
struct obs_encoder_info *ei = find_encoder(id);
return ei ? ei->get_name() : NULL;
return ei ? ei->get_name(ei->type_data) : NULL;
}
static bool init_encoder(struct obs_encoder *encoder, const char *name,

View File

@@ -120,9 +120,10 @@ struct obs_encoder_info {
/**
* Gets the full translated name of this encoder
*
* @return Translated name of the encoder
* @param type_data The type_data variable of this structure
* @return Translated name of the encoder
*/
const char *(*get_name)(void);
const char *(*get_name)(void *type_data);
/**
* Creates the encoder with the specified settings

View File

@@ -35,7 +35,7 @@ const struct obs_output_info *find_output(const char *id)
const char *obs_output_get_display_name(const char *id)
{
const struct obs_output_info *info = find_output(id);
return (info != NULL) ? info->get_name() : NULL;
return (info != NULL) ? info->get_name(info->type_data) : NULL;
}
static const char *output_signals[] = {

View File

@@ -36,7 +36,7 @@ struct obs_output_info {
uint32_t flags;
const char *(*get_name)(void);
const char *(*get_name)(void *type_data);
void *(*create)(obs_data_t *settings, obs_output_t *output);
void (*destroy)(void *data);

View File

@@ -42,9 +42,10 @@ static inline void signal_item_remove(struct obs_scene_item *item)
calldata_free(&params);
}
static const char *scene_getname(void)
static const char *scene_getname(void *unused)
{
/* TODO: locale */
UNUSED_PARAMETER(unused);
return "Scene";
}

View File

@@ -30,7 +30,7 @@ const struct obs_service_info *find_service(const char *id)
const char *obs_service_get_display_name(const char *id)
{
const struct obs_service_info *info = find_service(id);
return (info != NULL) ? info->get_name() : NULL;
return (info != NULL) ? info->get_name(info->type_data) : NULL;
}
obs_service_t *obs_service_create(const char *id, const char *name,

View File

@@ -32,7 +32,7 @@ struct obs_service_info {
/* required */
const char *id;
const char *(*get_name)(void);
const char *(*get_name)(void *type_data);
void *(*create)(obs_data_t *settings, obs_service_t *service);
void (*destroy)(void *data);

View File

@@ -112,7 +112,7 @@ const char *obs_source_get_display_name(enum obs_source_type type,
const char *id)
{
const struct obs_source_info *info = get_source_info(type, id);
return (info != NULL) ? info->get_name() : NULL;
return (info != NULL) ? info->get_name(info->type_data) : NULL;
}
/* internal initialization */

View File

@@ -133,9 +133,10 @@ struct obs_source_info {
/**
* Get the translated name of the source type
*
* @return The translated name of the source type
* @param type_data The type_data variable of this structure
* @return The translated name of the source type
*/
const char *(*get_name)(void);
const char *(*get_name)(void *type_data);
/**
* Creates the source data for the source