[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.11-81-g75b28e9
Lennart Poettering
gitmailer-noreply at 0pointer.de
Wed Aug 6 17:29:48 PDT 2008
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from bb7f80d4d884d02af440eaa1dc99394269206f7b (commit)
- Log -----------------------------------------------------------------
75b28e9... remove some leftover debug string
ecb2bc4... Modify pa_state_path() to take an additional argument for prepending the machine id to the file name.
bd05b36... Rework state/runtime directory logic
4e6fb67... don't spam to stderr in API functions
0075649... print machine id during startup
73e2577... add new function pa_machine_id()
b84f738... translate error strings
b983c0b... include host name in default sink/default source file
-----------------------------------------------------------------------
Summary of changes:
po/de.po | 46 ++--
src/Makefile.am | 1 +
src/daemon/main.c | 12 +-
src/modules/module-default-device-restore.c | 7 +-
src/modules/module-device-restore.c | 10 +-
src/modules/module-stream-restore.c | 10 +-
src/modules/module-volume-restore.c | 2 +-
src/pulse/util.c | 6 +-
src/pulsecore/core-util.c | 314 ++++++++++++++++++++++++---
src/pulsecore/core-util.h | 4 +-
10 files changed, 336 insertions(+), 76 deletions(-)
-----------------------------------------------------------------------
commit b983c0bd14150b7e6d9c57a8ddd9a43cfd8d13bb
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Aug 6 21:35:32 2008 +0200
include host name in default sink/default source file
diff --git a/src/modules/module-default-device-restore.c b/src/modules/module-default-device-restore.c
index 7f21efa..4037881 100644
--- a/src/modules/module-default-device-restore.c
+++ b/src/modules/module-default-device-restore.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <pulse/timeval.h>
+#include <pulse/util.h>
#include <pulsecore/core-util.h>
#include <pulsecore/module.h>
@@ -41,8 +42,6 @@ PA_MODULE_DESCRIPTION("Automatically restore the default sink and source");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(TRUE);
-#define DEFAULT_SINK_FILE "default-sink"
-#define DEFAULT_SOURCE_FILE "default-source"
#define DEFAULT_SAVE_INTERVAL 5
struct userdata {
@@ -155,16 +154,28 @@ static void subscribe_cb(pa_core *c, pa_subscription_event_type_t t, uint32_t id
int pa__init(pa_module *m) {
struct userdata *u;
+ char hn[256], *fn;
pa_assert(m);
m->userdata = u = pa_xnew0(struct userdata, 1);
u->core = m->core;
- if (!(u->sink_filename = pa_state_path(DEFAULT_SINK_FILE)))
+ if (!pa_get_host_name(hn, sizeof(hn)))
goto fail;
- if (!(u->source_filename = pa_state_path(DEFAULT_SOURCE_FILE)))
+ fn = pa_sprintf_malloc("default-sink.%s", hn);
+ u->sink_filename = pa_state_path(fn);
+ pa_xfree(fn);
+
+ if (!u->sink_filename)
+ goto fail;
+
+ fn = pa_sprintf_malloc("default-source.%s", hn);
+ u->source_filename = pa_state_path(fn);
+ pa_xfree(fn);
+
+ if (!u->source_filename)
goto fail;
load(u);
commit b84f738e502e3f9e41251934cc873985ab2c006f
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 7 01:57:23 2008 +0200
translate error strings
diff --git a/po/de.po b/po/de.po
index a836a9a..2a7c5de 100644
--- a/po/de.po
+++ b/po/de.po
@@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-08-06 20:24+0200\n"
-"PO-Revision-Date: 2008-08-06 20:26+0100\n"
+"PO-Revision-Date: 2008-08-06 20:34+0100\n"
"Last-Translator: Lennart Poettering <lennart at poettering.net>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
"MIME-Version: 1.0\n"
@@ -771,91 +771,91 @@ msgstr ""
#: ../src/pulse/error.c:44
msgid "Access denied"
-msgstr ""
+msgstr "Zugriff abgelehnt"
#: ../src/pulse/error.c:45
msgid "Unknown command"
-msgstr ""
+msgstr "Unbekannter Befehl"
#: ../src/pulse/error.c:46
msgid "Invalid argument"
-msgstr ""
+msgstr "Ungültiges Argument"
#: ../src/pulse/error.c:47
msgid "Entity exists"
-msgstr ""
+msgstr "Entität existiert bereits"
#: ../src/pulse/error.c:48
msgid "No such entity"
-msgstr ""
+msgstr "Keine Entität vorhanden"
#: ../src/pulse/error.c:49
msgid "Connection refused"
-msgstr ""
+msgstr "Verbindung zurückgewiesen"
#: ../src/pulse/error.c:50
msgid "Protocol error"
-msgstr ""
+msgstr "Protokollfehler"
#: ../src/pulse/error.c:51
msgid "Timeout"
-msgstr ""
+msgstr "Zeitüberschreitung"
#: ../src/pulse/error.c:52
msgid "No authorization key"
-msgstr ""
+msgstr "Kein Authorisierungsschlüssel vorhanden"
#: ../src/pulse/error.c:53
msgid "Internal error"
-msgstr ""
+msgstr "Interner Fehler"
#: ../src/pulse/error.c:54
msgid "Connection terminated"
-msgstr ""
+msgstr "Verbindung beendet"
#: ../src/pulse/error.c:55
msgid "Entity killed"
-msgstr ""
+msgstr "Entität terminiert."
#: ../src/pulse/error.c:56
msgid "Invalid server"
-msgstr ""
+msgstr "Ungültiger Server"
#: ../src/pulse/error.c:57
msgid "Module initalization failed"
-msgstr ""
+msgstr "Modulinitialisierung fehlgeschlagen"
#: ../src/pulse/error.c:58
msgid "Bad state"
-msgstr ""
+msgstr "Ungültiger Zustand"
#: ../src/pulse/error.c:59
msgid "No data"
-msgstr ""
+msgstr "Keine Daten vorhanden"
#: ../src/pulse/error.c:60
msgid "Incompatible protocol version"
-msgstr ""
+msgstr "Inkompatible Protokollversion"
#: ../src/pulse/error.c:61
msgid "Too large"
-msgstr ""
+msgstr "Zu groÃ"
#: ../src/pulse/error.c:62
msgid "Not supported"
-msgstr ""
+msgstr "Nicht unterstützt"
#: ../src/pulse/error.c:63
msgid "Unknown error code"
-msgstr ""
+msgstr "Unbekannter Fehlercode"
#: ../src/pulse/error.c:64
msgid "No such extension"
-msgstr ""
+msgstr "Erweiterung nicht vorhanden"
#: ../src/pulse/sample.c:134
msgid "Invalid"
-msgstr ""
+msgstr "Ungültig"
#: ../src/pulse/client-conf-x11.c:55
#: ../src/utils/pax11publish.c:100
commit 73e2577ca677710e1271b5e4590e26e9d73cad15
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 7 02:22:57 2008 +0200
add new function pa_machine_id()
diff --git a/src/Makefile.am b/src/Makefile.am
index ec99831..29a6ef4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,6 +57,7 @@ AM_CFLAGS += -DPA_SYSTEM_CONFIG_PATH=\"$(PA_SYSTEM_CONFIG_PATH)\"
AM_CFLAGS += -DPA_SYSTEM_STATE_PATH=\"$(PA_SYSTEM_STATE_PATH)\"
AM_CFLAGS += -DAO_REQUIRE_CAS
AM_CFLAGS += -DPULSE_LOCALEDIR=\"$(pulselocaledir)\"
+AM_CFLAGS += -DPA_MACHINE_ID=\"$(localstatedir)/lib/dbus/machine-id\"
# This cool debug trap works on i386/gcc only
AM_CFLAGS += '-DDEBUG_TRAP=__asm__("int $$3")'
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 7c1534a..abdf1e9 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2053,3 +2053,47 @@ pa_bool_t pa_in_system_mode(void) {
return !!atoi(e);
}
+
+char *pa_machine_id(void) {
+ FILE *f;
+ size_t l;
+
+ if ((f = fopen(PA_MACHINE_ID"x", "r"))) {
+ char ln[34] = "", *r;
+
+ r = fgets(ln, sizeof(ln)-1, f);
+ fclose(f);
+
+ if (r)
+ return pa_xstrdup(pa_strip_nl(ln));
+ }
+
+ l = 100;
+
+ for (;;) {
+ char *c;
+
+ c = pa_xnew(char, l);
+
+ if (!pa_get_host_name(c, l)) {
+
+ if (errno == EINVAL || errno == ENAMETOOLONG) {
+ pa_xfree(c);
+ l *= 2;
+ continue;
+ }
+
+ return NULL;
+ }
+
+ if (strlen(c) < l-1)
+ return c;
+
+ /* Hmm, the hostname is as long the space we offered the
+ * function, we cannot know if it fully fit in, so let's play
+ * safe and retry. */
+
+ pa_xfree(c);
+ l *= 2;
+ }
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 2ed81fc..b0c0758 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -184,4 +184,6 @@ pa_bool_t pa_in_system_mode(void);
#define pa_streq(a,b) (!strcmp((a),(b)))
+char *pa_machine_id(void);
+
#endif
commit 0075649f135a52d434f6e351c5cc34c75726dbc2
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 7 02:23:45 2008 +0200
print machine id during startup
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 00469c7..ab43832 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -767,12 +767,22 @@ int main(int argc, char *argv[]) {
pa_log_info(_("This is PulseAudio %s"), PACKAGE_VERSION);
pa_log_info(_("Page size is %lu bytes"), (unsigned long) PA_PAGE_SIZE);
+
+ if (!(s = pa_machine_id())) {
+ pa_log(_("Failed to get machine ID"));
+ goto finish;
+ }
+ pa_log_info(_("Machine ID is %s."), s);
+ pa_xfree(s);
+
if (!(s = pa_get_runtime_dir()))
goto finish;
pa_log_info(_("Using runtime directory %s."), s);
pa_xfree(s);
+
if (!(s = pa_get_state_dir()))
- pa_log_info(_("Using state directory %s."), s);
+ goto finish;
+ pa_log_info(_("Using state directory %s."), s);
pa_xfree(s);
pa_log_info(_("Running in system mode: %s"), pa_yes_no(pa_in_system_mode()));
commit 4e6fb67e9fc5c0342e3c92f4bcb9a9e16137dee1
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 7 02:24:19 2008 +0200
don't spam to stderr in API functions
diff --git a/src/pulse/util.c b/src/pulse/util.c
index c0911b5..f785a2e 100644
--- a/src/pulse/util.c
+++ b/src/pulse/util.c
@@ -113,10 +113,8 @@ char *pa_get_host_name(char *s, size_t l) {
pa_assert(s);
pa_assert(l > 0);
- if (gethostname(s, l) < 0) {
- pa_log("gethostname(): %s", pa_cstrerror(errno));
+ if (gethostname(s, l) < 0)
return NULL;
- }
s[l-1] = 0;
return s;
@@ -142,12 +140,10 @@ char *pa_get_home_dir(char *s, size_t l) {
#ifdef HAVE_PWD_H
#ifdef HAVE_GETPWUID_R
if (getpwuid_r(getuid(), &pw, buf, sizeof(buf), &r) != 0 || !r) {
- pa_log("getpwuid_r() failed");
#else
/* XXX Not thread-safe, but needed on OSes (e.g. FreeBSD 4.X)
* that do not support getpwuid_r. */
if ((r = getpwuid(getuid())) == NULL) {
- pa_log("getpwuid_r() failed");
#endif
return NULL;
}
commit bd05b36a1eb54f51c9e901738a422a621fe0918d
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 7 02:25:48 2008 +0200
Rework state/runtime directory logic
The runtime directory is now guaranteed to be in /tmp which will hopefully
provide support for POSIX file locking and UNIX sockets.
The state directory stays in $HOME.
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index abdf1e9..41bf42d 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1164,48 +1164,243 @@ int pa_unlock_lockfile(const char *fn, int fd) {
return r;
}
-static char *get_dir(mode_t m, const char *env_name) {
- const char *e;
- char *d;
+static char *get_pulse_home(void) {
+ char h[PATH_MAX];
+ struct stat st;
- if ((e = getenv(env_name)))
- d = pa_xstrdup(e);
- else {
- char h[PATH_MAX];
- struct stat st;
+ if (!pa_get_home_dir(h, sizeof(h))) {
+ pa_log_error("Failed to get home directory.");
+ return NULL;
+ }
- if (!pa_get_home_dir(h, sizeof(h))) {
- pa_log_error("Failed to get home directory.");
- return NULL;
- }
+ if (stat(h, &st) < 0) {
+ pa_log_error("Failed to stat home directory %s: %s", h, pa_cstrerror(errno));
+ return NULL;
+ }
- if (stat(h, &st) < 0) {
- pa_log_error("Failed to stat home directory %s: %s", h, pa_cstrerror(errno));
- return NULL;
- }
+ if (st.st_uid != getuid()) {
+ pa_log_error("Home directory %s not ours.", h);
+ return NULL;
+ }
- if (st.st_uid != getuid()) {
- pa_log_error("Home directory %s not ours.", h);
+ return pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
+}
+
+char *pa_get_state_dir(void) {
+ char *d;
+
+ /* The state directory shall contain dynamic data that should be
+ * kept across reboots, and is private to this user */
+
+ if (!(d = pa_xstrdup(getenv("PULSE_STATE_PATH"))))
+ if (!(d = get_pulse_home()))
return NULL;
- }
- d = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
- }
+ /* If PULSE_STATE_PATH and PULSE_RUNTIME_PATH point to the same
+ * dir then this will break. */
- if (pa_make_secure_dir(d, m, (pid_t) -1, (pid_t) -1) < 0) {
+ if (pa_make_secure_dir(d, 0700, (pid_t) -1, (pid_t) -1) < 0) {
pa_log_error("Failed to create secure directory: %s", pa_cstrerror(errno));
+ pa_xfree(d);
return NULL;
}
return d;
}
-char *pa_get_runtime_dir(void) {
- return get_dir(pa_in_system_mode() ? 0755 : 0700, "PULSE_RUNTIME_PATH");
+static char* make_random_dir(mode_t m) {
+ static const char table[] =
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789";
+
+ char fn[24] = "/tmp/pulse-";
+
+ fn[sizeof(fn)-1] = 0;
+
+ for (;;) {
+ unsigned i;
+ int r;
+ mode_t u;
+ int saved_errno;
+
+ for (i = 11; i < sizeof(fn)-1; i++)
+ fn[i] = table[rand() % (sizeof(table)-1)];
+
+ u = umask((~m) & 0777);
+ r = mkdir(fn, m);
+ saved_errno = errno;
+ umask(u);
+
+ if (r >= 0)
+ return pa_xstrdup(fn);
+
+ errno = saved_errno;
+
+ if (errno != EEXIST) {
+ pa_log_error("Failed to create random directory %s: %s", fn, pa_cstrerror(errno));
+ return NULL;
+ }
+ }
}
-char *pa_get_state_dir(void) {
- return get_dir(0700, "PULSE_STATE_PATH");
+static int make_random_dir_and_link(mode_t m, const char *k) {
+ char *p;
+
+ if (!(p = make_random_dir(m)))
+ return -1;
+
+ if (symlink(p, k) < 0) {
+ int saved_errno = errno;
+
+ if (errno != EEXIST)
+ pa_log_error("Failed to symlink %s to %s: %s", k, p, pa_cstrerror(errno));
+
+ rmdir(p);
+ pa_xfree(p);
+
+ errno = saved_errno;
+ return -1;
+ }
+
+ return 0;
+}
+
+char *pa_get_runtime_dir(void) {
+ char *d, *k = NULL, *p = NULL, *t = NULL, *mid;
+ struct stat st;
+
+ /* The runtime directory shall contain dynamic data that needs NOT
+ * to be kept accross reboots and is usuallly private to the user,
+ * except in system mode, where it might be accessible by other
+ * users, too. Since we need POSIX locking and UNIX sockets in
+ * this directory, we link it to a random subdir in /tmp, if it
+ * was not explicitly configured. */
+
+ if ((d = getenv("PULSE_RUNTIME_PATH"))) {
+ mode_t m;
+
+ m = pa_in_system_mode() ? 0755 : 0700;
+
+ if (pa_make_secure_dir(d, m, (pid_t) -1, (pid_t) -1) < 0) {
+ pa_log_error("Failed to create secure directory: %s", pa_cstrerror(errno));
+ goto fail;
+ }
+
+ return pa_xstrdup(d);
+ }
+
+ if (!(d = get_pulse_home()))
+ goto fail;
+
+ if (!(mid = pa_machine_id())) {
+ pa_xfree(d);
+ goto fail;
+ }
+
+ k = pa_sprintf_malloc("%s" PA_PATH_SEP "%s:runtime", d, mid);
+ pa_xfree(d);
+ pa_xfree(mid);
+
+ for (;;) {
+ /* OK, first let's check if the "runtime" symlink is already
+ * existant */
+
+ if (!(p = pa_readlink(k))) {
+
+ if (errno != ENOENT) {
+ pa_log_error("Failed to stat runtime directory %s: %s", k, pa_cstrerror(errno));
+ goto fail;
+ }
+
+ /* Hmm, so the runtime directory didn't exist yet, so let's
+ * create one in /tmp and symlink that to it */
+
+ if (make_random_dir_and_link(0700, k) < 0) {
+
+ /* Mhmm, maybe another process was quicker than us,
+ * let's check if that was valid */
+ if (errno == EEXIST)
+ continue;
+
+ goto fail;
+ }
+
+ return k;
+ }
+
+ /* Make sure that this actually makes sense */
+ if (!pa_is_path_absolute(p)) {
+ pa_log_error("Path %s in link %s is not absolute.", p, k);
+ goto fail;
+ }
+
+ /* Hmm, so this symlink is still around, make sure nobody fools
+ * us */
+
+ if (lstat(p, &st) < 0) {
+
+ if (errno != ENOENT) {
+ pa_log_error("Failed to stat runtime directory %s: %s", p, pa_cstrerror(errno));
+ goto fail;
+ }
+
+ } else {
+
+ if (S_ISDIR(st.st_mode) &&
+ (st.st_uid == getuid()) &&
+ ((st.st_mode & 0777) == 0700)) {
+
+ pa_xfree(p);
+ return k;
+ }
+
+ pa_log_info("Hmm, runtime path exists, but points to an invalid directory. Changing runtime directory.");
+ }
+
+ pa_xfree(p);
+ p = NULL;
+
+ /* Hmm, so the link points to some nonexisting or invalid
+ * dir. Let's replace it by a new link. We first create a
+ * temporary link and then rename that to allow concurrent
+ * execution of this function. */
+
+ t = pa_sprintf_malloc("%s.tmp", k);
+
+ if (make_random_dir_and_link(0700, t) < 0) {
+
+ if (errno != EEXIST) {
+ pa_log_error("Failed to symlink %s: %s", t, pa_cstrerror(errno));
+ goto fail;
+ }
+
+ pa_xfree(t);
+ t = NULL;
+
+ /* Hmm, someone lese was quicker then us. Let's give
+ * him some time to finish, and retry. */
+ pa_msleep(10);
+ continue;
+ }
+
+ /* OK, we succeeded in creating the temporary symlink, so
+ * let's rename it */
+ if (rename(t, k) < 0) {
+ pa_log_error("Failed to rename %s to %s: %s", t, k, pa_cstrerror(errno));
+ goto fail;
+ }
+
+ pa_xfree(t);
+ return k;
+ }
+
+fail:
+ pa_xfree(p);
+ pa_xfree(k);
+ pa_xfree(t);
+
+ return NULL;
}
/* Try to open a configuration file. If "env" is specified, open the
commit ecb2bc4f04e5a6a71e19d4be651596cebbb83500
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 7 02:28:47 2008 +0200
Modify pa_state_path() to take an additional argument for prepending the machine id to the file name.
diff --git a/src/modules/module-default-device-restore.c b/src/modules/module-default-device-restore.c
index 4037881..d2cc24f 100644
--- a/src/modules/module-default-device-restore.c
+++ b/src/modules/module-default-device-restore.c
@@ -154,28 +154,16 @@ static void subscribe_cb(pa_core *c, pa_subscription_event_type_t t, uint32_t id
int pa__init(pa_module *m) {
struct userdata *u;
- char hn[256], *fn;
pa_assert(m);
m->userdata = u = pa_xnew0(struct userdata, 1);
u->core = m->core;
- if (!pa_get_host_name(hn, sizeof(hn)))
+ if (!(u->sink_filename = pa_state_path("default-sink", TRUE)))
goto fail;
- fn = pa_sprintf_malloc("default-sink.%s", hn);
- u->sink_filename = pa_state_path(fn);
- pa_xfree(fn);
-
- if (!u->sink_filename)
- goto fail;
-
- fn = pa_sprintf_malloc("default-source.%s", hn);
- u->source_filename = pa_state_path(fn);
- pa_xfree(fn);
-
- if (!u->source_filename)
+ if (!(u->source_filename = pa_state_path("default-source", TRUE)))
goto fail;
load(u);
diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c
index fcd4021..3d731f1 100644
--- a/src/modules/module-device-restore.c
+++ b/src/modules/module-device-restore.c
@@ -284,7 +284,6 @@ int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
char *fname, *fn;
- char hn[256];
pa_sink *sink;
pa_source *source;
uint32_t idx;
@@ -321,11 +320,12 @@ int pa__init(pa_module*m) {
u->source_fixate_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) source_fixate_hook_callback, u);
}
- if (!pa_get_host_name(hn, sizeof(hn)))
- goto fail;
+ /* We include the host identifier in the file name because gdbm
+ * files are CPU dependant, and we don't want things to go wrong
+ * if we are on a multiarch system. */
- fn = pa_sprintf_malloc("device-volumes.%s."CANONICAL_HOST".gdbm", hn);
- fname = pa_state_path(fn);
+ fn = pa_sprintf_malloc("device-volumes."CANONICAL_HOST".gdbm");
+ fname = pa_state_path(fn, TRUE);
pa_xfree(fn);
if (!fname)
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index b6d7b0f..ec4e7c7 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -666,7 +666,6 @@ int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
char *fname, *fn;
- char hn[256];
pa_sink_input *si;
pa_source_output *so;
uint32_t idx;
@@ -714,11 +713,12 @@ int pa__init(pa_module*m) {
if (restore_volume || restore_muted)
u->sink_input_fixate_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_fixate_hook_callback, u);
- if (!pa_get_host_name(hn, sizeof(hn)))
- goto fail;
+ /* We include the host identifier in the file name because gdbm
+ * files are CPU dependant, and we don't want things to go wrong
+ * if we are on a multiarch system. */
- fn = pa_sprintf_malloc("stream-volumes.%s."CANONICAL_HOST".gdbm", hn);
- fname = pa_state_path(fn);
+ fn = pa_sprintf_malloc("stream-volumes."CANONICAL_HOST".gdbm");
+ fname = pa_state_path(fn, TRUE);
pa_xfree(fn);
if (!fname)
diff --git a/src/modules/module-volume-restore.c b/src/modules/module-volume-restore.c
index d862c20..0fb17a0 100644
--- a/src/modules/module-volume-restore.c
+++ b/src/modules/module-volume-restore.c
@@ -493,7 +493,7 @@ int pa__init(pa_module*m) {
m->userdata = u;
- if (!(u->table_file = pa_state_path(pa_modargs_get_value(ma, "table", DEFAULT_VOLUME_TABLE_FILE))))
+ if (!(u->table_file = pa_state_path(pa_modargs_get_value(ma, "table", DEFAULT_VOLUME_TABLE_FILE), TRUE)))
goto fail;
if (pa_modargs_get_value_boolean(ma, "restore_device", &restore_device) < 0 ||
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 41bf42d..d76abe8 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1690,7 +1690,7 @@ char *pa_make_path_absolute(const char *p) {
/* if fn is null return the PulseAudio run time path in s (~/.pulse)
* if fn is non-null and starts with / return fn
* otherwise append fn to the run time path and return it */
-static char *get_path(const char *fn, pa_bool_t rt) {
+static char *get_path(const char *fn, pa_bool_t prependmid, pa_bool_t rt) {
char *rtp;
if (pa_is_path_absolute(fn))
@@ -1703,7 +1703,20 @@ static char *get_path(const char *fn, pa_bool_t rt) {
if (fn) {
char *r;
- r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", rtp, fn);
+
+ if (prependmid) {
+ char *mid;
+
+ if (!(mid = pa_machine_id())) {
+ pa_xfree(rtp);
+ return NULL;
+ }
+
+ r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s:%s", rtp, mid, fn);
+ pa_xfree(mid);
+ } else
+ r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", rtp, fn);
+
pa_xfree(rtp);
return r;
} else
@@ -1711,11 +1724,11 @@ static char *get_path(const char *fn, pa_bool_t rt) {
}
char *pa_runtime_path(const char *fn) {
- return get_path(fn, 1);
+ return get_path(fn, FALSE, TRUE);
}
-char *pa_state_path(const char *fn) {
- return get_path(fn, 0);
+char *pa_state_path(const char *fn, pa_bool_t appendmid) {
+ return get_path(fn, appendmid, FALSE);
}
/* Convert the string s to a signed integer in *ret_i */
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index b0c0758..838e4ad 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -121,7 +121,7 @@ char* pa_find_config_file(const char *global, const char *local, const char *env
char *pa_get_runtime_dir(void);
char *pa_get_state_dir(void);
char *pa_runtime_path(const char *fn);
-char *pa_state_path(const char *fn);
+char *pa_state_path(const char *fn, pa_bool_t prepend_machine_id);
int pa_atoi(const char *s, int32_t *ret_i);
int pa_atou(const char *s, uint32_t *ret_u);
commit 75b28e97fa612d9dfdad60e37f6901a8923b92f4
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 7 02:29:44 2008 +0200
remove some leftover debug string
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index d76abe8..b2c91e4 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2266,7 +2266,7 @@ char *pa_machine_id(void) {
FILE *f;
size_t l;
- if ((f = fopen(PA_MACHINE_ID"x", "r"))) {
+ if ((f = fopen(PA_MACHINE_ID, "r"))) {
char ln[34] = "", *r;
r = fgets(ln, sizeof(ln)-1, f);
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list