mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pipewire: don't setlocale from pw_init, let parent app set it
Library code generally shouldn't modify global state, so pw_init() should not result to changing the C locale. Instead, set the C locale in main() for tools and daemons. We'll still setlocale for LC_MESSAGES, to get translated UI elements in wireplumber. This workaround should be removed eventually...
This commit is contained in:
parent
b409792ea4
commit
c66bb65c7a
13 changed files with 27 additions and 2 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
|
|
@ -74,6 +75,7 @@ int main(int argc, char *argv[])
|
||||||
snprintf(path, sizeof(path), "%s.conf", argv[0]);
|
snprintf(path, sizeof(path), "%s.conf", argv[0]);
|
||||||
config_name = basename(path);
|
config_name = basename(path);
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "hVc:v", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "hVc:v", long_options, NULL)) != -1) {
|
||||||
|
|
|
||||||
|
|
@ -413,8 +413,9 @@ static const char *i18n_ntext(void *object, const char *msgid, const char *msgid
|
||||||
|
|
||||||
static void init_i18n(struct support *support)
|
static void init_i18n(struct support *support)
|
||||||
{
|
{
|
||||||
/* Load locale from the environment. */
|
/* XXX: we should remove this setlocale() call, after wireplumber
|
||||||
setlocale(LC_ALL, "");
|
* XXX: starts setting the locale */
|
||||||
|
setlocale(LC_MESSAGES, "");
|
||||||
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
||||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||||
pw_set_domain(GETTEXT_PACKAGE);
|
pw_set_domain(GETTEXT_PACKAGE);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
|
|
||||||
|
|
@ -1489,6 +1490,7 @@ int main(int argc, char *argv[])
|
||||||
int exit_code = EXIT_FAILURE, c, ret;
|
int exit_code = EXIT_FAILURE, c, ret;
|
||||||
enum pw_stream_flags flags = 0;
|
enum pw_stream_flags flags = 0;
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
flags |= PW_STREAM_FLAG_AUTOCONNECT;
|
flags |= PW_STREAM_FLAG_AUTOCONNECT;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#if !defined(FNM_EXTMATCH)
|
#if !defined(FNM_EXTMATCH)
|
||||||
#define FNM_EXTMATCH 0
|
#define FNM_EXTMATCH 0
|
||||||
|
|
@ -3076,6 +3077,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "hVdr:", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "hVdr:", long_options, NULL)) != -1) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/utils/string.h>
|
#include <spa/utils/string.h>
|
||||||
|
|
@ -1091,6 +1092,7 @@ int main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "hVasdr:o:L9j:", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "hVasdr:o:L9j:", long_options, NULL)) != -1) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#if !defined(FNM_EXTMATCH)
|
#if !defined(FNM_EXTMATCH)
|
||||||
#define FNM_EXTMATCH 0
|
#define FNM_EXTMATCH 0
|
||||||
|
|
@ -1489,6 +1490,7 @@ int main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
data.out = stdout;
|
data.out = stdout;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/utils/string.h>
|
#include <spa/utils/string.h>
|
||||||
|
|
@ -599,6 +600,7 @@ int main(int argc, char *argv[])
|
||||||
{ NULL, 0, NULL, 0}
|
{ NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
spa_list_init(&data.objects);
|
spa_list_init(&data.objects);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/pod/builder.h>
|
#include <spa/pod/builder.h>
|
||||||
|
|
@ -124,6 +125,7 @@ int main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
int c, res = -1;
|
int c, res = -1;
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
data.channels = DEFAULT_CHANNELS;
|
data.channels = DEFAULT_CHANNELS;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/utils/string.h>
|
#include <spa/utils/string.h>
|
||||||
|
|
@ -198,6 +199,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
data.opt_name = "default";
|
data.opt_name = "default";
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/utils/defs.h>
|
#include <spa/utils/defs.h>
|
||||||
|
|
@ -195,6 +196,7 @@ int main(int argc, char *argv[])
|
||||||
{ NULL, 0, NULL, 0}
|
{ NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/utils/string.h>
|
#include <spa/utils/string.h>
|
||||||
|
|
@ -771,6 +772,7 @@ int main(int argc, char *argv[])
|
||||||
int c;
|
int c;
|
||||||
bool colors = false;
|
bool colors = false;
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/utils/string.h>
|
#include <spa/utils/string.h>
|
||||||
|
|
@ -565,6 +566,7 @@ int main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "hVr:o:", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "hVr:o:", long_options, NULL)) != -1) {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
|
|
@ -121,6 +122,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "hVn:a:p:m", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "hVn:a:p:m", long_options, NULL)) != -1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue