add i18n support

This commit is contained in:
Lennart Poettering 2008-08-06 18:54:13 +02:00
parent c4a953dc96
commit f1d2bf8408
35 changed files with 816 additions and 414 deletions

5
.gitignore vendored
View file

@ -1,3 +1,8 @@
ABOUT-NLS
common/
intltool-extract.in
intltool-merge.in
intltool-update.in
*~ *~
*.tar.gz *.tar.gz
*.pc *.pc

View file

@ -15,8 +15,10 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA. # USA.
ACLOCAL_AMFLAGS = -I common
EXTRA_DIST = bootstrap.sh LICENSE GPL LGPL doxygen/Makefile.am doxygen/Makefile.in doxygen/doxygen.conf.in README todo EXTRA_DIST = bootstrap.sh LICENSE GPL LGPL doxygen/Makefile.am doxygen/Makefile.in doxygen/doxygen.conf.in README todo
SUBDIRS=src doxygen man SUBDIRS=src doxygen man po
MAINTAINERCLEANFILES = MAINTAINERCLEANFILES =
noinst_DATA = noinst_DATA =
@ -60,3 +62,6 @@ dist-hook:
fi fi
.PHONY: homepage distcleancheck doxygen .PHONY: homepage distcleancheck doxygen
DISTCLEANFILES = \
po/.intltool-merge-cache

View file

@ -23,12 +23,12 @@ run_versioned() {
local V local V
V=$(echo "$2" | sed -e 's,\.,,g') V=$(echo "$2" | sed -e 's,\.,,g')
if [ -e "`which $1$V 2> /dev/null`" ] ; then if [ -e "`which $1$V 2> /dev/null`" ] ; then
P="$1$V" P="$1$V"
else else
if [ -e "`which $1-$2 2> /dev/null`" ] ; then if [ -e "`which $1-$2 2> /dev/null`" ] ; then
P="$1-$2" P="$1-$2"
else else
P="$1" P="$1"
fi fi
@ -43,21 +43,28 @@ set -ex
if [ "x$1" = "xam" ] ; then if [ "x$1" = "xam" ] ; then
run_versioned automake "$VERSION" -a -c --foreign run_versioned automake "$VERSION" -a -c --foreign
./config.status ./config.status
else else
rm -rf autom4te.cache rm -rf autom4te.cache
rm -f config.cache rm -f config.cache
rm -f Makefile.am~ configure.ac~
# Evil, evil, evil, evil hack
sed 's/read dummy/\#/' `which gettextize` | sh -s -- --copy --force
test -f Makefile.am~ && mv Makefile.am~ Makefile.am
test -f configure.ac~ && mv configure.ac~ configure.ac
touch config.rpath touch config.rpath
test "x$LIBTOOLIZE" = "x" && LIBTOOLIZE=libtoolize test "x$LIBTOOLIZE" = "x" && LIBTOOLIZE=libtoolize
intltoolize --copy --force --automake
"$LIBTOOLIZE" -c --force --ltdl "$LIBTOOLIZE" -c --force --ltdl
run_versioned aclocal "$VERSION" run_versioned aclocal "$VERSION" -I common
run_versioned autoconf 2.59 -Wall run_versioned autoconf 2.59 -Wall
run_versioned autoheader 2.59 run_versioned autoheader 2.59
run_versioned automake "$VERSION" --copy --foreign --add-missing run_versioned automake "$VERSION" --copy --foreign --add-missing
if test "x$NOCONFIGURE" = "x"; then if test "x$NOCONFIGURE" = "x"; then
CFLAGS="-g -O0" ./configure --sysconfdir=/etc --localstatedir=/var --enable-force-preopen "$@" CFLAGS="-g -O0" ./configure --sysconfdir=/etc --localstatedir=/var --enable-force-preopen "$@"
make clean make clean
fi fi
fi fi

View file

@ -440,6 +440,17 @@ AC_CHECK_FUNCS([open64])
AM_ICONV AM_ICONV
AM_GNU_GETTEXT([external])
IT_PROG_INTLTOOL([0.35.0])
GETTEXT_PACKAGE=pulseaudio
AC_SUBST([GETTEXT_PACKAGE])
AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
AM_GLIB_GNU_GETTEXT
pulselocaledir='${prefix}/${DATADIRNAME}/locale'
AC_SUBST(pulselocaledir)
################################### ###################################
# External libraries # # External libraries #
################################### ###################################
@ -1128,6 +1139,7 @@ libpulse-mainloop-glib.pc
doxygen/Makefile doxygen/Makefile
doxygen/doxygen.conf doxygen/doxygen.conf
src/pulse/version.h src/pulse/version.h
po/Makefile.in
]) ])
AC_OUTPUT AC_OUTPUT

12
po/.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
Makefile.in.in
Makevars.template
POTFILES
Rules-quot
boldquot.sed
en@boldquot.header
en@quot.header
insert-header.sin
pulseaudio.pot
quot.sed
remove-potcdate.sin
ChangeLog

192
po/POTFILES.in Normal file
View file

@ -0,0 +1,192 @@
src/modules/module-rescue-streams.c
src/modules/module-tunnel.c
src/modules/module-native-protocol-fd.c
src/modules/module-zeroconf-discover.c
src/modules/module-alsa-source.c
src/modules/module-device-restore.c
src/modules/module-match.c
src/modules/dbus-util.c
src/modules/module-console-kit.c
src/modules/module-oss.c
src/modules/oss-util.c
src/modules/module-mmkbd-evdev.c
src/modules/module-position-event-sounds.c
src/modules/alsa-util.c
src/modules/module-pipe-source.c
src/modules/module-solaris.c
src/modules/module-default-device-restore.c
src/modules/module-x11-xsmp.c
src/modules/module-remap-sink.c
src/modules/module-bt-proximity.c
src/modules/module-detect.c
src/modules/module-always-sink.c
src/modules/module-lirc.c
src/modules/module-hal-detect.c
src/modules/module-sine.c
src/modules/module-zeroconf-publish.c
src/modules/module-jack-source.c
src/modules/module-cli.c
src/modules/gconf/module-gconf.c
src/modules/gconf/gconf-helper.c
src/modules/module-esound-sink.c
src/modules/module-alsa-sink.c
src/modules/module-volume-restore.c
src/modules/module-x11-bell.c
src/modules/module-protocol-stub.c
src/modules/module-stream-restore.c
src/modules/module-jack-sink.c
src/modules/module-esound-compat-spawnfd.c
src/modules/module-esound-compat-spawnpid.c
#src/modules/module-waveout.c
src/modules/module-combine.c
src/modules/bt-proximity-helper.c
src/modules/module-x11-publish.c
src/modules/rtp/module-rtp-recv.c
src/modules/rtp/sdp.c
src/modules/rtp/rtp.c
src/modules/rtp/sap.c
src/modules/rtp/module-rtp-send.c
src/modules/module-ladspa-sink.c
src/modules/module-suspend-on-idle.c
src/modules/module-pipe-sink.c
src/modules/module-null-sink.c
src/pulsecore/memblock.c
src/pulsecore/queue.c
src/pulsecore/core.c
#src/pulsecore/shmasyncq.c
src/pulsecore/x11wrap.c
src/pulsecore/rtclock.c
src/pulsecore/ioline.c
src/pulsecore/autoload.c
src/pulsecore/asyncq.c
src/pulsecore/mutex-posix.c
src/pulsecore/protocol-esound.c
src/pulsecore/proplist-util.c
src/pulsecore/pstream.c
src/pulsecore/cli-command.c
src/pulsecore/ltdl-helper.c
src/pulsecore/ipacl.c
src/pulsecore/sample-util.c
src/pulsecore/log.c
src/pulsecore/auth-cookie.c
src/pulsecore/protocol-cli.c
src/pulsecore/resampler.c
src/pulsecore/pdispatch.c
src/pulsecore/hook-list.c
src/pulsecore/conf-parser.c
src/pulsecore/mcalign.c
src/pulsecore/core-subscribe.c
src/pulsecore/protocol-native.c
src/pulsecore/source-output.c
src/pulsecore/modargs.c
src/pulsecore/core-scache.c
src/pulsecore/iochannel.c
src/pulsecore/shared.c
src/pulsecore/socket-client.c
src/pulsecore/idxset.c
src/pulsecore/pipe.c
src/pulsecore/asyncmsgq.c
src/pulsecore/inet_pton.c
src/pulsecore/socket-util.c
src/pulsecore/object.c
src/pulsecore/sioman.c
src/pulsecore/sink-input.c
src/pulsecore/x11prop.c
src/pulsecore/sconv-s16be.c
src/pulsecore/thread-posix.c
src/pulsecore/client.c
src/pulsecore/inet_ntop.c
src/pulsecore/strlist.c
src/pulsecore/msgobject.c
src/pulsecore/mutex-win32.c
src/pulsecore/dynarray.c
src/pulsecore/rtsig.c
src/pulsecore/once.c
src/pulsecore/source.c
src/pulsecore/memchunk.c
src/pulsecore/protocol-simple.c
src/pulsecore/sink.c
src/pulsecore/sconv-s16le.c
src/pulsecore/sconv.c
src/pulsecore/core-error.c
src/pulsecore/strbuf.c
src/pulsecore/play-memblockq.c
src/pulsecore/dllmain.c
src/pulsecore/envelope.c
src/pulsecore/pid.c
src/pulsecore/thread-mq.c
src/pulsecore/shm.c
src/pulsecore/play-memchunk.c
src/pulsecore/hashmap.c
src/pulsecore/avahi-wrap.c
src/pulsecore/authkey.c
src/pulsecore/namereg.c
src/pulsecore/poll.c
src/pulsecore/tokenizer.c
src/pulsecore/semaphore-posix.c
src/pulsecore/cli-text.c
src/pulsecore/g711.c
src/pulsecore/core-util.c
src/pulsecore/thread-win32.c
src/pulsecore/tagstruct.c
src/pulsecore/socket-server.c
src/pulsecore/flist.c
src/pulsecore/fdsem.c
src/pulsecore/random.c
src/pulsecore/modinfo.c
src/pulsecore/start-child.c
src/pulsecore/packet.c
src/pulsecore/pstream-util.c
src/pulsecore/rtpoll.c
src/pulsecore/sound-file.c
src/pulsecore/module.c
src/pulsecore/ffmpeg/resample2.c
src/pulsecore/cli.c
src/pulsecore/time-smoother.c
src/pulsecore/parseaddr.c
src/pulsecore/sound-file-stream.c
src/pulsecore/memblockq.c
src/pulsecore/protocol-http.c
src/pulsecore/semaphore-win32.c
src/daemon/cpulimit.c
src/daemon/ltdl-bind-now.c
src/daemon/polkit.c
src/daemon/main.c
src/daemon/cmdline.c
src/daemon/dumpmodules.c
src/daemon/daemon-conf.c
src/daemon/caps.c
src/pulse/channelmap.c
src/pulse/error.c
src/pulse/proplist.c
src/pulse/xmalloc.c
src/pulse/ext-stream-restore.c
src/pulse/stream.c
src/pulse/i18n.c
src/pulse/util.c
src/pulse/utf8.c
src/pulse/mainloop-api.c
src/pulse/sample.c
src/pulse/client-conf-x11.c
src/pulse/client-conf.c
src/pulse/browser.c
src/pulse/volume.c
src/pulse/simple.c
src/pulse/subscribe.c
src/pulse/introspect.c
src/pulse/mainloop.c
src/pulse/mainloop-signal.c
src/pulse/operation.c
src/pulse/context.c
src/pulse/thread-mainloop.c
src/pulse/scache.c
src/pulse/glib-mainloop.c
src/pulse/timeval.c
src/utils/pacat.c
src/utils/pasuspender.c
src/utils/pabrowse.c
src/utils/pactl.c
src/utils/padsp.c
src/utils/pax11publish.c
src/utils/pacmd.c
src/utils/paplay.c

1
po/POTFILES.skip Normal file
View file

@ -0,0 +1 @@
src/pulsecore/atomic.h

View file

@ -56,6 +56,7 @@ AM_CFLAGS += -DPA_SYSTEM_RUNTIME_PATH=\"$(PA_SYSTEM_RUNTIME_PATH)\"
AM_CFLAGS += -DPA_SYSTEM_CONFIG_PATH=\"$(PA_SYSTEM_CONFIG_PATH)\" AM_CFLAGS += -DPA_SYSTEM_CONFIG_PATH=\"$(PA_SYSTEM_CONFIG_PATH)\"
AM_CFLAGS += -DPA_SYSTEM_STATE_PATH=\"$(PA_SYSTEM_STATE_PATH)\" AM_CFLAGS += -DPA_SYSTEM_STATE_PATH=\"$(PA_SYSTEM_STATE_PATH)\"
AM_CFLAGS += -DAO_REQUIRE_CAS AM_CFLAGS += -DAO_REQUIRE_CAS
AM_CFLAGS += -DPULSE_LOCALEDIR=\"$(pulselocaledir)\"
# This cool debug trap works on i386/gcc only # This cool debug trap works on i386/gcc only
AM_CFLAGS += '-DDEBUG_TRAP=__asm__("int $$3")' AM_CFLAGS += '-DDEBUG_TRAP=__asm__("int $$3")'
@ -532,7 +533,8 @@ libpulse_la_SOURCES = \
pulse/volume.c pulse/volume.h \ pulse/volume.c pulse/volume.h \
pulse/xmalloc.c pulse/xmalloc.h \ pulse/xmalloc.c pulse/xmalloc.h \
pulse/proplist.c pulse/proplist.h \ pulse/proplist.c pulse/proplist.h \
pulse/ext-stream-restore.c pulse/ext-stream-restore.h pulse/ext-stream-restore.c pulse/ext-stream-restore.h \
pulse/i18n.c pulse/i18n.h
# Internal stuff that is shared with libpulsecore # Internal stuff that is shared with libpulsecore
libpulse_la_SOURCES += \ libpulse_la_SOURCES += \
@ -727,7 +729,8 @@ libpulsecore_la_SOURCES = \
pulse/util.c pulse/util.h \ pulse/util.c pulse/util.h \
pulse/volume.c pulse/volume.h \ pulse/volume.c pulse/volume.h \
pulse/xmalloc.c pulse/xmalloc.h \ pulse/xmalloc.c pulse/xmalloc.h \
pulse/proplist.c pulse/proplist.h pulse/proplist.c pulse/proplist.h \
pulse/i18n.c pulse/i18n.h
# Pure core stuff (some are shared in libpulse though). # Pure core stuff (some are shared in libpulse though).
libpulsecore_la_SOURCES += \ libpulsecore_la_SOURCES += \

View file

@ -28,7 +28,12 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <pulse/i18n.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulsecore/core-error.h>
#include <pulsecore/log.h>
#ifdef HAVE_SYS_CAPABILITY_H #ifdef HAVE_SYS_CAPABILITY_H
#include <sys/capability.h> #include <sys/capability.h>
@ -37,10 +42,6 @@
#include <sys/prctl.h> #include <sys/prctl.h>
#endif #endif
#include <pulsecore/core-error.h>
#include <pulsecore/log.h>
#include "caps.h" #include "caps.h"
/* Glibc <= 2.2 has broken unistd.h */ /* Glibc <= 2.2 has broken unistd.h */
@ -58,7 +59,7 @@ void pa_drop_root(void) {
if (uid == 0 || geteuid() != 0) if (uid == 0 || geteuid() != 0)
return; return;
pa_log_info("Dropping root priviliges."); pa_log_info(_("Dropping root priviliges."));
#if defined(HAVE_SETRESUID) #if defined(HAVE_SETRESUID)
pa_assert_se(setresuid(uid, uid, uid) >= 0); pa_assert_se(setresuid(uid, uid, uid) >= 0);
@ -98,7 +99,7 @@ void pa_limit_caps(void) {
* that */ * that */
pa_drop_caps(); pa_drop_caps();
else else
pa_log_info("Limited capabilities successfully to CAP_SYS_NICE."); pa_log_info(_("Limited capabilities successfully to CAP_SYS_NICE."));
pa_assert_se(cap_free(caps) == 0); pa_assert_se(cap_free(caps) == 0);

View file

@ -30,6 +30,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/strbuf.h> #include <pulsecore/strbuf.h>
@ -111,7 +112,7 @@ void pa_cmdline_help(const char *argv0) {
else else
e = argv0; e = argv0;
printf("%s [options]\n\n" printf(_("%s [options]\n\n"
"COMMANDS:\n" "COMMANDS:\n"
" -h, --help Show this help\n" " -h, --help Show this help\n"
" --version Show version\n" " --version Show version\n"
@ -160,7 +161,7 @@ void pa_cmdline_help(const char *argv0) {
" -C Open a command line on the running TTY\n" " -C Open a command line on the running TTY\n"
" after startup\n\n" " after startup\n\n"
" -n Don't load default script file\n", e); " -n Don't load default script file\n"), e);
} }
int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) { int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
@ -237,14 +238,14 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
case ARG_DAEMONIZE: case ARG_DAEMONIZE:
case 'D': case 'D':
if ((conf->daemonize = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->daemonize = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--daemonize expects boolean argument"); pa_log(_("--daemonize expects boolean argument"));
goto fail; goto fail;
} }
break; break;
case ARG_FAIL: case ARG_FAIL:
if ((conf->fail = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->fail = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--fail expects boolean argument"); pa_log(_("--fail expects boolean argument"));
goto fail; goto fail;
} }
break; break;
@ -254,7 +255,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
if (optarg) { if (optarg) {
if (pa_daemon_conf_set_log_level(conf, optarg) < 0) { if (pa_daemon_conf_set_log_level(conf, optarg) < 0) {
pa_log("--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error)."); pa_log(_("--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error)."));
goto fail; goto fail;
} }
} else { } else {
@ -266,28 +267,28 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
case ARG_HIGH_PRIORITY: case ARG_HIGH_PRIORITY:
if ((conf->high_priority = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->high_priority = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--high-priority expects boolean argument"); pa_log(_("--high-priority expects boolean argument"));
goto fail; goto fail;
} }
break; break;
case ARG_REALTIME: case ARG_REALTIME:
if ((conf->realtime_scheduling = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->realtime_scheduling = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--realtime expects boolean argument"); pa_log(_("--realtime expects boolean argument"));
goto fail; goto fail;
} }
break; break;
case ARG_DISALLOW_MODULE_LOADING: case ARG_DISALLOW_MODULE_LOADING:
if ((conf->disallow_module_loading = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->disallow_module_loading = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--disallow-module-loading expects boolean argument"); pa_log(_("--disallow-module-loading expects boolean argument"));
goto fail; goto fail;
} }
break; break;
case ARG_USE_PID_FILE: case ARG_USE_PID_FILE:
if ((conf->use_pid_file = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->use_pid_file = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--use-pid-file expects boolean argument"); pa_log(_("--use-pid-file expects boolean argument"));
goto fail; goto fail;
} }
break; break;
@ -304,7 +305,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
case ARG_LOG_TARGET: case ARG_LOG_TARGET:
if (pa_daemon_conf_set_log_target(conf, optarg) < 0) { if (pa_daemon_conf_set_log_target(conf, optarg) < 0) {
pa_log("Invalid log target: use either 'syslog', 'stderr' or 'auto'."); pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto'."));
goto fail; goto fail;
} }
break; break;
@ -323,28 +324,28 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
case ARG_RESAMPLE_METHOD: case ARG_RESAMPLE_METHOD:
if (pa_daemon_conf_set_resample_method(conf, optarg) < 0) { if (pa_daemon_conf_set_resample_method(conf, optarg) < 0) {
pa_log("Invalid resample method '%s'.", optarg); pa_log(_("Invalid resample method '%s'."), optarg);
goto fail; goto fail;
} }
break; break;
case ARG_SYSTEM: case ARG_SYSTEM:
if ((conf->system_instance = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->system_instance = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--system expects boolean argument"); pa_log(_("--system expects boolean argument"));
goto fail; goto fail;
} }
break; break;
case ARG_NO_CPU_LIMIT: case ARG_NO_CPU_LIMIT:
if ((conf->no_cpu_limit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->no_cpu_limit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--no-cpu-limit expects boolean argument"); pa_log(_("--no-cpu-limit expects boolean argument"));
goto fail; goto fail;
} }
break; break;
case ARG_DISABLE_SHM: case ARG_DISABLE_SHM:
if ((conf->disable_shm = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { if ((conf->disable_shm = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
pa_log("--disable-shm expects boolean argument"); pa_log(_("--disable-shm expects boolean argument"));
goto fail; goto fail;
} }
break; break;

View file

@ -32,6 +32,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/timeval.h> #include <pulse/timeval.h>
#include <pulse/i18n.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
@ -198,7 +199,7 @@ static int parse_log_target(const char *filename, unsigned line, const char *lva
pa_assert(data); pa_assert(data);
if (pa_daemon_conf_set_log_target(c, rvalue) < 0) { if (pa_daemon_conf_set_log_target(c, rvalue) < 0) {
pa_log("[%s:%u] Invalid log target '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid log target '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -214,7 +215,7 @@ static int parse_log_level(const char *filename, unsigned line, const char *lval
pa_assert(data); pa_assert(data);
if (pa_daemon_conf_set_log_level(c, rvalue) < 0) { if (pa_daemon_conf_set_log_level(c, rvalue) < 0) {
pa_log("[%s:%u] Invalid log level '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid log level '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -230,7 +231,7 @@ static int parse_resample_method(const char *filename, unsigned line, const char
pa_assert(data); pa_assert(data);
if (pa_daemon_conf_set_resample_method(c, rvalue) < 0) { if (pa_daemon_conf_set_resample_method(c, rvalue) < 0) {
pa_log("[%s:%u] Invalid resample method '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid resample method '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -253,14 +254,14 @@ static int parse_rlimit(const char *filename, unsigned line, const char *lvalue,
} else { } else {
int32_t k; int32_t k;
if (pa_atoi(rvalue, &k) < 0) { if (pa_atoi(rvalue, &k) < 0) {
pa_log("[%s:%u] Invalid rlimit '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid rlimit '%s'."), filename, line, rvalue);
return -1; return -1;
} }
r->is_set = k >= 0; r->is_set = k >= 0;
r->value = k >= 0 ? (rlim_t) k : 0; r->value = k >= 0 ? (rlim_t) k : 0;
} }
#else #else
pa_log_warn("[%s:%u] rlimit not supported on this platform.", filename, line); pa_log_warn(_("[%s:%u] rlimit not supported on this platform."), filename, line);
#endif #endif
return 0; return 0;
@ -276,7 +277,7 @@ static int parse_sample_format(const char *filename, unsigned line, const char *
pa_assert(data); pa_assert(data);
if ((f = pa_parse_sample_format(rvalue)) < 0) { if ((f = pa_parse_sample_format(rvalue)) < 0) {
pa_log("[%s:%u] Invalid sample format '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid sample format '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -294,7 +295,7 @@ static int parse_sample_rate(const char *filename, unsigned line, const char *lv
pa_assert(data); pa_assert(data);
if (pa_atoi(rvalue, &r) < 0 || r > (int32_t) PA_RATE_MAX || r <= 0) { if (pa_atoi(rvalue, &r) < 0 || r > (int32_t) PA_RATE_MAX || r <= 0) {
pa_log("[%s:%u] Invalid sample rate '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid sample rate '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -312,7 +313,7 @@ static int parse_sample_channels(const char *filename, unsigned line, const char
pa_assert(data); pa_assert(data);
if (pa_atoi(rvalue, &n) < 0 || n > (int32_t) PA_CHANNELS_MAX || n <= 0) { if (pa_atoi(rvalue, &n) < 0 || n > (int32_t) PA_CHANNELS_MAX || n <= 0) {
pa_log("[%s:%u] Invalid sample channels '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid sample channels '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -330,7 +331,7 @@ static int parse_fragments(const char *filename, unsigned line, const char *lval
pa_assert(data); pa_assert(data);
if (pa_atoi(rvalue, &n) < 0 || n < 2) { if (pa_atoi(rvalue, &n) < 0 || n < 2) {
pa_log("[%s:%u] Invalid number of fragments '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid number of fragments '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -348,7 +349,7 @@ static int parse_fragment_size_msec(const char *filename, unsigned line, const c
pa_assert(data); pa_assert(data);
if (pa_atoi(rvalue, &n) < 0 || n < 1) { if (pa_atoi(rvalue, &n) < 0 || n < 1) {
pa_log("[%s:%u] Invalid fragment size '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid fragment size '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -366,7 +367,7 @@ static int parse_nice_level(const char *filename, unsigned line, const char *lva
pa_assert(data); pa_assert(data);
if (pa_atoi(rvalue, &level) < 0 || level < -20 || level > 19) { if (pa_atoi(rvalue, &level) < 0 || level < -20 || level > 19) {
pa_log("[%s:%u] Invalid nice level '%s'.", filename, line, rvalue); pa_log(_("[%s:%u] Invalid nice level '%s'."), filename, line, rvalue);
return -1; return -1;
} }
@ -557,7 +558,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file); pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file);
if (!f && errno != ENOENT) { if (!f && errno != ENOENT) {
pa_log_warn("Failed to open configuration file: %s", pa_cstrerror(errno)); pa_log_warn(_("Failed to open configuration file: %s"), pa_cstrerror(errno));
goto finish; goto finish;
} }
@ -631,7 +632,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
s = pa_strbuf_new(); s = pa_strbuf_new();
if (c->config_file) if (c->config_file)
pa_strbuf_printf(s, "### Read from configuration file: %s ###\n", c->config_file); pa_strbuf_printf(s, _("### Read from configuration file: %s ###\n"), c->config_file);
pa_assert(c->log_level <= PA_LOG_LEVEL_MAX); pa_assert(c->log_level <= PA_LOG_LEVEL_MAX);

View file

@ -30,6 +30,7 @@
#include <ltdl.h> #include <ltdl.h>
#include <pulse/util.h> #include <pulse/util.h>
#include <pulse/i18n.h>
#include <pulsecore/modinfo.h> #include <pulsecore/modinfo.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
@ -56,24 +57,24 @@ static void long_info(const char *name, const char *path, pa_modinfo *i) {
nl = 1; nl = 1;
printf("Name: %s\n", name); printf(_("Name: %s\n"), name);
if (!i->description && !i->version && !i->author && !i->usage) if (!i->description && !i->version && !i->author && !i->usage)
printf("No module information available\n"); printf(_("No module information available\n"));
else { else {
if (i->version) if (i->version)
printf("Version: %s\n", i->version); printf(_("Version: %s\n"), i->version);
if (i->description) if (i->description)
printf("Description: %s\n", i->description); printf(_("Description: %s\n"), i->description);
if (i->author) if (i->author)
printf("Author: %s\n", i->author); printf(_("Author: %s\n"), i->author);
if (i->usage) if (i->usage)
printf("Usage: %s\n", i->usage); printf(_("Usage: %s\n"), i->usage);
printf("Load Once: %s\n", pa_yes_no(i->load_once)); printf(_("Load Once: %s\n"), pa_yes_no(i->load_once));
} }
if (path) if (path)
printf("Path: %s\n", path); printf(_("Path: %s\n"), path);
} }
static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, pa_modinfo*i)) { static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, pa_modinfo*i)) {

View file

@ -32,13 +32,12 @@
#include <sys/dl.h> #include <sys/dl.h>
#endif #endif
#ifndef HAVE_STRUCT_LT_USER_DLLOADER
/* Only used with ltdl 2.2 */
#include <string.h> #include <string.h>
#endif
#include <ltdl.h> #include <ltdl.h>
#include <pulse/i18n.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulsecore/mutex.h> #include <pulsecore/mutex.h>
#include <pulsecore/thread.h> #include <pulsecore/thread.h>
@ -54,6 +53,8 @@
#undef PA_BIND_NOW #undef PA_BIND_NOW
#endif #endif
#ifdef HAVE_LT_DLMUTEX_REGISTER
static pa_mutex *libtool_mutex = NULL; static pa_mutex *libtool_mutex = NULL;
PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls); PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls);
@ -74,6 +75,8 @@ static const char *libtool_get_error(void) {
return PA_STATIC_TLS_GET(libtool_tls); return PA_STATIC_TLS_GET(libtool_tls);
} }
#endif
#ifdef PA_BIND_NOW #ifdef PA_BIND_NOW
/* /*
@ -89,10 +92,11 @@ static const char *libtool_get_error(void) {
*/ */
#ifndef HAVE_LT_DLADVISE #ifndef HAVE_LT_DLADVISE
static lt_module bind_now_open(lt_user_data d, const char *fname) { static lt_module bind_now_open(lt_user_data d, const char *fname)
#else #else
static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise) { static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise)
#endif #endif
{
lt_module m; lt_module m;
pa_assert(fname); pa_assert(fname);
@ -150,8 +154,9 @@ void pa_ltdl_init(void) {
#endif #endif
pa_assert_se(lt_dlinit() == 0); pa_assert_se(lt_dlinit() == 0);
pa_assert_se(libtool_mutex = pa_mutex_new(TRUE, FALSE));
#ifdef HAVE_LT_DLMUTEX_REGISTER #ifdef HAVE_LT_DLMUTEX_REGISTER
pa_assert_se(libtool_mutex = pa_mutex_new(TRUE, FALSE));
pa_assert_se(lt_dlmutex_register(libtool_lock, libtool_unlock, libtool_set_error, libtool_get_error) == 0); pa_assert_se(lt_dlmutex_register(libtool_lock, libtool_unlock, libtool_set_error, libtool_get_error) == 0);
#endif #endif
@ -163,14 +168,15 @@ void pa_ltdl_init(void) {
/* Add our BIND_NOW loader as the default module loader. */ /* Add our BIND_NOW loader as the default module loader. */
if (lt_dlloader_add(place, &loader, "bind-now-loader") != 0) if (lt_dlloader_add(place, &loader, "bind-now-loader") != 0)
pa_log_warn("Failed to add bind-now-loader."); pa_log_warn(_("Failed to add bind-now-loader."));
# else # else
/* Already initialised */ /* Already initialised */
if ( dlopen_loader != NULL ) return; if (dlopen_loader)
return;
if (!(dlopen_loader = lt_dlloader_find("dlopen"))) { if (!(dlopen_loader = lt_dlloader_find("dlopen"))) {
pa_log_warn("Failed to find original dlopen loader."); pa_log_warn(_("Failed to find original dlopen loader."));
return; return;
} }
memcpy(&bindnow_loader, dlopen_loader, sizeof(bindnow_loader)); memcpy(&bindnow_loader, dlopen_loader, sizeof(bindnow_loader));
@ -182,14 +188,16 @@ void pa_ltdl_init(void) {
/* Add our BIND_NOW loader as the default module loader. */ /* Add our BIND_NOW loader as the default module loader. */
if (lt_dlloader_add(&bindnow_loader) != 0) if (lt_dlloader_add(&bindnow_loader) != 0)
pa_log_warn("Failed to add bind-now-loader."); pa_log_warn(_("Failed to add bind-now-loader."));
# endif # endif
#endif #endif
} }
void pa_ltdl_done(void) { void pa_ltdl_done(void) {
pa_assert_se(lt_dlexit() == 0); pa_assert_se(lt_dlexit() == 0);
#ifdef HAVE_LT_DLMUTEX_REGISTER
pa_mutex_free(libtool_mutex); pa_mutex_free(libtool_mutex);
libtool_mutex = NULL; libtool_mutex = NULL;
#endif
} }

View file

@ -64,6 +64,7 @@
#include <pulse/mainloop-signal.h> #include <pulse/mainloop-signal.h>
#include <pulse/timeval.h> #include <pulse/timeval.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/winsock.h> #include <pulsecore/winsock.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
@ -131,7 +132,7 @@ static void message_cb(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const s
#endif #endif
static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e, int sig, void *userdata) { static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e, int sig, void *userdata) {
pa_log_info("Got signal %s.", pa_sig2str(sig)); pa_log_info(_("Got signal %s."), pa_sig2str(sig));
switch (sig) { switch (sig) {
#ifdef SIGUSR1 #ifdef SIGUSR1
@ -158,7 +159,7 @@ static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e,
case SIGINT: case SIGINT:
case SIGTERM: case SIGTERM:
default: default:
pa_log_info("Exiting."); pa_log_info(_("Exiting."));
m->quit(m, 1); m->quit(m, 1);
break; break;
} }
@ -176,41 +177,41 @@ static int change_user(void) {
* afterwards. */ * afterwards. */
if (!(pw = getpwnam(PA_SYSTEM_USER))) { if (!(pw = getpwnam(PA_SYSTEM_USER))) {
pa_log("Failed to find user '%s'.", PA_SYSTEM_USER); pa_log(_("Failed to find user '%s'."), PA_SYSTEM_USER);
return -1; return -1;
} }
if (!(gr = getgrnam(PA_SYSTEM_GROUP))) { if (!(gr = getgrnam(PA_SYSTEM_GROUP))) {
pa_log("Failed to find group '%s'.", PA_SYSTEM_GROUP); pa_log(_("Failed to find group '%s'."), PA_SYSTEM_GROUP);
return -1; return -1;
} }
pa_log_info("Found user '%s' (UID %lu) and group '%s' (GID %lu).", pa_log_info(_("Found user '%s' (UID %lu) and group '%s' (GID %lu)."),
PA_SYSTEM_USER, (unsigned long) pw->pw_uid, PA_SYSTEM_USER, (unsigned long) pw->pw_uid,
PA_SYSTEM_GROUP, (unsigned long) gr->gr_gid); PA_SYSTEM_GROUP, (unsigned long) gr->gr_gid);
if (pw->pw_gid != gr->gr_gid) { if (pw->pw_gid != gr->gr_gid) {
pa_log("GID of user '%s' and of group '%s' don't match.", PA_SYSTEM_USER, PA_SYSTEM_GROUP); pa_log(_("GID of user '%s' and of group '%s' don't match."), PA_SYSTEM_USER, PA_SYSTEM_GROUP);
return -1; return -1;
} }
if (strcmp(pw->pw_dir, PA_SYSTEM_RUNTIME_PATH) != 0) if (strcmp(pw->pw_dir, PA_SYSTEM_RUNTIME_PATH) != 0)
pa_log_warn("Warning: home directory of user '%s' is not '%s', ignoring.", PA_SYSTEM_USER, PA_SYSTEM_RUNTIME_PATH); pa_log_warn(_("Home directory of user '%s' is not '%s', ignoring."), PA_SYSTEM_USER, PA_SYSTEM_RUNTIME_PATH);
if (pa_make_secure_dir(PA_SYSTEM_RUNTIME_PATH, 0755, pw->pw_uid, gr->gr_gid) < 0) { if (pa_make_secure_dir(PA_SYSTEM_RUNTIME_PATH, 0755, pw->pw_uid, gr->gr_gid) < 0) {
pa_log("Failed to create '%s': %s", PA_SYSTEM_RUNTIME_PATH, pa_cstrerror(errno)); pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_RUNTIME_PATH, pa_cstrerror(errno));
return -1; return -1;
} }
if (pa_make_secure_dir(PA_SYSTEM_STATE_PATH, 0700, pw->pw_uid, gr->gr_gid) < 0) { if (pa_make_secure_dir(PA_SYSTEM_STATE_PATH, 0700, pw->pw_uid, gr->gr_gid) < 0) {
pa_log("Failed to create '%s': %s", PA_SYSTEM_STATE_PATH, pa_cstrerror(errno)); pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_STATE_PATH, pa_cstrerror(errno));
return -1; return -1;
} }
/* We don't create the config dir here, because we don't need to write to it */ /* We don't create the config dir here, because we don't need to write to it */
if (initgroups(PA_SYSTEM_USER, gr->gr_gid) != 0) { if (initgroups(PA_SYSTEM_USER, gr->gr_gid) != 0) {
pa_log("Failed to change group list: %s", pa_cstrerror(errno)); pa_log(_("Failed to change group list: %s"), pa_cstrerror(errno));
return -1; return -1;
} }
@ -226,7 +227,7 @@ static int change_user(void) {
#endif #endif
if (r < 0) { if (r < 0) {
pa_log("Failed to change GID: %s", pa_cstrerror(errno)); pa_log(_("Failed to change GID: %s"), pa_cstrerror(errno));
return -1; return -1;
} }
@ -242,7 +243,7 @@ static int change_user(void) {
#endif #endif
if (r < 0) { if (r < 0) {
pa_log("Failed to change UID: %s", pa_cstrerror(errno)); pa_log(_("Failed to change UID: %s"), pa_cstrerror(errno));
return -1; return -1;
} }
@ -256,7 +257,7 @@ static int change_user(void) {
pa_set_env("PULSE_CONFIG_PATH", PA_SYSTEM_CONFIG_PATH); pa_set_env("PULSE_CONFIG_PATH", PA_SYSTEM_CONFIG_PATH);
pa_set_env("PULSE_STATE_PATH", PA_SYSTEM_STATE_PATH); pa_set_env("PULSE_STATE_PATH", PA_SYSTEM_STATE_PATH);
pa_log_info("Successfully dropped root privileges."); pa_log_info(_("Successfully dropped root privileges."));
return 0; return 0;
} }
@ -264,7 +265,7 @@ static int change_user(void) {
#else /* HAVE_PWD_H && HAVE_GRP_H */ #else /* HAVE_PWD_H && HAVE_GRP_H */
static int change_user(void) { static int change_user(void) {
pa_log("System wide mode unsupported on this platform."); pa_log(_("System wide mode unsupported on this platform."));
return -1; return -1;
} }
@ -282,7 +283,7 @@ static int set_one_rlimit(const pa_rlimit *r, int resource, const char *name) {
rl.rlim_cur = rl.rlim_max = r->value; rl.rlim_cur = rl.rlim_max = r->value;
if (setrlimit(resource, &rl) < 0) { if (setrlimit(resource, &rl) < 0) {
pa_log_info("setrlimit(%s, (%u, %u)) failed: %s", name, (unsigned) r->value, (unsigned) r->value, pa_cstrerror(errno)); pa_log_info(_("setrlimit(%s, (%u, %u)) failed: %s"), name, (unsigned) r->value, (unsigned) r->value, pa_cstrerror(errno));
return -1; return -1;
} }
@ -407,6 +408,8 @@ int main(int argc, char *argv[]) {
* still are normal root. */ * still are normal root. */
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
pa_init_i18n();
pa_log_set_maximal_level(PA_LOG_INFO); pa_log_set_maximal_level(PA_LOG_INFO);
pa_log_set_ident("pulseaudio"); pa_log_set_ident("pulseaudio");
@ -419,7 +422,7 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
if (pa_cmdline_parse(conf, argc, argv, &d) < 0) { if (pa_cmdline_parse(conf, argc, argv, &d) < 0) {
pa_log("Failed to parse command line."); pa_log(_("Failed to parse command line."));
goto finish; goto finish;
} }
@ -435,14 +438,14 @@ int main(int argc, char *argv[]) {
if (conf->high_priority && !allow_high_priority) { if (conf->high_priority && !allow_high_priority) {
if (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) > 0) { if (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) > 0) {
pa_log_info("We're in the group '"PA_REALTIME_GROUP"', allowing high-priority scheduling."); pa_log_info(_("We're in the group '%s', allowing high-priority scheduling."), PA_REALTIME_GROUP);
allow_high_priority = TRUE; allow_high_priority = TRUE;
} }
} }
if (conf->realtime_scheduling && !allow_realtime) { if (conf->realtime_scheduling && !allow_realtime) {
if (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) > 0) { if (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) > 0) {
pa_log_info("We're in the group '"PA_REALTIME_GROUP"', allowing real-time scheduling."); pa_log_info(_("We're in the group '%s', allowing real-time scheduling."), PA_REALTIME_GROUP);
allow_realtime = TRUE; allow_realtime = TRUE;
} }
} }
@ -450,18 +453,18 @@ int main(int argc, char *argv[]) {
#ifdef HAVE_POLKIT #ifdef HAVE_POLKIT
if (conf->high_priority && !allow_high_priority) { if (conf->high_priority && !allow_high_priority) {
if (pa_polkit_check("org.pulseaudio.acquire-high-priority") > 0) { if (pa_polkit_check("org.pulseaudio.acquire-high-priority") > 0) {
pa_log_info("PolicyKit grants us acquire-high-priority privilege."); pa_log_info(_("PolicyKit grants us acquire-high-priority privilege."));
allow_high_priority = TRUE; allow_high_priority = TRUE;
} else } else
pa_log_info("PolicyKit refuses acquire-high-priority privilege."); pa_log_info(_("PolicyKit refuses acquire-high-priority privilege."));
} }
if (conf->realtime_scheduling && !allow_realtime) { if (conf->realtime_scheduling && !allow_realtime) {
if (pa_polkit_check("org.pulseaudio.acquire-real-time") > 0) { if (pa_polkit_check("org.pulseaudio.acquire-real-time") > 0) {
pa_log_info("PolicyKit grants us acquire-real-time privilege."); pa_log_info(_("PolicyKit grants us acquire-real-time privilege."));
allow_realtime = TRUE; allow_realtime = TRUE;
} else } else
pa_log_info("PolicyKit refuses acquire-real-time privilege."); pa_log_info(_("PolicyKit refuses acquire-real-time privilege."));
} }
#endif #endif
@ -473,9 +476,9 @@ int main(int argc, char *argv[]) {
pa_drop_caps(); pa_drop_caps();
if (conf->high_priority || conf->realtime_scheduling) if (conf->high_priority || conf->realtime_scheduling)
pa_log_notice("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n" pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n"
"We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n" "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
"For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."); "For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
} }
} }
@ -491,7 +494,7 @@ int main(int argc, char *argv[]) {
#endif #endif
if (conf->high_priority && !pa_can_high_priority()) if (conf->high_priority && !pa_can_high_priority())
pa_log_warn("High-priority scheduling enabled in configuration but not allowed by policy."); pa_log_warn(_("High-priority scheduling enabled in configuration but not allowed by policy."));
if (conf->high_priority && (conf->cmd == PA_CMD_DAEMON || conf->cmd == PA_CMD_START)) if (conf->high_priority && (conf->cmd == PA_CMD_DAEMON || conf->cmd == PA_CMD_START))
pa_raise_priority(conf->nice_level); pa_raise_priority(conf->nice_level);
@ -516,24 +519,24 @@ int main(int argc, char *argv[]) {
rl.rlim_max = rl.rlim_cur = 9; rl.rlim_max = rl.rlim_cur = 9;
if (setrlimit(RLIMIT_RTPRIO, &rl) >= 0) { if (setrlimit(RLIMIT_RTPRIO, &rl) >= 0) {
pa_log_info("Successfully increased RLIMIT_RTPRIO"); pa_log_info(_("Successfully increased RLIMIT_RTPRIO"));
drop = TRUE; drop = TRUE;
} else } else
pa_log_warn("RLIMIT_RTPRIO failed: %s", pa_cstrerror(errno)); pa_log_warn(_("RLIMIT_RTPRIO failed: %s"), pa_cstrerror(errno));
} }
} }
} }
#endif #endif
if (drop) { if (drop) {
pa_log_info("Giving up CAP_NICE"); pa_log_info(_("Giving up CAP_NICE"));
pa_drop_caps(); pa_drop_caps();
suid_root = FALSE; suid_root = FALSE;
} }
} }
if (conf->realtime_scheduling && !pa_can_realtime()) if (conf->realtime_scheduling && !pa_can_realtime())
pa_log_warn("Real-time scheduling enabled in configuration but not allowed by policy."); pa_log_warn(_("Real-time scheduling enabled in configuration but not allowed by policy."));
pa_log_debug("Can realtime: %s, can high-priority: %s", pa_yes_no(pa_can_realtime()), pa_yes_no(pa_can_high_priority())); pa_log_debug("Can realtime: %s, can high-priority: %s", pa_yes_no(pa_can_realtime()), pa_yes_no(pa_can_high_priority()));
@ -591,9 +594,9 @@ int main(int argc, char *argv[]) {
pid_t pid; pid_t pid;
if (pa_pid_file_check_running(&pid, "pulseaudio") < 0) if (pa_pid_file_check_running(&pid, "pulseaudio") < 0)
pa_log_info("Daemon not running"); pa_log_info(_("Daemon not running"));
else { else {
pa_log_info("Daemon running as PID %u", pid); pa_log_info(_("Daemon running as PID %u"), pid);
retval = 0; retval = 0;
} }
@ -603,7 +606,7 @@ int main(int argc, char *argv[]) {
case PA_CMD_KILL: case PA_CMD_KILL:
if (pa_pid_file_kill(SIGINT, NULL, "pulseaudio") < 0) if (pa_pid_file_kill(SIGINT, NULL, "pulseaudio") < 0)
pa_log("Failed to kill daemon."); pa_log(_("Failed to kill daemon."));
else else
retval = 0; retval = 0;
@ -621,14 +624,14 @@ int main(int argc, char *argv[]) {
} }
if (real_root && !conf->system_instance) if (real_root && !conf->system_instance)
pa_log_warn("This program is not intended to be run as root (unless --system is specified)."); pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
else if (!real_root && conf->system_instance) { else if (!real_root && conf->system_instance) {
pa_log("Root priviliges required."); pa_log(_("Root priviliges required."));
goto finish; goto finish;
} }
if (conf->cmd == PA_CMD_START && conf->system_instance) { if (conf->cmd == PA_CMD_START && conf->system_instance) {
pa_log("--start not supported for system instances."); pa_log(_("--start not supported for system instances."));
goto finish; goto finish;
} }
@ -646,18 +649,18 @@ int main(int argc, char *argv[]) {
int tty_fd; int tty_fd;
if (pa_stdio_acquire() < 0) { if (pa_stdio_acquire() < 0) {
pa_log("Failed to acquire stdio."); pa_log(_("Failed to acquire stdio."));
goto finish; goto finish;
} }
#ifdef HAVE_FORK #ifdef HAVE_FORK
if (pipe(daemon_pipe) < 0) { if (pipe(daemon_pipe) < 0) {
pa_log("pipe failed: %s", pa_cstrerror(errno)); pa_log(_("pipe failed: %s"), pa_cstrerror(errno));
goto finish; goto finish;
} }
if ((child = fork()) < 0) { if ((child = fork()) < 0) {
pa_log("fork() failed: %s", pa_cstrerror(errno)); pa_log(_("fork() failed: %s"), pa_cstrerror(errno));
goto finish; goto finish;
} }
@ -671,15 +674,15 @@ int main(int argc, char *argv[]) {
if ((n = pa_loop_read(daemon_pipe[0], &retval, sizeof(retval), NULL)) != sizeof(retval)) { if ((n = pa_loop_read(daemon_pipe[0], &retval, sizeof(retval), NULL)) != sizeof(retval)) {
if (n < 0) if (n < 0)
pa_log("read() failed: %s", pa_cstrerror(errno)); pa_log(_("read() failed: %s"), pa_cstrerror(errno));
retval = 1; retval = 1;
} }
if (retval) if (retval)
pa_log("Daemon startup failed."); pa_log(_("Daemon startup failed."));
else else
pa_log_info("Daemon startup successful."); pa_log_info(_("Daemon startup successful."));
goto finish; goto finish;
} }
@ -746,17 +749,17 @@ int main(int argc, char *argv[]) {
pa_set_env("PULSE_SYSTEM", conf->system_instance ? "1" : "0"); pa_set_env("PULSE_SYSTEM", conf->system_instance ? "1" : "0");
pa_log_info("This is PulseAudio " PACKAGE_VERSION); pa_log_info(_("This is PulseAudio %s"), PACKAGE_VERSION);
pa_log_info("Page size is %lu bytes", (unsigned long) PA_PAGE_SIZE); pa_log_info(_("Page size is %lu bytes"), (unsigned long) PA_PAGE_SIZE);
if (!(s = pa_get_runtime_dir())) if (!(s = pa_get_runtime_dir()))
goto finish; goto finish;
pa_log_info("Using runtime directory %s.", s); pa_log_info(_("Using runtime directory %s."), s);
pa_xfree(s); pa_xfree(s);
if (!(s = pa_get_state_dir())) if (!(s = pa_get_state_dir()))
pa_log_info("Using state directory %s.", s); pa_log_info(_("Using state directory %s."), s);
pa_xfree(s); pa_xfree(s);
pa_log_info("Running in system mode: %s", pa_yes_no(pa_in_system_mode())); pa_log_info(_("Running in system mode: %s"), pa_yes_no(pa_in_system_mode()));
if (conf->use_pid_file) { if (conf->use_pid_file) {
int z; int z;
@ -771,7 +774,7 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
} }
pa_log("pa_pid_file_create() failed."); pa_log(_("pa_pid_file_create() failed."));
goto finish; goto finish;
} }
@ -783,9 +786,9 @@ int main(int argc, char *argv[]) {
#endif #endif
if (pa_rtclock_hrtimer()) if (pa_rtclock_hrtimer())
pa_log_info("Fresh high-resolution timers available! Bon appetit!"); pa_log_info(_("Fresh high-resolution timers available! Bon appetit!"));
else else
pa_log_info("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"); pa_log_info(_("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"));
#ifdef SIGRTMIN #ifdef SIGRTMIN
/* Valgrind uses SIGRTMAX. To easy debugging we don't use it here */ /* Valgrind uses SIGRTMAX. To easy debugging we don't use it here */
@ -795,7 +798,7 @@ int main(int argc, char *argv[]) {
pa_assert_se(mainloop = pa_mainloop_new()); pa_assert_se(mainloop = pa_mainloop_new());
if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm))) { if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm))) {
pa_log("pa_core_new() failed."); pa_log(_("pa_core_new() failed."));
goto finish; goto finish;
} }
@ -854,17 +857,17 @@ int main(int argc, char *argv[]) {
c->disallow_module_loading = !!conf->disallow_module_loading; c->disallow_module_loading = !!conf->disallow_module_loading;
if (r < 0 && conf->fail) { if (r < 0 && conf->fail) {
pa_log("Failed to initialize daemon."); pa_log(_("Failed to initialize daemon."));
goto finish; goto finish;
} }
if (!c->modules || pa_idxset_size(c->modules) == 0) { if (!c->modules || pa_idxset_size(c->modules) == 0) {
pa_log("Daemon startup without any loaded modules, refusing to work."); pa_log(_("Daemon startup without any loaded modules, refusing to work."));
goto finish; goto finish;
} }
if (c->default_sink_name && !pa_namereg_get(c, c->default_sink_name, PA_NAMEREG_SINK, TRUE) && conf->fail) { if (c->default_sink_name && !pa_namereg_get(c, c->default_sink_name, PA_NAMEREG_SINK, TRUE) && conf->fail) {
pa_log_error("Default sink name (%s) does not exist in name register.", c->default_sink_name); pa_log_error(_("Default sink name (%s) does not exist in name register."), c->default_sink_name);
goto finish; goto finish;
} }
@ -877,13 +880,13 @@ int main(int argc, char *argv[]) {
} }
#endif #endif
pa_log_info("Daemon startup complete."); pa_log_info(_("Daemon startup complete."));
retval = 0; retval = 0;
if (pa_mainloop_run(mainloop, &retval) < 0) if (pa_mainloop_run(mainloop, &retval) < 0)
goto finish; goto finish;
pa_log_info("Daemon shutdown initiated."); pa_log_info(_("Daemon shutdown initiated."));
finish: finish:
@ -900,7 +903,7 @@ finish:
if (c) { if (c) {
pa_core_unref(c); pa_core_unref(c);
pa_log_info("Daemon terminated."); pa_log_info(_("Daemon terminated."));
} }
if (!conf->no_cpu_limit) if (!conf->no_cpu_limit)

View file

@ -31,6 +31,8 @@
#include <dbus/dbus.h> #include <dbus/dbus.h>
#include <polkit-dbus/polkit-dbus.h> #include <polkit-dbus/polkit-dbus.h>
#include <pulse/i18n.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
@ -50,7 +52,7 @@ int pa_polkit_check(const char *action_id) {
dbus_error_init(&dbus_error); dbus_error_init(&dbus_error);
if (!(bus = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error))) { if (!(bus = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error))) {
pa_log_error("Cannot connect to system bus: %s", dbus_error.message); pa_log_error(_("Cannot connect to system bus: %s"), dbus_error.message);
goto finish; goto finish;
} }
@ -60,7 +62,7 @@ int pa_polkit_check(const char *action_id) {
dbus_connection_set_exit_on_disconnect(bus, FALSE); dbus_connection_set_exit_on_disconnect(bus, FALSE);
if (!(caller = polkit_caller_new_from_pid(bus, getpid(), &dbus_error))) { if (!(caller = polkit_caller_new_from_pid(bus, getpid(), &dbus_error))) {
pa_log_error("Cannot get caller from PID: %s", dbus_error.message); pa_log_error(_("Cannot get caller from PID: %s"), dbus_error.message);
goto finish; goto finish;
} }
@ -72,12 +74,12 @@ int pa_polkit_check(const char *action_id) {
* -- an not the EUID or any other user id. */ * -- an not the EUID or any other user id. */
if (!(polkit_caller_set_uid(caller, getuid()))) { if (!(polkit_caller_set_uid(caller, getuid()))) {
pa_log_error("Cannot set UID on caller object."); pa_log_error(_("Cannot set UID on caller object."));
goto finish; goto finish;
} }
if (!(polkit_caller_get_ck_session(caller, &session))) { if (!(polkit_caller_get_ck_session(caller, &session))) {
pa_log_error("Failed to get CK session."); pa_log_error(_("Failed to get CK session."));
goto finish; goto finish;
} }
@ -85,27 +87,27 @@ int pa_polkit_check(const char *action_id) {
* object */ * object */
if (!(polkit_session_set_uid(session, getuid()))) { if (!(polkit_session_set_uid(session, getuid()))) {
pa_log_error("Cannot set UID on session object."); pa_log_error(_("Cannot set UID on session object."));
goto finish; goto finish;
} }
if (!(action = polkit_action_new())) { if (!(action = polkit_action_new())) {
pa_log_error("Cannot allocate PolKitAction."); pa_log_error(_("Cannot allocate PolKitAction."));
goto finish; goto finish;
} }
if (!polkit_action_set_action_id(action, action_id)) { if (!polkit_action_set_action_id(action, action_id)) {
pa_log_error("Cannot set action_id"); pa_log_error(_("Cannot set action_id"));
goto finish; goto finish;
} }
if (!(context = polkit_context_new())) { if (!(context = polkit_context_new())) {
pa_log_error("Cannot allocate PolKitContext."); pa_log_error(_("Cannot allocate PolKitContext."));
goto finish; goto finish;
} }
if (!polkit_context_init(context, &polkit_error)) { if (!polkit_context_init(context, &polkit_error)) {
pa_log_error("Cannot initialize PolKitContext: %s", polkit_error_get_error_message(polkit_error)); pa_log_error(_("Cannot initialize PolKitContext: %s"), polkit_error_get_error_message(polkit_error));
goto finish; goto finish;
} }
@ -114,7 +116,7 @@ int pa_polkit_check(const char *action_id) {
polkit_result = polkit_context_is_caller_authorized(context, action, caller, TRUE, &polkit_error); polkit_result = polkit_context_is_caller_authorized(context, action, caller, TRUE, &polkit_error);
if (polkit_error_is_set(polkit_error)) { if (polkit_error_is_set(polkit_error)) {
pa_log_error("Could not determine whether caller is authorized: %s", polkit_error_get_error_message(polkit_error)); pa_log_error(_("Could not determine whether caller is authorized: %s"), polkit_error_get_error_message(polkit_error));
goto finish; goto finish;
} }
@ -134,7 +136,7 @@ int pa_polkit_check(const char *action_id) {
} }
if (dbus_error_is_set(&dbus_error)) { if (dbus_error_is_set(&dbus_error)) {
pa_log_error("Cannot obtain auth: %s", dbus_error.message); pa_log_error(_("Cannot obtain auth: %s"), dbus_error.message);
goto finish; goto finish;
} }
} }
@ -143,7 +145,7 @@ int pa_polkit_check(const char *action_id) {
} }
if (polkit_result != POLKIT_RESULT_YES && polkit_result != POLKIT_RESULT_NO) if (polkit_result != POLKIT_RESULT_YES && polkit_result != POLKIT_RESULT_NO)
pa_log_warn("PolicyKit responded with '%s'", polkit_result_to_string_representation(polkit_result)); pa_log_warn(_("PolicyKit responded with '%s'"), polkit_result_to_string_representation(polkit_result));
ret = polkit_result == POLKIT_RESULT_YES; ret = polkit_result == POLKIT_RESULT_YES;

View file

@ -29,6 +29,7 @@
#include <string.h> #include <string.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
@ -98,66 +99,66 @@ const char *const table[PA_CHANNEL_POSITION_MAX] = {
}; };
const char *const pretty_table[PA_CHANNEL_POSITION_MAX] = { const char *const pretty_table[PA_CHANNEL_POSITION_MAX] = {
[PA_CHANNEL_POSITION_MONO] = "Mono", [PA_CHANNEL_POSITION_MONO] = N_("Mono"),
[PA_CHANNEL_POSITION_FRONT_CENTER] = "Front Center", [PA_CHANNEL_POSITION_FRONT_CENTER] = N_("Front Center"),
[PA_CHANNEL_POSITION_FRONT_LEFT] = "Front Left", [PA_CHANNEL_POSITION_FRONT_LEFT] = N_("Front Left"),
[PA_CHANNEL_POSITION_FRONT_RIGHT] = "Front Right", [PA_CHANNEL_POSITION_FRONT_RIGHT] = N_("Front Right"),
[PA_CHANNEL_POSITION_REAR_CENTER] = "Rear Center", [PA_CHANNEL_POSITION_REAR_CENTER] = N_("Rear Center"),
[PA_CHANNEL_POSITION_REAR_LEFT] = "Rear Left", [PA_CHANNEL_POSITION_REAR_LEFT] = N_("Rear Left"),
[PA_CHANNEL_POSITION_REAR_RIGHT] = "Rear Right", [PA_CHANNEL_POSITION_REAR_RIGHT] = N_("Rear Right"),
[PA_CHANNEL_POSITION_LFE] = "Low Frequency Emmiter", [PA_CHANNEL_POSITION_LFE] = N_("Low Frequency Emmiter"),
[PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER] = "Front Left-of-center", [PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER] = N_("Front Left-of-center"),
[PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER] = "Front Right-of-center", [PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER] = N_("Front Right-of-center"),
[PA_CHANNEL_POSITION_SIDE_LEFT] = "Side Left", [PA_CHANNEL_POSITION_SIDE_LEFT] = N_("Side Left"),
[PA_CHANNEL_POSITION_SIDE_RIGHT] = "Side Right", [PA_CHANNEL_POSITION_SIDE_RIGHT] = N_("Side Right"),
[PA_CHANNEL_POSITION_AUX0] = "Auxiliary 0", [PA_CHANNEL_POSITION_AUX0] = N_("Auxiliary 0"),
[PA_CHANNEL_POSITION_AUX1] = "Auxiliary 1", [PA_CHANNEL_POSITION_AUX1] = N_("Auxiliary 1"),
[PA_CHANNEL_POSITION_AUX2] = "Auxiliary 2", [PA_CHANNEL_POSITION_AUX2] = N_("Auxiliary 2"),
[PA_CHANNEL_POSITION_AUX3] = "Auxiliary 3", [PA_CHANNEL_POSITION_AUX3] = N_("Auxiliary 3"),
[PA_CHANNEL_POSITION_AUX4] = "Auxiliary 4", [PA_CHANNEL_POSITION_AUX4] = N_("Auxiliary 4"),
[PA_CHANNEL_POSITION_AUX5] = "Auxiliary 5", [PA_CHANNEL_POSITION_AUX5] = N_("Auxiliary 5"),
[PA_CHANNEL_POSITION_AUX6] = "Auxiliary 6", [PA_CHANNEL_POSITION_AUX6] = N_("Auxiliary 6"),
[PA_CHANNEL_POSITION_AUX7] = "Auxiliary 7", [PA_CHANNEL_POSITION_AUX7] = N_("Auxiliary 7"),
[PA_CHANNEL_POSITION_AUX8] = "Auxiliary 8", [PA_CHANNEL_POSITION_AUX8] = N_("Auxiliary 8"),
[PA_CHANNEL_POSITION_AUX9] = "Auxiliary 9", [PA_CHANNEL_POSITION_AUX9] = N_("Auxiliary 9"),
[PA_CHANNEL_POSITION_AUX10] = "Auxiliary 10", [PA_CHANNEL_POSITION_AUX10] = N_("Auxiliary 10"),
[PA_CHANNEL_POSITION_AUX11] = "Auxiliary 11", [PA_CHANNEL_POSITION_AUX11] = N_("Auxiliary 11"),
[PA_CHANNEL_POSITION_AUX12] = "Auxiliary 12", [PA_CHANNEL_POSITION_AUX12] = N_("Auxiliary 12"),
[PA_CHANNEL_POSITION_AUX13] = "Auxiliary 13", [PA_CHANNEL_POSITION_AUX13] = N_("Auxiliary 13"),
[PA_CHANNEL_POSITION_AUX14] = "Auxiliary 14", [PA_CHANNEL_POSITION_AUX14] = N_("Auxiliary 14"),
[PA_CHANNEL_POSITION_AUX15] = "Auxiliary 15", [PA_CHANNEL_POSITION_AUX15] = N_("Auxiliary 15"),
[PA_CHANNEL_POSITION_AUX16] = "Auxiliary 16", [PA_CHANNEL_POSITION_AUX16] = N_("Auxiliary 16"),
[PA_CHANNEL_POSITION_AUX17] = "Auxiliary 17", [PA_CHANNEL_POSITION_AUX17] = N_("Auxiliary 17"),
[PA_CHANNEL_POSITION_AUX18] = "Auxiliary 18", [PA_CHANNEL_POSITION_AUX18] = N_("Auxiliary 18"),
[PA_CHANNEL_POSITION_AUX19] = "Auxiliary 19", [PA_CHANNEL_POSITION_AUX19] = N_("Auxiliary 19"),
[PA_CHANNEL_POSITION_AUX20] = "Auxiliary 20", [PA_CHANNEL_POSITION_AUX20] = N_("Auxiliary 20"),
[PA_CHANNEL_POSITION_AUX21] = "Auxiliary 21", [PA_CHANNEL_POSITION_AUX21] = N_("Auxiliary 21"),
[PA_CHANNEL_POSITION_AUX22] = "Auxiliary 22", [PA_CHANNEL_POSITION_AUX22] = N_("Auxiliary 22"),
[PA_CHANNEL_POSITION_AUX23] = "Auxiliary 23", [PA_CHANNEL_POSITION_AUX23] = N_("Auxiliary 23"),
[PA_CHANNEL_POSITION_AUX24] = "Auxiliary 24", [PA_CHANNEL_POSITION_AUX24] = N_("Auxiliary 24"),
[PA_CHANNEL_POSITION_AUX25] = "Auxiliary 25", [PA_CHANNEL_POSITION_AUX25] = N_("Auxiliary 25"),
[PA_CHANNEL_POSITION_AUX26] = "Auxiliary 26", [PA_CHANNEL_POSITION_AUX26] = N_("Auxiliary 26"),
[PA_CHANNEL_POSITION_AUX27] = "Auxiliary 27", [PA_CHANNEL_POSITION_AUX27] = N_("Auxiliary 27"),
[PA_CHANNEL_POSITION_AUX28] = "Auxiliary 28", [PA_CHANNEL_POSITION_AUX28] = N_("Auxiliary 28"),
[PA_CHANNEL_POSITION_AUX29] = "Auxiliary 29", [PA_CHANNEL_POSITION_AUX29] = N_("Auxiliary 29"),
[PA_CHANNEL_POSITION_AUX30] = "Auxiliary 30", [PA_CHANNEL_POSITION_AUX30] = N_("Auxiliary 30"),
[PA_CHANNEL_POSITION_AUX31] = "Auxiliary 31", [PA_CHANNEL_POSITION_AUX31] = N_("Auxiliary 31"),
[PA_CHANNEL_POSITION_TOP_CENTER] = "Top Center", [PA_CHANNEL_POSITION_TOP_CENTER] = N_("Top Center"),
[PA_CHANNEL_POSITION_TOP_FRONT_CENTER] = "Top Front Center", [PA_CHANNEL_POSITION_TOP_FRONT_CENTER] = N_("Top Front Center"),
[PA_CHANNEL_POSITION_TOP_FRONT_LEFT] = "Top Front Left", [PA_CHANNEL_POSITION_TOP_FRONT_LEFT] = N_("Top Front Left"),
[PA_CHANNEL_POSITION_TOP_FRONT_RIGHT] = "Top Front Right", [PA_CHANNEL_POSITION_TOP_FRONT_RIGHT] = N_("Top Front Right"),
[PA_CHANNEL_POSITION_TOP_REAR_CENTER] = "Top Rear Center", [PA_CHANNEL_POSITION_TOP_REAR_CENTER] = N_("Top Rear Center"),
[PA_CHANNEL_POSITION_TOP_REAR_LEFT] = "Top Rear left", [PA_CHANNEL_POSITION_TOP_REAR_LEFT] = N_("Top Rear left"),
[PA_CHANNEL_POSITION_TOP_REAR_RIGHT] = "Top Rear Right" [PA_CHANNEL_POSITION_TOP_REAR_RIGHT] = N_("Top Rear Right")
}; };
pa_channel_map* pa_channel_map_init(pa_channel_map *m) { pa_channel_map* pa_channel_map_init(pa_channel_map *m) {
@ -432,10 +433,13 @@ const char* pa_channel_position_to_string(pa_channel_position_t pos) {
} }
const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos) { const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos) {
pa_init_i18n();
if (pos < 0 || pos >= PA_CHANNEL_POSITION_MAX) if (pos < 0 || pos >= PA_CHANNEL_POSITION_MAX)
return NULL; return NULL;
return pretty_table[pos]; return _(pretty_table[pos]);
} }
int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) { int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) {
@ -552,7 +556,6 @@ int pa_channel_map_valid(const pa_channel_map *map) {
if (map->map[c] < 0 ||map->map[c] >= PA_CHANNEL_POSITION_MAX) if (map->map[c] < 0 ||map->map[c] >= PA_CHANNEL_POSITION_MAX)
return 0; return 0;
} }
return 1; return 1;

View file

@ -29,6 +29,7 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/x11prop.h> #include <pulsecore/x11prop.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
@ -51,7 +52,7 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
goto finish; goto finish;
if (!(d = XOpenDisplay(dname))) { if (!(d = XOpenDisplay(dname))) {
pa_log("XOpenDisplay() failed"); pa_log(_("XOpenDisplay() failed"));
goto finish; goto finish;
} }
@ -74,7 +75,7 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
uint8_t cookie[PA_NATIVE_COOKIE_LENGTH]; uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
if (pa_parsehex(t, cookie, sizeof(cookie)) != sizeof(cookie)) { if (pa_parsehex(t, cookie, sizeof(cookie)) != sizeof(cookie)) {
pa_log("failed to parse cookie data"); pa_log(_("Failed to parse cookie data"));
goto finish; goto finish;
} }

View file

@ -30,6 +30,7 @@
#include <string.h> #include <string.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
@ -113,7 +114,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
if (filename) { if (filename) {
if (!(f = fopen(filename, "r"))) { if (!(f = fopen(filename, "r"))) {
pa_log("Failed to open configuration file '%s': %s", fn, pa_cstrerror(errno)); pa_log(_("Failed to open configuration file '%s': %s"), fn, pa_cstrerror(errno));
goto finish; goto finish;
} }

View file

@ -53,6 +53,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/utf8.h> #include <pulse/utf8.h>
#include <pulse/util.h> #include <pulse/util.h>
#include <pulse/i18n.h>
#include <pulsecore/winsock.h> #include <pulsecore/winsock.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
@ -106,7 +107,7 @@ static void unlock_autospawn_lock_file(pa_context *c) {
char *lf; char *lf;
if (!(lf = pa_runtime_path(AUTOSPAWN_LOCK))) if (!(lf = pa_runtime_path(AUTOSPAWN_LOCK)))
pa_log_warn("Cannot unlock autospawn because runtime path is no more."); pa_log_warn(_("Cannot unlock autospawn because runtime path is no more."));
pa_unlock_lockfile(lf, c->autospawn_lock_fd); pa_unlock_lockfile(lf, c->autospawn_lock_fd);
pa_xfree(lf); pa_xfree(lf);
@ -139,6 +140,8 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char *
pa_assert(mainloop); pa_assert(mainloop);
pa_init_i18n();
if (!name && !pa_proplist_contains(p, PA_PROP_APPLICATION_NAME)) if (!name && !pa_proplist_contains(p, PA_PROP_APPLICATION_NAME))
return NULL; return NULL;
@ -530,7 +533,7 @@ static void setup_context(pa_context *c, pa_iochannel *io) {
c->pdispatch = pa_pdispatch_new(c->mainloop, command_table, PA_COMMAND_MAX); c->pdispatch = pa_pdispatch_new(c->mainloop, command_table, PA_COMMAND_MAX);
if (!c->conf->cookie_valid) if (!c->conf->cookie_valid)
pa_log_info("No cookie loaded. Attempting to connect without."); pa_log_info(_("No cookie loaded. Attempting to connect without."));
t = pa_tagstruct_command(c, PA_COMMAND_AUTH, &tag); t = pa_tagstruct_command(c, PA_COMMAND_AUTH, &tag);
@ -584,7 +587,7 @@ static int context_connect_spawn(pa_context *c) {
pa_context_ref(c); pa_context_ref(c);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
pa_log_error("socketpair(): %s", pa_cstrerror(errno)); pa_log_error(_("socketpair(): %s"), pa_cstrerror(errno));
pa_context_fail(c, PA_ERR_INTERNAL); pa_context_fail(c, PA_ERR_INTERNAL);
goto fail; goto fail;
} }
@ -598,7 +601,7 @@ static int context_connect_spawn(pa_context *c) {
c->spawn_api.prefork(); c->spawn_api.prefork();
if ((pid = fork()) < 0) { if ((pid = fork()) < 0) {
pa_log_error("fork(): %s", pa_cstrerror(errno)); pa_log_error(_("fork(): %s"), pa_cstrerror(errno));
pa_context_fail(c, PA_ERR_INTERNAL); pa_context_fail(c, PA_ERR_INTERNAL);
if (c->spawn_api.postfork) if (c->spawn_api.postfork)
@ -661,7 +664,7 @@ static int context_connect_spawn(pa_context *c) {
c->spawn_api.postfork(); c->spawn_api.postfork();
if (r < 0) { if (r < 0) {
pa_log("waitpid(): %s", pa_cstrerror(errno)); pa_log(_("waitpid(): %s"), pa_cstrerror(errno));
pa_context_fail(c, PA_ERR_INTERNAL); pa_context_fail(c, PA_ERR_INTERNAL);
goto fail; goto fail;
} else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { } else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
@ -1259,7 +1262,7 @@ void pa_command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t
if (!strcmp(name, "module-stream-restore")) if (!strcmp(name, "module-stream-restore"))
pa_ext_stream_restore_command(c, tag, t); pa_ext_stream_restore_command(c, tag, t);
else else
pa_log("Received message for unknown extension '%s'", name); pa_log(_("Received message for unknown extension '%s'"), name);
finish: finish:
pa_context_unref(c); pa_context_unref(c);

View file

@ -30,6 +30,7 @@
#include <string.h> #include <string.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/native-common.h> #include <pulsecore/native-common.h>
@ -39,32 +40,34 @@
const char*pa_strerror(int error) { const char*pa_strerror(int error) {
static const char* const errortab[PA_ERR_MAX] = { static const char* const errortab[PA_ERR_MAX] = {
[PA_OK] = "OK", [PA_OK] = N_("OK"),
[PA_ERR_ACCESS] = "Access denied", [PA_ERR_ACCESS] = N_("Access denied"),
[PA_ERR_COMMAND] = "Unknown command", [PA_ERR_COMMAND] = N_("Unknown command"),
[PA_ERR_INVALID] = "Invalid argument", [PA_ERR_INVALID] = N_("Invalid argument"),
[PA_ERR_EXIST] = "Entity exists", [PA_ERR_EXIST] = N_("Entity exists"),
[PA_ERR_NOENTITY] = "No such entity", [PA_ERR_NOENTITY] = N_("No such entity"),
[PA_ERR_CONNECTIONREFUSED] = "Connection refused", [PA_ERR_CONNECTIONREFUSED] = N_("Connection refused"),
[PA_ERR_PROTOCOL] = "Protocol error", [PA_ERR_PROTOCOL] = N_("Protocol error"),
[PA_ERR_TIMEOUT] = "Timeout", [PA_ERR_TIMEOUT] = N_("Timeout"),
[PA_ERR_AUTHKEY] = "No authorization key", [PA_ERR_AUTHKEY] = N_("No authorization key"),
[PA_ERR_INTERNAL] = "Internal error", [PA_ERR_INTERNAL] = N_("Internal error"),
[PA_ERR_CONNECTIONTERMINATED] = "Connection terminated", [PA_ERR_CONNECTIONTERMINATED] = N_("Connection terminated"),
[PA_ERR_KILLED] = "Entity killed", [PA_ERR_KILLED] = N_("Entity killed"),
[PA_ERR_INVALIDSERVER] = "Invalid server", [PA_ERR_INVALIDSERVER] = N_("Invalid server"),
[PA_ERR_MODINITFAILED] = "Module initalization failed", [PA_ERR_MODINITFAILED] = N_("Module initalization failed"),
[PA_ERR_BADSTATE] = "Bad state", [PA_ERR_BADSTATE] = N_("Bad state"),
[PA_ERR_NODATA] = "No data", [PA_ERR_NODATA] = N_("No data"),
[PA_ERR_VERSION] = "Incompatible protocol version", [PA_ERR_VERSION] = N_("Incompatible protocol version"),
[PA_ERR_TOOLARGE] = "Too large", [PA_ERR_TOOLARGE] = N_("Too large"),
[PA_ERR_NOTSUPPORTED] = "Not supported", [PA_ERR_NOTSUPPORTED] = N_("Not supported"),
[PA_ERR_UNKNOWN] = "Unknown error code", [PA_ERR_UNKNOWN] = N_("Unknown error code"),
[PA_ERR_NOEXTENSION] = "No such extension" [PA_ERR_NOEXTENSION] = N_("No such extension")
}; };
pa_init_i18n();
if (error < 0 || error >= PA_ERR_MAX) if (error < 0 || error >= PA_ERR_MAX)
return NULL; return NULL;
return errortab[error]; return _(errortab[error]);
} }

38
src/pulse/i18n.c Normal file
View file

@ -0,0 +1,38 @@
/***
This file is part of PulseAudio.
Copyright 2008 Lennart Poettering
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <pulsecore/once.h>
#include "i18n.h"
void pa_init_i18n(void) {
PA_ONCE_BEGIN {
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
} PA_ONCE_END;
}

62
src/pulse/i18n.h Normal file
View file

@ -0,0 +1,62 @@
#ifndef foopulsei18nhfoo
#define foopulsei18nhfoo
/***
This file is part of PulseAudio.
Copyright 2008 Lennart Poettering
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
#include <pulse/cdecl.h>
#include <pulse/gccmacro.h>
PA_C_DECL_BEGIN
#if !defined(GETTEXT_PACKAGE)
#error "Something is very wrong here, config.h needs to be included first"
#endif
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext(GETTEXT_PACKAGE, String)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
#define N_(String) (String)
#endif
#else /* NLS is disabled */
#define _(String) (String)
#define N_(String) (String)
#define textdomain(String) (String)
#define gettext(String) (String)
#define dgettext(Domain,String) (String)
#define dcgettext(Domain,String,Type) (String)
#define bindtextdomain(Domain,Directory) (Domain)
#define bind_textdomain_codeset(Domain,Codeset) (Codeset)
#endif /* ENABLE_NLS */
void pa_init_i18n(void);
PA_C_DECL_END
#endif

View file

@ -27,6 +27,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/gccmacro.h> #include <pulse/gccmacro.h>
#include <pulse/i18n.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
@ -65,6 +66,8 @@ void pa_mainloop_api_once(pa_mainloop_api* m, void (*callback)(pa_mainloop_api *
pa_assert(m); pa_assert(m);
pa_assert(callback); pa_assert(callback);
pa_init_i18n();
i = pa_xnew(struct once_info, 1); i = pa_xnew(struct once_info, 1);
i->callback = callback; i->callback = callback;
i->userdata = userdata; i->userdata = userdata;

View file

@ -38,6 +38,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/gccmacro.h> #include <pulse/gccmacro.h>
#include <pulse/i18n.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
@ -165,6 +166,8 @@ pa_signal_event* pa_signal_new(int sig, pa_signal_cb_t _callback, void *userdata
pa_assert(sig > 0); pa_assert(sig > 0);
pa_assert(_callback); pa_assert(_callback);
pa_init_i18n();
for (e = signals; e; e = e->next) for (e = signals; e; e = e->next)
if (e->sig == sig) if (e->sig == sig)
goto fail; goto fail;

View file

@ -44,6 +44,7 @@
#include <pulse/timeval.h> #include <pulse/timeval.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/llist.h> #include <pulsecore/llist.h>
@ -446,6 +447,8 @@ static const pa_mainloop_api vtable = {
pa_mainloop *pa_mainloop_new(void) { pa_mainloop *pa_mainloop_new(void) {
pa_mainloop *m; pa_mainloop *m;
pa_init_i18n();
m = pa_xnew(pa_mainloop, 1); m = pa_xnew(pa_mainloop, 1);
m->wakeup_pipe_type = 0; m->wakeup_pipe_type = 0;

View file

@ -27,6 +27,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/utf8.h> #include <pulse/utf8.h>
#include <pulse/i18n.h>
#include <pulsecore/hashmap.h> #include <pulsecore/hashmap.h>
#include <pulsecore/strbuf.h> #include <pulsecore/strbuf.h>
@ -63,6 +64,8 @@ static void property_free(struct property *prop) {
} }
pa_proplist* pa_proplist_new(void) { pa_proplist* pa_proplist_new(void) {
pa_init_i18n();
return MAKE_PROPLIST(pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func)); return MAKE_PROPLIST(pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func));
} }

View file

@ -28,9 +28,11 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <pulse/timeval.h>
#include <pulse/i18n.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulse/timeval.h>
#include "sample.h" #include "sample.h"
@ -126,8 +128,10 @@ char *pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec) {
pa_assert(l); pa_assert(l);
pa_assert(spec); pa_assert(spec);
pa_init_i18n();
if (!pa_sample_spec_valid(spec)) if (!pa_sample_spec_valid(spec))
pa_snprintf(s, l, "Invalid"); pa_snprintf(s, l, _("Invalid"));
else else
pa_snprintf(s, l, "%s %uch %uHz", pa_sample_format_to_string(spec->format), spec->channels, spec->rate); pa_snprintf(s, l, "%s %uch %uHz", pa_sample_format_to_string(spec->format), spec->channels, spec->rate);

View file

@ -453,4 +453,3 @@ unlock_and_fail:
pa_threaded_mainloop_unlock(p->mainloop); pa_threaded_mainloop_unlock(p->mainloop);
return (pa_usec_t) -1; return (pa_usec_t) -1;
} }

View file

@ -35,6 +35,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/mainloop.h> #include <pulse/mainloop.h>
#include <pulse/i18n.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/hashmap.h> #include <pulsecore/hashmap.h>
@ -94,6 +95,8 @@ static void thread(void *userdata) {
pa_threaded_mainloop *pa_threaded_mainloop_new(void) { pa_threaded_mainloop *pa_threaded_mainloop_new(void) {
pa_threaded_mainloop *m; pa_threaded_mainloop *m;
pa_init_i18n();
m = pa_xnew(pa_threaded_mainloop, 1); m = pa_xnew(pa_threaded_mainloop, 1);
if (!(m->real_mainloop = pa_mainloop_new())) { if (!(m->real_mainloop = pa_mainloop_new())) {

View file

@ -33,15 +33,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <getopt.h> #include <getopt.h>
#include <fcntl.h> #include <fcntl.h>
#include <locale.h>
#include <pulse/i18n.h>
#include <pulse/pulseaudio.h> #include <pulse/pulseaudio.h>
#define TIME_EVENT_USEC 50000 #define TIME_EVENT_USEC 50000
#if PA_API_VERSION < 10
#error Invalid PulseAudio API version
#endif
#define CLEAR_LINE "\x1B[K" #define CLEAR_LINE "\x1B[K"
static enum { RECORD, PLAYBACK } mode = PLAYBACK; static enum { RECORD, PLAYBACK } mode = PLAYBACK;
@ -92,7 +90,7 @@ static void do_stream_write(size_t length) {
l = buffer_length; l = buffer_length;
if (pa_stream_write(stream, (uint8_t*) buffer + buffer_index, l, NULL, 0, PA_SEEK_RELATIVE) < 0) { if (pa_stream_write(stream, (uint8_t*) buffer + buffer_index, l, NULL, 0, PA_SEEK_RELATIVE) < 0) {
fprintf(stderr, "pa_stream_write() failed: %s\n", pa_strerror(pa_context_errno(context))); fprintf(stderr, _("pa_stream_write() failed: %s\n"), pa_strerror(pa_context_errno(context)));
quit(1); quit(1);
return; return;
} }
@ -131,7 +129,7 @@ static void stream_read_callback(pa_stream *s, size_t length, void *userdata) {
mainloop_api->io_enable(stdio_event, PA_IO_EVENT_OUTPUT); mainloop_api->io_enable(stdio_event, PA_IO_EVENT_OUTPUT);
if (pa_stream_peek(s, &data, &length) < 0) { if (pa_stream_peek(s, &data, &length) < 0) {
fprintf(stderr, "pa_stream_peek() failed: %s\n", pa_strerror(pa_context_errno(context))); fprintf(stderr, _("pa_stream_peek() failed: %s\n"), pa_strerror(pa_context_errno(context)));
quit(1); quit(1);
return; return;
} }
@ -140,9 +138,9 @@ static void stream_read_callback(pa_stream *s, size_t length, void *userdata) {
assert(length > 0); assert(length > 0);
if (buffer) { if (buffer) {
fprintf(stderr, "Buffer overrun, dropping incoming data\n"); fprintf(stderr, _("Buffer overrun, dropping incoming data\n"));
if (pa_stream_drop(s) < 0) { if (pa_stream_drop(s) < 0) {
fprintf(stderr, "pa_stream_drop() failed: %s\n", pa_strerror(pa_context_errno(context))); fprintf(stderr, _("pa_stream_drop() failed: %s\n"), pa_strerror(pa_context_errno(context)));
quit(1); quit(1);
} }
return; return;
@ -168,25 +166,25 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
const pa_buffer_attr *a; const pa_buffer_attr *a;
char cmt[PA_CHANNEL_MAP_SNPRINT_MAX], sst[PA_SAMPLE_SPEC_SNPRINT_MAX]; char cmt[PA_CHANNEL_MAP_SNPRINT_MAX], sst[PA_SAMPLE_SPEC_SNPRINT_MAX];
fprintf(stderr, "Stream successfully created.\n"); fprintf(stderr, _("Stream successfully created.\n"));
if (!(a = pa_stream_get_buffer_attr(s))) if (!(a = pa_stream_get_buffer_attr(s)))
fprintf(stderr, "pa_stream_get_buffer_attr() failed: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s)))); fprintf(stderr, _("pa_stream_get_buffer_attr() failed: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s))));
else { else {
if (mode == PLAYBACK) if (mode == PLAYBACK)
fprintf(stderr, "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n", a->maxlength, a->tlength, a->prebuf, a->minreq); fprintf(stderr, _("Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"), a->maxlength, a->tlength, a->prebuf, a->minreq);
else { else {
assert(mode == RECORD); assert(mode == RECORD);
fprintf(stderr, "Buffer metrics: maxlength=%u, fragsize=%u\n", a->maxlength, a->fragsize); fprintf(stderr, _("Buffer metrics: maxlength=%u, fragsize=%u\n"), a->maxlength, a->fragsize);
} }
} }
fprintf(stderr, "Using sample spec '%s', channel map '%s'.\n", fprintf(stderr, _("Using sample spec '%s', channel map '%s'.\n"),
pa_sample_spec_snprint(sst, sizeof(sst), pa_stream_get_sample_spec(s)), pa_sample_spec_snprint(sst, sizeof(sst), pa_stream_get_sample_spec(s)),
pa_channel_map_snprint(cmt, sizeof(cmt), pa_stream_get_channel_map(s))); pa_channel_map_snprint(cmt, sizeof(cmt), pa_stream_get_channel_map(s)));
fprintf(stderr, "Connected to device %s (%u, %ssuspended).\n", fprintf(stderr, _("Connected to device %s (%u, %ssuspended).\n"),
pa_stream_get_device_name(s), pa_stream_get_device_name(s),
pa_stream_get_device_index(s), pa_stream_get_device_index(s),
pa_stream_is_suspended(s) ? "" : "not "); pa_stream_is_suspended(s) ? "" : "not ");
@ -196,7 +194,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
case PA_STREAM_FAILED: case PA_STREAM_FAILED:
default: default:
fprintf(stderr, "Stream error: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s)))); fprintf(stderr, _("Stream error: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s))));
quit(1); quit(1);
} }
} }
@ -206,9 +204,9 @@ static void stream_suspended_callback(pa_stream *s, void *userdata) {
if (verbose) { if (verbose) {
if (pa_stream_is_suspended(s)) if (pa_stream_is_suspended(s))
fprintf(stderr, "Stream device suspended." CLEAR_LINE " \n"); fprintf(stderr, _("Stream device suspended.%s \n"), CLEAR_LINE);
else else
fprintf(stderr, "Stream device resumed." CLEAR_LINE " \n"); fprintf(stderr, _("Stream device resumed.%s \n"), CLEAR_LINE);
} }
} }
@ -216,28 +214,28 @@ static void stream_underflow_callback(pa_stream *s, void *userdata) {
assert(s); assert(s);
if (verbose) if (verbose)
fprintf(stderr, "Stream underrun." CLEAR_LINE " \n"); fprintf(stderr, _("Stream underrun.%s \n"), CLEAR_LINE);
} }
static void stream_overflow_callback(pa_stream *s, void *userdata) { static void stream_overflow_callback(pa_stream *s, void *userdata) {
assert(s); assert(s);
if (verbose) if (verbose)
fprintf(stderr, "Stream overrun." CLEAR_LINE " \n"); fprintf(stderr, _("Stream overrun.%s \n"), CLEAR_LINE);
} }
static void stream_started_callback(pa_stream *s, void *userdata) { static void stream_started_callback(pa_stream *s, void *userdata) {
assert(s); assert(s);
if (verbose) if (verbose)
fprintf(stderr, "Stream started." CLEAR_LINE " \n"); fprintf(stderr, _("Stream started.%s \n"), CLEAR_LINE);
} }
static void stream_moved_callback(pa_stream *s, void *userdata) { static void stream_moved_callback(pa_stream *s, void *userdata) {
assert(s); assert(s);
if (verbose) if (verbose)
fprintf(stderr, "Stream moved to device %s (%u, %ssuspended)." CLEAR_LINE " \n", pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : "not "); fprintf(stderr, _("Stream moved to device %s (%u, %ssuspended).%s \n"), pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : _("not "), CLEAR_LINE);
} }
/* This is called whenever the context status changes */ /* This is called whenever the context status changes */
@ -258,10 +256,10 @@ static void context_state_callback(pa_context *c, void *userdata) {
assert(!stream); assert(!stream);
if (verbose) if (verbose)
fprintf(stderr, "Connection established." CLEAR_LINE " \n"); fprintf(stderr, _("Connection established.%s \n"), CLEAR_LINE);
if (!(stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL))) { if (!(stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL))) {
fprintf(stderr, "pa_stream_new() failed: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("pa_stream_new() failed: %s\n"), pa_strerror(pa_context_errno(c)));
goto fail; goto fail;
} }
@ -286,13 +284,13 @@ static void context_state_callback(pa_context *c, void *userdata) {
if (mode == PLAYBACK) { if (mode == PLAYBACK) {
pa_cvolume cv; pa_cvolume cv;
if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) { if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) {
fprintf(stderr, "pa_stream_connect_playback() failed: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("pa_stream_connect_playback() failed: %s\n"), pa_strerror(pa_context_errno(c)));
goto fail; goto fail;
} }
} else { } else {
if ((r = pa_stream_connect_record(stream, device, latency > 0 ? &buffer_attr : NULL, flags)) < 0) { if ((r = pa_stream_connect_record(stream, device, latency > 0 ? &buffer_attr : NULL, flags)) < 0) {
fprintf(stderr, "pa_stream_connect_record() failed: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("pa_stream_connect_record() failed: %s\n"), pa_strerror(pa_context_errno(c)));
goto fail; goto fail;
} }
} }
@ -306,7 +304,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED: case PA_CONTEXT_FAILED:
default: default:
fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c)));
goto fail; goto fail;
} }
@ -327,12 +325,12 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) {
pa_operation *o; pa_operation *o;
if (!success) { if (!success) {
fprintf(stderr, "Failed to drain stream: %s\n", pa_strerror(pa_context_errno(context))); fprintf(stderr, _("Failed to drain stream: %s\n"), pa_strerror(pa_context_errno(context)));
quit(1); quit(1);
} }
if (verbose) if (verbose)
fprintf(stderr, "Playback stream drained.\n"); fprintf(stderr, _("Playback stream drained.\n"));
pa_stream_disconnect(stream); pa_stream_disconnect(stream);
pa_stream_unref(stream); pa_stream_unref(stream);
@ -342,7 +340,7 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) {
pa_context_disconnect(context); pa_context_disconnect(context);
else { else {
if (verbose) if (verbose)
fprintf(stderr, "Draining connection to server.\n"); fprintf(stderr, _("Draining connection to server.\n"));
} }
} }
@ -368,13 +366,13 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even
if ((r = read(fd, buffer, l)) <= 0) { if ((r = read(fd, buffer, l)) <= 0) {
if (r == 0) { if (r == 0) {
if (verbose) if (verbose)
fprintf(stderr, "Got EOF.\n"); fprintf(stderr, _("Got EOF.\n"));
if (stream) { if (stream) {
pa_operation *o; pa_operation *o;
if (!(o = pa_stream_drain(stream, stream_drain_complete, NULL))) { if (!(o = pa_stream_drain(stream, stream_drain_complete, NULL))) {
fprintf(stderr, "pa_stream_drain(): %s\n", pa_strerror(pa_context_errno(context))); fprintf(stderr, _("pa_stream_drain(): %s\n"), pa_strerror(pa_context_errno(context)));
quit(1); quit(1);
return; return;
} }
@ -384,7 +382,7 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even
quit(0); quit(0);
} else { } else {
fprintf(stderr, "read() failed: %s\n", strerror(errno)); fprintf(stderr, _("read() failed: %s\n"), strerror(errno));
quit(1); quit(1);
} }
@ -416,7 +414,7 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve
assert(buffer_length); assert(buffer_length);
if ((r = write(fd, (uint8_t*) buffer+buffer_index, buffer_length)) <= 0) { if ((r = write(fd, (uint8_t*) buffer+buffer_index, buffer_length)) <= 0) {
fprintf(stderr, "write() failed: %s\n", strerror(errno)); fprintf(stderr, _("write() failed: %s\n"), strerror(errno));
quit(1); quit(1);
mainloop_api->io_free(stdio_event); mainloop_api->io_free(stdio_event);
@ -437,7 +435,7 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve
/* UNIX signal to quit recieved */ /* UNIX signal to quit recieved */
static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) { static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
if (verbose) if (verbose)
fprintf(stderr, "Got signal, exiting.\n"); fprintf(stderr, _("Got signal, exiting.\n"));
quit(0); quit(0);
} }
@ -451,12 +449,12 @@ static void stream_update_timing_callback(pa_stream *s, int success, void *userd
if (!success || if (!success ||
pa_stream_get_time(s, &usec) < 0 || pa_stream_get_time(s, &usec) < 0 ||
pa_stream_get_latency(s, &l, &negative) < 0) { pa_stream_get_latency(s, &l, &negative) < 0) {
fprintf(stderr, "Failed to get latency: %s\n", pa_strerror(pa_context_errno(context))); fprintf(stderr, _("Failed to get latency: %s\n"), pa_strerror(pa_context_errno(context)));
quit(1); quit(1);
return; return;
} }
fprintf(stderr, "Time: %0.3f sec; Latency: %0.0f usec. \r", fprintf(stderr, _("Time: %0.3f sec; Latency: %0.0f usec. \r"),
(float) usec / 1000000, (float) usec / 1000000,
(float) l * (negative?-1:1)); (float) l * (negative?-1:1));
} }
@ -476,7 +474,7 @@ static void time_event_callback(pa_mainloop_api*m, pa_time_event *e, const struc
if (stream && pa_stream_get_state(stream) == PA_STREAM_READY) { if (stream && pa_stream_get_state(stream) == PA_STREAM_READY) {
pa_operation *o; pa_operation *o;
if (!(o = pa_stream_update_timing_info(stream, stream_update_timing_callback, NULL))) if (!(o = pa_stream_update_timing_info(stream, stream_update_timing_callback, NULL)))
fprintf(stderr, "pa_stream_update_timing_info() failed: %s\n", pa_strerror(pa_context_errno(context))); fprintf(stderr, _("pa_stream_update_timing_info() failed: %s\n"), pa_strerror(pa_context_errno(context)));
else else
pa_operation_unref(o); pa_operation_unref(o);
} }
@ -489,7 +487,7 @@ static void time_event_callback(pa_mainloop_api*m, pa_time_event *e, const struc
static void help(const char *argv0) { static void help(const char *argv0) {
printf("%s [options]\n\n" printf(_("%s [options]\n\n"
" -h, --help Show this help\n" " -h, --help Show this help\n"
" --version Show version\n\n" " --version Show version\n\n"
" -r, --record Create a connection for recording\n" " -r, --record Create a connection for recording\n"
@ -515,7 +513,7 @@ static void help(const char *argv0) {
" --no-remix Don't upmix or downmix channels.\n" " --no-remix Don't upmix or downmix channels.\n"
" --no-remap Map channels by index instead of name.\n" " --no-remap Map channels by index instead of name.\n"
" --latency=BYTES Request the specified latency in bytes.\n" " --latency=BYTES Request the specified latency in bytes.\n"
" --process-time=BYTES Request the specified process time per request in bytes.\n" " --process-time=BYTES Request the specified process time per request in bytes.\n")
, ,
argv0); argv0);
} }
@ -568,6 +566,9 @@ int main(int argc, char *argv[]) {
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
if (!(bn = strrchr(argv[0], '/'))) if (!(bn = strrchr(argv[0], '/')))
bn = argv[0]; bn = argv[0];
else else
@ -587,7 +588,7 @@ int main(int argc, char *argv[]) {
goto quit; goto quit;
case ARG_VERSION: case ARG_VERSION:
printf("pacat "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version()); printf(_("pacat %s\nCompiled with libpulse %s\nLinked with libpulse %s\n"), PACKAGE_VERSION, pa_get_headers_version(), pa_get_library_version());
ret = 0; ret = 0;
goto quit; goto quit;
@ -643,7 +644,7 @@ int main(int argc, char *argv[]) {
case ARG_CHANNELMAP: case ARG_CHANNELMAP:
if (!pa_channel_map_parse(&channel_map, optarg)) { if (!pa_channel_map_parse(&channel_map, optarg)) {
fprintf(stderr, "Invalid channel map '%s'\n", optarg); fprintf(stderr, _("Invalid channel map '%s'\n"), optarg);
goto quit; goto quit;
} }
@ -672,14 +673,14 @@ int main(int argc, char *argv[]) {
case ARG_LATENCY: case ARG_LATENCY:
if (((latency = atoi(optarg))) <= 0) { if (((latency = atoi(optarg))) <= 0) {
fprintf(stderr, "Invalid latency specification '%s'\n", optarg); fprintf(stderr, _("Invalid latency specification '%s'\n"), optarg);
goto quit; goto quit;
} }
break; break;
case ARG_PROCESS_TIME: case ARG_PROCESS_TIME:
if (((process_time = atoi(optarg))) <= 0) { if (((process_time = atoi(optarg))) <= 0) {
fprintf(stderr, "Invalid process time specification '%s'\n", optarg); fprintf(stderr, _("Invalid process time specification '%s'\n"), optarg);
goto quit; goto quit;
} }
break; break;
@ -690,19 +691,19 @@ int main(int argc, char *argv[]) {
} }
if (!pa_sample_spec_valid(&sample_spec)) { if (!pa_sample_spec_valid(&sample_spec)) {
fprintf(stderr, "Invalid sample specification\n"); fprintf(stderr, _("Invalid sample specification\n"));
goto quit; goto quit;
} }
if (channel_map_set && channel_map.channels != sample_spec.channels) { if (channel_map_set && channel_map.channels != sample_spec.channels) {
fprintf(stderr, "Channel map doesn't match sample specification\n"); fprintf(stderr, _("Channel map doesn't match sample specification\n"));
goto quit; goto quit;
} }
if (verbose) { if (verbose) {
char t[PA_SAMPLE_SPEC_SNPRINT_MAX]; char t[PA_SAMPLE_SPEC_SNPRINT_MAX];
pa_sample_spec_snprint(t, sizeof(t), &sample_spec); pa_sample_spec_snprint(t, sizeof(t), &sample_spec);
fprintf(stderr, "Opening a %s stream with sample specification '%s'.\n", mode == RECORD ? "recording" : "playback", t); fprintf(stderr, _("Opening a %s stream with sample specification '%s'.\n"), mode == RECORD ? _("recording") : _("playback"), t);
} }
if (!(optind >= argc)) { if (!(optind >= argc)) {
@ -710,12 +711,12 @@ int main(int argc, char *argv[]) {
int fd; int fd;
if ((fd = open(argv[optind], mode == PLAYBACK ? O_RDONLY : O_WRONLY|O_TRUNC|O_CREAT, 0666)) < 0) { if ((fd = open(argv[optind], mode == PLAYBACK ? O_RDONLY : O_WRONLY|O_TRUNC|O_CREAT, 0666)) < 0) {
fprintf(stderr, "open(): %s\n", strerror(errno)); fprintf(stderr, _("open(): %s\n"), strerror(errno));
goto quit; goto quit;
} }
if (dup2(fd, mode == PLAYBACK ? 0 : 1) < 0) { if (dup2(fd, mode == PLAYBACK ? 0 : 1) < 0) {
fprintf(stderr, "dup2(): %s\n", strerror(errno)); fprintf(stderr, _("dup2(): %s\n"), strerror(errno));
goto quit; goto quit;
} }
@ -725,7 +726,7 @@ int main(int argc, char *argv[]) {
stream_name = pa_xstrdup(argv[optind]); stream_name = pa_xstrdup(argv[optind]);
} else { } else {
fprintf(stderr, "Too many arguments.\n"); fprintf(stderr, _("Too many arguments.\n"));
goto quit; goto quit;
} }
} }
@ -738,7 +739,7 @@ int main(int argc, char *argv[]) {
/* Set up a new main loop */ /* Set up a new main loop */
if (!(m = pa_mainloop_new())) { if (!(m = pa_mainloop_new())) {
fprintf(stderr, "pa_mainloop_new() failed.\n"); fprintf(stderr, _("pa_mainloop_new() failed.\n"));
goto quit; goto quit;
} }
@ -759,13 +760,13 @@ int main(int argc, char *argv[]) {
mode == PLAYBACK ? STDIN_FILENO : STDOUT_FILENO, mode == PLAYBACK ? STDIN_FILENO : STDOUT_FILENO,
mode == PLAYBACK ? PA_IO_EVENT_INPUT : PA_IO_EVENT_OUTPUT, mode == PLAYBACK ? PA_IO_EVENT_INPUT : PA_IO_EVENT_OUTPUT,
mode == PLAYBACK ? stdin_callback : stdout_callback, NULL))) { mode == PLAYBACK ? stdin_callback : stdout_callback, NULL))) {
fprintf(stderr, "io_new() failed.\n"); fprintf(stderr, _("io_new() failed.\n"));
goto quit; goto quit;
} }
/* Create a new connection context */ /* Create a new connection context */
if (!(context = pa_context_new(mainloop_api, client_name))) { if (!(context = pa_context_new(mainloop_api, client_name))) {
fprintf(stderr, "pa_context_new() failed.\n"); fprintf(stderr, _("pa_context_new() failed.\n"));
goto quit; goto quit;
} }
@ -781,14 +782,14 @@ int main(int argc, char *argv[]) {
pa_timeval_add(&tv, TIME_EVENT_USEC); pa_timeval_add(&tv, TIME_EVENT_USEC);
if (!(time_event = mainloop_api->time_new(mainloop_api, &tv, time_event_callback, NULL))) { if (!(time_event = mainloop_api->time_new(mainloop_api, &tv, time_event_callback, NULL))) {
fprintf(stderr, "time_new() failed.\n"); fprintf(stderr, _("time_new() failed.\n"));
goto quit; goto quit;
} }
} }
/* Run the main loop */ /* Run the main loop */
if (pa_mainloop_run(m, &ret) < 0) { if (pa_mainloop_run(m, &ret) < 0) {
fprintf(stderr, "pa_mainloop_run() failed.\n"); fprintf(stderr, _("pa_mainloop_run() failed.\n"));
goto quit; goto quit;
} }

View file

@ -31,10 +31,12 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <sys/un.h> #include <sys/un.h>
#include <locale.h>
#include <pulse/error.h> #include <pulse/error.h>
#include <pulse/util.h> #include <pulse/util.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
@ -50,13 +52,16 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
fd_set ifds, ofds; fd_set ifds, ofds;
char *cli; char *cli;
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
if (pa_pid_file_check_running(&pid, "pulseaudio") < 0) { if (pa_pid_file_check_running(&pid, "pulseaudio") < 0) {
pa_log("no PulseAudio daemon running"); pa_log("No PulseAudio daemon running");
goto fail; goto fail;
} }
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
pa_log("socket(PF_UNIX, SOCK_STREAM, 0): %s", strerror(errno)); pa_log(_("socket(PF_UNIX, SOCK_STREAM, 0): %s"), strerror(errno));
goto fail; goto fail;
} }
@ -73,7 +78,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
int r; int r;
if ((r = connect(fd, (struct sockaddr*) &sa, sizeof(sa))) < 0 && (errno != ECONNREFUSED && errno != ENOENT)) { if ((r = connect(fd, (struct sockaddr*) &sa, sizeof(sa))) < 0 && (errno != ECONNREFUSED && errno != ENOENT)) {
pa_log("connect(): %s", strerror(errno)); pa_log(_("connect(): %s"), strerror(errno));
goto fail; goto fail;
} }
@ -81,7 +86,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
break; break;
if (pa_pid_file_kill(SIGUSR2, NULL, "pulseaudio") < 0) { if (pa_pid_file_kill(SIGUSR2, NULL, "pulseaudio") < 0) {
pa_log("failed to kill PulseAudio daemon."); pa_log(_("Failed to kill PulseAudio daemon."));
goto fail; goto fail;
} }
@ -89,7 +94,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
} }
if (i >= 5) { if (i >= 5) {
pa_log("daemon not responding."); pa_log(_("Daemon not responding."));
goto fail; goto fail;
} }
@ -104,7 +109,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
for (;;) { for (;;) {
if (select(FD_SETSIZE, &ifds, &ofds, NULL, NULL) < 0) { if (select(FD_SETSIZE, &ifds, &ofds, NULL, NULL) < 0) {
pa_log("select(): %s", strerror(errno)); pa_log(_("select(): %s"), strerror(errno));
goto fail; goto fail;
} }
@ -116,7 +121,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
if (r == 0) if (r == 0)
break; break;
pa_log("read(): %s", strerror(errno)); pa_log(_("read(): %s"), strerror(errno));
goto fail; goto fail;
} }
@ -132,7 +137,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
if (r == 0) if (r == 0)
break; break;
pa_log("read(): %s", strerror(errno)); pa_log(_("read(): %s"), strerror(errno));
goto fail; goto fail;
} }
@ -145,7 +150,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
assert(obuf_length); assert(obuf_length);
if ((r = write(1, obuf + obuf_index, obuf_length)) < 0) { if ((r = write(1, obuf + obuf_index, obuf_length)) < 0) {
pa_log("write(): %s", strerror(errno)); pa_log(_("write(): %s"), strerror(errno));
goto fail; goto fail;
} }
@ -159,7 +164,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
assert(ibuf_length); assert(ibuf_length);
if ((r = write(fd, ibuf + ibuf_index, ibuf_length)) < 0) { if ((r = write(fd, ibuf + ibuf_index, ibuf_length)) < 0) {
pa_log("write(): %s", strerror(errno)); pa_log(_("write(): %s"), strerror(errno));
goto fail; goto fail;
} }
@ -182,7 +187,6 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
FD_SET(fd, &ofds); FD_SET(fd, &ofds);
} }
ret = 0; ret = 0;
fail: fail:

View file

@ -32,16 +32,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
#include <getopt.h> #include <getopt.h>
#include <locale.h>
#include <sndfile.h> #include <sndfile.h>
#include <pulse/i18n.h>
#include <pulse/pulseaudio.h> #include <pulse/pulseaudio.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#if PA_API_VERSION < 10
#error Invalid PulseAudio API version
#endif
#define BUFSIZE 1024 #define BUFSIZE 1024
static pa_context *context = NULL; static pa_context *context = NULL;
@ -106,19 +104,19 @@ static void complete_action(void) {
static void stat_callback(pa_context *c, const pa_stat_info *i, void *userdata) { static void stat_callback(pa_context *c, const pa_stat_info *i, void *userdata) {
char s[128]; char s[128];
if (!i) { if (!i) {
fprintf(stderr, "Failed to get statistics: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get statistics: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
pa_bytes_snprint(s, sizeof(s), i->memblock_total_size); pa_bytes_snprint(s, sizeof(s), i->memblock_total_size);
printf("Currently in use: %u blocks containing %s bytes total.\n", i->memblock_total, s); printf(_("Currently in use: %u blocks containing %s bytes total.\n"), i->memblock_total, s);
pa_bytes_snprint(s, sizeof(s), i->memblock_allocated_size); pa_bytes_snprint(s, sizeof(s), i->memblock_allocated_size);
printf("Allocated during whole lifetime: %u blocks containing %s bytes total.\n", i->memblock_allocated, s); printf(_("Allocated during whole lifetime: %u blocks containing %s bytes total.\n"), i->memblock_allocated, s);
pa_bytes_snprint(s, sizeof(s), i->scache_size); pa_bytes_snprint(s, sizeof(s), i->scache_size);
printf("Sample cache size: %s\n", s); printf(_("Sample cache size: %s\n"), s);
complete_action(); complete_action();
} }
@ -127,21 +125,21 @@ static void get_server_info_callback(pa_context *c, const pa_server_info *i, voi
char s[PA_SAMPLE_SPEC_SNPRINT_MAX]; char s[PA_SAMPLE_SPEC_SNPRINT_MAX];
if (!i) { if (!i) {
fprintf(stderr, "Failed to get server information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get server information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec); pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec);
printf("User name: %s\n" printf(_("User name: %s\n"
"Host Name: %s\n" "Host Name: %s\n"
"Server Name: %s\n" "Server Name: %s\n"
"Server Version: %s\n" "Server Version: %s\n"
"Default Sample Specification: %s\n" "Default Sample Specification: %s\n"
"Default Sink: %s\n" "Default Sink: %s\n"
"Default Source: %s\n" "Default Source: %s\n"
"Cookie: %08x\n", "Cookie: %08x\n"),
i->user_name, i->user_name,
i->host_name, i->host_name,
i->server_name, i->server_name,
@ -159,7 +157,7 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
char *pl; char *pl;
if (is_last < 0) { if (is_last < 0) {
fprintf(stderr, "Failed to get sink information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get sink information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -175,7 +173,7 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
printf("\n"); printf("\n");
nl = 1; nl = 1;
printf("*** Sink #%u ***\n" printf(_("*** Sink #%u ***\n"
"Name: %s\n" "Name: %s\n"
"Driver: %s\n" "Driver: %s\n"
"Sample Specification: %s\n" "Sample Specification: %s\n"
@ -185,14 +183,14 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
"Monitor Source: %s\n" "Monitor Source: %s\n"
"Latency: %0.0f usec, configured %0.0f usec\n" "Latency: %0.0f usec, configured %0.0f usec\n"
"Flags: %s%s%s%s%s%s\n" "Flags: %s%s%s%s%s%s\n"
"Properties:\n%s", "Properties:\n%s"),
i->index, i->index,
i->name, i->name,
pa_strnull(i->driver), pa_strnull(i->driver),
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
i->owner_module, i->owner_module,
i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume), i->mute ? _("muted") : pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
pa_strnull(i->monitor_source_name), pa_strnull(i->monitor_source_name),
(double) i->latency, (double) i->configured_latency, (double) i->latency, (double) i->configured_latency,
i->flags & PA_SINK_HARDWARE ? "HARDWARE " : "", i->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
@ -211,7 +209,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
char *pl; char *pl;
if (is_last < 0) { if (is_last < 0) {
fprintf(stderr, "Failed to get source information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get source information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -227,7 +225,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
printf("\n"); printf("\n");
nl = 1; nl = 1;
printf("*** Source #%u ***\n" printf(_("*** Source #%u ***\n"
"Name: %s\n" "Name: %s\n"
"Driver: %s\n" "Driver: %s\n"
"Sample Specification: %s\n" "Sample Specification: %s\n"
@ -237,7 +235,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
"Monitor of Sink: %s\n" "Monitor of Sink: %s\n"
"Latency: %0.0f usec, configured %0.0f usec\n" "Latency: %0.0f usec, configured %0.0f usec\n"
"Flags: %s%s%s%s%s%s\n" "Flags: %s%s%s%s%s%s\n"
"Properties:\n%s", "Properties:\n%s"),
i->index, i->index,
i->name, i->name,
pa_strnull(i->driver), pa_strnull(i->driver),
@ -245,7 +243,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
i->owner_module, i->owner_module,
i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume), i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
i->monitor_of_sink_name ? i->monitor_of_sink_name : "n/a", i->monitor_of_sink_name ? i->monitor_of_sink_name : _("n/a"),
(double) i->latency, (double) i->configured_latency, (double) i->latency, (double) i->configured_latency,
i->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "", i->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
i->flags & PA_SOURCE_NETWORK ? "NETWORK " : "", i->flags & PA_SOURCE_NETWORK ? "NETWORK " : "",
@ -262,7 +260,7 @@ static void get_module_info_callback(pa_context *c, const pa_module_info *i, int
char t[32]; char t[32];
if (is_last < 0) { if (is_last < 0) {
fprintf(stderr, "Failed to get module information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get module information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -280,15 +278,15 @@ static void get_module_info_callback(pa_context *c, const pa_module_info *i, int
snprintf(t, sizeof(t), "%u", i->n_used); snprintf(t, sizeof(t), "%u", i->n_used);
printf("*** Module #%u ***\n" printf(_("*** Module #%u ***\n"
"Name: %s\n" "Name: %s\n"
"Argument: %s\n" "Argument: %s\n"
"Usage counter: %s\n" "Usage counter: %s\n"
"Auto unload: %s\n", "Auto unload: %s\n"),
i->index, i->index,
i->name, i->name,
i->argument ? i->argument : "", i->argument ? i->argument : "",
i->n_used != PA_INVALID_INDEX ? t : "n/a", i->n_used != PA_INVALID_INDEX ? t : _("n/a"),
pa_yes_no(i->auto_unload)); pa_yes_no(i->auto_unload));
} }
@ -297,7 +295,7 @@ static void get_client_info_callback(pa_context *c, const pa_client_info *i, int
char *pl; char *pl;
if (is_last < 0) { if (is_last < 0) {
fprintf(stderr, "Failed to get client information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get client information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -315,13 +313,13 @@ static void get_client_info_callback(pa_context *c, const pa_client_info *i, int
snprintf(t, sizeof(t), "%u", i->owner_module); snprintf(t, sizeof(t), "%u", i->owner_module);
printf("*** Client #%u ***\n" printf(_("*** Client #%u ***\n"
"Driver: %s\n" "Driver: %s\n"
"Owner Module: %s\n" "Owner Module: %s\n"
"Properties:\n%s", "Properties:\n%s"),
i->index, i->index,
pa_strnull(i->driver), pa_strnull(i->driver),
i->owner_module != PA_INVALID_INDEX ? t : "n/a", i->owner_module != PA_INVALID_INDEX ? t : _("n/a"),
pl = pa_proplist_to_string(i->proplist)); pl = pa_proplist_to_string(i->proplist));
pa_xfree(pl); pa_xfree(pl);
@ -332,7 +330,7 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info
char *pl; char *pl;
if (is_last < 0) { if (is_last < 0) {
fprintf(stderr, "Failed to get sink input information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get sink input information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -351,7 +349,7 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info
snprintf(t, sizeof(t), "%u", i->owner_module); snprintf(t, sizeof(t), "%u", i->owner_module);
snprintf(k, sizeof(k), "%u", i->client); snprintf(k, sizeof(k), "%u", i->client);
printf("*** Sink Input #%u ***\n" printf(_("*** Sink Input #%u ***\n"
"Driver: %s\n" "Driver: %s\n"
"Owner Module: %s\n" "Owner Module: %s\n"
"Client: %s\n" "Client: %s\n"
@ -362,18 +360,18 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info
"Buffer Latency: %0.0f usec\n" "Buffer Latency: %0.0f usec\n"
"Sink Latency: %0.0f usec\n" "Sink Latency: %0.0f usec\n"
"Resample method: %s\n" "Resample method: %s\n"
"Properties:\n%s", "Properties:\n%s"),
i->index, i->index,
pa_strnull(i->driver), pa_strnull(i->driver),
i->owner_module != PA_INVALID_INDEX ? t : "n/a", i->owner_module != PA_INVALID_INDEX ? t : _("n/a"),
i->client != PA_INVALID_INDEX ? k : "n/a", i->client != PA_INVALID_INDEX ? k : _("n/a"),
i->sink, i->sink,
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume), i->mute ? _("muted") : pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
(double) i->buffer_usec, (double) i->buffer_usec,
(double) i->sink_usec, (double) i->sink_usec,
i->resample_method ? i->resample_method : "n/a", i->resample_method ? i->resample_method : _("n/a"),
pl = pa_proplist_to_string(i->proplist)); pl = pa_proplist_to_string(i->proplist));
pa_xfree(pl); pa_xfree(pl);
@ -384,7 +382,7 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu
char *pl; char *pl;
if (is_last < 0) { if (is_last < 0) {
fprintf(stderr, "Failed to get source output information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get source output information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -404,7 +402,7 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu
snprintf(t, sizeof(t), "%u", i->owner_module); snprintf(t, sizeof(t), "%u", i->owner_module);
snprintf(k, sizeof(k), "%u", i->client); snprintf(k, sizeof(k), "%u", i->client);
printf("*** Source Output #%u ***\n" printf(_("*** Source Output #%u ***\n"
"Driver: %s\n" "Driver: %s\n"
"Owner Module: %s\n" "Owner Module: %s\n"
"Client: %s\n" "Client: %s\n"
@ -414,17 +412,17 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu
"Buffer Latency: %0.0f usec\n" "Buffer Latency: %0.0f usec\n"
"Source Latency: %0.0f usec\n" "Source Latency: %0.0f usec\n"
"Resample method: %s\n" "Resample method: %s\n"
"Properties:\n%s", "Properties:\n%s"),
i->index, i->index,
pa_strnull(i->driver), pa_strnull(i->driver),
i->owner_module != PA_INVALID_INDEX ? t : "n/a", i->owner_module != PA_INVALID_INDEX ? t : _("n/a"),
i->client != PA_INVALID_INDEX ? k : "n/a", i->client != PA_INVALID_INDEX ? k : _("n/a"),
i->source, i->source,
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
(double) i->buffer_usec, (double) i->buffer_usec,
(double) i->source_usec, (double) i->source_usec,
i->resample_method ? i->resample_method : "n/a", i->resample_method ? i->resample_method : _("n/a"),
pl = pa_proplist_to_string(i->proplist)); pl = pa_proplist_to_string(i->proplist));
pa_xfree(pl); pa_xfree(pl);
@ -435,7 +433,7 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int
char *pl; char *pl;
if (is_last < 0) { if (is_last < 0) {
fprintf(stderr, "Failed to get sample information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get sample information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -454,7 +452,7 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int
pa_bytes_snprint(t, sizeof(t), i->bytes); pa_bytes_snprint(t, sizeof(t), i->bytes);
printf("*** Sample #%u ***\n" printf(_("*** Sample #%u ***\n"
"Name: %s\n" "Name: %s\n"
"Volume: %s\n" "Volume: %s\n"
"Sample Specification: %s\n" "Sample Specification: %s\n"
@ -463,16 +461,16 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int
"Size: %s\n" "Size: %s\n"
"Lazy: %s\n" "Lazy: %s\n"
"Filename: %s\n" "Filename: %s\n"
"Properties:\n%s", "Properties:\n%s"),
i->index, i->index,
i->name, i->name,
pa_cvolume_snprint(cv, sizeof(cv), &i->volume), pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
pa_sample_spec_valid(&i->sample_spec) ? pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec) : "n/a", pa_sample_spec_valid(&i->sample_spec) ? pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec) : _("n/a"),
pa_sample_spec_valid(&i->sample_spec) ? pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map) : "n/a", pa_sample_spec_valid(&i->sample_spec) ? pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map) : _("n/a"),
(double) i->duration/1000000, (double) i->duration/1000000,
t, t,
pa_yes_no(i->lazy), pa_yes_no(i->lazy),
i->filename ? i->filename : "n/a", i->filename ? i->filename : _("n/a"),
pl = pa_proplist_to_string(i->proplist)); pl = pa_proplist_to_string(i->proplist));
pa_xfree(pl); pa_xfree(pl);
@ -480,7 +478,7 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int
static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata) { static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata) {
if (is_last < 0) { if (is_last < 0) {
fprintf(stderr, "Failed to get autoload information: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failed to get autoload information: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -496,21 +494,21 @@ static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i,
printf("\n"); printf("\n");
nl = 1; nl = 1;
printf("*** Autoload Entry #%u ***\n" printf(_("*** Autoload Entry #%u ***\n"
"Name: %s\n" "Name: %s\n"
"Type: %s\n" "Type: %s\n"
"Module: %s\n" "Module: %s\n"
"Argument: %s\n", "Argument: %s\n"),
i->index, i->index,
i->name, i->name,
i->type == PA_AUTOLOAD_SINK ? "sink" : "source", i->type == PA_AUTOLOAD_SINK ? _("sink") : _("source"),
i->module, i->module,
i->argument ? i->argument : ""); i->argument ? i->argument : "");
} }
static void simple_callback(pa_context *c, int success, void *userdata) { static void simple_callback(pa_context *c, int success, void *userdata) {
if (!success) { if (!success) {
fprintf(stderr, "Failure: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failure: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -520,7 +518,7 @@ static void simple_callback(pa_context *c, int success, void *userdata) {
static void index_callback(pa_context *c, uint32_t idx, void *userdata) { static void index_callback(pa_context *c, uint32_t idx, void *userdata) {
if (idx == PA_INVALID_INDEX) { if (idx == PA_INVALID_INDEX) {
fprintf(stderr, "Failure: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failure: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -544,7 +542,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
case PA_STREAM_FAILED: case PA_STREAM_FAILED:
default: default:
fprintf(stderr, "Failed to upload sample: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s)))); fprintf(stderr, _("Failed to upload sample: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s))));
quit(1); quit(1);
} }
} }
@ -561,7 +559,7 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) {
if ((sf_readf_float(sndfile, d, l)) != l) { if ((sf_readf_float(sndfile, d, l)) != l) {
pa_xfree(d); pa_xfree(d);
fprintf(stderr, "Premature end of file\n"); fprintf(stderr, _("Premature end of file\n"));
quit(1); quit(1);
} }
@ -665,19 +663,19 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED: case PA_CONTEXT_FAILED:
default: default:
fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
} }
} }
static void exit_signal_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) { static void exit_signal_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) {
fprintf(stderr, "Got SIGINT, exiting.\n"); fprintf(stderr, _("Got SIGINT, exiting.\n"));
quit(0); quit(0);
} }
static void help(const char *argv0) { static void help(const char *argv0) {
printf("%s [options] stat\n" printf(_("%s [options] stat\n"
"%s [options] list\n" "%s [options] list\n"
"%s [options] exit\n" "%s [options] exit\n"
"%s [options] upload-sample FILENAME [NAME]\n" "%s [options] upload-sample FILENAME [NAME]\n"
@ -692,7 +690,7 @@ static void help(const char *argv0) {
" -h, --help Show this help\n" " -h, --help Show this help\n"
" --version Show version\n\n" " --version Show version\n\n"
" -s, --server=SERVER The name of the server to connect to\n" " -s, --server=SERVER The name of the server to connect to\n"
" -n, --client-name=NAME How to call this client on the server\n", " -n, --client-name=NAME How to call this client on the server\n"),
argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0); argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0);
} }
@ -712,6 +710,9 @@ int main(int argc, char *argv[]) {
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
if (!(bn = strrchr(argv[0], '/'))) if (!(bn = strrchr(argv[0], '/')))
bn = argv[0]; bn = argv[0];
else else
@ -725,7 +726,12 @@ int main(int argc, char *argv[]) {
goto quit; goto quit;
case ARG_VERSION: case ARG_VERSION:
printf("pactl "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version()); printf(_("pactl %s\n"
"Compiled with libpulse %s\n"
"Linked with libpulse %s\n"),
PACKAGE_VERSION,
pa_get_headers_version(),
pa_get_library_version());
ret = 0; ret = 0;
goto quit; goto quit;
@ -759,7 +765,7 @@ int main(int argc, char *argv[]) {
action = UPLOAD_SAMPLE; action = UPLOAD_SAMPLE;
if (optind+1 >= argc) { if (optind+1 >= argc) {
fprintf(stderr, "Please specify a sample file to load\n"); fprintf(stderr, _("Please specify a sample file to load\n"));
goto quit; goto quit;
} }
@ -781,7 +787,7 @@ int main(int argc, char *argv[]) {
memset(&sfinfo, 0, sizeof(sfinfo)); memset(&sfinfo, 0, sizeof(sfinfo));
if (!(sndfile = sf_open(argv[optind+1], SFM_READ, &sfinfo))) { if (!(sndfile = sf_open(argv[optind+1], SFM_READ, &sfinfo))) {
fprintf(stderr, "Failed to open sound file.\n"); fprintf(stderr, _("Failed to open sound file.\n"));
goto quit; goto quit;
} }
@ -793,7 +799,7 @@ int main(int argc, char *argv[]) {
} else if (!strcmp(argv[optind], "play-sample")) { } else if (!strcmp(argv[optind], "play-sample")) {
action = PLAY_SAMPLE; action = PLAY_SAMPLE;
if (argc != optind+2 && argc != optind+3) { if (argc != optind+2 && argc != optind+3) {
fprintf(stderr, "You have to specify a sample name to play\n"); fprintf(stderr, _("You have to specify a sample name to play\n"));
goto quit; goto quit;
} }
@ -805,7 +811,7 @@ int main(int argc, char *argv[]) {
} else if (!strcmp(argv[optind], "remove-sample")) { } else if (!strcmp(argv[optind], "remove-sample")) {
action = REMOVE_SAMPLE; action = REMOVE_SAMPLE;
if (argc != optind+2) { if (argc != optind+2) {
fprintf(stderr, "You have to specify a sample name to remove\n"); fprintf(stderr, _("You have to specify a sample name to remove\n"));
goto quit; goto quit;
} }
@ -813,7 +819,7 @@ int main(int argc, char *argv[]) {
} else if (!strcmp(argv[optind], "move-sink-input")) { } else if (!strcmp(argv[optind], "move-sink-input")) {
action = MOVE_SINK_INPUT; action = MOVE_SINK_INPUT;
if (argc != optind+3) { if (argc != optind+3) {
fprintf(stderr, "You have to specify a sink input index and a sink\n"); fprintf(stderr, _("You have to specify a sink input index and a sink\n"));
goto quit; goto quit;
} }
@ -822,7 +828,7 @@ int main(int argc, char *argv[]) {
} else if (!strcmp(argv[optind], "move-source-output")) { } else if (!strcmp(argv[optind], "move-source-output")) {
action = MOVE_SOURCE_OUTPUT; action = MOVE_SOURCE_OUTPUT;
if (argc != optind+3) { if (argc != optind+3) {
fprintf(stderr, "You have to specify a source output index and a source\n"); fprintf(stderr, _("You have to specify a source output index and a source\n"));
goto quit; goto quit;
} }
@ -836,7 +842,7 @@ int main(int argc, char *argv[]) {
action = LOAD_MODULE; action = LOAD_MODULE;
if (argc <= optind+1) { if (argc <= optind+1) {
fprintf(stderr, "You have to specify a module name and arguments.\n"); fprintf(stderr, _("You have to specify a module name and arguments.\n"));
goto quit; goto quit;
} }
@ -856,7 +862,7 @@ int main(int argc, char *argv[]) {
action = UNLOAD_MODULE; action = UNLOAD_MODULE;
if (argc != optind+2) { if (argc != optind+2) {
fprintf(stderr, "You have to specify a module index\n"); fprintf(stderr, _("You have to specify a module index\n"));
goto quit; goto quit;
} }
@ -866,7 +872,7 @@ int main(int argc, char *argv[]) {
action = SUSPEND_SINK; action = SUSPEND_SINK;
if (argc > optind+3 || optind+1 >= argc) { if (argc > optind+3 || optind+1 >= argc) {
fprintf(stderr, "You may not specify more than one sink. You have to specify at least one boolean value.\n"); fprintf(stderr, _("You may not specify more than one sink. You have to specify at least one boolean value.\n"));
goto quit; goto quit;
} }
@ -879,7 +885,7 @@ int main(int argc, char *argv[]) {
action = SUSPEND_SOURCE; action = SUSPEND_SOURCE;
if (argc > optind+3 || optind+1 >= argc) { if (argc > optind+3 || optind+1 >= argc) {
fprintf(stderr, "You may not specify more than one source. You have to specify at least one boolean value.\n"); fprintf(stderr, _("You may not specify more than one source. You have to specify at least one boolean value.\n"));
goto quit; goto quit;
} }
@ -895,12 +901,12 @@ int main(int argc, char *argv[]) {
} }
if (action == NONE) { if (action == NONE) {
fprintf(stderr, "No valid command specified.\n"); fprintf(stderr, _("No valid command specified.\n"));
goto quit; goto quit;
} }
if (!(m = pa_mainloop_new())) { if (!(m = pa_mainloop_new())) {
fprintf(stderr, "pa_mainloop_new() failed.\n"); fprintf(stderr, _("pa_mainloop_new() failed.\n"));
goto quit; goto quit;
} }
@ -914,7 +920,7 @@ int main(int argc, char *argv[]) {
#endif #endif
if (!(context = pa_context_new(mainloop_api, client_name))) { if (!(context = pa_context_new(mainloop_api, client_name))) {
fprintf(stderr, "pa_context_new() failed.\n"); fprintf(stderr, _("pa_context_new() failed.\n"));
goto quit; goto quit;
} }
@ -922,7 +928,7 @@ int main(int argc, char *argv[]) {
pa_context_connect(context, server, 0, NULL); pa_context_connect(context, server, 0, NULL);
if (pa_mainloop_run(m, &ret) < 0) { if (pa_mainloop_run(m, &ret) < 0) {
fprintf(stderr, "pa_mainloop_run() failed.\n"); fprintf(stderr, _("pa_mainloop_run() failed.\n"));
goto quit; goto quit;
} }

View file

@ -37,10 +37,7 @@
#include <sndfile.h> #include <sndfile.h>
#include <pulse/pulseaudio.h> #include <pulse/pulseaudio.h>
#include <pulse/i18n.h>
#if PA_API_VERSION < 9
#error Invalid PulseAudio API version
#endif
static pa_context *context = NULL; static pa_context *context = NULL;
static pa_stream *stream = NULL; static pa_stream *stream = NULL;
@ -75,12 +72,12 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) {
pa_operation *o; pa_operation *o;
if (!success) { if (!success) {
fprintf(stderr, "Failed to drain stream: %s\n", pa_strerror(pa_context_errno(context))); fprintf(stderr, _("Failed to drain stream: %s\n"), pa_strerror(pa_context_errno(context)));
quit(1); quit(1);
} }
if (verbose) if (verbose)
fprintf(stderr, "Playback stream drained.\n"); fprintf(stderr, _("Playback stream drained.\n"));
pa_stream_disconnect(stream); pa_stream_disconnect(stream);
pa_stream_unref(stream); pa_stream_unref(stream);
@ -92,7 +89,7 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) {
pa_operation_unref(o); pa_operation_unref(o);
if (verbose) if (verbose)
fprintf(stderr, "Draining connection to server.\n"); fprintf(stderr, _("Draining connection to server.\n"));
} }
} }
@ -139,12 +136,12 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
case PA_STREAM_READY: case PA_STREAM_READY:
if (verbose) if (verbose)
fprintf(stderr, "Stream successfully created\n"); fprintf(stderr, _("Stream successfully created\n"));
break; break;
case PA_STREAM_FAILED: case PA_STREAM_FAILED:
default: default:
fprintf(stderr, "Stream errror: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s)))); fprintf(stderr, _("Stream errror: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s))));
quit(1); quit(1);
} }
} }
@ -165,7 +162,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
assert(c && !stream); assert(c && !stream);
if (verbose) if (verbose)
fprintf(stderr, "Connection established.\n"); fprintf(stderr, _("Connection established.\n"));
stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL); stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL);
assert(stream); assert(stream);
@ -183,7 +180,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED: case PA_CONTEXT_FAILED:
default: default:
fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
} }
} }
@ -191,14 +188,14 @@ static void context_state_callback(pa_context *c, void *userdata) {
/* UNIX signal to quit recieved */ /* UNIX signal to quit recieved */
static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) { static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
if (verbose) if (verbose)
fprintf(stderr, "Got SIGINT, exiting.\n"); fprintf(stderr, _("Got SIGINT, exiting.\n"));
quit(0); quit(0);
} }
static void help(const char *argv0) { static void help(const char *argv0) {
printf("%s [options] [FILE]\n\n" printf(_("%s [options] [FILE]\n\n"
" -h, --help Show this help\n" " -h, --help Show this help\n"
" --version Show version\n\n" " --version Show version\n\n"
" -v, --verbose Enable verbose operation\n\n" " -v, --verbose Enable verbose operation\n\n"
@ -207,7 +204,7 @@ static void help(const char *argv0) {
" -n, --client-name=NAME How to call this client on the server\n" " -n, --client-name=NAME How to call this client on the server\n"
" --stream-name=NAME How to call this stream on the server\n" " --stream-name=NAME How to call this stream on the server\n"
" --volume=VOLUME Specify the initial (linear) volume in range 0...65536\n" " --volume=VOLUME Specify the initial (linear) volume in range 0...65536\n"
" --channel-map=CHANNELMAP Set the channel map to the use\n", " --channel-map=CHANNELMAP Set the channel map to the use\n"),
argv0); argv0);
} }
@ -239,6 +236,7 @@ int main(int argc, char *argv[]) {
}; };
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
if (!(bn = strrchr(argv[0], '/'))) if (!(bn = strrchr(argv[0], '/')))
bn = argv[0]; bn = argv[0];
@ -254,7 +252,8 @@ int main(int argc, char *argv[]) {
goto quit; goto quit;
case ARG_VERSION: case ARG_VERSION:
printf("paplay "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version()); printf(_("paplay %s\nCompiled with libpulse %s\n"
"Linked with libpulse %s\n"), PACKAGE_VERSION, pa_get_headers_version(), pa_get_library_version());
ret = 0; ret = 0;
goto quit; goto quit;
@ -290,7 +289,7 @@ int main(int argc, char *argv[]) {
case ARG_CHANNELMAP: case ARG_CHANNELMAP:
if (!pa_channel_map_parse(&channel_map, optarg)) { if (!pa_channel_map_parse(&channel_map, optarg)) {
fprintf(stderr, "Invalid channel map\n"); fprintf(stderr, _("Invalid channel map\n"));
goto quit; goto quit;
} }
@ -312,7 +311,7 @@ int main(int argc, char *argv[]) {
sndfile = sf_open_fd(STDIN_FILENO, SFM_READ, &sfinfo, 0); sndfile = sf_open_fd(STDIN_FILENO, SFM_READ, &sfinfo, 0);
if (!sndfile) { if (!sndfile) {
fprintf(stderr, "Failed to open file '%s'\n", filename); fprintf(stderr, _("Failed to open file '%s'\n"), filename);
goto quit; goto quit;
} }
@ -348,7 +347,7 @@ int main(int argc, char *argv[]) {
assert(pa_sample_spec_valid(&sample_spec)); assert(pa_sample_spec_valid(&sample_spec));
if (channel_map_set && channel_map.channels != sample_spec.channels) { if (channel_map_set && channel_map.channels != sample_spec.channels) {
fprintf(stderr, "Channel map doesn't match file.\n"); fprintf(stderr, _("Channel map doesn't match file.\n"));
goto quit; goto quit;
} }
@ -374,12 +373,12 @@ int main(int argc, char *argv[]) {
if (verbose) { if (verbose) {
char t[PA_SAMPLE_SPEC_SNPRINT_MAX]; char t[PA_SAMPLE_SPEC_SNPRINT_MAX];
pa_sample_spec_snprint(t, sizeof(t), &sample_spec); pa_sample_spec_snprint(t, sizeof(t), &sample_spec);
fprintf(stderr, "Using sample spec '%s'\n", t); fprintf(stderr, _("Using sample spec '%s'\n"), t);
} }
/* Set up a new main loop */ /* Set up a new main loop */
if (!(m = pa_mainloop_new())) { if (!(m = pa_mainloop_new())) {
fprintf(stderr, "pa_mainloop_new() failed.\n"); fprintf(stderr, _("pa_mainloop_new() failed.\n"));
goto quit; goto quit;
} }
@ -394,7 +393,7 @@ int main(int argc, char *argv[]) {
/* Create a new connection context */ /* Create a new connection context */
if (!(context = pa_context_new(mainloop_api, client_name))) { if (!(context = pa_context_new(mainloop_api, client_name))) {
fprintf(stderr, "pa_context_new() failed.\n"); fprintf(stderr, _("pa_context_new() failed.\n"));
goto quit; goto quit;
} }
@ -405,7 +404,7 @@ int main(int argc, char *argv[]) {
/* Run the main loop */ /* Run the main loop */
if (pa_mainloop_run(m, &ret) < 0) { if (pa_mainloop_run(m, &ret) < 0) {
fprintf(stderr, "pa_mainloop_run() failed.\n"); fprintf(stderr, _("pa_mainloop_run() failed.\n"));
goto quit; goto quit;
} }

View file

@ -35,20 +35,16 @@
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
#include <getopt.h> #include <getopt.h>
#include <locale.h>
#include <sndfile.h>
#ifdef __linux__ #ifdef __linux__
#include <sys/prctl.h> #include <sys/prctl.h>
#endif #endif
#include <pulse/i18n.h>
#include <pulse/pulseaudio.h> #include <pulse/pulseaudio.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#if PA_API_VERSION < 10
#error Invalid PulseAudio API version
#endif
#define BUFSIZE 1024 #define BUFSIZE 1024
static pa_context *context = NULL; static pa_context *context = NULL;
@ -82,7 +78,7 @@ static void start_child(void) {
if ((child_pid = fork()) < 0) { if ((child_pid = fork()) < 0) {
fprintf(stderr, "fork(): %s\n", strerror(errno)); fprintf(stderr, _("fork(): %s\n"), strerror(errno));
quit(1); quit(1);
} else if (child_pid == 0) { } else if (child_pid == 0) {
@ -93,7 +89,7 @@ static void start_child(void) {
#endif #endif
if (execvp(child_argv[0], child_argv) < 0) if (execvp(child_argv[0], child_argv) < 0)
fprintf(stderr, "execvp(): %s\n", strerror(errno)); fprintf(stderr, _("execvp(): %s\n"), strerror(errno));
_exit(1); _exit(1);
@ -110,7 +106,7 @@ static void suspend_complete(pa_context *c, int success, void *userdata) {
n++; n++;
if (!success) { if (!success) {
fprintf(stderr, "Failure to suspend: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failure to suspend: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -125,7 +121,7 @@ static void resume_complete(pa_context *c, int success, void *userdata) {
n++; n++;
if (!success) { if (!success) {
fprintf(stderr, "Failure to resume: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Failure to resume: %s\n"), pa_strerror(pa_context_errno(c)));
quit(1); quit(1);
return; return;
} }
@ -148,7 +144,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
pa_operation_unref(pa_context_suspend_sink_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL)); pa_operation_unref(pa_context_suspend_sink_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL));
pa_operation_unref(pa_context_suspend_source_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL)); pa_operation_unref(pa_context_suspend_source_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL));
} else { } else {
fprintf(stderr, "WARNING: Sound server is not local, not suspending.\n"); fprintf(stderr, _("WARNING: Sound server is not local, not suspending.\n"));
start_child(); start_child();
} }
@ -160,7 +156,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED: case PA_CONTEXT_FAILED:
default: default:
fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c)));
pa_context_unref(context); pa_context_unref(context);
context = NULL; context = NULL;
@ -177,7 +173,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
} }
static void sigint_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) { static void sigint_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) {
fprintf(stderr, "Got SIGINT, exiting.\n"); fprintf(stderr, _("Got SIGINT, exiting.\n"));
quit(0); quit(0);
} }
@ -195,7 +191,7 @@ static void sigchld_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, vo
if (WIFEXITED(status)) if (WIFEXITED(status))
child_ret = WEXITSTATUS(status); child_ret = WEXITSTATUS(status);
else if (WIFSIGNALED(status)) { else if (WIFSIGNALED(status)) {
fprintf(stderr, "WARNING: Child process terminated by signal %u\n", WTERMSIG(status)); fprintf(stderr, _("WARNING: Child process terminated by signal %u\n"), WTERMSIG(status));
child_ret = 1; child_ret = 1;
} }
@ -213,10 +209,10 @@ static void sigchld_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, vo
static void help(const char *argv0) { static void help(const char *argv0) {
printf("%s [options] ... \n\n" printf(_("%s [options] ... \n\n"
" -h, --help Show this help\n" " -h, --help Show this help\n"
" --version Show version\n" " --version Show version\n"
" -s, --server=SERVER The name of the server to connect to\n\n", " -s, --server=SERVER The name of the server to connect to\n\n"),
argv0); argv0);
} }
@ -236,6 +232,9 @@ int main(int argc, char *argv[]) {
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
if (!(bn = strrchr(argv[0], '/'))) if (!(bn = strrchr(argv[0], '/')))
bn = argv[0]; bn = argv[0];
else else
@ -249,7 +248,12 @@ int main(int argc, char *argv[]) {
goto quit; goto quit;
case ARG_VERSION: case ARG_VERSION:
printf("pasuspender "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version()); printf(_("pasuspender %s\n"
"Compiled with libpulse %s\n"
"Linked with libpulse %s\n"),
PACKAGE_VERSION,
pa_get_headers_version(),
pa_get_library_version());
ret = 0; ret = 0;
goto quit; goto quit;
@ -273,7 +277,7 @@ int main(int argc, char *argv[]) {
} }
if (!(m = pa_mainloop_new())) { if (!(m = pa_mainloop_new())) {
fprintf(stderr, "pa_mainloop_new() failed.\n"); fprintf(stderr, _("pa_mainloop_new() failed.\n"));
goto quit; goto quit;
} }
@ -286,7 +290,7 @@ int main(int argc, char *argv[]) {
#endif #endif
if (!(context = pa_context_new(mainloop_api, bn))) { if (!(context = pa_context_new(mainloop_api, bn))) {
fprintf(stderr, "pa_context_new() failed.\n"); fprintf(stderr, _("pa_context_new() failed.\n"));
goto quit; goto quit;
} }
@ -294,7 +298,7 @@ int main(int argc, char *argv[]) {
pa_context_connect(context, server, PA_CONTEXT_NOAUTOSPAWN, NULL); pa_context_connect(context, server, PA_CONTEXT_NOAUTOSPAWN, NULL);
if (pa_mainloop_run(m, &ret) < 0) { if (pa_mainloop_run(m, &ret) < 0) {
fprintf(stderr, "pa_mainloop_run() failed.\n"); fprintf(stderr, _("pa_mainloop_run() failed.\n"));
goto quit; goto quit;
} }

View file

@ -27,11 +27,13 @@
#include <getopt.h> #include <getopt.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <locale.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <pulse/util.h> #include <pulse/util.h>
#include <pulse/i18n.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
@ -47,17 +49,20 @@ int main(int argc, char *argv[]) {
Display *d = NULL; Display *d = NULL;
enum { DUMP, EXPORT, IMPORT, REMOVE } mode = DUMP; enum { DUMP, EXPORT, IMPORT, REMOVE } mode = DUMP;
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
while ((c = getopt(argc, argv, "deiD:S:O:I:c:hr")) != -1) { while ((c = getopt(argc, argv, "deiD:S:O:I:c:hr")) != -1) {
switch (c) { switch (c) {
case 'D' : case 'D' :
dname = optarg; dname = optarg;
break; break;
case 'h': case 'h':
printf("%s [-D display] [-S server] [-O sink] [-I source] [-c file] [-d|-e|-i|-r]\n\n" printf(_("%s [-D display] [-S server] [-O sink] [-I source] [-c file] [-d|-e|-i|-r]\n\n"
" -d Show current PulseAudio data attached to X11 display (default)\n" " -d Show current PulseAudio data attached to X11 display (default)\n"
" -e Export local PulseAudio data to X11 display\n" " -e Export local PulseAudio data to X11 display\n"
" -i Import PulseAudio data from X11 display to local environment variables and cookie file.\n" " -i Import PulseAudio data from X11 display to local environment variables and cookie file.\n"
" -r Remove PulseAudio data from X11 display\n", " -r Remove PulseAudio data from X11 display\n"),
pa_path_get_filename(argv[0])); pa_path_get_filename(argv[0]));
ret = 0; ret = 0;
goto finish; goto finish;
@ -86,13 +91,13 @@ int main(int argc, char *argv[]) {
server = optarg; server = optarg;
break; break;
default: default:
fprintf(stderr, "Failed to parse command line.\n"); fprintf(stderr, _("Failed to parse command line.\n"));
goto finish; goto finish;
} }
} }
if (!(d = XOpenDisplay(dname))) { if (!(d = XOpenDisplay(dname))) {
pa_log("XOpenDisplay() failed"); pa_log(_("XOpenDisplay() failed"));
goto finish; goto finish;
} }
@ -100,13 +105,13 @@ int main(int argc, char *argv[]) {
case DUMP: { case DUMP: {
char t[1024]; char t[1024];
if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t))) if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t)))
printf("Server: %s\n", t); printf(_("Server: %s\n"), t);
if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t))) if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t)))
printf("Source: %s\n", t); printf(_("Source: %s\n"), t);
if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t))) if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t)))
printf("Sink: %s\n", t); printf(_("Sink: %s\n"), t);
if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t))) if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t)))
printf("Cookie: %s\n", t); printf(_("Cookie: %s\n"), t);
break; break;
} }
@ -124,12 +129,12 @@ int main(int argc, char *argv[]) {
uint8_t cookie[PA_NATIVE_COOKIE_LENGTH]; uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
size_t l; size_t l;
if ((l = pa_parsehex(t, cookie, sizeof(cookie))) != sizeof(cookie)) { if ((l = pa_parsehex(t, cookie, sizeof(cookie))) != sizeof(cookie)) {
fprintf(stderr, "Failed to parse cookie data\n"); fprintf(stderr, _("Failed to parse cookie data\n"));
goto finish; goto finish;
} }
if (pa_authkey_save(cookie_file, cookie, l) < 0) { if (pa_authkey_save(cookie_file, cookie, l) < 0) {
fprintf(stderr, "Failed to save cookie data\n"); fprintf(stderr, _("Failed to save cookie data\n"));
goto finish; goto finish;
} }
} }
@ -144,12 +149,12 @@ int main(int argc, char *argv[]) {
assert(conf); assert(conf);
if (pa_client_conf_load(conf, NULL) < 0) { if (pa_client_conf_load(conf, NULL) < 0) {
fprintf(stderr, "Failed to load client configuration file.\n"); fprintf(stderr, _("Failed to load client configuration file.\n"));
goto finish; goto finish;
} }
if (pa_client_conf_env(conf) < 0) { if (pa_client_conf_env(conf) < 0) {
fprintf(stderr, "Failed to read environment configuration data.\n"); fprintf(stderr, _("Failed to read environment configuration data.\n"));
goto finish; goto finish;
} }
@ -166,7 +171,7 @@ int main(int argc, char *argv[]) {
else { else {
char hn[256]; char hn[256];
if (!pa_get_fqdn(hn, sizeof(hn))) { if (!pa_get_fqdn(hn, sizeof(hn))) {
fprintf(stderr, "Failed to get FQDN.\n"); fprintf(stderr, _("Failed to get FQDN.\n"));
goto finish; goto finish;
} }
@ -186,7 +191,7 @@ int main(int argc, char *argv[]) {
pa_client_conf_free(conf); pa_client_conf_free(conf);
if (pa_authkey_load_auto(cookie_file, cookie, sizeof(cookie)) < 0) { if (pa_authkey_load_auto(cookie_file, cookie, sizeof(cookie)) < 0) {
fprintf(stderr, "Failed to load cookie data\n"); fprintf(stderr, _("Failed to load cookie data\n"));
goto finish; goto finish;
} }
@ -203,7 +208,7 @@ int main(int argc, char *argv[]) {
break; break;
default: default:
fprintf(stderr, "No yet implemented.\n"); fprintf(stderr, _("Not yet implemented.\n"));
goto finish; goto finish;
} }