sink, source: Always create a hashmap for ports.

Having the hashmap sometimes NULL requires a lot of checking
here and there, so ensuring that the hashmap is always
non-NULL simplifies the code.
This commit is contained in:
Tanu Kaskinen 2012-06-08 21:49:09 +03:00
parent 21c6c70438
commit 1a6da64b16
10 changed files with 56 additions and 66 deletions

View file

@ -73,6 +73,7 @@ pa_source_new_data* pa_source_new_data_init(pa_source_new_data *data) {
pa_zero(*data);
data->proplist = pa_proplist_new();
data->ports = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
return data;
}
@ -283,11 +284,11 @@ pa_source* pa_source_new(
s->active_port = NULL;
s->save_port = FALSE;
if (data->active_port && s->ports)
if (data->active_port)
if ((s->active_port = pa_hashmap_get(s->ports, data->active_port)))
s->save_port = data->save_port;
if (!s->active_port && s->ports) {
if (!s->active_port) {
void *state;
pa_device_port *p;
@ -2570,7 +2571,7 @@ int pa_source_set_port(pa_source *s, const char *name, pa_bool_t save) {
return -PA_ERR_NOTIMPLEMENTED;
}
if (!s->ports || !name)
if (!name)
return -PA_ERR_NOENTITY;
if (!(port = pa_hashmap_get(s->ports, name)))