mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
interface: add an interface struct
The interface struct has the type,version and methods of the interface. Make spa interfaces extend from spa_interface and make a separate structure for the methods. Pass a generic void* as the first argument of methods, like we don in PipeWire. Bundle the methods + implementation in a versioned inteface and use that to invoke methods. This way we can do version checks on the methods. Make resource and proxy interfaces that we can can call. We can then make the core interfaces independent on proxy/resource and hide them in the lower layers. Add add_listener method to methods of core interfaces, just like SPA.
This commit is contained in:
parent
eb6481efb3
commit
ff946e3d4b
85 changed files with 3051 additions and 3000 deletions
|
|
@ -367,16 +367,14 @@ static int enum_devices(struct impl *this)
|
|||
}
|
||||
|
||||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
impl_monitor_set_callbacks(void *object,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
void *data)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
struct impl *this = object;
|
||||
|
||||
spa_return_val_if_fail(monitor != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
|
|
@ -397,9 +395,9 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
SPA_VERSION_MONITOR,
|
||||
impl_monitor_set_callbacks,
|
||||
static const struct spa_monitor_methods impl_monitor = {
|
||||
SPA_VERSION_MONITOR_METHODS,
|
||||
.set_callbacks = impl_monitor_set_callbacks,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -422,7 +420,7 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **i
|
|||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this = (struct impl *) handle;
|
||||
impl_monitor_set_callbacks(&this->monitor, NULL, NULL);
|
||||
impl_monitor_set_callbacks(this, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -462,7 +460,10 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
this->monitor = impl_monitor;
|
||||
this->monitor.iface = SPA_INTERFACE_INIT(
|
||||
SPA_TYPE_INTERFACE_Monitor,
|
||||
SPA_VERSION_MONITOR,
|
||||
&impl_monitor, this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue