summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-06-22 22:33:09 +0200
committerLennart Poettering <lennart@poettering.net>2009-06-22 22:33:09 +0200
commitc4d90ea98617026fbeb9f8bc11e98ab528338274 (patch)
tree19c653dff30c8e79050ae97ed82164b4cb1edad8
parent25e5197f6adb6a371631237a53de15eb4dc1a776 (diff)
restore: change 'save' flag behaviour to reflect whether an entry shall and/or is in the on-disk databases
-rw-r--r--src/modules/module-card-restore.c2
-rw-r--r--src/modules/module-device-restore.c30
-rw-r--r--src/modules/module-rescue-streams.c6
-rw-r--r--src/modules/module-stream-restore.c34
4 files changed, 39 insertions, 33 deletions
diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
index 85583b2c0..ec55371cd 100644
--- a/src/modules/module-card-restore.c
+++ b/src/modules/module-card-restore.c
@@ -199,7 +199,7 @@ static pa_hook_result_t card_new_hook_callback(pa_core *c, pa_card_new_data *new
if (!new_data->active_profile) {
pa_log_info("Restoring profile for card %s.", new_data->name);
pa_card_new_data_set_profile(new_data, e->profile);
- new_data->save_profile = FALSE;
+ new_data->save_profile = TRUE;
} else
pa_log_debug("Not restoring profile for card %s, because already set.", new_data->name);
diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c
index a2745b88e..3acbdc81d 100644
--- a/src/modules/module-device-restore.c
+++ b/src/modules/module-device-restore.c
@@ -296,10 +296,10 @@ static pa_hook_result_t sink_new_hook_callback(pa_core *c, pa_sink_new_data *new
char *name;
struct entry *e;
+ pa_assert(c);
pa_assert(new_data);
-
- if (!u->restore_port)
- return PA_HOOK_OK;
+ pa_assert(u);
+ pa_assert(u->restore_port);
name = pa_sprintf_malloc("sink:%s", new_data->name);
@@ -309,7 +309,7 @@ static pa_hook_result_t sink_new_hook_callback(pa_core *c, pa_sink_new_data *new
if (!new_data->active_port) {
pa_log_info("Restoring port for sink %s.", name);
pa_sink_new_data_set_port(new_data, e->port);
- new_data->save_port = FALSE;
+ new_data->save_port = TRUE;
} else
pa_log_debug("Not restoring port for sink %s, because already set.", name);
}
@@ -326,7 +326,10 @@ static pa_hook_result_t sink_fixate_hook_callback(pa_core *c, pa_sink_new_data *
char *name;
struct entry *e;
+ pa_assert(c);
pa_assert(new_data);
+ pa_assert(u);
+ pa_assert(u->restore_volume || u->restore_muted);
name = pa_sprintf_malloc("sink:%s", new_data->name);
@@ -343,7 +346,7 @@ static pa_hook_result_t sink_fixate_hook_callback(pa_core *c, pa_sink_new_data *
pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map);
pa_sink_new_data_set_volume(new_data, &v);
- new_data->save_volume = FALSE;
+ new_data->save_volume = TRUE;
} else
pa_log_debug("Not restoring volume for sink %s, because already set.", new_data->name);
}
@@ -353,7 +356,7 @@ static pa_hook_result_t sink_fixate_hook_callback(pa_core *c, pa_sink_new_data *
if (!new_data->muted_is_set) {
pa_log_info("Restoring mute state for sink %s.", new_data->name);
pa_sink_new_data_set_muted(new_data, e->muted);
- new_data->save_muted = FALSE;
+ new_data->save_muted = TRUE;
} else
pa_log_debug("Not restoring mute state for sink %s, because already set.", new_data->name);
}
@@ -370,10 +373,10 @@ static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data
char *name;
struct entry *e;
+ pa_assert(c);
pa_assert(new_data);
-
- if (!u->restore_port)
- return PA_HOOK_OK;
+ pa_assert(u);
+ pa_assert(u->restore_port);
name = pa_sprintf_malloc("source:%s", new_data->name);
@@ -383,7 +386,7 @@ static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data
if (!new_data->active_port) {
pa_log_info("Restoring port for source %s.", name);
pa_source_new_data_set_port(new_data, e->port);
- new_data->save_port = FALSE;
+ new_data->save_port = TRUE;
} else
pa_log_debug("Not restoring port for source %s, because already set.", name);
}
@@ -400,7 +403,10 @@ static pa_hook_result_t source_fixate_hook_callback(pa_core *c, pa_source_new_da
char *name;
struct entry *e;
+ pa_assert(c);
pa_assert(new_data);
+ pa_assert(u);
+ pa_assert(u->restore_volume || u->restore_muted);
name = pa_sprintf_malloc("source:%s", new_data->name);
@@ -417,7 +423,7 @@ static pa_hook_result_t source_fixate_hook_callback(pa_core *c, pa_source_new_da
pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map);
pa_source_new_data_set_volume(new_data, &v);
- new_data->save_volume = FALSE;
+ new_data->save_volume = TRUE;
} else
pa_log_debug("Not restoring volume for source %s, because already set.", new_data->name);
}
@@ -427,7 +433,7 @@ static pa_hook_result_t source_fixate_hook_callback(pa_core *c, pa_source_new_da
if (!new_data->muted_is_set) {
pa_log_info("Restoring mute state for source %s.", new_data->name);
pa_source_new_data_set_muted(new_data, e->muted);
- new_data->save_muted = FALSE;
+ new_data->save_muted = TRUE;
} else
pa_log_debug("Not restoring mute state for source %s, because already set.", new_data->name);
}
diff --git a/src/modules/module-rescue-streams.c b/src/modules/module-rescue-streams.c
index c22711aef..f0b07eb58 100644
--- a/src/modules/module-rescue-streams.c
+++ b/src/modules/module-rescue-streams.c
@@ -65,14 +65,14 @@ static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* user
return PA_HOOK_OK;
}
- if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SINK)) || target == sink) {
+ if (!(target = pa_namereg_get_default_sink(c)) || target == sink) {
PA_IDXSET_FOREACH(target, c->sinks, idx)
if (target != sink)
break;
if (!target) {
- pa_log_info("No evacuation sink found.");
+ pa_log_debug("No evacuation sink found.");
return PA_HOOK_OK;
}
}
@@ -108,7 +108,7 @@ static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void
return PA_HOOK_OK;
}
- if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SOURCE)) || target == source) {
+ if (!(target = pa_namereg_get_default_source(c)) || target == source) {
PA_IDXSET_FOREACH(target, c->sources, idx)
if (target != source && !target->monitor_of == !source->monitor_of)
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index f2aea27be..b519bc174 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -353,10 +353,10 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
char *name;
struct entry *e;
+ pa_assert(c);
pa_assert(new_data);
-
- if (!u->restore_device)
- return PA_HOOK_OK;
+ pa_assert(u);
+ pa_assert(u->restore_device);
if (!(name = get_name(new_data->proplist, "sink-input")))
return PA_HOOK_OK;
@@ -370,9 +370,9 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
if (!new_data->sink) {
pa_log_info("Restoring device for stream %s.", name);
new_data->sink = s;
- new_data->save_sink = FALSE;
+ new_data->save_sink = TRUE;
} else
- pa_log_info("Not restoring device for stream %s, because already set.", name);
+ pa_log_debug("Not restoring device for stream %s, because already set.", name);
}
}
@@ -388,10 +388,10 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
char *name;
struct entry *e;
+ pa_assert(c);
pa_assert(new_data);
-
- if (!u->restore_volume && !u->restore_muted)
- return PA_HOOK_OK;
+ pa_assert(u);
+ pa_assert(u->restore_volume || u->restore_muted);
if (!(name = get_name(new_data->proplist, "sink-input")))
return PA_HOOK_OK;
@@ -410,7 +410,7 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
pa_sink_input_new_data_set_volume(new_data, &v);
new_data->volume_is_absolute = FALSE;
- new_data->save_volume = FALSE;
+ new_data->save_volume = TRUE;
} else
pa_log_debug("Not restoring volume for sink input %s, because already set.", name);
}
@@ -420,7 +420,7 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
if (!new_data->muted_is_set) {
pa_log_info("Restoring mute state for sink input %s.", name);
pa_sink_input_new_data_set_muted(new_data, e->muted);
- new_data->save_muted = FALSE;
+ new_data->save_muted = TRUE;
} else
pa_log_debug("Not restoring mute state for sink input %s, because already set.", name);
}
@@ -437,10 +437,10 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
char *name;
struct entry *e;
+ pa_assert(c);
pa_assert(new_data);
-
- if (!u->restore_device)
- return PA_HOOK_OK;
+ pa_assert(u);
+ pa_assert(u->restore_device);
if (new_data->direct_on_input)
return PA_HOOK_OK;
@@ -456,9 +456,9 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
if (!new_data->source) {
pa_log_info("Restoring device for stream %s.", name);
new_data->source = s;
- new_data->save_source = FALSE;
+ new_data->save_source = TRUE;
} else
- pa_log_info("Not restoring device for stream %s, because already set", name);
+ pa_log_debug("Not restoring device for stream %s, because already set", name);
}
}
@@ -829,10 +829,10 @@ int pa__init(pa_module*m) {
pa_log_info("Sucessfully opened database file '%s'.", fname);
pa_xfree(fname);
- for (si = pa_idxset_first(m->core->sink_inputs, &idx); si; si = pa_idxset_next(m->core->sink_inputs, &idx))
+ PA_IDXSET_FOREACH(si, m->core->sink_inputs, idx)
subscribe_callback(m->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW, si->index, u);
- for (so = pa_idxset_first(m->core->source_outputs, &idx); so; so = pa_idxset_next(m->core->source_outputs, &idx))
+ PA_IDXSET_FOREACH(so, m->core->source_outputs, idx)
subscribe_callback(m->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW, so->index, u);
pa_modargs_free(ma);