mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
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:
parent
21c6c70438
commit
1a6da64b16
10 changed files with 56 additions and 66 deletions
|
|
@ -81,6 +81,7 @@ pa_sink_new_data* pa_sink_new_data_init(pa_sink_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;
|
||||
}
|
||||
|
|
@ -295,11 +296,11 @@ pa_sink* pa_sink_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;
|
||||
|
||||
|
|
@ -3300,7 +3301,7 @@ int pa_sink_set_port(pa_sink *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)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue