mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
spa-monitor: remove device when destroyed
Remove the device from our list when it got destroyed.
This commit is contained in:
parent
973a92b49d
commit
4661ee882c
1 changed files with 28 additions and 7 deletions
|
|
@ -54,6 +54,7 @@ struct monitor_item {
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
void *iface;
|
void *iface;
|
||||||
void *object;
|
void *object;
|
||||||
|
struct spa_hook object_listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
|
|
@ -67,6 +68,22 @@ struct impl {
|
||||||
struct spa_list item_list;
|
struct spa_list item_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void device_free(void *data)
|
||||||
|
{
|
||||||
|
struct monitor_item *mitem = data;
|
||||||
|
spa_hook_remove(&mitem->object_listener);
|
||||||
|
spa_list_remove(&mitem->link);
|
||||||
|
spa_handle_clear(mitem->handle);
|
||||||
|
free(mitem->handle);
|
||||||
|
free(mitem->id);
|
||||||
|
free(mitem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct pw_device_events device_events = {
|
||||||
|
PW_VERSION_DEVICE_EVENTS,
|
||||||
|
.free = device_free
|
||||||
|
};
|
||||||
|
|
||||||
static struct monitor_item *add_item(struct pw_spa_monitor *this,
|
static struct monitor_item *add_item(struct pw_spa_monitor *this,
|
||||||
struct spa_pod *item, uint64_t now)
|
struct spa_pod *item, uint64_t now)
|
||||||
{
|
{
|
||||||
|
|
@ -139,7 +156,7 @@ static struct monitor_item *add_item(struct pw_spa_monitor *this,
|
||||||
|
|
||||||
|
|
||||||
if ((res = spa_handle_get_interface(handle, type, &iface)) < 0) {
|
if ((res = spa_handle_get_interface(handle, type, &iface)) < 0) {
|
||||||
pw_log_error("can't get NODE interface: %d", res);
|
pw_log_error("can't get %d interface: %d", type, res);
|
||||||
pw_properties_free(props);
|
pw_properties_free(props);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -151,10 +168,19 @@ static struct monitor_item *add_item(struct pw_spa_monitor *this,
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SPA_TYPE_INTERFACE_Device:
|
case SPA_TYPE_INTERFACE_Device:
|
||||||
mitem->object = pw_spa_device_new(impl->core, NULL, impl->parent, name,
|
{
|
||||||
|
struct pw_device *device;
|
||||||
|
device = pw_spa_device_new(impl->core, NULL, impl->parent, name,
|
||||||
0, iface, handle, props, 0);
|
0, iface, handle, props, 0);
|
||||||
|
pw_device_add_listener(device, &mitem->object_listener,
|
||||||
|
&device_events, mitem);
|
||||||
|
mitem->object = device;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
|
pw_log_error("interface %d not implemented", type);
|
||||||
|
free(mitem->id);
|
||||||
|
free(mitem);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,11 +214,6 @@ void destroy_item(struct monitor_item *mitem)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spa_list_remove(&mitem->link);
|
|
||||||
spa_handle_clear(mitem->handle);
|
|
||||||
free(mitem->handle);
|
|
||||||
free(mitem->id);
|
|
||||||
free(mitem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_item(struct pw_spa_monitor *this, struct spa_pod *item, uint64_t now)
|
static void remove_item(struct pw_spa_monitor *this, struct spa_pod *item, uint64_t now)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue