mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
Modify pa_state_path() to take an additional argument for prepending the machine id to the file name.
This commit is contained in:
parent
bd05b36a1e
commit
ecb2bc4f04
6 changed files with 32 additions and 31 deletions
|
|
@ -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) {
|
int pa__init(pa_module *m) {
|
||||||
struct userdata *u;
|
struct userdata *u;
|
||||||
char hn[256], *fn;
|
|
||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
m->userdata = u = pa_xnew0(struct userdata, 1);
|
m->userdata = u = pa_xnew0(struct userdata, 1);
|
||||||
u->core = m->core;
|
u->core = m->core;
|
||||||
|
|
||||||
if (!pa_get_host_name(hn, sizeof(hn)))
|
if (!(u->sink_filename = pa_state_path("default-sink", TRUE)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
fn = pa_sprintf_malloc("default-sink.%s", hn);
|
if (!(u->source_filename = pa_state_path("default-source", TRUE)))
|
||||||
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;
|
goto fail;
|
||||||
|
|
||||||
load(u);
|
load(u);
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,6 @@ int pa__init(pa_module*m) {
|
||||||
pa_modargs *ma = NULL;
|
pa_modargs *ma = NULL;
|
||||||
struct userdata *u;
|
struct userdata *u;
|
||||||
char *fname, *fn;
|
char *fname, *fn;
|
||||||
char hn[256];
|
|
||||||
pa_sink *sink;
|
pa_sink *sink;
|
||||||
pa_source *source;
|
pa_source *source;
|
||||||
uint32_t idx;
|
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);
|
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)))
|
/* We include the host identifier in the file name because gdbm
|
||||||
goto fail;
|
* 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);
|
fn = pa_sprintf_malloc("device-volumes."CANONICAL_HOST".gdbm");
|
||||||
fname = pa_state_path(fn);
|
fname = pa_state_path(fn, TRUE);
|
||||||
pa_xfree(fn);
|
pa_xfree(fn);
|
||||||
|
|
||||||
if (!fname)
|
if (!fname)
|
||||||
|
|
|
||||||
|
|
@ -666,7 +666,6 @@ int pa__init(pa_module*m) {
|
||||||
pa_modargs *ma = NULL;
|
pa_modargs *ma = NULL;
|
||||||
struct userdata *u;
|
struct userdata *u;
|
||||||
char *fname, *fn;
|
char *fname, *fn;
|
||||||
char hn[256];
|
|
||||||
pa_sink_input *si;
|
pa_sink_input *si;
|
||||||
pa_source_output *so;
|
pa_source_output *so;
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
|
|
@ -714,11 +713,12 @@ int pa__init(pa_module*m) {
|
||||||
if (restore_volume || restore_muted)
|
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);
|
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)))
|
/* We include the host identifier in the file name because gdbm
|
||||||
goto fail;
|
* 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);
|
fn = pa_sprintf_malloc("stream-volumes."CANONICAL_HOST".gdbm");
|
||||||
fname = pa_state_path(fn);
|
fname = pa_state_path(fn, TRUE);
|
||||||
pa_xfree(fn);
|
pa_xfree(fn);
|
||||||
|
|
||||||
if (!fname)
|
if (!fname)
|
||||||
|
|
|
||||||
|
|
@ -493,7 +493,7 @@ int pa__init(pa_module*m) {
|
||||||
|
|
||||||
m->userdata = u;
|
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;
|
goto fail;
|
||||||
|
|
||||||
if (pa_modargs_get_value_boolean(ma, "restore_device", &restore_device) < 0 ||
|
if (pa_modargs_get_value_boolean(ma, "restore_device", &restore_device) < 0 ||
|
||||||
|
|
|
||||||
|
|
@ -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 null return the PulseAudio run time path in s (~/.pulse)
|
||||||
* if fn is non-null and starts with / return fn
|
* if fn is non-null and starts with / return fn
|
||||||
* otherwise append fn to the run time path and return it */
|
* 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;
|
char *rtp;
|
||||||
|
|
||||||
if (pa_is_path_absolute(fn))
|
if (pa_is_path_absolute(fn))
|
||||||
|
|
@ -1703,7 +1703,20 @@ static char *get_path(const char *fn, pa_bool_t rt) {
|
||||||
|
|
||||||
if (fn) {
|
if (fn) {
|
||||||
char *r;
|
char *r;
|
||||||
|
|
||||||
|
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);
|
r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", rtp, fn);
|
||||||
|
|
||||||
pa_xfree(rtp);
|
pa_xfree(rtp);
|
||||||
return r;
|
return r;
|
||||||
} else
|
} else
|
||||||
|
|
@ -1711,11 +1724,11 @@ static char *get_path(const char *fn, pa_bool_t rt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pa_runtime_path(const char *fn) {
|
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) {
|
char *pa_state_path(const char *fn, pa_bool_t appendmid) {
|
||||||
return get_path(fn, 0);
|
return get_path(fn, appendmid, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the string s to a signed integer in *ret_i */
|
/* Convert the string s to a signed integer in *ret_i */
|
||||||
|
|
|
||||||
|
|
@ -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_runtime_dir(void);
|
||||||
char *pa_get_state_dir(void);
|
char *pa_get_state_dir(void);
|
||||||
char *pa_runtime_path(const char *fn);
|
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_atoi(const char *s, int32_t *ret_i);
|
||||||
int pa_atou(const char *s, uint32_t *ret_u);
|
int pa_atou(const char *s, uint32_t *ret_u);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue