mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
client-device: fix cleanup
This commit is contained in:
parent
4754335d31
commit
b1ea91fa1d
2 changed files with 25 additions and 16 deletions
|
|
@ -44,16 +44,6 @@ struct device_data {
|
||||||
struct spa_hook proxy_listener;
|
struct spa_hook proxy_listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define pw_device_proxy_event(o,method,version,...) \
|
|
||||||
({ \
|
|
||||||
int _res = -ENOTSUP; \
|
|
||||||
struct spa_interface *_p = o; \
|
|
||||||
spa_interface_call_res(&_p->iface, \
|
|
||||||
struct pw_core_proxy_methods, _res, \
|
|
||||||
method, version, ##__VA_ARGS__); \
|
|
||||||
_res; \
|
|
||||||
})
|
|
||||||
|
|
||||||
static void device_event_info(void *_data, const struct spa_device_info *info)
|
static void device_event_info(void *_data, const struct spa_device_info *info)
|
||||||
{
|
{
|
||||||
struct device_data *data = _data;
|
struct device_data *data = _data;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_core *core;
|
struct pw_core *core;
|
||||||
struct pw_device *device;
|
struct pw_device *device;
|
||||||
|
struct spa_hook device_listener;
|
||||||
|
|
||||||
struct spa_device impl;
|
struct spa_device impl;
|
||||||
struct spa_hook_list hooks;
|
struct spa_hook_list hooks;
|
||||||
|
|
@ -143,7 +144,7 @@ static void device_object_info(void *data, uint32_t id,
|
||||||
spa_device_emit_object_info(&impl->hooks, id, info);
|
spa_device_emit_object_info(&impl->hooks, id, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct spa_device_events device_events = {
|
static const struct spa_device_events resource_implementation = {
|
||||||
SPA_VERSION_DEVICE_EVENTS,
|
SPA_VERSION_DEVICE_EVENTS,
|
||||||
.info = device_info,
|
.info = device_info,
|
||||||
.result = device_result,
|
.result = device_result,
|
||||||
|
|
@ -154,14 +155,13 @@ static const struct spa_device_events device_events = {
|
||||||
static void device_resource_destroy(void *data)
|
static void device_resource_destroy(void *data)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
struct pw_device *device = impl->device;
|
|
||||||
|
|
||||||
pw_log_debug("client-device %p: destroy", impl);
|
pw_log_debug("client-device %p: destroy", impl);
|
||||||
|
|
||||||
impl->resource = NULL;
|
impl->resource = NULL;
|
||||||
|
spa_hook_remove(&impl->device_listener);
|
||||||
spa_hook_remove(&impl->resource_listener);
|
spa_hook_remove(&impl->resource_listener);
|
||||||
|
pw_device_destroy(impl->device);
|
||||||
pw_device_destroy(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_resource_pong(void *data, int seq)
|
static void device_resource_pong(void *data, int seq)
|
||||||
|
|
@ -176,6 +176,23 @@ static const struct pw_resource_events resource_events = {
|
||||||
.pong = device_resource_pong,
|
.pong = device_resource_pong,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void device_destroy(void *data)
|
||||||
|
{
|
||||||
|
struct impl *impl = data;
|
||||||
|
|
||||||
|
pw_log_debug("client-device %p: destroy", impl);
|
||||||
|
|
||||||
|
impl->device = NULL;
|
||||||
|
spa_hook_remove(&impl->device_listener);
|
||||||
|
spa_hook_remove(&impl->resource_listener);
|
||||||
|
pw_resource_destroy(impl->resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct pw_device_events device_events = {
|
||||||
|
PW_VERSION_DEVICE_EVENTS,
|
||||||
|
.destroy = device_destroy,
|
||||||
|
};
|
||||||
|
|
||||||
struct pw_device *pw_client_device_new(struct pw_resource *resource,
|
struct pw_device *pw_client_device_new(struct pw_resource *resource,
|
||||||
struct pw_global *parent,
|
struct pw_global *parent,
|
||||||
struct pw_properties *properties)
|
struct pw_properties *properties)
|
||||||
|
|
@ -206,14 +223,16 @@ struct pw_device *pw_client_device_new(struct pw_resource *resource,
|
||||||
spa_hook_list_init(&impl->hooks);
|
spa_hook_list_init(&impl->hooks);
|
||||||
pw_device_set_implementation(device, &impl->impl);
|
pw_device_set_implementation(device, &impl->impl);
|
||||||
|
|
||||||
|
pw_device_add_listener(impl->device,
|
||||||
|
&impl->device_listener,
|
||||||
|
&device_events, impl);
|
||||||
pw_resource_add_listener(impl->resource,
|
pw_resource_add_listener(impl->resource,
|
||||||
&impl->resource_listener,
|
&impl->resource_listener,
|
||||||
&resource_events,
|
&resource_events,
|
||||||
impl);
|
impl);
|
||||||
pw_resource_set_implementation(impl->resource,
|
pw_resource_set_implementation(impl->resource,
|
||||||
&device_events,
|
&resource_implementation,
|
||||||
impl);
|
impl);
|
||||||
|
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue