summaryrefslogtreecommitdiffstats
path: root/src/modules/module-device-manager.c
diff options
context:
space:
mode:
authorColin Guthrie <cguthrie@mandriva.org>2009-09-20 18:23:52 +0100
committerColin Guthrie <cguthrie@mandriva.org>2009-10-01 09:08:30 +0100
commit1d04c353ea61f47961c2f25aff20b75c602e8c93 (patch)
tree36cd4ca484a3824400621b6e097576bce2dc47db /src/modules/module-device-manager.c
parent74c1c27eaac2e9d40902442f4b3671e12499494b (diff)
device-manager: Set the most appropriate sink/source when new streams are created
Diffstat (limited to 'src/modules/module-device-manager.c')
-rw-r--r--src/modules/module-device-manager.c66
1 files changed, 50 insertions, 16 deletions
diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c
index 87588ae5..5c3c3958 100644
--- a/src/modules/module-device-manager.c
+++ b/src/modules/module-device-manager.c
@@ -515,17 +515,34 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
if (!u->role_device_priority_routing)
return PA_HOOK_OK;
- /*if (!(name = get_name(new_data->proplist, "sink-input")))
- return PA_HOOK_OK;
-
if (new_data->sink)
- pa_log_debug("Not restoring device for stream %s, because already set.", name);
- else if ((e = read_entry(u, name))) {
+ pa_log_debug("Not restoring device for stream, because already set.");
+ else {
+ const char *role;
+ uint32_t role_index;
- pa_xfree(e);
- }
+ if (!(role = pa_proplist_gets(new_data->proplist, PA_PROP_MEDIA_ROLE)))
+ role_index = get_role_index("");
+ else
+ role_index = get_role_index(role);
+
+ if (PA_INVALID_INDEX != role_index) {
+ role_indexes_t *indexes;
+ uint32_t device_index;
+
+ pa_assert_se(indexes = get_highest_priority_device_indexes(u, "sink:"));
+
+ device_index = *indexes[role_index];
+ if (PA_INVALID_INDEX != device_index) {
+ pa_sink *sink;
- pa_xfree(name);*/
+ if ((sink = pa_idxset_get_by_index(u->core->sinks, device_index))) {
+ new_data->sink = sink;
+ new_data->save_sink = TRUE;
+ }
+ }
+ }
+ }
return PA_HOOK_OK;
}
@@ -541,17 +558,34 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
if (new_data->direct_on_input)
return PA_HOOK_OK;
- /*if (!(name = get_name(new_data->proplist, "source-output")))
- return PA_HOOK_OK;
-
if (new_data->source)
- pa_log_debug("Not restoring device for stream %s, because already set", name);
- else if ((e = read_entry(u, name))) {
+ pa_log_debug("Not restoring device for stream, because already set");
+ else {
+ const char *role;
+ uint32_t role_index;
- pa_xfree(e);
- }
+ if (!(role = pa_proplist_gets(new_data->proplist, PA_PROP_MEDIA_ROLE)))
+ role_index = get_role_index("");
+ else
+ role_index = get_role_index(role);
+
+ if (PA_INVALID_INDEX != role_index) {
+ role_indexes_t *indexes;
+ uint32_t device_index;
+
+ pa_assert_se(indexes = get_highest_priority_device_indexes(u, "source:"));
+
+ device_index = *indexes[role_index];
+ if (PA_INVALID_INDEX != device_index) {
+ pa_source *source;
- pa_xfree(name);*/
+ if ((source = pa_idxset_get_by_index(u->core->sources, device_index))) {
+ new_data->source = source;
+ new_data->save_source = TRUE;
+ }
+ }
+ }
+ }
return PA_HOOK_OK;
}