pw_device -> pw_impl_device

This commit is contained in:
Wim Taymans 2019-12-11 11:34:02 +01:00
parent 95688939bf
commit 73900eea1b
12 changed files with 112 additions and 258 deletions

View file

@ -40,7 +40,7 @@ struct data {
struct pw_core *core; struct pw_core *core;
struct spa_hook core_listener; struct spa_hook core_listener;
struct pw_device *device; struct pw_impl_device *device;
const char *library; const char *library;
const char *factory; const char *factory;
const char *path; const char *path;
@ -65,7 +65,7 @@ static int make_device(struct data *data)
props, SPA_ID_INVALID); props, SPA_ID_INVALID);
pw_core_export(data->core, SPA_TYPE_INTERFACE_Device, NULL, pw_core_export(data->core, SPA_TYPE_INTERFACE_Device, NULL,
pw_device_get_implementation(data->device), 0); pw_impl_device_get_implementation(data->device), 0);
return 0; return 0;
} }

View file

@ -83,7 +83,6 @@ pipewire_module_client_node = shared_library('pipewire-module-client-node',
pipewire_module_metadata = shared_library('pipewire-module-metadata', pipewire_module_metadata = shared_library('pipewire-module-metadata',
[ 'module-metadata.c', [ 'module-metadata.c',
'module-metadata/resource-metadata.c',
'module-metadata/proxy-metadata.c', 'module-metadata/proxy-metadata.c',
'module-metadata/metadata.c', 'module-metadata/metadata.c',
'module-metadata/protocol-native.c'], 'module-metadata/protocol-native.c'],

View file

@ -40,7 +40,7 @@
struct impl { struct impl {
struct pw_context *context; struct pw_context *context;
struct pw_device *device; struct pw_impl_device *device;
struct spa_hook device_listener; struct spa_hook device_listener;
struct pw_resource *resource; struct pw_resource *resource;
@ -54,8 +54,8 @@ static void device_info(void *data, const struct spa_device_info *info)
{ {
struct impl *impl = data; struct impl *impl = data;
if (!impl->registered) { if (!impl->registered) {
pw_device_register(impl->device, NULL); pw_impl_device_register(impl->device, NULL);
pw_device_set_implementation(impl->device, pw_impl_device_set_implementation(impl->device,
(struct spa_device*)impl->resource); (struct spa_device*)impl->resource);
impl->registered = true; impl->registered = true;
} }
@ -76,7 +76,7 @@ static void device_resource_destroy(void *data)
spa_hook_remove(&impl->device_listener); spa_hook_remove(&impl->device_listener);
spa_hook_remove(&impl->resource_listener); spa_hook_remove(&impl->resource_listener);
spa_hook_remove(&impl->object_listener); spa_hook_remove(&impl->object_listener);
pw_device_destroy(impl->device); pw_impl_device_destroy(impl->device);
} }
static const struct pw_resource_events resource_events = { static const struct pw_resource_events resource_events = {
@ -100,24 +100,24 @@ static void device_destroy(void *data)
static void device_initialized(void *data) static void device_initialized(void *data)
{ {
struct impl *impl = data; struct impl *impl = data;
struct pw_device *device = impl->device; struct pw_impl_device *device = impl->device;
struct pw_global *global = pw_device_get_global(device); struct pw_global *global = pw_impl_device_get_global(device);
pw_log_debug("client-device %p: initialized global:%d", impl, global->id); pw_log_debug("client-device %p: initialized global:%d", impl, global->id);
pw_resource_set_bound_id(impl->resource, global->id); pw_resource_set_bound_id(impl->resource, global->id);
} }
static const struct pw_device_events device_events = { static const struct pw_impl_device_events device_events = {
PW_VERSION_DEVICE_EVENTS, PW_VERSION_IMPL_DEVICE_EVENTS,
.destroy = device_destroy, .destroy = device_destroy,
.initialized = device_initialized, .initialized = device_initialized,
}; };
struct pw_device *pw_client_device_new(struct pw_resource *resource, struct pw_impl_device *pw_client_device_new(struct pw_resource *resource,
struct pw_properties *properties) struct pw_properties *properties)
{ {
struct impl *impl; struct impl *impl;
struct pw_device *device; struct pw_impl_device *device;
struct pw_impl_client *client = pw_resource_get_client(resource); struct pw_impl_client *client = pw_resource_get_client(resource);
struct pw_context *context = pw_impl_client_get_context(client); struct pw_context *context = pw_impl_client_get_context(client);
@ -128,16 +128,16 @@ struct pw_device *pw_client_device_new(struct pw_resource *resource,
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id); pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id);
device = pw_device_new(context, properties, sizeof(struct impl)); device = pw_impl_device_new(context, properties, sizeof(struct impl));
if (device == NULL) if (device == NULL)
return NULL; return NULL;
impl = pw_device_get_user_data(device); impl = pw_impl_device_get_user_data(device);
impl->device = device; impl->device = device;
impl->context = context; impl->context = context;
impl->resource = resource; impl->resource = resource;
pw_device_add_listener(impl->device, pw_impl_device_add_listener(impl->device,
&impl->device_listener, &impl->device_listener,
&device_events, impl); &device_events, impl);

View file

@ -1,145 +0,0 @@
/* PipeWire
*
* Copyright © 2018 Wim Taymans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <stddef.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <spa/monitor/device.h>
#include <spa/monitor/utils.h>
#include <spa/pod/filter.h>
#include <spa/pod/parser.h>
#include <spa/debug/types.h>
#include <pipewire/impl.h>
#include "pipewire/private.h"
struct impl {
struct pw_context *context;
struct pw_device *device;
struct spa_hook device_listener;
struct pw_resource *resource;
struct spa_hook resource_listener;
struct spa_hook object_listener;
unsigned int registered:1;
};
static void device_info(void *data, const struct spa_device_info *info)
{
struct impl *impl = data;
if (!impl->registered) {
pw_device_register(impl->device, NULL);
pw_device_set_implementation(impl->device,
(struct spa_device*)impl->resource);
impl->registered = true;
}
}
static const struct spa_device_events object_events = {
SPA_VERSION_DEVICE_EVENTS,
.info = device_info,
};
static void device_resource_destroy(void *data)
{
struct impl *impl = data;
pw_log_debug("client-device %p: destroy", impl);
impl->resource = NULL;
spa_hook_remove(&impl->device_listener);
spa_hook_remove(&impl->resource_listener);
spa_hook_remove(&impl->object_listener);
pw_device_destroy(impl->device);
}
static const struct pw_resource_events resource_events = {
PW_VERSION_RESOURCE_EVENTS,
.destroy = device_resource_destroy,
};
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);
spa_hook_remove(&impl->object_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_properties *properties)
{
struct impl *impl;
struct pw_device *device;
struct pw_impl_client *client = pw_resource_get_client(resource);
struct pw_context *context = pw_impl_client_get_context(client);
if (properties == NULL)
properties = pw_properties_new(NULL, NULL);
if (properties == NULL)
return NULL;
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id);
device = pw_device_new(context, properties, sizeof(struct impl));
if (device == NULL)
return NULL;
impl = pw_device_get_user_data(device);
impl->device = device;
impl->context = context;
impl->resource = resource;
pw_resource_install_marshal(resource, true);
pw_device_add_listener(impl->device,
&impl->device_listener,
&device_events, impl);
pw_resource_add_listener(impl->resource,
&impl->resource_listener,
&resource_events,
impl);
pw_resource_add_object_listener(impl->resource,
&impl->object_listener,
&object_events,
impl);
return device;
}

View file

@ -59,7 +59,7 @@ struct factory_data {
struct device_data { struct device_data {
struct spa_list link; struct spa_list link;
struct pw_device *device; struct pw_impl_device *device;
struct spa_hook device_listener; struct spa_hook device_listener;
}; };
@ -70,8 +70,8 @@ static void device_destroy(void *data)
spa_hook_remove(&nd->device_listener); spa_hook_remove(&nd->device_listener);
} }
static const struct pw_device_events device_events = { static const struct pw_impl_device_events device_events = {
PW_VERSION_DEVICE_EVENTS, PW_VERSION_IMPL_DEVICE_EVENTS,
.destroy = device_destroy, .destroy = device_destroy,
}; };
@ -84,7 +84,7 @@ static void *create_object(void *_data,
{ {
struct factory_data *data = _data; struct factory_data *data = _data;
struct pw_context *context = data->context; struct pw_context *context = data->context;
struct pw_device *device; struct pw_impl_device *device;
const char *factory_name; const char *factory_name;
struct device_data *nd; struct device_data *nd;
struct pw_impl_client *client; struct pw_impl_client *client;
@ -121,10 +121,10 @@ static void *create_object(void *_data,
nd->device = device; nd->device = device;
spa_list_append(&data->device_list, &nd->link); spa_list_append(&data->device_list, &nd->link);
pw_device_add_listener(device, &nd->device_listener, &device_events, nd); pw_impl_device_add_listener(device, &nd->device_listener, &device_events, nd);
if (client) { if (client) {
pw_global_bind(pw_device_get_global(device), pw_global_bind(pw_impl_device_get_global(device),
client, client,
PW_PERM_RWX, version, PW_PERM_RWX, version,
new_id); new_id);
@ -160,7 +160,7 @@ static void factory_destroy(void *_data)
spa_hook_remove(&data->module_listener); spa_hook_remove(&data->module_listener);
spa_list_consume(nd, &data->device_list, link) spa_list_consume(nd, &data->device_list, link)
pw_device_destroy(nd->device); pw_impl_device_destroy(nd->device);
} }
static const struct pw_factory_events factory_events = { static const struct pw_factory_events factory_events = {

View file

@ -43,7 +43,7 @@ static const struct spa_dict_item module_props[] = {
}; };
struct device_data { struct device_data {
struct pw_device *this; struct pw_impl_device *this;
struct pw_context *context; struct pw_context *context;
struct spa_hook module_listener; struct spa_hook module_listener;
@ -55,7 +55,7 @@ static void module_destroy(void *_data)
spa_hook_remove(&data->module_listener); spa_hook_remove(&data->module_listener);
pw_device_destroy(data->this); pw_impl_device_destroy(data->this);
} }
static const struct pw_module_events module_events = { static const struct pw_module_events module_events = {
@ -70,7 +70,7 @@ int pipewire__module_init(struct pw_module *module, const char *args)
char **argv = NULL; char **argv = NULL;
int n_tokens; int n_tokens;
struct pw_context *context = pw_module_get_context(module); struct pw_context *context = pw_module_get_context(module);
struct pw_device *device; struct pw_impl_device *device;
struct device_data *data; struct device_data *data;
int res; int res;

View file

@ -38,7 +38,7 @@
#include "pipewire/private.h" #include "pipewire/private.h"
struct impl { struct impl {
struct pw_device *this; struct pw_impl_device *this;
enum pw_spa_device_flags flags; enum pw_spa_device_flags flags;
@ -54,7 +54,7 @@ struct impl {
static void device_destroy(void *data) static void device_destroy(void *data)
{ {
struct impl *impl = data; struct impl *impl = data;
struct pw_device *device = impl->this; struct pw_impl_device *device = impl->this;
pw_log_debug("spa-device %p: free", device); pw_log_debug("spa-device %p: free", device);
@ -63,12 +63,12 @@ static void device_destroy(void *data)
pw_unload_spa_handle(impl->handle); pw_unload_spa_handle(impl->handle);
} }
static const struct pw_device_events device_events = { static const struct pw_impl_device_events device_events = {
PW_VERSION_DEVICE_EVENTS, PW_VERSION_IMPL_DEVICE_EVENTS,
.destroy = device_destroy, .destroy = device_destroy,
}; };
struct pw_device * struct pw_impl_device *
pw_spa_device_new(struct pw_context *context, pw_spa_device_new(struct pw_context *context,
enum pw_spa_device_flags flags, enum pw_spa_device_flags flags,
struct spa_device *device, struct spa_device *device,
@ -76,11 +76,11 @@ pw_spa_device_new(struct pw_context *context,
struct pw_properties *properties, struct pw_properties *properties,
size_t user_data_size) size_t user_data_size)
{ {
struct pw_device *this; struct pw_impl_device *this;
struct impl *impl; struct impl *impl;
int res; int res;
this = pw_device_new(context, properties, sizeof(struct impl) + user_data_size); this = pw_impl_device_new(context, properties, sizeof(struct impl) + user_data_size);
if (this == NULL) if (this == NULL)
return NULL; return NULL;
@ -93,34 +93,34 @@ pw_spa_device_new(struct pw_context *context,
if (user_data_size > 0) if (user_data_size > 0)
impl->user_data = SPA_MEMBER(impl, sizeof(struct impl), void); impl->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
pw_device_add_listener(this, &impl->device_listener, &device_events, impl); pw_impl_device_add_listener(this, &impl->device_listener, &device_events, impl);
pw_device_set_implementation(this, impl->device); pw_impl_device_set_implementation(this, impl->device);
if (!SPA_FLAG_IS_SET(impl->flags, PW_SPA_DEVICE_FLAG_NO_REGISTER)) { if (!SPA_FLAG_IS_SET(impl->flags, PW_SPA_DEVICE_FLAG_NO_REGISTER)) {
if ((res = pw_device_register(this, NULL)) < 0) if ((res = pw_impl_device_register(this, NULL)) < 0)
goto error_register; goto error_register;
} }
return this; return this;
error_register: error_register:
pw_device_destroy(this); pw_impl_device_destroy(this);
errno = -res; errno = -res;
return NULL; return NULL;
} }
void *pw_spa_device_get_user_data(struct pw_device *device) void *pw_spa_device_get_user_data(struct pw_impl_device *device)
{ {
struct impl *impl = device->user_data; struct impl *impl = device->user_data;
return impl->user_data; return impl->user_data;
} }
struct pw_device *pw_spa_device_load(struct pw_context *context, struct pw_impl_device *pw_spa_device_load(struct pw_context *context,
const char *factory_name, const char *factory_name,
enum pw_spa_device_flags flags, enum pw_spa_device_flags flags,
struct pw_properties *properties, struct pw_properties *properties,
size_t user_data_size) size_t user_data_size)
{ {
struct pw_device *this; struct pw_impl_device *this;
struct spa_handle *handle; struct spa_handle *handle;
void *iface; void *iface;
int res; int res;

View file

@ -38,7 +38,7 @@ enum pw_spa_device_flags {
PW_SPA_DEVICE_FLAG_NO_REGISTER = (1 << 1), PW_SPA_DEVICE_FLAG_NO_REGISTER = (1 << 1),
}; };
struct pw_device * struct pw_impl_device *
pw_spa_device_new(struct pw_context *context, pw_spa_device_new(struct pw_context *context,
enum pw_spa_device_flags flags, enum pw_spa_device_flags flags,
struct spa_device *device, struct spa_device *device,
@ -46,14 +46,14 @@ pw_spa_device_new(struct pw_context *context,
struct pw_properties *properties, struct pw_properties *properties,
size_t user_data_size); size_t user_data_size);
struct pw_device * struct pw_impl_device *
pw_spa_device_load(struct pw_context *context, pw_spa_device_load(struct pw_context *context,
const char *factory_name, const char *factory_name,
enum pw_spa_device_flags flags, enum pw_spa_device_flags flags,
struct pw_properties *properties, struct pw_properties *properties,
size_t user_data_size); size_t user_data_size);
void *pw_spa_device_get_user_data(struct pw_device *device); void *pw_spa_device_get_user_data(struct pw_impl_device *device);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -650,7 +650,7 @@ void pw_context_destroy(struct pw_context *context)
struct impl *impl = SPA_CONTAINER_OF(context, struct impl, this); struct impl *impl = SPA_CONTAINER_OF(context, struct impl, this);
struct pw_global *global; struct pw_global *global;
struct pw_module *module; struct pw_module *module;
struct pw_device *device; struct pw_impl_device *device;
struct pw_core *core; struct pw_core *core;
struct pw_resource *resource; struct pw_resource *resource;
struct pw_node *node; struct pw_node *node;
@ -671,7 +671,7 @@ void pw_context_destroy(struct pw_context *context)
pw_node_destroy(node); pw_node_destroy(node);
spa_list_consume(device, &context->device_list, link) spa_list_consume(device, &context->device_list, link)
pw_device_destroy(device); pw_impl_device_destroy(device);
spa_list_consume(resource, &context->registry_resource_list, link) spa_list_consume(resource, &context->registry_resource_list, link)
pw_resource_destroy(resource); pw_resource_destroy(resource);

View file

@ -33,7 +33,7 @@
#define NAME "device" #define NAME "device"
struct impl { struct impl {
struct pw_device this; struct pw_impl_device this;
}; };
#define pw_device_resource(r,m,v,...) pw_resource_call(r,struct pw_device_proxy_events,m,v,__VA_ARGS__) #define pw_device_resource(r,m,v,...) pw_resource_call(r,struct pw_device_proxy_events,m,v,__VA_ARGS__)
@ -48,7 +48,7 @@ struct result_device_params_data {
}; };
struct resource_data { struct resource_data {
struct pw_device *device; struct pw_impl_device *device;
struct pw_resource *resource; struct pw_resource *resource;
struct spa_hook resource_listener; struct spa_hook resource_listener;
@ -77,7 +77,7 @@ static void object_destroy(struct object_data *od)
pw_node_destroy(od->object); pw_node_destroy(od->object);
break; break;
case SPA_TYPE_INTERFACE_Device: case SPA_TYPE_INTERFACE_Device:
pw_device_destroy(od->object); pw_impl_device_destroy(od->object);
break; break;
} }
} }
@ -89,7 +89,7 @@ static void object_update(struct object_data *od, const struct spa_dict *props)
pw_node_update_properties(od->object, props); pw_node_update_properties(od->object, props);
break; break;
case SPA_TYPE_INTERFACE_Device: case SPA_TYPE_INTERFACE_Device:
pw_device_update_properties(od->object, props); pw_impl_device_update_properties(od->object, props);
break; break;
} }
} }
@ -102,12 +102,12 @@ static void object_register(struct object_data *od)
pw_node_set_active(od->object, true); pw_node_set_active(od->object, true);
break; break;
case SPA_TYPE_INTERFACE_Device: case SPA_TYPE_INTERFACE_Device:
pw_device_register(od->object, NULL); pw_impl_device_register(od->object, NULL);
break; break;
} }
} }
static void check_properties(struct pw_device *device) static void check_properties(struct pw_impl_device *device)
{ {
const char *str; const char *str;
@ -119,12 +119,12 @@ static void check_properties(struct pw_device *device)
} }
SPA_EXPORT SPA_EXPORT
struct pw_device *pw_device_new(struct pw_context *context, struct pw_impl_device *pw_impl_device_new(struct pw_context *context,
struct pw_properties *properties, struct pw_properties *properties,
size_t user_data_size) size_t user_data_size)
{ {
struct impl *impl; struct impl *impl;
struct pw_device *this; struct pw_impl_device *this;
int res; int res;
impl = calloc(1, sizeof(struct impl) + user_data_size); impl = calloc(1, sizeof(struct impl) + user_data_size);
@ -169,12 +169,12 @@ error_cleanup:
} }
SPA_EXPORT SPA_EXPORT
void pw_device_destroy(struct pw_device *device) void pw_impl_device_destroy(struct pw_impl_device *device)
{ {
struct object_data *od; struct object_data *od;
pw_log_debug(NAME" %p: destroy", device); pw_log_debug(NAME" %p: destroy", device);
pw_device_emit_destroy(device); pw_impl_device_emit_destroy(device);
spa_list_consume(od, &device->object_list, link) spa_list_consume(od, &device->object_list, link)
object_destroy(od); object_destroy(od);
@ -187,7 +187,7 @@ void pw_device_destroy(struct pw_device *device)
pw_global_destroy(device->global); pw_global_destroy(device->global);
} }
pw_log_debug(NAME" %p: free", device); pw_log_debug(NAME" %p: free", device);
pw_device_emit_free(device); pw_impl_device_emit_free(device);
pw_properties_free(device->properties); pw_properties_free(device->properties);
free(device->name); free(device->name);
@ -232,7 +232,7 @@ static void result_device_params(void *data, int seq, int res, uint32_t type, co
} }
SPA_EXPORT SPA_EXPORT
int pw_device_for_each_param(struct pw_device *device, int pw_impl_device_for_each_param(struct pw_impl_device *device,
int seq, uint32_t param_id, int seq, uint32_t param_id,
uint32_t index, uint32_t max, uint32_t index, uint32_t max,
const struct spa_pod *filter, const struct spa_pod *filter,
@ -296,7 +296,7 @@ static int device_enum_params(void *object, int seq, uint32_t id, uint32_t start
{ {
struct resource_data *data = object; struct resource_data *data = object;
struct pw_resource *resource = data->resource; struct pw_resource *resource = data->resource;
struct pw_device *device = data->device; struct pw_impl_device *device = data->device;
struct pw_impl_client *client = resource->client; struct pw_impl_client *client = resource->client;
int res; int res;
static const struct spa_device_events device_events = { static const struct spa_device_events device_events = {
@ -304,7 +304,7 @@ static int device_enum_params(void *object, int seq, uint32_t id, uint32_t start
.result = result_device_params_async, .result = result_device_params_async,
}; };
res = pw_device_for_each_param(device, seq, id, start, num, res = pw_impl_device_for_each_param(device, seq, id, start, num,
filter, reply_param, data); filter, reply_param, data);
if (res < 0) { if (res < 0) {
@ -329,7 +329,7 @@ static int device_set_param(void *object, uint32_t id, uint32_t flags,
{ {
struct resource_data *data = object; struct resource_data *data = object;
struct pw_resource *resource = data->resource; struct pw_resource *resource = data->resource;
struct pw_device *device = data->device; struct pw_impl_device *device = data->device;
int res; int res;
if ((res = spa_device_set_param(device->device, id, flags, param)) < 0) if ((res = spa_device_set_param(device->device, id, flags, param)) < 0)
@ -347,7 +347,7 @@ static int
global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions, global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions,
uint32_t version, uint32_t id) uint32_t version, uint32_t id)
{ {
struct pw_device *this = _data; struct pw_impl_device *this = _data;
struct pw_global *global = this->global; struct pw_global *global = this->global;
struct pw_resource *resource; struct pw_resource *resource;
struct resource_data *data; struct resource_data *data;
@ -386,10 +386,10 @@ error_resource:
static void global_destroy(void *object) static void global_destroy(void *object)
{ {
struct pw_device *device = object; struct pw_impl_device *device = object;
spa_hook_remove(&device->global_listener); spa_hook_remove(&device->global_listener);
device->global = NULL; device->global = NULL;
pw_device_destroy(device); pw_impl_device_destroy(device);
} }
static const struct pw_global_events global_events = { static const struct pw_global_events global_events = {
@ -398,7 +398,7 @@ static const struct pw_global_events global_events = {
}; };
SPA_EXPORT SPA_EXPORT
int pw_device_register(struct pw_device *device, int pw_impl_device_register(struct pw_impl_device *device,
struct pw_properties *properties) struct pw_properties *properties)
{ {
struct pw_context *context = device->context; struct pw_context *context = device->context;
@ -442,7 +442,7 @@ int pw_device_register(struct pw_device *device,
pw_properties_setf(device->properties, PW_KEY_OBJECT_ID, "%d", device->info.id); pw_properties_setf(device->properties, PW_KEY_OBJECT_ID, "%d", device->info.id);
device->info.props = &device->properties->dict; device->info.props = &device->properties->dict;
pw_device_emit_initialized(device); pw_impl_device_emit_initialized(device);
pw_global_add_listener(device->global, &device->global_listener, &global_events, device); pw_global_add_listener(device->global, &device->global_listener, &global_events, device);
pw_global_register(device->global); pw_global_register(device->global);
@ -476,17 +476,17 @@ static const struct pw_node_events node_object_events = {
.free = on_object_free, .free = on_object_free,
}; };
static const struct pw_device_events device_object_events = { static const struct pw_impl_device_events device_object_events = {
PW_VERSION_DEVICE_EVENTS, PW_VERSION_IMPL_DEVICE_EVENTS,
.destroy = on_object_destroy, .destroy = on_object_destroy,
.free = on_object_free, .free = on_object_free,
}; };
static void emit_info_changed(struct pw_device *device) static void emit_info_changed(struct pw_impl_device *device)
{ {
struct pw_resource *resource; struct pw_resource *resource;
pw_device_emit_info_changed(device, &device->info); pw_impl_device_emit_info_changed(device, &device->info);
if (device->global) if (device->global)
spa_list_for_each(resource, &device->global->resource_list, link) spa_list_for_each(resource, &device->global->resource_list, link)
@ -495,7 +495,7 @@ static void emit_info_changed(struct pw_device *device)
device->info.change_mask = 0; device->info.change_mask = 0;
} }
static int update_properties(struct pw_device *device, const struct spa_dict *dict) static int update_properties(struct pw_impl_device *device, const struct spa_dict *dict)
{ {
int changed; int changed;
@ -514,7 +514,7 @@ static int update_properties(struct pw_device *device, const struct spa_dict *di
static void device_info(void *data, const struct spa_device_info *info) static void device_info(void *data, const struct spa_device_info *info)
{ {
struct pw_device *device = data; struct pw_impl_device *device = data;
if (info->change_mask & SPA_DEVICE_CHANGE_MASK_PROPS) { if (info->change_mask & SPA_DEVICE_CHANGE_MASK_PROPS) {
update_properties(device, info->props); update_properties(device, info->props);
} }
@ -527,7 +527,7 @@ static void device_info(void *data, const struct spa_device_info *info)
emit_info_changed(device); emit_info_changed(device);
} }
static void device_add_object(struct pw_device *device, uint32_t id, static void device_add_object(struct pw_impl_device *device, uint32_t id,
const struct spa_device_object_info *info) const struct spa_device_object_info *info)
{ {
struct pw_context *context = device->context; struct pw_context *context = device->context;
@ -573,13 +573,13 @@ static void device_add_object(struct pw_device *device, uint32_t id,
} }
case SPA_TYPE_INTERFACE_Device: case SPA_TYPE_INTERFACE_Device:
{ {
struct pw_device *dev; struct pw_impl_device *dev;
dev = pw_device_new(context, props, sizeof(struct object_data)); dev = pw_impl_device_new(context, props, sizeof(struct object_data));
od = pw_device_get_user_data(dev); od = pw_impl_device_get_user_data(dev);
od->object = dev; od->object = dev;
pw_device_add_listener(dev, &od->listener, &device_object_events, od); pw_impl_device_add_listener(dev, &od->listener, &device_object_events, od);
pw_device_set_implementation(dev, iface); pw_impl_device_set_implementation(dev, iface);
break; break;
} }
default: default:
@ -599,7 +599,7 @@ static void device_add_object(struct pw_device *device, uint32_t id,
return; return;
} }
static struct object_data *find_object(struct pw_device *device, uint32_t id) static struct object_data *find_object(struct pw_impl_device *device, uint32_t id)
{ {
struct object_data *od; struct object_data *od;
spa_list_for_each(od, &device->object_list, link) { spa_list_for_each(od, &device->object_list, link) {
@ -612,7 +612,7 @@ static struct object_data *find_object(struct pw_device *device, uint32_t id)
static void device_object_info(void *data, uint32_t id, static void device_object_info(void *data, uint32_t id,
const struct spa_device_object_info *info) const struct spa_device_object_info *info)
{ {
struct pw_device *device = data; struct pw_impl_device *device = data;
struct object_data *od; struct object_data *od;
od = find_object(device, id); od = find_object(device, id);
@ -642,7 +642,7 @@ static const struct spa_device_events device_events = {
}; };
SPA_EXPORT SPA_EXPORT
int pw_device_set_implementation(struct pw_device *device, struct spa_device *spa_device) int pw_impl_device_set_implementation(struct pw_impl_device *device, struct spa_device *spa_device)
{ {
pw_log_debug(NAME" %p: implementation %p", device, spa_device); pw_log_debug(NAME" %p: implementation %p", device, spa_device);
@ -659,19 +659,19 @@ int pw_device_set_implementation(struct pw_device *device, struct spa_device *sp
} }
SPA_EXPORT SPA_EXPORT
struct spa_device *pw_device_get_implementation(struct pw_device *device) struct spa_device *pw_impl_device_get_implementation(struct pw_impl_device *device)
{ {
return device->device; return device->device;
} }
SPA_EXPORT SPA_EXPORT
const struct pw_properties *pw_device_get_properties(struct pw_device *device) const struct pw_properties *pw_impl_device_get_properties(struct pw_impl_device *device)
{ {
return device->properties; return device->properties;
} }
SPA_EXPORT SPA_EXPORT
int pw_device_update_properties(struct pw_device *device, const struct spa_dict *dict) int pw_impl_device_update_properties(struct pw_impl_device *device, const struct spa_dict *dict)
{ {
int changed = update_properties(device, dict); int changed = update_properties(device, dict);
emit_info_changed(device); emit_info_changed(device);
@ -679,21 +679,21 @@ int pw_device_update_properties(struct pw_device *device, const struct spa_dict
} }
SPA_EXPORT SPA_EXPORT
void *pw_device_get_user_data(struct pw_device *device) void *pw_impl_device_get_user_data(struct pw_impl_device *device)
{ {
return device->user_data; return device->user_data;
} }
SPA_EXPORT SPA_EXPORT
struct pw_global *pw_device_get_global(struct pw_device *device) struct pw_global *pw_impl_device_get_global(struct pw_impl_device *device)
{ {
return device->global; return device->global;
} }
SPA_EXPORT SPA_EXPORT
void pw_device_add_listener(struct pw_device *device, void pw_impl_device_add_listener(struct pw_impl_device *device,
struct spa_hook *listener, struct spa_hook *listener,
const struct pw_device_events *events, const struct pw_impl_device_events *events,
void *data) void *data)
{ {
spa_hook_list_append(&device->listener_list, listener, events, data); spa_hook_list_append(&device->listener_list, listener, events, data);

View file

@ -22,14 +22,14 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef PIPEWIRE_DEVICE_H #ifndef PIPEWIRE_IMPL_DEVICE_H
#define PIPEWIRE_DEVICE_H #define PIPEWIRE_IMPL_DEVICE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** \class pw_device /** \class pw_impl_device
* *
* \brief PipeWire device interface. * \brief PipeWire device interface.
* *
@ -40,7 +40,7 @@ extern "C" {
* The purpose of the device is to provide an interface to * The purpose of the device is to provide an interface to
* dynamically create/remove/configure the nodes it manages. * dynamically create/remove/configure the nodes it manages.
*/ */
struct pw_device; struct pw_impl_device;
#include <spa/monitor/device.h> #include <spa/monitor/device.h>
@ -49,9 +49,9 @@ struct pw_device;
#include <pipewire/properties.h> #include <pipewire/properties.h>
#include <pipewire/resource.h> #include <pipewire/resource.h>
/** Device events, listen to them with \ref pw_device_add_listener */ /** Device events, listen to them with \ref pw_impl_device_add_listener */
struct pw_device_events { struct pw_impl_device_events {
#define PW_VERSION_DEVICE_EVENTS 0 #define PW_VERSION_IMPL_DEVICE_EVENTS 0
uint32_t version; uint32_t version;
/** the device is destroyed */ /** the device is destroyed */
@ -65,36 +65,36 @@ struct pw_device_events {
void (*info_changed) (void *data, const struct pw_device_info *info); void (*info_changed) (void *data, const struct pw_device_info *info);
}; };
struct pw_device *pw_device_new(struct pw_context *context, struct pw_impl_device *pw_impl_device_new(struct pw_context *context,
struct pw_properties *properties, struct pw_properties *properties,
size_t user_data_size); size_t user_data_size);
int pw_device_register(struct pw_device *device, int pw_impl_device_register(struct pw_impl_device *device,
struct pw_properties *properties); struct pw_properties *properties);
void pw_device_destroy(struct pw_device *device); void pw_impl_device_destroy(struct pw_impl_device *device);
void *pw_device_get_user_data(struct pw_device *device); void *pw_impl_device_get_user_data(struct pw_impl_device *device);
/** Set the device implementation */ /** Set the device implementation */
int pw_device_set_implementation(struct pw_device *device, struct spa_device *spa_device); int pw_impl_device_set_implementation(struct pw_impl_device *device, struct spa_device *spa_device);
/** Get the device implementation */ /** Get the device implementation */
struct spa_device *pw_device_get_implementation(struct pw_device *device); struct spa_device *pw_impl_device_get_implementation(struct pw_impl_device *device);
/** Get the global of this device */ /** Get the global of this device */
struct pw_global *pw_device_get_global(struct pw_device *device); struct pw_global *pw_impl_device_get_global(struct pw_impl_device *device);
/** Add an event listener */ /** Add an event listener */
void pw_device_add_listener(struct pw_device *device, void pw_impl_device_add_listener(struct pw_impl_device *device,
struct spa_hook *listener, struct spa_hook *listener,
const struct pw_device_events *events, const struct pw_impl_device_events *events,
void *data); void *data);
int pw_device_update_properties(struct pw_device *device, const struct spa_dict *dict); int pw_impl_device_update_properties(struct pw_impl_device *device, const struct spa_dict *dict);
const struct pw_properties *pw_device_get_properties(struct pw_device *device); const struct pw_properties *pw_impl_device_get_properties(struct pw_impl_device *device);
int pw_device_for_each_param(struct pw_device *device, int pw_impl_device_for_each_param(struct pw_impl_device *device,
int seq, uint32_t param_id, int seq, uint32_t param_id,
uint32_t index, uint32_t max, uint32_t index, uint32_t max,
const struct spa_pod *filter, const struct spa_pod *filter,
@ -106,4 +106,4 @@ int pw_device_for_each_param(struct pw_device *device,
} }
#endif #endif
#endif /* PIPEWIRE_DEVICE_H */ #endif /* PIPEWIRE_IMPL_DEVICE_H */

View file

@ -271,13 +271,13 @@ struct pw_main_loop {
unsigned int running:1; unsigned int running:1;
}; };
#define pw_device_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_device_events, m, v, ##__VA_ARGS__) #define pw_impl_device_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_impl_device_events, m, v, ##__VA_ARGS__)
#define pw_device_emit_destroy(m) pw_device_emit(m, destroy, 0) #define pw_impl_device_emit_destroy(m) pw_impl_device_emit(m, destroy, 0)
#define pw_device_emit_free(m) pw_device_emit(m, free, 0) #define pw_impl_device_emit_free(m) pw_impl_device_emit(m, free, 0)
#define pw_device_emit_initialized(m) pw_device_emit(m, initialized, 0) #define pw_impl_device_emit_initialized(m) pw_impl_device_emit(m, initialized, 0)
#define pw_device_emit_info_changed(n,i) pw_device_emit(n, info_changed, 0, i) #define pw_impl_device_emit_info_changed(n,i) pw_impl_device_emit(n, info_changed, 0, i)
struct pw_device { struct pw_impl_device {
struct pw_context *context; /**< the context object */ struct pw_context *context; /**< the context object */
struct spa_list link; /**< link in the context device_list */ struct spa_list link; /**< link in the context device_list */
struct pw_global *global; /**< global object for this device */ struct pw_global *global; /**< global object for this device */