mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2026-03-15 05:33:56 -04:00
Turn device ports into reference counted objects
Since both cards and sinks can hold references to a port, it makes sense to reference count them. Although no current implementation actually has sinks with ports but without a card, it felt wrong to make it harder to make such an implementation in the future. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
parent
961ec210a6
commit
d9685ec85d
7 changed files with 138 additions and 69 deletions
|
|
@ -139,40 +139,13 @@ void pa_sink_new_data_done(pa_sink_new_data *data) {
|
|||
|
||||
pa_proplist_free(data->proplist);
|
||||
|
||||
if (data->ports) {
|
||||
pa_device_port *p;
|
||||
|
||||
while ((p = pa_hashmap_steal_first(data->ports)))
|
||||
pa_device_port_free(p);
|
||||
|
||||
pa_hashmap_free(data->ports, NULL, NULL);
|
||||
}
|
||||
if (data->ports)
|
||||
pa_device_port_hashmap_free(data->ports);
|
||||
|
||||
pa_xfree(data->name);
|
||||
pa_xfree(data->active_port);
|
||||
}
|
||||
|
||||
pa_device_port *pa_device_port_new(const char *name, const char *description, size_t extra) {
|
||||
pa_device_port *p;
|
||||
|
||||
pa_assert(name);
|
||||
|
||||
p = pa_xmalloc(PA_ALIGN(sizeof(pa_device_port)) + extra);
|
||||
p->name = pa_xstrdup(name);
|
||||
p->description = pa_xstrdup(description);
|
||||
|
||||
p->priority = 0;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void pa_device_port_free(pa_device_port *p) {
|
||||
pa_assert(p);
|
||||
|
||||
pa_xfree(p->name);
|
||||
pa_xfree(p->description);
|
||||
pa_xfree(p);
|
||||
}
|
||||
|
||||
/* Called from main context */
|
||||
static void reset_callbacks(pa_sink *s) {
|
||||
|
|
@ -762,14 +735,8 @@ static void sink_free(pa_object *o) {
|
|||
if (s->proplist)
|
||||
pa_proplist_free(s->proplist);
|
||||
|
||||
if (s->ports) {
|
||||
pa_device_port *p;
|
||||
|
||||
while ((p = pa_hashmap_steal_first(s->ports)))
|
||||
pa_device_port_free(p);
|
||||
|
||||
pa_hashmap_free(s->ports, NULL, NULL);
|
||||
}
|
||||
if (s->ports)
|
||||
pa_device_port_hashmap_free(s->ports);
|
||||
|
||||
pa_xfree(s);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue