From 899f053034f2218925deeffe00215e1332181c95 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 25 Jun 2014 00:21:16 -0700 Subject: [PATCH 1/4] Add API for setting/getting current locale This API is used to set the current locale for libobs, which it will set for all modules when a module is loaded or specifically when the locale is manually changed. --- libobs/obs-internal.h | 2 ++ libobs/obs.c | 23 ++++++++++++++++++++--- libobs/obs.h | 19 +++++++++++++++++-- obs/window-basic-main.cpp | 2 +- test/osx/test.mm | 2 +- test/win/test.cpp | 2 +- 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index ddf71929d28823..c6fd25e7ed69fd 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -173,6 +173,8 @@ struct obs_core { signal_handler_t signals; proc_handler_t procs; + char *locale; + /* segmented into multiple sub-structures to keep things a bit more * clean and organized */ struct obs_core_video video; diff --git a/libobs/obs.c b/libobs/obs.c index ffe22795f1aa36..c0d4f4ff99e275 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -503,7 +503,7 @@ static inline bool obs_init_handlers(void) extern const struct obs_source_info scene_info; -static bool obs_init(void) +static bool obs_init(const char *locale) { obs = bzalloc(sizeof(struct obs_core)); @@ -512,11 +512,12 @@ static bool obs_init(void) if (!obs_init_handlers()) return false; + obs->locale = bstrdup(locale); obs_register_source(&scene_info); return true; } -bool obs_startup(void) +bool obs_startup(const char *locale) { bool success; @@ -525,7 +526,7 @@ bool obs_startup(void) return false; } - success = obs_init(); + success = obs_init(locale); if (!success) obs_shutdown(); @@ -559,6 +560,7 @@ void obs_shutdown(void) free_module(obs->modules.array+i); da_free(obs->modules); + bfree(obs->locale); bfree(obs); obs = NULL; } @@ -568,6 +570,21 @@ bool obs_initialized(void) return obs != NULL; } +void obs_set_locale(const char *locale) +{ + if (!obs) + return; + + if (obs->locale) + bfree(obs->locale); + obs->locale = bstrdup(locale); +} + +const char *obs_get_locale(void) +{ + return obs ? obs->locale : NULL; +} + bool obs_reset_video(struct obs_video_info *ovi) { if (!obs) return false; diff --git a/libobs/obs.h b/libobs/obs.h index 70b10503fcaf0d..3bccadd57a9dfb 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -197,8 +197,12 @@ struct source_frame { /* ------------------------------------------------------------------------- */ /* OBS context */ -/** Initializes OBS */ -EXPORT bool obs_startup(void); +/** + * Initializes OBS + * + * @param locale The locale to use for modules + */ +EXPORT bool obs_startup(const char *locale); /** Releases all data associated with OBS and terminates the OBS context */ EXPORT void obs_shutdown(void); @@ -206,6 +210,17 @@ EXPORT void obs_shutdown(void); /** @return true if the main OBS context has been initialized */ EXPORT bool obs_initialized(void); +/** + * Sets a new locale to use for modules. This will call obs_module_set_locale + * for each module with the new locale. + * + * @param locale The locale to use for modules + */ +EXPORT void obs_set_locale(const char *locale); + +/** @return the current locale */ +EXPORT const char *obs_get_locale(void); + /** * Sets base video ouput base resolution/fps/format * diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 10136bfbab9ab5..be29b571cc9d42 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -468,7 +468,7 @@ void OBSBasic::OBSInit() show(); App()->processEvents(); - if (!obs_startup()) + if (!obs_startup(App()->GetLocale())) throw "Failed to initialize libobs"; if (!InitBasicConfig()) throw "Failed to load basic.ini"; diff --git a/test/osx/test.mm b/test/osx/test.mm index bc346d53887f09..df03c3de6b46ba 100644 --- a/test/osx/test.mm +++ b/test/osx/test.mm @@ -38,7 +38,7 @@ explicit OBSUniqueHandle(T *obj=nullptr) : base(obj, D) {} static void CreateOBS(NSView *view) { - if (!obs_startup()) + if (!obs_startup("en")) throw "Couldn't create OBS"; struct obs_video_info ovi; diff --git a/test/win/test.cpp b/test/win/test.cpp index ef435ca8cfef7c..1cd4293197619c 100644 --- a/test/win/test.cpp +++ b/test/win/test.cpp @@ -71,7 +71,7 @@ static void CreateOBS(HWND hwnd) RECT rc; GetClientRect(hwnd, &rc); - if (!obs_startup()) + if (!obs_startup("en")) throw "Couldn't create OBS"; struct obs_video_info ovi; From 74b4743bce754a607b20121ba5d764f5db303c35 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 24 Jun 2014 23:54:10 -0700 Subject: [PATCH 2/4] Remove 'locale' from properties Having the value stored here is somewhat pointless, so this is one step in fixing the locale handling. Locale should be handled by the modules themselves with their own loaded locale lookup information. --- libobs/obs-properties.c | 17 +++++------------ libobs/obs-properties.h | 8 +++----- plugins/linux-pulseaudio/pulse-input.c | 2 +- plugins/linux-v4l2/v4l2-input.c | 2 +- plugins/linux-xcomposite/xcompcap-main.cpp | 2 +- plugins/linux-xshm/xshm-input.c | 2 +- plugins/mac-avcapture/av-capture.m | 2 +- plugins/mac-capture/mac-audio.c | 2 +- plugins/obs-ffmpeg/obs-ffmpeg-aac.c | 2 +- plugins/obs-libfdk/obs-libfdk.c | 2 +- plugins/obs-outputs/flv-output.c | 2 +- plugins/obs-outputs/rtmp-stream.c | 2 +- plugins/obs-x264/obs-x264.c | 2 +- plugins/rtmp-services/rtmp-common.c | 2 +- plugins/rtmp-services/rtmp-custom.c | 2 +- plugins/win-capture/window-capture.c | 2 +- plugins/win-dshow/win-dshow.cpp | 2 +- plugins/win-wasapi/win-wasapi.cpp | 2 +- 18 files changed, 24 insertions(+), 33 deletions(-) diff --git a/libobs/obs-properties.c b/libobs/obs-properties.c index ff7ab514bf4ab7..43c5f68ee7c4a8 100644 --- a/libobs/obs-properties.c +++ b/libobs/obs-properties.c @@ -90,7 +90,6 @@ struct obs_property { }; struct obs_properties { - const char *locale; void *param; void (*destroy)(void *param); @@ -98,12 +97,11 @@ struct obs_properties { struct obs_property **last; }; -obs_properties_t obs_properties_create(const char *locale) +obs_properties_t obs_properties_create(void) { struct obs_properties *props; props = bzalloc(sizeof(struct obs_properties)); - props->locale = locale; - props->last = &props->first_property; + props->last = &props->first_property; return props; } @@ -125,10 +123,10 @@ void *obs_properties_get_param(obs_properties_t props) return props ? props->param : NULL; } -obs_properties_t obs_properties_create_param(const char *locale, - void *param, void (*destroy)(void *param)) +obs_properties_t obs_properties_create_param(void *param, + void (*destroy)(void *param)) { - struct obs_properties *props = obs_properties_create(locale); + struct obs_properties *props = obs_properties_create(); obs_properties_set_param(props, param, destroy); return props; } @@ -161,11 +159,6 @@ void obs_properties_destroy(obs_properties_t props) } } -const char *obs_properties_locale(obs_properties_t props) -{ - return props ? props->locale : NULL; -} - obs_property_t obs_properties_first(obs_properties_t props) { return (props != NULL) ? props->first_property : NULL; diff --git a/libobs/obs-properties.h b/libobs/obs-properties.h index ed956fc493a68e..cd0656d9c9f50f 100644 --- a/libobs/obs-properties.h +++ b/libobs/obs-properties.h @@ -61,17 +61,15 @@ typedef struct obs_property *obs_property_t; /* ------------------------------------------------------------------------- */ -EXPORT obs_properties_t obs_properties_create(const char *locale); -EXPORT obs_properties_t obs_properties_create_param(const char *locale, - void *param, void (*destroy)(void *param)); +EXPORT obs_properties_t obs_properties_create(void); +EXPORT obs_properties_t obs_properties_create_param(void *param, + void (*destroy)(void *param)); EXPORT void obs_properties_destroy(obs_properties_t props); EXPORT void obs_properties_set_param(obs_properties_t props, void *param, void (*destroy)(void *param)); EXPORT void *obs_properties_get_param(obs_properties_t props); -EXPORT const char *obs_properties_locale(obs_properties_t props); - EXPORT obs_property_t obs_properties_first(obs_properties_t props); EXPORT obs_property_t obs_properties_get(obs_properties_t props, diff --git a/plugins/linux-pulseaudio/pulse-input.c b/plugins/linux-pulseaudio/pulse-input.c index 415612739347e9..40109a68063f2b 100644 --- a/plugins/linux-pulseaudio/pulse-input.c +++ b/plugins/linux-pulseaudio/pulse-input.c @@ -283,7 +283,7 @@ static void pulse_output_info(pa_context *c, const pa_source_info *i, int eol, */ static obs_properties_t pulse_properties(const char *locale, bool input) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); obs_property_t devices = obs_properties_add_list(props, "device_id", "Device", OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); diff --git a/plugins/linux-v4l2/v4l2-input.c b/plugins/linux-v4l2/v4l2-input.c index fe14808e01b314..aeae8a99baa90f 100644 --- a/plugins/linux-v4l2/v4l2-input.c +++ b/plugins/linux-v4l2/v4l2-input.c @@ -454,7 +454,7 @@ static bool resolution_selected(obs_properties_t props, obs_property_t p, static obs_properties_t v4l2_properties(const char *locale) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); obs_property_t device_list = obs_properties_add_list(props, "device_id", "Device", OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_t format_list = obs_properties_add_list(props, diff --git a/plugins/linux-xcomposite/xcompcap-main.cpp b/plugins/linux-xcomposite/xcompcap-main.cpp index bd9ec55f4d12e2..76b9c92633f4b4 100644 --- a/plugins/linux-xcomposite/xcompcap-main.cpp +++ b/plugins/linux-xcomposite/xcompcap-main.cpp @@ -48,7 +48,7 @@ void XCompcapMain::deinit() obs_properties_t XCompcapMain::properties(const char *locale) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); obs_property_t wins = obs_properties_add_list(props, "capture_window", "Captured Window", OBS_COMBO_TYPE_LIST, diff --git a/plugins/linux-xshm/xshm-input.c b/plugins/linux-xshm/xshm-input.c index ea0d07f1bbf440..2fce366144664b 100644 --- a/plugins/linux-xshm/xshm-input.c +++ b/plugins/linux-xshm/xshm-input.c @@ -156,7 +156,7 @@ static void xshm_defaults(obs_data_t defaults) */ static obs_properties_t xshm_properties(const char *locale) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); int_fast32_t screen_max; Display *dpy = XOpenDisplay(NULL); diff --git a/plugins/mac-avcapture/av-capture.m b/plugins/mac-avcapture/av-capture.m index 44d829be9e2fc9..183e7c6ea7c698 100644 --- a/plugins/mac-avcapture/av-capture.m +++ b/plugins/mac-avcapture/av-capture.m @@ -571,7 +571,7 @@ static bool properties_device_changed(obs_properties_t props, obs_property_t p, static obs_properties_t av_capture_properties(char const *locale) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); /* TODO: locale */ obs_property_t dev_list = obs_properties_add_list(props, "device", diff --git a/plugins/mac-capture/mac-audio.c b/plugins/mac-capture/mac-audio.c index 50e6fc318b5b77..0f1c953629e068 100644 --- a/plugins/mac-capture/mac-audio.c +++ b/plugins/mac-capture/mac-audio.c @@ -706,7 +706,7 @@ static void *coreaudio_create_output_capture(obs_data_t settings, static obs_properties_t coreaudio_properties(const char *locale, bool input) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); obs_property_t property; struct device_list devices; diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-aac.c b/plugins/obs-ffmpeg/obs-ffmpeg-aac.c index 1ae1f4026da3b4..bdd7b7fee9017c 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-aac.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-aac.c @@ -240,7 +240,7 @@ static void aac_defaults(obs_data_t settings) static obs_properties_t aac_properties(const char *locale) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); /* TODO: locale */ obs_properties_add_int(props, "bitrate", "Bitrate", 32, 320, 32); diff --git a/plugins/obs-libfdk/obs-libfdk.c b/plugins/obs-libfdk/obs-libfdk.c index 77369abc6ee2d6..f5f86999c473e6 100644 --- a/plugins/obs-libfdk/obs-libfdk.c +++ b/plugins/obs-libfdk/obs-libfdk.c @@ -67,7 +67,7 @@ static const char *libfdk_getname(const char *locale) static obs_properties_t libfdk_properties(const char *locale) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); obs_properties_add_int(props, "bitrate", "Bitrate", 32, 256, 32); obs_properties_add_bool(props, "afterburner", "Enable AAC Afterburner"); diff --git a/plugins/obs-outputs/flv-output.c b/plugins/obs-outputs/flv-output.c index 0a7e1345285a1d..fe83699bd46efc 100644 --- a/plugins/obs-outputs/flv-output.c +++ b/plugins/obs-outputs/flv-output.c @@ -191,7 +191,7 @@ static void flv_output_data(void *data, struct encoder_packet *packet) static obs_properties_t flv_output_properties(const char *locale) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); /* TODO: locale */ obs_properties_add_text(props, "path", "File Path", OBS_TEXT_DEFAULT); diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 154d3905b8cbdf..8fbcd4d7d6acb6 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -569,7 +569,7 @@ static void rtmp_stream_defaults(obs_data_t defaults) static obs_properties_t rtmp_stream_properties(const char *locale) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); /* TODO: locale */ obs_properties_add_text(props, "path", "Stream URL", OBS_TEXT_DEFAULT); diff --git a/plugins/obs-x264/obs-x264.c b/plugins/obs-x264/obs-x264.c index 718bc7fdbbab63..73e0c2131530b3 100644 --- a/plugins/obs-x264/obs-x264.c +++ b/plugins/obs-x264/obs-x264.c @@ -97,7 +97,7 @@ static obs_properties_t obs_x264_props(const char *locale) { /* TODO: locale */ - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); obs_property_t list; obs_properties_add_int(props, "bitrate", "Bitrate", 50, 100000, 1); diff --git a/plugins/rtmp-services/rtmp-common.c b/plugins/rtmp-services/rtmp-common.c index de76fcab40226e..5e9a9780d12b1c 100644 --- a/plugins/rtmp-services/rtmp-common.c +++ b/plugins/rtmp-services/rtmp-common.c @@ -202,7 +202,7 @@ static bool service_selected(obs_properties_t props, obs_property_t p, static obs_properties_t rtmp_common_properties(const char *locale) { - obs_properties_t ppts = obs_properties_create(locale); + obs_properties_t ppts = obs_properties_create(); obs_property_t list; char *file; diff --git a/plugins/rtmp-services/rtmp-custom.c b/plugins/rtmp-services/rtmp-custom.c index bb09a10f8fb06b..4e0e51202a1193 100644 --- a/plugins/rtmp-services/rtmp-custom.c +++ b/plugins/rtmp-services/rtmp-custom.c @@ -43,7 +43,7 @@ static void *rtmp_custom_create(obs_data_t settings, obs_service_t service) static obs_properties_t rtmp_custom_properties(const char *locale) { - obs_properties_t ppts = obs_properties_create(locale); + obs_properties_t ppts = obs_properties_create(); /* TODO: locale */ diff --git a/plugins/win-capture/window-capture.c b/plugins/win-capture/window-capture.c index 39e18ec697627e..e728ddec4cdf17 100644 --- a/plugins/win-capture/window-capture.c +++ b/plugins/win-capture/window-capture.c @@ -364,7 +364,7 @@ static void wc_defaults(obs_data_t defaults) static obs_properties_t wc_properties(const char *locale) { - obs_properties_t ppts = obs_properties_create(locale); + obs_properties_t ppts = obs_properties_create(); obs_property_t p; /* TODO: locale */ diff --git a/plugins/win-dshow/win-dshow.cpp b/plugins/win-dshow/win-dshow.cpp index 463b24fac79f65..8c044379d40a5b 100644 --- a/plugins/win-dshow/win-dshow.cpp +++ b/plugins/win-dshow/win-dshow.cpp @@ -780,7 +780,7 @@ static bool DeviceIntervalChanged(obs_properties_t props, obs_property_t p, static obs_properties_t GetDShowProperties(const char *locale) { - obs_properties_t ppts = obs_properties_create(locale); + obs_properties_t ppts = obs_properties_create(); PropertiesData *data = new PropertiesData; obs_properties_set_param(ppts, data, PropertiesDataDestroy); diff --git a/plugins/win-wasapi/win-wasapi.cpp b/plugins/win-wasapi/win-wasapi.cpp index 335b6b82b791a6..85d71b63190511 100644 --- a/plugins/win-wasapi/win-wasapi.cpp +++ b/plugins/win-wasapi/win-wasapi.cpp @@ -468,7 +468,7 @@ static void UpdateWASAPISource(void *obj, obs_data_t settings) static obs_properties_t GetWASAPIProperties(const char *locale, bool input) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); vector devices; /* TODO: translate */ From 0b4a259e561d9f3251cb9716ca82ebc2c89db89c Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 25 Jun 2014 00:13:00 -0700 Subject: [PATCH 3/4] Remove 'locale' parameter from all callbacks 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. --- libobs/obs-encoder.c | 13 ++++----- libobs/obs-encoder.h | 6 ++-- libobs/obs-output.c | 12 ++++---- libobs/obs-output.h | 4 +-- libobs/obs-scene.c | 3 +- libobs/obs-service.c | 13 ++++----- libobs/obs-service.h | 4 +-- libobs/obs-source.c | 13 ++++----- libobs/obs-source.h | 6 ++-- libobs/obs.h | 34 ++++++++-------------- obs/window-basic-main.cpp | 5 ++-- obs/window-basic-properties.cpp | 4 +-- obs/window-basic-settings.cpp | 10 +++---- obs/window-basic-source-select.cpp | 3 +- plugins/linux-pulseaudio/pulse-input.c | 18 ++++++------ plugins/linux-v4l2/v4l2-input.c | 7 +++-- plugins/linux-xcomposite/plugin-main.cpp | 9 +++--- plugins/linux-xcomposite/xcompcap-main.cpp | 2 +- plugins/linux-xcomposite/xcompcap-main.h | 2 +- plugins/linux-xshm/xshm-input.c | 7 +++-- plugins/mac-avcapture/av-capture.m | 5 ++-- plugins/mac-capture/mac-audio.c | 16 +++++----- plugins/obs-ffmpeg/obs-ffmpeg-aac.c | 6 ++-- plugins/obs-ffmpeg/obs-ffmpeg-output.c | 4 +-- plugins/obs-libfdk/obs-libfdk.c | 6 ++-- plugins/obs-outputs/flv-output.c | 6 ++-- plugins/obs-outputs/rtmp-stream.c | 5 ++-- plugins/obs-x264/obs-x264.c | 5 ++-- plugins/rtmp-services/rtmp-common.c | 6 ++-- plugins/rtmp-services/rtmp-custom.c | 6 ++-- plugins/win-capture/monitor-capture.c | 4 +-- plugins/win-capture/window-capture.c | 5 ++-- plugins/win-dshow/win-dshow.cpp | 6 ++-- plugins/win-wasapi/win-wasapi.cpp | 14 ++++----- test/test-input/test-desktop.m | 7 ++--- test/test-input/test-filter.c | 3 +- test/test-input/test-random.c | 3 +- test/test-input/test-sinewave.c | 3 +- 38 files changed, 125 insertions(+), 160 deletions(-) diff --git a/libobs/obs-encoder.c b/libobs/obs-encoder.c index bbeb99f87d8477..b900a2e048aa5a 100644 --- a/libobs/obs-encoder.c +++ b/libobs/obs-encoder.c @@ -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, @@ -227,14 +227,14 @@ 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; @@ -242,12 +242,11 @@ obs_properties_t obs_get_encoder_properties(const char *id, const char *locale) 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; } diff --git a/libobs/obs-encoder.h b/libobs/obs-encoder.h index 1b0cd3d410e14c..ca8ff16cdcf1de 100644 --- a/libobs/obs-encoder.h +++ b/libobs/obs-encoder.h @@ -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 @@ -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 diff --git a/libobs/obs-output.c b/libobs/obs-output.c index 8415f9662734cf..62ee4835ac0fbd 100644 --- a/libobs/obs-output.c +++ b/libobs/obs-output.c @@ -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[] = { @@ -166,14 +166,14 @@ 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; @@ -181,11 +181,11 @@ obs_properties_t obs_get_output_properties(const char *id, const char *locale) 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; } diff --git a/libobs/obs-output.h b/libobs/obs-output.h index 76b738f4434e02..ec4e32cf321dfc 100644 --- a/libobs/obs-output.h +++ b/libobs/obs-output.h @@ -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); @@ -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); }; diff --git a/libobs/obs-scene.c b/libobs/obs-scene.c index c335ed0013b6b3..c038e5420cf70a 100644 --- a/libobs/obs-scene.c +++ b/libobs/obs-scene.c @@ -43,10 +43,9 @@ static inline void signal_item_remove(struct obs_scene_item *item) calldata_free(¶ms); } -static const char *scene_getname(const char *locale) +static const char *scene_getname(void) { /* TODO: locale */ - UNUSED_PARAMETER(locale); return "Scene"; } diff --git a/libobs/obs-service.c b/libobs/obs-service.c index bd4eb60660a889..e19d350e6698bc 100644 --- a/libobs/obs-service.c +++ b/libobs/obs-service.c @@ -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, @@ -112,14 +112,14 @@ 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; @@ -127,12 +127,11 @@ obs_properties_t obs_get_service_properties(const char *id, const char *locale) 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; } diff --git a/libobs/obs-service.h b/libobs/obs-service.h index 676c8d4d44f03b..c053d4b891a5b7 100644 --- a/libobs/obs-service.h +++ b/libobs/obs-service.h @@ -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); @@ -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 diff --git a/libobs/obs-source.c b/libobs/obs-source.c index fba15897d04bc0..8bc5083cdc8b4c 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -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 */ @@ -322,14 +321,14 @@ 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; @@ -337,11 +336,11 @@ obs_properties_t obs_get_source_properties(enum obs_source_type type, 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; } diff --git a/libobs/obs-source.h b/libobs/obs-source.h index 479fd4b44f3896..a7b5be99c712e3 100644 --- a/libobs/obs-source.h +++ b/libobs/obs-source.h @@ -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 @@ -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 diff --git a/libobs/obs.h b/libobs/obs.h index 3bccadd57a9dfb..a82d49789e11a2 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -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. @@ -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); @@ -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. @@ -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); @@ -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 @@ -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 @@ -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); @@ -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); diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index be29b571cc9d42..285e4f537730b7 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -210,7 +210,7 @@ static inline bool HasAudioDevices(const char *source_id) { const char *output_id = source_id; obs_properties_t props = obs_get_source_properties( - OBS_SOURCE_TYPE_INPUT, output_id, App()->GetLocale()); + OBS_SOURCE_TYPE_INPUT, output_id); size_t count = 0; if (!props) @@ -1299,8 +1299,7 @@ void OBSBasic::AddSourcePopupMenu(const QPoint &pos) QMenu popup; while (obs_enum_input_types(idx++, &type)) { const char *name = obs_source_getdisplayname( - OBS_SOURCE_TYPE_INPUT, - type, App()->GetLocale()); + OBS_SOURCE_TYPE_INPUT, type); if (strcmp(type, "scene") == 0) continue; diff --git a/obs/window-basic-properties.cpp b/obs/window-basic-properties.cpp index 1310cc1d248f99..954575a5cb8723 100644 --- a/obs/window-basic-properties.cpp +++ b/obs/window-basic-properties.cpp @@ -44,8 +44,8 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_) obs_data_release(settings); view = new OBSPropertiesView(settings, - obs_source_properties(source, App()->GetLocale()), - source, (PropertiesUpdateCallback)obs_source_update); + obs_source_properties(source), source, + (PropertiesUpdateCallback)obs_source_update); layout()->addWidget(view); layout()->setAlignment(view, Qt::AlignBottom); diff --git a/obs/window-basic-settings.cpp b/obs/window-basic-settings.cpp index 276d9818114e6d..655a43970ab25b 100644 --- a/obs/window-basic-settings.cpp +++ b/obs/window-basic-settings.cpp @@ -212,8 +212,7 @@ void OBSBasicSettings::LoadServiceTypes() size_t idx = 0; while (obs_enum_service_types(idx++, &type)) { - const char *name = obs_service_getdisplayname(type, - App()->GetLocale()); + const char *name = obs_service_getdisplayname(type); QString qName = QT_UTF8(name); QString qType = QT_UTF8(type); @@ -229,8 +228,7 @@ void OBSBasicSettings::LoadServiceInfo() QLayout *layout = ui->streamContainer->layout(); obs_service_t service = main->GetService(); obs_data_t settings = obs_service_get_settings(service); - obs_properties_t properties = obs_service_properties(service, - App()->GetLocale()); + obs_properties_t properties = obs_service_properties(service); delete streamProperties; streamProperties = new OBSPropertiesView( @@ -480,9 +478,9 @@ void OBSBasicSettings::LoadAudioDevices() const char *output_id = App()->OutputAudioSource(); obs_properties_t input_props = obs_get_source_properties( - OBS_SOURCE_TYPE_INPUT, input_id, App()->GetLocale()); + OBS_SOURCE_TYPE_INPUT, input_id); obs_properties_t output_props = obs_get_source_properties( - OBS_SOURCE_TYPE_INPUT, output_id, App()->GetLocale()); + OBS_SOURCE_TYPE_INPUT, output_id); if (input_props) { obs_property_t inputs = obs_properties_get(input_props, diff --git a/obs/window-basic-source-select.cpp b/obs/window-basic-source-select.cpp index b4a6beae68b25e..76f97c3b9cd525 100644 --- a/obs/window-basic-source-select.cpp +++ b/obs/window-basic-source-select.cpp @@ -169,8 +169,7 @@ OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, const char *type_) ui->setupUi(this); QString placeHolderText{QT_UTF8(obs_source_getdisplayname( - OBS_SOURCE_TYPE_INPUT, - type_, App()->GetLocale()))}; + OBS_SOURCE_TYPE_INPUT, type_))}; QString text{placeHolderText}; int i = 1; diff --git a/plugins/linux-pulseaudio/pulse-input.c b/plugins/linux-pulseaudio/pulse-input.c index 40109a68063f2b..659b241106c26c 100644 --- a/plugins/linux-pulseaudio/pulse-input.c +++ b/plugins/linux-pulseaudio/pulse-input.c @@ -281,7 +281,7 @@ static void pulse_output_info(pa_context *c, const pa_source_info *i, int eol, /** * Get plugin properties */ -static obs_properties_t pulse_properties(const char *locale, bool input) +static obs_properties_t pulse_properties(bool input) { obs_properties_t props = obs_properties_create(); obs_property_t devices = obs_properties_add_list(props, "device_id", @@ -295,14 +295,14 @@ static obs_properties_t pulse_properties(const char *locale, bool input) return props; } -static obs_properties_t pulse_input_properties(const char *locale) +static obs_properties_t pulse_input_properties(void) { - return pulse_properties(locale, true); + return pulse_properties(true); } -static obs_properties_t pulse_output_properties(const char *locale) +static obs_properties_t pulse_output_properties(void) { - return pulse_properties(locale, false); + return pulse_properties(false); } /** @@ -366,15 +366,15 @@ static void pulse_output_defaults(obs_data_t settings) /** * Returns the name of the plugin */ -static const char *pulse_input_getname(const char *locale) +static const char *pulse_input_getname(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "Pulse Audio Input Capture"; } -static const char *pulse_output_getname(const char *locale) +static const char *pulse_output_getname(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "Pulse Audio Output Capture"; } diff --git a/plugins/linux-v4l2/v4l2-input.c b/plugins/linux-v4l2/v4l2-input.c index aeae8a99baa90f..21f94d74ef3a7b 100644 --- a/plugins/linux-v4l2/v4l2-input.c +++ b/plugins/linux-v4l2/v4l2-input.c @@ -266,9 +266,9 @@ static void *v4l2_thread(void *vptr) return NULL; } -static const char* v4l2_getname(const char* locale) +static const char* v4l2_getname(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "V4L2 Capture Input"; } @@ -452,8 +452,9 @@ static bool resolution_selected(obs_properties_t props, obs_property_t p, return true; } -static obs_properties_t v4l2_properties(const char *locale) +static obs_properties_t v4l2_properties(void) { + /* TODO: locale */ obs_properties_t props = obs_properties_create(); obs_property_t device_list = obs_properties_add_list(props, "device_id", "Device", OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); diff --git a/plugins/linux-xcomposite/plugin-main.cpp b/plugins/linux-xcomposite/plugin-main.cpp index cd814852b8abd5..b6f21aed594459 100644 --- a/plugins/linux-xcomposite/plugin-main.cpp +++ b/plugins/linux-xcomposite/plugin-main.cpp @@ -37,9 +37,9 @@ static uint32_t xcompcap_getheight(void* data) return cc->height(); } -static obs_properties_t xcompcap_props(const char *locale) +static obs_properties_t xcompcap_props(void) { - return XCompcapMain::properties(locale); + return XCompcapMain::properties(); } void xcompcap_defaults(obs_data_t settings) @@ -55,10 +55,9 @@ void xcompcap_update(void *data, obs_data_t settings) OBS_DECLARE_MODULE() -static const char* xcompcap_getname(const char* locale) +static const char* xcompcap_getname(void) { - UNUSED_PARAMETER(locale); - + /* TODO: locale */ return "Xcomposite capture"; } diff --git a/plugins/linux-xcomposite/xcompcap-main.cpp b/plugins/linux-xcomposite/xcompcap-main.cpp index 76b9c92633f4b4..5ca630a3a90630 100644 --- a/plugins/linux-xcomposite/xcompcap-main.cpp +++ b/plugins/linux-xcomposite/xcompcap-main.cpp @@ -46,7 +46,7 @@ void XCompcapMain::deinit() XCompcap::cleanupDisplay(); } -obs_properties_t XCompcapMain::properties(const char *locale) +obs_properties_t XCompcapMain::properties() { obs_properties_t props = obs_properties_create(); diff --git a/plugins/linux-xcomposite/xcompcap-main.h b/plugins/linux-xcomposite/xcompcap-main.h index 8d231764ab6417..5bf64a21588582 100644 --- a/plugins/linux-xcomposite/xcompcap-main.h +++ b/plugins/linux-xcomposite/xcompcap-main.h @@ -8,7 +8,7 @@ class XCompcapMain static bool init(); static void deinit(); - static obs_properties_t properties(const char *locale); + static obs_properties_t properties(); static void defaults(obs_data_t settings); XCompcapMain(obs_data_t settings, obs_source_t source); diff --git a/plugins/linux-xshm/xshm-input.c b/plugins/linux-xshm/xshm-input.c index 2fce366144664b..8d032995d47db6 100644 --- a/plugins/linux-xshm/xshm-input.c +++ b/plugins/linux-xshm/xshm-input.c @@ -108,9 +108,9 @@ static int_fast32_t xshm_update_geometry(struct xshm_data *data, /** * Returns the name of the plugin */ -static const char* xshm_getname(const char* locale) +static const char* xshm_getname(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "X11 Shared Memory Screen Input"; } @@ -154,8 +154,9 @@ static void xshm_defaults(obs_data_t defaults) /** * Get the properties for the capture */ -static obs_properties_t xshm_properties(const char *locale) +static obs_properties_t xshm_properties(void) { + /* TODO: locale */ obs_properties_t props = obs_properties_create(); int_fast32_t screen_max; diff --git a/plugins/mac-avcapture/av-capture.m b/plugins/mac-avcapture/av-capture.m index 183e7c6ea7c698..9e178c9e85e26f 100644 --- a/plugins/mac-avcapture/av-capture.m +++ b/plugins/mac-avcapture/av-capture.m @@ -131,10 +131,9 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput } @end -static const char *av_capture_getname(const char *locale) +static const char *av_capture_getname(void) { /* TODO: locale */ - UNUSED_PARAMETER(locale); return "Video Capture Device"; } @@ -569,7 +568,7 @@ static bool properties_device_changed(obs_properties_t props, obs_property_t p, return true; } -static obs_properties_t av_capture_properties(char const *locale) +static obs_properties_t av_capture_properties(void) { obs_properties_t props = obs_properties_create(); diff --git a/plugins/mac-capture/mac-audio.c b/plugins/mac-capture/mac-audio.c index 0f1c953629e068..22b560658e5d2e 100644 --- a/plugins/mac-capture/mac-audio.c +++ b/plugins/mac-capture/mac-audio.c @@ -628,17 +628,15 @@ static void coreaudio_uninit(struct coreaudio_data *ca) /* ------------------------------------------------------------------------- */ -static const char *coreaudio_input_getname(const char *locale) +static const char *coreaudio_input_getname(void) { /* TODO: Locale */ - UNUSED_PARAMETER(locale); return "CoreAudio Input Capture"; } -static const char *coreaudio_output_getname(const char *locale) +static const char *coreaudio_output_getname(void) { /* TODO: Locale */ - UNUSED_PARAMETER(locale); return "CoreAudio Output Capture"; } @@ -704,7 +702,7 @@ static void *coreaudio_create_output_capture(obs_data_t settings, return coreaudio_create(settings, source, false); } -static obs_properties_t coreaudio_properties(const char *locale, bool input) +static obs_properties_t coreaudio_properties(bool input) { obs_properties_t props = obs_properties_create(); obs_property_t property; @@ -732,14 +730,14 @@ static obs_properties_t coreaudio_properties(const char *locale, bool input) return props; } -static obs_properties_t coreaudio_input_properties(const char *locale) +static obs_properties_t coreaudio_input_properties(void) { - return coreaudio_properties(locale, true); + return coreaudio_properties(true); } -static obs_properties_t coreaudio_output_properties(const char *locale) +static obs_properties_t coreaudio_output_properties(void) { - return coreaudio_properties(locale, false); + return coreaudio_properties(false); } struct obs_source_info coreaudio_input_capture_info = { diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-aac.c b/plugins/obs-ffmpeg/obs-ffmpeg-aac.c index bdd7b7fee9017c..3457ed70c35648 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-aac.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-aac.c @@ -44,9 +44,9 @@ struct aac_encoder { int frame_size_bytes; }; -static const char *aac_getname(const char *locale) +static const char *aac_getname(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "FFmpeg Default AAC Encoder"; } @@ -238,7 +238,7 @@ static void aac_defaults(obs_data_t settings) obs_data_set_default_int(settings, "bitrate", 128); } -static obs_properties_t aac_properties(const char *locale) +static obs_properties_t aac_properties(void) { obs_properties_t props = obs_properties_create(); diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.c b/plugins/obs-ffmpeg/obs-ffmpeg-output.c index 2eca7304a26435..e6cf94f0a52408 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-output.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.c @@ -396,9 +396,9 @@ static bool ffmpeg_data_init(struct ffmpeg_data *data, const char *filename, /* ------------------------------------------------------------------------- */ -static const char *ffmpeg_output_getname(const char *locale) +static const char *ffmpeg_output_getname(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "FFmpeg file output"; } diff --git a/plugins/obs-libfdk/obs-libfdk.c b/plugins/obs-libfdk/obs-libfdk.c index f5f86999c473e6..9a3d91354842a0 100644 --- a/plugins/obs-libfdk/obs-libfdk.c +++ b/plugins/obs-libfdk/obs-libfdk.c @@ -59,13 +59,13 @@ typedef struct libfdk_encoder { int packet_buffer_size; } libfdk_encoder_t; -static const char *libfdk_getname(const char *locale) +static const char *libfdk_getname(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "libfdk aac encoder"; } -static obs_properties_t libfdk_properties(const char *locale) +static obs_properties_t libfdk_properties(void) { obs_properties_t props = obs_properties_create(); diff --git a/plugins/obs-outputs/flv-output.c b/plugins/obs-outputs/flv-output.c index fe83699bd46efc..7b84fa1ae7ea57 100644 --- a/plugins/obs-outputs/flv-output.c +++ b/plugins/obs-outputs/flv-output.c @@ -32,9 +32,9 @@ struct flv_output { int64_t last_packet_ts; }; -static const char *flv_output_getname(const char *locale) +static const char *flv_output_getname(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "FLV File Output"; } @@ -189,7 +189,7 @@ static void flv_output_data(void *data, struct encoder_packet *packet) } } -static obs_properties_t flv_output_properties(const char *locale) +static obs_properties_t flv_output_properties(void) { obs_properties_t props = obs_properties_create(); diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 8fbcd4d7d6acb6..baf4a964e0d5cf 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -61,10 +61,9 @@ struct rtmp_stream { RTMP rtmp; }; -static const char *rtmp_stream_getname(const char *locale) +static const char *rtmp_stream_getname(void) { /* TODO: locale stuff */ - UNUSED_PARAMETER(locale); return "RTMP Stream"; } @@ -567,7 +566,7 @@ static void rtmp_stream_defaults(obs_data_t defaults) obs_data_set_default_int(defaults, "drop_threshold", 600000); } -static obs_properties_t rtmp_stream_properties(const char *locale) +static obs_properties_t rtmp_stream_properties(void) { obs_properties_t props = obs_properties_create(); diff --git a/plugins/obs-x264/obs-x264.c b/plugins/obs-x264/obs-x264.c index 73e0c2131530b3..5f043c1c3d5a96 100644 --- a/plugins/obs-x264/obs-x264.c +++ b/plugins/obs-x264/obs-x264.c @@ -38,10 +38,9 @@ struct obs_x264 { /* ------------------------------------------------------------------------- */ -static const char *obs_x264_getname(const char *locale) +static const char *obs_x264_getname(void) { /* TODO locale lookup */ - UNUSED_PARAMETER(locale); return "x264"; } @@ -93,7 +92,7 @@ static inline void add_strings(obs_property_t list, const char *const *strings) } } -static obs_properties_t obs_x264_props(const char *locale) +static obs_properties_t obs_x264_props(void) { /* TODO: locale */ diff --git a/plugins/rtmp-services/rtmp-common.c b/plugins/rtmp-services/rtmp-common.c index 5e9a9780d12b1c..c96174604172e2 100644 --- a/plugins/rtmp-services/rtmp-common.c +++ b/plugins/rtmp-services/rtmp-common.c @@ -8,10 +8,8 @@ struct rtmp_common { char *key; }; -static const char *rtmp_common_getname(const char *locale) +static const char *rtmp_common_getname(void) { - UNUSED_PARAMETER(locale); - /* TODO: locale */ return "Streaming Services"; } @@ -200,7 +198,7 @@ static bool service_selected(obs_properties_t props, obs_property_t p, return true; } -static obs_properties_t rtmp_common_properties(const char *locale) +static obs_properties_t rtmp_common_properties(void) { obs_properties_t ppts = obs_properties_create(); obs_property_t list; diff --git a/plugins/rtmp-services/rtmp-custom.c b/plugins/rtmp-services/rtmp-custom.c index 4e0e51202a1193..875b3243f19237 100644 --- a/plugins/rtmp-services/rtmp-custom.c +++ b/plugins/rtmp-services/rtmp-custom.c @@ -4,10 +4,8 @@ struct rtmp_custom { char *server, *key; }; -static const char *rtmp_custom_name(const char *locale) +static const char *rtmp_custom_name(void) { - UNUSED_PARAMETER(locale); - /* TODO: locale */ return "Custom Streaming Server"; } @@ -41,7 +39,7 @@ static void *rtmp_custom_create(obs_data_t settings, obs_service_t service) return data; } -static obs_properties_t rtmp_custom_properties(const char *locale) +static obs_properties_t rtmp_custom_properties(void) { obs_properties_t ppts = obs_properties_create(); diff --git a/plugins/win-capture/monitor-capture.c b/plugins/win-capture/monitor-capture.c index 719a60d3cf5f3c..8f72e2ebfba4c4 100644 --- a/plugins/win-capture/monitor-capture.c +++ b/plugins/win-capture/monitor-capture.c @@ -81,9 +81,9 @@ static inline void update_settings(struct monitor_capture *capture, /* ------------------------------------------------------------------------- */ -static const char *monitor_capture_getname(const char *locale) +static const char *monitor_capture_getname(void) { - /* TODO: translate */ + /* TODO: locale */ return "Monitor Capture"; } diff --git a/plugins/win-capture/window-capture.c b/plugins/win-capture/window-capture.c index e728ddec4cdf17..02ecc69a4d7c3f 100644 --- a/plugins/win-capture/window-capture.c +++ b/plugins/win-capture/window-capture.c @@ -294,10 +294,9 @@ static HWND find_window(struct window_capture *wc) /* ------------------------------------------------------------------------- */ -static const char *wc_getname(const char *locale) +static const char *wc_getname(void) { /* TODO: locale */ - UNUSED_PARAMETER(locale); return "Window capture"; } @@ -362,7 +361,7 @@ static void wc_defaults(obs_data_t defaults) obs_data_setbool(defaults, "compatibility", false); } -static obs_properties_t wc_properties(const char *locale) +static obs_properties_t wc_properties(void) { obs_properties_t ppts = obs_properties_create(); obs_property_t p; diff --git a/plugins/win-dshow/win-dshow.cpp b/plugins/win-dshow/win-dshow.cpp index 8c044379d40a5b..1d1a8a6fdc234a 100644 --- a/plugins/win-dshow/win-dshow.cpp +++ b/plugins/win-dshow/win-dshow.cpp @@ -251,9 +251,9 @@ void DShowInput::Update(obs_data_t settings) /* ------------------------------------------------------------------------- */ -static const char *GetDShowInputName(const char *locale) +static const char *GetDShowInputName(void) { - UNUSED_PARAMETER(locale); + /* TODO: locale */ return "Video Capture Device"; } @@ -778,7 +778,7 @@ static bool DeviceIntervalChanged(obs_properties_t props, obs_property_t p, return true; } -static obs_properties_t GetDShowProperties(const char *locale) +static obs_properties_t GetDShowProperties(void) { obs_properties_t ppts = obs_properties_create(); PropertiesData *data = new PropertiesData; diff --git a/plugins/win-wasapi/win-wasapi.cpp b/plugins/win-wasapi/win-wasapi.cpp index 85d71b63190511..366fd08bc9ee41 100644 --- a/plugins/win-wasapi/win-wasapi.cpp +++ b/plugins/win-wasapi/win-wasapi.cpp @@ -416,13 +416,13 @@ DWORD WINAPI WASAPISource::CaptureThread(LPVOID param) /* ------------------------------------------------------------------------- */ -static const char *GetWASAPIInputName(const char *locale) +static const char *GetWASAPIInputName(void) { /* TODO: translate */ return "Audio Input Capture (WASAPI)"; } -static const char *GetWASAPIOutputName(const char *locale) +static const char *GetWASAPIOutputName(void) { /* TODO: translate */ return "Audio Output Capture (WASAPI)"; @@ -466,7 +466,7 @@ static void UpdateWASAPISource(void *obj, obs_data_t settings) static_cast(obj)->Update(settings); } -static obs_properties_t GetWASAPIProperties(const char *locale, bool input) +static obs_properties_t GetWASAPIProperties(bool input) { obs_properties_t props = obs_properties_create(); vector devices; @@ -494,14 +494,14 @@ static obs_properties_t GetWASAPIProperties(const char *locale, bool input) return props; } -static obs_properties_t GetWASAPIPropertiesInput(const char *locale) +static obs_properties_t GetWASAPIPropertiesInput(void) { - return GetWASAPIProperties(locale, true); + return GetWASAPIProperties(true); } -static obs_properties_t GetWASAPIPropertiesOutput(const char *locale) +static obs_properties_t GetWASAPIPropertiesOutput(void) { - return GetWASAPIProperties(locale, false); + return GetWASAPIProperties(false); } void RegisterWASAPIInput() diff --git a/test/test-input/test-desktop.m b/test/test-input/test-desktop.m index ac114128f720fd..77b88b08692347 100644 --- a/test/test-input/test-desktop.m +++ b/test/test-input/test-desktop.m @@ -258,9 +258,8 @@ static void display_capture_video_render(void *data, effect_t effect) technique_end(tech); } -static const char *display_capture_getname(const char *locale) +static const char *display_capture_getname(void) { - UNUSED_PARAMETER(locale); return "Display Capture"; } @@ -300,9 +299,9 @@ static void display_capture_update(void *data, obs_data_t settings) gs_leavecontext(); } -static obs_properties_t display_capture_properties(char const *locale) +static obs_properties_t display_capture_properties(void) { - obs_properties_t props = obs_properties_create(locale); + obs_properties_t props = obs_properties_create(); obs_property_t list = obs_properties_add_list(props, "display", "Display", diff --git a/test/test-input/test-filter.c b/test/test-input/test-filter.c index 478bc37b9552a6..ae993c6c8c0268 100644 --- a/test/test-input/test-filter.c +++ b/test/test-input/test-filter.c @@ -5,9 +5,8 @@ struct test_filter { effect_t whatever; }; -static const char *filter_getname(const char *locale) +static const char *filter_getname(void) { - UNUSED_PARAMETER(locale); return "Test"; } diff --git a/test/test-input/test-random.c b/test/test-input/test-random.c index 761c5325720d56..34af3026779dc0 100644 --- a/test/test-input/test-random.c +++ b/test/test-input/test-random.c @@ -10,9 +10,8 @@ struct random_tex { bool initialized; }; -static const char *random_getname(const char *locale) +static const char *random_getname(void) { - UNUSED_PARAMETER(locale); return "20x20 Random Pixel Texture Source (Test)"; } diff --git a/test/test-input/test-sinewave.c b/test/test-input/test-sinewave.c index dae293483ab50e..e9dba67cf32808 100644 --- a/test/test-input/test-sinewave.c +++ b/test/test-input/test-sinewave.c @@ -58,9 +58,8 @@ static void *sinewave_thread(void *pdata) /* ------------------------------------------------------------------------- */ -static const char *sinewave_getname(const char *locale) +static const char *sinewave_getname(void) { - UNUSED_PARAMETER(locale); return "Sinewave Sound Source (Test)"; } From 1abf91577ed4c7683eae6d06bcb78f55330a0c29 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 25 Jun 2014 00:22:54 -0700 Subject: [PATCH 4/4] Add module callbacks for loading locale data The module callback obs_module_set_locale will be called after loading the module, and any time the locale is manually changed via core API. When this function is called, the module is expected to load new text lookup values for all the text it uses based upon the current locale. --- libobs/obs-internal.h | 1 + libobs/obs-module.c | 7 ++++++- libobs/obs-module.h | 11 +++++------ libobs/obs.c | 7 +++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index c6fd25e7ed69fd..80226df610f006 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -52,6 +52,7 @@ struct draw_callback { struct obs_module { char *name; void *module; + void (*set_locale)(const char *locale); }; extern void free_module(struct obs_module *mod); diff --git a/libobs/obs-module.c b/libobs/obs-module.c index f081fbcddb70f3..a94d84d0ca5f2a 100644 --- a/libobs/obs-module.c +++ b/libobs/obs-module.c @@ -73,7 +73,12 @@ int obs_load_module(const char *path) return errorcode; } - mod.name = bstrdup(path); + mod.name = bstrdup(path); + mod.set_locale = os_dlsym(mod.module, "obs_module_set_locale"); + + if (mod.set_locale) + mod.set_locale(obs->locale); + da_push_back(obs->modules, &mod); return MODULE_SUCCESS; } diff --git a/libobs/obs-module.h b/libobs/obs-module.h index 61b7c6269457ee..9fc899ae2acde6 100644 --- a/libobs/obs-module.h +++ b/libobs/obs-module.h @@ -50,6 +50,9 @@ MODULE_EXPORT bool obs_module_load(uint32_t libobs_version); /** Optional: Called when the module is unloaded. */ MODULE_EXPORT void obs_module_unload(void); +/** Called to set the current locale data for the module. */ +MODULE_EXPORT void obs_module_set_locale(const char *locale); + /** * Optional: Declares the author(s) of the module * @@ -59,9 +62,5 @@ MODULE_EXPORT void obs_module_unload(void); MODULE_EXPORT const char *obs_module_author(void); \ const char *obs_module_author(void) {return name;} -/** - * Optional: Declares the author of the module - * - * @param locale Locale to look up the description for. - */ -MODULE_EXPORT const char *obs_module_description(const char *locale); +/** Optional: Returns a description of the module */ +MODULE_EXPORT const char *obs_module_description(void); diff --git a/libobs/obs.c b/libobs/obs.c index c0d4f4ff99e275..35ffd71a3e577c 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -578,6 +578,13 @@ void obs_set_locale(const char *locale) if (obs->locale) bfree(obs->locale); obs->locale = bstrdup(locale); + + for (size_t i = 0; i < obs->modules.num; i++) { + struct obs_module *module = obs->modules.array+i; + + if (module->set_locale) + module->set_locale(locale); + } } const char *obs_get_locale(void)