Skip to content

Commit

Permalink
Remove 'locale' parameter from all callbacks
Browse files Browse the repository at this point in the history
The locale parameter was a mistake, because it puts extra needless
burden upon the module developer to have to handle this variable for
each and every single callback function.  The parameter is being removed
in favor of a single centralized module callback function that
specifically updates locale information for a module only when needed.
  • Loading branch information
jp9000 committed Jun 25, 2014
1 parent 74b4743 commit 0b4a259
Show file tree
Hide file tree
Showing 38 changed files with 125 additions and 160 deletions.
13 changes: 6 additions & 7 deletions libobs/obs-encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ static inline struct obs_encoder_info *get_encoder_info(const char *id)
return NULL;
}

const char *obs_encoder_getdisplayname(const char *id, const char *locale)
const char *obs_encoder_getdisplayname(const char *id)
{
struct obs_encoder_info *ei = get_encoder_info(id);
return ei ? ei->getname(locale) : NULL;
return ei ? ei->getname() : NULL;
}

static bool init_encoder(struct obs_encoder *encoder, const char *name,
Expand Down Expand Up @@ -227,27 +227,26 @@ obs_data_t obs_encoder_defaults(const char *id)
return (info) ? get_defaults(info) : NULL;
}

obs_properties_t obs_get_encoder_properties(const char *id, const char *locale)
obs_properties_t obs_get_encoder_properties(const char *id)
{
const struct obs_encoder_info *ei = get_encoder_info(id);
if (ei && ei->properties) {
obs_data_t defaults = get_defaults(ei);
obs_properties_t properties;

properties = ei->properties(locale);
properties = ei->properties();
obs_properties_apply_settings(properties, defaults);
obs_data_release(defaults);
return properties;
}
return NULL;
}

obs_properties_t obs_encoder_properties(obs_encoder_t encoder,
const char *locale)
obs_properties_t obs_encoder_properties(obs_encoder_t encoder)
{
if (encoder && encoder->info.properties) {
obs_properties_t props;
props = encoder->info.properties(locale);
props = encoder->info.properties();
obs_properties_apply_settings(props, encoder->context.settings);
return props;
}
Expand Down
6 changes: 2 additions & 4 deletions libobs/obs-encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ struct obs_encoder_info {
/**
* Gets the full translated name of this encoder
*
* @param locale Locale to use for translation
* @return Translated name of the encoder
*/
const char *(*getname)(const char *locale);
const char *(*getname)(void);

/**
* Creates the encoder with the specified settings
Expand Down Expand Up @@ -155,10 +154,9 @@ struct obs_encoder_info {
/**
* Gets the property information of this encoder
*
* @param locale The locale to translate with
* @return The properties data
*/
obs_properties_t (*properties)(const char *locale);
obs_properties_t (*properties)(void);

/**
* Updates the settings for this encoder (usually used for things like
Expand Down
12 changes: 6 additions & 6 deletions libobs/obs-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ static inline const struct obs_output_info *find_output(const char *id)
return NULL;
}

const char *obs_output_getdisplayname(const char *id, const char *locale)
const char *obs_output_getdisplayname(const char *id)
{
const struct obs_output_info *info = find_output(id);
return (info != NULL) ? info->getname(locale) : NULL;
return (info != NULL) ? info->getname() : NULL;
}

static const char *output_signals[] = {
Expand Down Expand Up @@ -166,26 +166,26 @@ obs_data_t obs_output_defaults(const char *id)
return (info) ? get_defaults(info) : NULL;
}

obs_properties_t obs_get_output_properties(const char *id, const char *locale)
obs_properties_t obs_get_output_properties(const char *id)
{
const struct obs_output_info *info = find_output(id);
if (info && info->properties) {
obs_data_t defaults = get_defaults(info);
obs_properties_t properties;

properties = info->properties(locale);
properties = info->properties();
obs_properties_apply_settings(properties, defaults);
obs_data_release(defaults);
return properties;
}
return NULL;
}

obs_properties_t obs_output_properties(obs_output_t output, const char *locale)
obs_properties_t obs_output_properties(obs_output_t output)
{
if (output && output->info.properties) {
obs_properties_t props;
props = output->info.properties(locale);
props = output->info.properties();
obs_properties_apply_settings(props, output->context.settings);
return props;
}
Expand Down
4 changes: 2 additions & 2 deletions libobs/obs-output.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct obs_output_info {

uint32_t flags;

const char *(*getname)(const char *locale);
const char *(*getname)(void);

void *(*create)(obs_data_t settings, obs_output_t output);
void (*destroy)(void *data);
Expand All @@ -49,7 +49,7 @@ struct obs_output_info {

void (*defaults)(obs_data_t settings);

obs_properties_t (*properties)(const char *locale);
obs_properties_t (*properties)(void);

void (*pause)(void *data);
};
Expand Down
3 changes: 1 addition & 2 deletions libobs/obs-scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ static inline void signal_item_remove(struct obs_scene_item *item)
calldata_free(&params);
}

static const char *scene_getname(const char *locale)
static const char *scene_getname(void)
{
/* TODO: locale */
UNUSED_PARAMETER(locale);
return "Scene";
}

Expand Down
13 changes: 6 additions & 7 deletions libobs/obs-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ static inline const struct obs_service_info *find_service(const char *id)
return NULL;
}

const char *obs_service_getdisplayname(const char *id, const char *locale)
const char *obs_service_getdisplayname(const char *id)
{
const struct obs_service_info *info = find_service(id);
return (info != NULL) ? info->getname(locale) : NULL;
return (info != NULL) ? info->getname() : NULL;
}

obs_service_t obs_service_create(const char *id, const char *name,
Expand Down Expand Up @@ -112,27 +112,26 @@ obs_data_t obs_service_defaults(const char *id)
return (info) ? get_defaults(info) : NULL;
}

obs_properties_t obs_get_service_properties(const char *id, const char *locale)
obs_properties_t obs_get_service_properties(const char *id)
{
const struct obs_service_info *info = find_service(id);
if (info && info->properties) {
obs_data_t defaults = get_defaults(info);
obs_properties_t properties;

properties = info->properties(locale);
properties = info->properties();
obs_properties_apply_settings(properties, defaults);
obs_data_release(defaults);
return properties;
}
return NULL;
}

obs_properties_t obs_service_properties(obs_service_t service,
const char *locale)
obs_properties_t obs_service_properties(obs_service_t service)
{
if (service && service->info.properties) {
obs_properties_t props;
props = service->info.properties(locale);
props = service->info.properties();
obs_properties_apply_settings(props, service->context.settings);
return props;
}
Expand Down
4 changes: 2 additions & 2 deletions libobs/obs-service.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct obs_service_info {
/* required */
const char *id;

const char *(*getname)(const char *locale);
const char *(*getname)(void);
void *(*create)(obs_data_t settings, obs_service_t service);
void (*destroy)(void *data);

Expand All @@ -33,7 +33,7 @@ struct obs_service_info {

void (*defaults)(obs_data_t settings);

obs_properties_t (*properties)(const char *locale);
obs_properties_t (*properties)(void);

/**
* Called when getting ready to start up an output, before the encoders
Expand Down
13 changes: 6 additions & 7 deletions libobs/obs-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ bool obs_source_init_context(struct obs_source *source,
source_signals);
}

const char *obs_source_getdisplayname(enum obs_source_type type,
const char *id, const char *locale)
const char *obs_source_getdisplayname(enum obs_source_type type, const char *id)
{
const struct obs_source_info *info = get_source_info(type, id);
return (info != NULL) ? info->getname(locale) : NULL;
return (info != NULL) ? info->getname() : NULL;
}

/* internal initialization */
Expand Down Expand Up @@ -322,26 +321,26 @@ obs_data_t obs_source_settings(enum obs_source_type type, const char *id)
}

obs_properties_t obs_get_source_properties(enum obs_source_type type,
const char *id, const char *locale)
const char *id)
{
const struct obs_source_info *info = get_source_info(type, id);
if (info && info->properties) {
obs_data_t defaults = get_defaults(info);
obs_properties_t properties;

properties = info->properties(locale);
properties = info->properties();
obs_properties_apply_settings(properties, defaults);
obs_data_release(defaults);
return properties;
}
return NULL;
}

obs_properties_t obs_source_properties(obs_source_t source, const char *locale)
obs_properties_t obs_source_properties(obs_source_t source)
{
if (source_valid(source) && source->info.properties) {
obs_properties_t props;
props = source->info.properties(locale);
props = source->info.properties();
obs_properties_apply_settings(props, source->context.settings);
return props;
}
Expand Down
6 changes: 2 additions & 4 deletions libobs/obs-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ struct obs_source_info {
/**
* Get the translated name of the source type
*
* @param locale The locale to translate with
* @return The translated name of the source type
*/
const char *(*getname)(const char *locale);
const char *(*getname)(void);

/**
* Creates the source data for the source
Expand Down Expand Up @@ -161,10 +160,9 @@ struct obs_source_info {
/**
* Gets the property information of this source
*
* @param locale The locale to translate with
* @return The properties data
*/
obs_properties_t (*properties)(const char *locale);
obs_properties_t (*properties)(void);

/**
* Updates the settings for this source
Expand Down
34 changes: 12 additions & 22 deletions libobs/obs.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ EXPORT void obs_display_remove_draw_callback(obs_display_t display,

/** Returns the translated display name of a source */
EXPORT const char *obs_source_getdisplayname(enum obs_source_type type,
const char *id, const char *locale);
const char *id);

/**
* Creates a source of the specified type with the specified settings.
Expand Down Expand Up @@ -512,14 +512,13 @@ EXPORT obs_data_t obs_get_source_defaults(enum obs_source_type type,

/** Returns the property list, if any. Free with obs_properties_destroy */
EXPORT obs_properties_t obs_get_source_properties(enum obs_source_type type,
const char *id, const char *locale);
const char *id);

/**
* Returns the properties list for a specific existing source. Free with
* obs_properties_destroy
*/
EXPORT obs_properties_t obs_source_properties(obs_source_t source,
const char *locale);
EXPORT obs_properties_t obs_source_properties(obs_source_t source);

/** Updates settings for this source */
EXPORT void obs_source_update(obs_source_t source, obs_data_t settings);
Expand Down Expand Up @@ -752,8 +751,7 @@ EXPORT void obs_sceneitem_get_box_transform(obs_sceneitem_t item,
/* ------------------------------------------------------------------------- */
/* Outputs */

EXPORT const char *obs_output_getdisplayname(const char *id,
const char *locale);
EXPORT const char *obs_output_getdisplayname(const char *id);

/**
* Creates an output.
Expand All @@ -778,15 +776,13 @@ EXPORT bool obs_output_active(obs_output_t output);
EXPORT obs_data_t obs_output_defaults(const char *id);

/** Returns the property list, if any. Free with obs_properties_destroy */
EXPORT obs_properties_t obs_get_output_properties(const char *id,
const char *locale);
EXPORT obs_properties_t obs_get_output_properties(const char *id);

/**
* Returns the property list of an existing output, if any. Free with
* obs_properties_destroy
*/
EXPORT obs_properties_t obs_output_properties(obs_output_t output,
const char *locale);
EXPORT obs_properties_t obs_output_properties(obs_output_t output);

/** Updates the settings for this output context */
EXPORT void obs_output_update(obs_output_t output, obs_data_t settings);
Expand Down Expand Up @@ -898,8 +894,7 @@ EXPORT void obs_output_signal_stop(obs_output_t output, int code);
/* ------------------------------------------------------------------------- */
/* Encoders */

EXPORT const char *obs_encoder_getdisplayname(const char *id,
const char *locale);
EXPORT const char *obs_encoder_getdisplayname(const char *id);

/**
* Creates a video encoder context
Expand Down Expand Up @@ -933,15 +928,13 @@ EXPORT const char *obs_encoder_get_codec(obs_encoder_t encoder);
EXPORT obs_data_t obs_encoder_defaults(const char *id);

/** Returns the property list, if any. Free with obs_properties_destroy */
EXPORT obs_properties_t obs_get_encoder_properties(const char *id,
const char *locale);
EXPORT obs_properties_t obs_get_encoder_properties(const char *id);

/**
* Returns the property list of an existing encoder, if any. Free with
* obs_properties_destroy
*/
EXPORT obs_properties_t obs_encoder_properties(obs_encoder_t encoder,
const char *locale);
EXPORT obs_properties_t obs_encoder_properties(obs_encoder_t encoder);

/**
* Updates the settings of the encoder context. Usually used for changing
Expand Down Expand Up @@ -987,8 +980,7 @@ EXPORT void obs_free_encoder_packet(struct encoder_packet *packet);
/* ------------------------------------------------------------------------- */
/* Stream Services */

EXPORT const char *obs_service_getdisplayname(const char *id,
const char *locale);
EXPORT const char *obs_service_getdisplayname(const char *id);

EXPORT obs_service_t obs_service_create(const char *id, const char *name,
obs_data_t settings);
Expand All @@ -1000,15 +992,13 @@ EXPORT const char *obs_service_getname(obs_service_t service);
EXPORT obs_data_t obs_service_defaults(const char *id);

/** Returns the property list, if any. Free with obs_properties_destroy */
EXPORT obs_properties_t obs_get_service_properties(const char *id,
const char *locale);
EXPORT obs_properties_t obs_get_service_properties(const char *id);

/**
* Returns the property list of an existing service context, if any. Free with
* obs_properties_destroy
*/
EXPORT obs_properties_t obs_service_properties(obs_service_t service,
const char *locale);
EXPORT obs_properties_t obs_service_properties(obs_service_t service);

/** Gets the service type */
EXPORT const char *obs_service_gettype(obs_service_t service);
Expand Down
Loading

0 comments on commit 0b4a259

Please sign in to comment.