mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
pw_device -> pw_impl_device
This commit is contained in:
parent
95688939bf
commit
73900eea1b
12 changed files with 112 additions and 258 deletions
|
|
@ -83,7 +83,6 @@ pipewire_module_client_node = shared_library('pipewire-module-client-node',
|
|||
|
||||
pipewire_module_metadata = shared_library('pipewire-module-metadata',
|
||||
[ 'module-metadata.c',
|
||||
'module-metadata/resource-metadata.c',
|
||||
'module-metadata/proxy-metadata.c',
|
||||
'module-metadata/metadata.c',
|
||||
'module-metadata/protocol-native.c'],
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
struct impl {
|
||||
struct pw_context *context;
|
||||
struct pw_device *device;
|
||||
struct pw_impl_device *device;
|
||||
struct spa_hook device_listener;
|
||||
|
||||
struct pw_resource *resource;
|
||||
|
|
@ -54,8 +54,8 @@ 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,
|
||||
pw_impl_device_register(impl->device, NULL);
|
||||
pw_impl_device_set_implementation(impl->device,
|
||||
(struct spa_device*)impl->resource);
|
||||
impl->registered = true;
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ static void device_resource_destroy(void *data)
|
|||
spa_hook_remove(&impl->device_listener);
|
||||
spa_hook_remove(&impl->resource_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 = {
|
||||
|
|
@ -100,24 +100,24 @@ static void device_destroy(void *data)
|
|||
static void device_initialized(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct pw_device *device = impl->device;
|
||||
struct pw_global *global = pw_device_get_global(device);
|
||||
struct pw_impl_device *device = impl->device;
|
||||
struct pw_global *global = pw_impl_device_get_global(device);
|
||||
|
||||
pw_log_debug("client-device %p: initialized global:%d", impl, global->id);
|
||||
pw_resource_set_bound_id(impl->resource, global->id);
|
||||
}
|
||||
|
||||
static const struct pw_device_events device_events = {
|
||||
PW_VERSION_DEVICE_EVENTS,
|
||||
static const struct pw_impl_device_events device_events = {
|
||||
PW_VERSION_IMPL_DEVICE_EVENTS,
|
||||
.destroy = device_destroy,
|
||||
.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 impl *impl;
|
||||
struct pw_device *device;
|
||||
struct pw_impl_device *device;
|
||||
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||
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);
|
||||
|
||||
device = pw_device_new(context, properties, sizeof(struct impl));
|
||||
device = pw_impl_device_new(context, properties, sizeof(struct impl));
|
||||
if (device == NULL)
|
||||
return NULL;
|
||||
|
||||
impl = pw_device_get_user_data(device);
|
||||
impl = pw_impl_device_get_user_data(device);
|
||||
impl->device = device;
|
||||
impl->context = context;
|
||||
impl->resource = resource;
|
||||
|
||||
pw_device_add_listener(impl->device,
|
||||
pw_impl_device_add_listener(impl->device,
|
||||
&impl->device_listener,
|
||||
&device_events, impl);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ struct factory_data {
|
|||
|
||||
struct device_data {
|
||||
struct spa_list link;
|
||||
struct pw_device *device;
|
||||
struct pw_impl_device *device;
|
||||
struct spa_hook device_listener;
|
||||
};
|
||||
|
||||
|
|
@ -70,8 +70,8 @@ static void device_destroy(void *data)
|
|||
spa_hook_remove(&nd->device_listener);
|
||||
}
|
||||
|
||||
static const struct pw_device_events device_events = {
|
||||
PW_VERSION_DEVICE_EVENTS,
|
||||
static const struct pw_impl_device_events device_events = {
|
||||
PW_VERSION_IMPL_DEVICE_EVENTS,
|
||||
.destroy = device_destroy,
|
||||
};
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ static void *create_object(void *_data,
|
|||
{
|
||||
struct factory_data *data = _data;
|
||||
struct pw_context *context = data->context;
|
||||
struct pw_device *device;
|
||||
struct pw_impl_device *device;
|
||||
const char *factory_name;
|
||||
struct device_data *nd;
|
||||
struct pw_impl_client *client;
|
||||
|
|
@ -121,10 +121,10 @@ static void *create_object(void *_data,
|
|||
nd->device = device;
|
||||
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) {
|
||||
pw_global_bind(pw_device_get_global(device),
|
||||
pw_global_bind(pw_impl_device_get_global(device),
|
||||
client,
|
||||
PW_PERM_RWX, version,
|
||||
new_id);
|
||||
|
|
@ -160,7 +160,7 @@ static void factory_destroy(void *_data)
|
|||
spa_hook_remove(&data->module_listener);
|
||||
|
||||
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 = {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static const struct spa_dict_item module_props[] = {
|
|||
};
|
||||
|
||||
struct device_data {
|
||||
struct pw_device *this;
|
||||
struct pw_impl_device *this;
|
||||
struct pw_context *context;
|
||||
|
||||
struct spa_hook module_listener;
|
||||
|
|
@ -55,7 +55,7 @@ static void module_destroy(void *_data)
|
|||
|
||||
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 = {
|
||||
|
|
@ -70,7 +70,7 @@ int pipewire__module_init(struct pw_module *module, const char *args)
|
|||
char **argv = NULL;
|
||||
int n_tokens;
|
||||
struct pw_context *context = pw_module_get_context(module);
|
||||
struct pw_device *device;
|
||||
struct pw_impl_device *device;
|
||||
struct device_data *data;
|
||||
int res;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#include "pipewire/private.h"
|
||||
|
||||
struct impl {
|
||||
struct pw_device *this;
|
||||
struct pw_impl_device *this;
|
||||
|
||||
enum pw_spa_device_flags flags;
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ struct impl {
|
|||
static void device_destroy(void *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);
|
||||
|
||||
|
|
@ -63,12 +63,12 @@ static void device_destroy(void *data)
|
|||
pw_unload_spa_handle(impl->handle);
|
||||
}
|
||||
|
||||
static const struct pw_device_events device_events = {
|
||||
PW_VERSION_DEVICE_EVENTS,
|
||||
static const struct pw_impl_device_events device_events = {
|
||||
PW_VERSION_IMPL_DEVICE_EVENTS,
|
||||
.destroy = device_destroy,
|
||||
};
|
||||
|
||||
struct pw_device *
|
||||
struct pw_impl_device *
|
||||
pw_spa_device_new(struct pw_context *context,
|
||||
enum pw_spa_device_flags flags,
|
||||
struct spa_device *device,
|
||||
|
|
@ -76,11 +76,11 @@ pw_spa_device_new(struct pw_context *context,
|
|||
struct pw_properties *properties,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct pw_device *this;
|
||||
struct pw_impl_device *this;
|
||||
struct impl *impl;
|
||||
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)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -93,34 +93,34 @@ pw_spa_device_new(struct pw_context *context,
|
|||
if (user_data_size > 0)
|
||||
impl->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||
|
||||
pw_device_add_listener(this, &impl->device_listener, &device_events, impl);
|
||||
pw_device_set_implementation(this, impl->device);
|
||||
pw_impl_device_add_listener(this, &impl->device_listener, &device_events, impl);
|
||||
pw_impl_device_set_implementation(this, impl->device);
|
||||
|
||||
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;
|
||||
}
|
||||
return this;
|
||||
|
||||
error_register:
|
||||
pw_device_destroy(this);
|
||||
pw_impl_device_destroy(this);
|
||||
errno = -res;
|
||||
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;
|
||||
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,
|
||||
enum pw_spa_device_flags flags,
|
||||
struct pw_properties *properties,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct pw_device *this;
|
||||
struct pw_impl_device *this;
|
||||
struct spa_handle *handle;
|
||||
void *iface;
|
||||
int res;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ enum pw_spa_device_flags {
|
|||
PW_SPA_DEVICE_FLAG_NO_REGISTER = (1 << 1),
|
||||
};
|
||||
|
||||
struct pw_device *
|
||||
struct pw_impl_device *
|
||||
pw_spa_device_new(struct pw_context *context,
|
||||
enum pw_spa_device_flags flags,
|
||||
struct spa_device *device,
|
||||
|
|
@ -46,14 +46,14 @@ pw_spa_device_new(struct pw_context *context,
|
|||
struct pw_properties *properties,
|
||||
size_t user_data_size);
|
||||
|
||||
struct pw_device *
|
||||
struct pw_impl_device *
|
||||
pw_spa_device_load(struct pw_context *context,
|
||||
const char *factory_name,
|
||||
enum pw_spa_device_flags flags,
|
||||
struct pw_properties *properties,
|
||||
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue