mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
avoid including private.h
Expose some more methods to make it possible to build without including the private.h header, especially in modules.
This commit is contained in:
parent
8e6a5a1714
commit
df519ee3b3
43 changed files with 349 additions and 372 deletions
|
|
@ -30,7 +30,6 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <pipewire/impl.h>
|
#include <pipewire/impl.h>
|
||||||
#include <pipewire/private.h>
|
|
||||||
|
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
#include <pipewire/private.h>
|
|
||||||
|
|
||||||
#include "daemon/command.h"
|
#include "daemon/command.h"
|
||||||
#include "daemon/daemon-config.h"
|
#include "daemon/daemon-config.h"
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@
|
||||||
#include <spa/debug/dict.h>
|
#include <spa/debug/dict.h>
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
#define NAME "media-session"
|
#define NAME "media-session"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <spa/node/node.h>
|
#include <spa/node/node.h>
|
||||||
#include <spa/utils/hook.h>
|
#include <spa/utils/hook.h>
|
||||||
|
#include <spa/utils/result.h>
|
||||||
#include <spa/param/audio/format-utils.h>
|
#include <spa/param/audio/format-utils.h>
|
||||||
#include <spa/param/props.h>
|
#include <spa/param/props.h>
|
||||||
#include <spa/debug/pod.h>
|
#include <spa/debug/pod.h>
|
||||||
|
|
@ -39,7 +40,6 @@
|
||||||
#include <spa/monitor/device.h>
|
#include <spa/monitor/device.h>
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
#include "extensions/session-manager.h"
|
#include "extensions/session-manager.h"
|
||||||
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@
|
||||||
#include <spa/debug/pod.h>
|
#include <spa/debug/pod.h>
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
#include "extensions/session-manager.h"
|
#include "extensions/session-manager.h"
|
||||||
|
|
||||||
#include "media-session.h"
|
#include "media-session.h"
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,13 @@
|
||||||
|
|
||||||
#include <spa/node/node.h>
|
#include <spa/node/node.h>
|
||||||
#include <spa/utils/hook.h>
|
#include <spa/utils/hook.h>
|
||||||
|
#include <spa/utils/result.h>
|
||||||
#include <spa/param/audio/format-utils.h>
|
#include <spa/param/audio/format-utils.h>
|
||||||
#include <spa/param/props.h>
|
#include <spa/param/props.h>
|
||||||
#include <spa/debug/pod.h>
|
#include <spa/debug/pod.h>
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
#include "extensions/session-manager.h"
|
#include "extensions/session-manager.h"
|
||||||
#include "media-session.h"
|
#include "media-session.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@
|
||||||
|
|
||||||
#include <spa/node/node.h>
|
#include <spa/node/node.h>
|
||||||
#include <spa/utils/hook.h>
|
#include <spa/utils/hook.h>
|
||||||
|
#include <spa/utils/result.h>
|
||||||
|
|
||||||
#include <pipewire/impl.h>
|
#include <pipewire/impl.h>
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
#include "modules/spa/spa-node.h"
|
#include "modules/spa/spa-node.h"
|
||||||
#include "module-adapter/adapter.h"
|
#include "module-adapter/adapter.h"
|
||||||
|
|
@ -153,13 +153,14 @@ static void *create_object(void *_data,
|
||||||
if (properties == NULL)
|
if (properties == NULL)
|
||||||
goto error_properties;
|
goto error_properties;
|
||||||
|
|
||||||
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d", d->this->global->id);
|
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d",
|
||||||
|
pw_impl_factory_get_info(d->this)->id);
|
||||||
|
|
||||||
client = resource ? pw_resource_get_client(resource): NULL;
|
client = resource ? pw_resource_get_client(resource): NULL;
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
|
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
|
||||||
client->global->id);
|
pw_impl_client_get_info(client)->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
slave = NULL;
|
slave = NULL;
|
||||||
|
|
@ -265,7 +266,7 @@ static void module_registered(void *data)
|
||||||
char id[16];
|
char id[16];
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
snprintf(id, sizeof(id), "%d", module->global->id);
|
snprintf(id, sizeof(id), "%d", pw_impl_module_get_info(module)->id);
|
||||||
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
|
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
|
||||||
pw_impl_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
|
pw_impl_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
#include "modules/spa/spa-node.h"
|
#include "modules/spa/spa-node.h"
|
||||||
|
|
||||||
|
|
@ -123,7 +122,7 @@ static void node_port_init(void *data, struct pw_impl_port *port)
|
||||||
|
|
||||||
if ((str = pw_properties_get(old, PW_KEY_AUDIO_CHANNEL)) == NULL ||
|
if ((str = pw_properties_get(old, PW_KEY_AUDIO_CHANNEL)) == NULL ||
|
||||||
strcmp(str, "UNK") == 0) {
|
strcmp(str, "UNK") == 0) {
|
||||||
snprintf(position, 7, "%d", port->port_id);
|
snprintf(position, 7, "%d", pw_impl_port_get_id(port));
|
||||||
str = position;
|
str = position;
|
||||||
}
|
}
|
||||||
if (direction == n->direction) {
|
if (direction == n->direction) {
|
||||||
|
|
@ -139,7 +138,7 @@ static void node_port_init(void *data, struct pw_impl_port *port)
|
||||||
node_name = "node";
|
node_name = "node";
|
||||||
}
|
}
|
||||||
pw_properties_setf(new, PW_KEY_OBJECT_PATH, "%s:%s_%d",
|
pw_properties_setf(new, PW_KEY_OBJECT_PATH, "%s:%s_%d",
|
||||||
path ? path : node_name, prefix, port->port_id);
|
path ? path : node_name, prefix, pw_impl_port_get_id(port));
|
||||||
|
|
||||||
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
|
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
|
||||||
pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s_%s",
|
pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s_%s",
|
||||||
|
|
@ -166,7 +165,7 @@ static int find_format(struct pw_impl_node *node, enum pw_direction direction,
|
||||||
struct spa_pod *format;
|
struct spa_pod *format;
|
||||||
|
|
||||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||||
if ((res = spa_node_port_enum_params_sync(node->node,
|
if ((res = spa_node_port_enum_params_sync(pw_impl_node_get_implementation(node),
|
||||||
direction == PW_DIRECTION_INPUT ?
|
direction == PW_DIRECTION_INPUT ?
|
||||||
SPA_DIRECTION_INPUT :
|
SPA_DIRECTION_INPUT :
|
||||||
SPA_DIRECTION_OUTPUT, 0,
|
SPA_DIRECTION_OUTPUT, 0,
|
||||||
|
|
@ -236,7 +235,8 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (media_type == SPA_MEDIA_TYPE_audio) {
|
if (media_type == SPA_MEDIA_TYPE_audio) {
|
||||||
pw_properties_setf(props, "audio.adapt.slave", "pointer:%p", slave->node);
|
pw_properties_setf(props, "audio.adapt.slave", "pointer:%p",
|
||||||
|
pw_impl_node_get_implementation(slave));
|
||||||
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert");
|
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert");
|
||||||
if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL)
|
if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL)
|
||||||
pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Audio/%s",
|
pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Audio/%s",
|
||||||
|
|
@ -244,7 +244,8 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
|
||||||
factory_name = SPA_NAME_AUDIO_ADAPT;
|
factory_name = SPA_NAME_AUDIO_ADAPT;
|
||||||
}
|
}
|
||||||
else if (media_type == SPA_MEDIA_TYPE_video) {
|
else if (media_type == SPA_MEDIA_TYPE_video) {
|
||||||
pw_properties_setf(props, "video.adapt.slave", "pointer:%p", slave->node);
|
pw_properties_setf(props, "video.adapt.slave", "pointer:%p",
|
||||||
|
pw_impl_node_get_implementation(slave));
|
||||||
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "videoconvert/libspa-videoconvert");
|
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "videoconvert/libspa-videoconvert");
|
||||||
if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL)
|
if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL)
|
||||||
pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Video/%s",
|
pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Video/%s",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
#include <spa/monitor/device.h>
|
#include <spa/monitor/device.h>
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
struct device_data {
|
struct device_data {
|
||||||
struct spa_device *device;
|
struct spa_device *device;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
#include <pipewire/impl.h>
|
#include <pipewire/impl.h>
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_context *context;
|
struct pw_context *context;
|
||||||
|
|
@ -102,9 +101,10 @@ static void device_initialized(void *data)
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
struct pw_impl_device *device = impl->device;
|
struct pw_impl_device *device = impl->device;
|
||||||
struct pw_global *global = pw_impl_device_get_global(device);
|
struct pw_global *global = pw_impl_device_get_global(device);
|
||||||
|
uint32_t id = pw_global_get_id(global);
|
||||||
|
|
||||||
pw_log_debug("client-device %p: initialized global:%d", impl, global->id);
|
pw_log_debug("client-device %p: initialized global:%d", impl, id);
|
||||||
pw_resource_set_bound_id(impl->resource, global->id);
|
pw_resource_set_bound_id(impl->resource, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_impl_device_events device_events = {
|
static const struct pw_impl_device_events device_events = {
|
||||||
|
|
@ -126,7 +126,8 @@ struct pw_impl_device *pw_client_device_new(struct pw_resource *resource,
|
||||||
if (properties == NULL)
|
if (properties == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id);
|
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
|
||||||
|
pw_impl_client_get_info(client)->id);
|
||||||
|
|
||||||
device = pw_context_create_device(context, properties, sizeof(struct impl));
|
device = pw_context_create_device(context, properties, sizeof(struct impl));
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <spa/pod/parser.h>
|
#include <spa/pod/parser.h>
|
||||||
#include <spa/node/utils.h>
|
#include <spa/node/utils.h>
|
||||||
|
#include <spa/utils/result.h>
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <spa/pod/parser.h>
|
#include <spa/pod/parser.h>
|
||||||
|
#include <spa/pod/builder.h>
|
||||||
|
#include <spa/utils/type-info.h>
|
||||||
|
|
||||||
#include "pipewire/impl.h"
|
#include "pipewire/impl.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
#include "extensions/protocol-native.h"
|
#include "extensions/protocol-native.h"
|
||||||
|
|
||||||
|
|
@ -45,6 +46,7 @@ client_node_marshal_add_mem(void *object,
|
||||||
int memfd, uint32_t flags)
|
int memfd, uint32_t flags)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_builder *b;
|
struct spa_pod_builder *b;
|
||||||
const char *typename;
|
const char *typename;
|
||||||
|
|
||||||
|
|
@ -64,7 +66,7 @@ client_node_marshal_add_mem(void *object,
|
||||||
|
|
||||||
spa_pod_builder_add_struct(b,
|
spa_pod_builder_add_struct(b,
|
||||||
"i", mem_id,
|
"i", mem_id,
|
||||||
"I", pw_protocol_native0_find_type(resource->client, typename),
|
"I", pw_protocol_native0_find_type(client, typename),
|
||||||
"i", pw_protocol_native_add_resource_fd(resource, memfd),
|
"i", pw_protocol_native_add_resource_fd(resource, memfd),
|
||||||
"i", flags);
|
"i", flags);
|
||||||
|
|
||||||
|
|
@ -127,7 +129,7 @@ static void
|
||||||
client_node_marshal_command(void *object, uint32_t seq, const struct spa_command *command)
|
client_node_marshal_command(void *object, uint32_t seq, const struct spa_command *command)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_builder *b;
|
struct spa_pod_builder *b;
|
||||||
struct spa_pod_frame f;
|
struct spa_pod_frame f;
|
||||||
|
|
||||||
|
|
@ -185,7 +187,7 @@ client_node_marshal_port_set_param(void *object,
|
||||||
const struct spa_pod *param)
|
const struct spa_pod *param)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_builder *b;
|
struct spa_pod_builder *b;
|
||||||
struct spa_pod_frame f;
|
struct spa_pod_frame f;
|
||||||
const char *typename;
|
const char *typename;
|
||||||
|
|
@ -224,7 +226,7 @@ client_node_marshal_port_use_buffers(void *object,
|
||||||
uint32_t n_buffers, struct pw_client_node0_buffer *buffers)
|
uint32_t n_buffers, struct pw_client_node0_buffer *buffers)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_builder *b;
|
struct spa_pod_builder *b;
|
||||||
struct spa_pod_frame f;
|
struct spa_pod_frame f;
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
|
|
@ -277,7 +279,7 @@ client_node_marshal_port_command(void *object,
|
||||||
const struct spa_command *command)
|
const struct spa_command *command)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_builder *b;
|
struct spa_pod_builder *b;
|
||||||
struct spa_pod_frame f;
|
struct spa_pod_frame f;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,9 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <spa/utils/result.h>
|
||||||
|
|
||||||
#include <pipewire/impl.h>
|
#include <pipewire/impl.h>
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
#define NAME "link-factory"
|
#define NAME "link-factory"
|
||||||
|
|
||||||
|
|
@ -145,6 +146,7 @@ static const struct pw_impl_link_events link_events = {
|
||||||
static struct pw_impl_port *get_port(struct pw_impl_node *node, enum spa_direction direction)
|
static struct pw_impl_port *get_port(struct pw_impl_node *node, enum spa_direction direction)
|
||||||
{
|
{
|
||||||
struct pw_impl_port *p;
|
struct pw_impl_port *p;
|
||||||
|
struct pw_context *context = pw_impl_node_get_context(node);
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
p = pw_impl_node_find_port(node, direction, SPA_ID_INVALID);
|
p = pw_impl_node_find_port(node, direction, SPA_ID_INVALID);
|
||||||
|
|
@ -156,7 +158,7 @@ static struct pw_impl_port *get_port(struct pw_impl_node *node, enum spa_directi
|
||||||
if (port_id == SPA_ID_INVALID)
|
if (port_id == SPA_ID_INVALID)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
p = pw_context_create_port(node->context, direction, port_id, NULL, 0);
|
p = pw_context_create_port(context, direction, port_id, NULL, 0);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -253,9 +255,11 @@ static void *create_object(void *_data,
|
||||||
str = pw_properties_get(properties, PW_KEY_OBJECT_LINGER);
|
str = pw_properties_get(properties, PW_KEY_OBJECT_LINGER);
|
||||||
linger = str ? pw_properties_parse_bool(str) : false;
|
linger = str ? pw_properties_parse_bool(str) : false;
|
||||||
|
|
||||||
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d", d->this->global->id);
|
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d",
|
||||||
|
pw_impl_factory_get_info(d->this)->id);
|
||||||
if (!linger)
|
if (!linger)
|
||||||
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id);
|
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
|
||||||
|
pw_impl_client_get_info(client)->id);
|
||||||
|
|
||||||
|
|
||||||
link = pw_context_create_link(context, outport, inport, NULL, properties, sizeof(struct link_data));
|
link = pw_context_create_link(context, outport, inport, NULL, properties, sizeof(struct link_data));
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/impl.h>
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
#include <extensions/metadata.h>
|
#include <extensions/metadata.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
#include <spa/pod/parser.h>
|
#include <spa/pod/parser.h>
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
#include "extensions/metadata.h"
|
#include "extensions/metadata.h"
|
||||||
|
|
||||||
struct object_data {
|
struct object_data {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
|
||||||
#include <spa/pod/iter.h>
|
#include <spa/pod/iter.h>
|
||||||
|
#include <spa/utils/result.h>
|
||||||
#include <spa/debug/pod.h>
|
#include <spa/debug/pod.h>
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,10 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include <spa/debug/pod.h>
|
#include <spa/debug/pod.h>
|
||||||
|
#include <spa/utils/result.h>
|
||||||
|
#include <spa/pod/builder.h>
|
||||||
|
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "spa/pod/parser.h"
|
#include "spa/pod/parser.h"
|
||||||
|
#include "spa/pod/builder.h"
|
||||||
#include "spa/debug/pod.h"
|
#include "spa/debug/pod.h"
|
||||||
|
|
||||||
#include "pipewire/pipewire.h"
|
#include "pipewire/pipewire.h"
|
||||||
|
|
@ -169,6 +170,7 @@ static void core_marshal_remove_id(void *object, uint32_t id)
|
||||||
static int core_demarshal_client_update(void *object, const struct pw_protocol_native_message *msg)
|
static int core_demarshal_client_update(void *object, const struct pw_protocol_native_message *msg)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_dict props;
|
struct spa_dict props;
|
||||||
struct spa_pod_parser prs;
|
struct spa_pod_parser prs;
|
||||||
struct spa_pod_frame f;
|
struct spa_pod_frame f;
|
||||||
|
|
@ -188,7 +190,7 @@ static int core_demarshal_client_update(void *object, const struct pw_protocol_n
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
pw_impl_client_update_properties(resource->client, &props);
|
pw_impl_client_update_properties(client, &props);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -727,7 +729,7 @@ static void registry_marshal_global(void *object, uint32_t id, uint32_t permissi
|
||||||
const char *type, uint32_t version, const struct spa_dict *props)
|
const char *type, uint32_t version, const struct spa_dict *props)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_builder *b;
|
struct spa_pod_builder *b;
|
||||||
struct spa_pod_frame f;
|
struct spa_pod_frame f;
|
||||||
uint32_t i, n_items, parent_id;
|
uint32_t i, n_items, parent_id;
|
||||||
|
|
@ -775,6 +777,7 @@ static void registry_marshal_global_remove(void *object, uint32_t id)
|
||||||
static int registry_demarshal_bind(void *object, const struct pw_protocol_native_message *msg)
|
static int registry_demarshal_bind(void *object, const struct pw_protocol_native_message *msg)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_parser prs;
|
struct spa_pod_parser prs;
|
||||||
uint32_t id, version, type, new_id;
|
uint32_t id, version, type, new_id;
|
||||||
const char *type_name;
|
const char *type_name;
|
||||||
|
|
@ -787,7 +790,7 @@ static int registry_demarshal_bind(void *object, const struct pw_protocol_native
|
||||||
"i", &new_id) < 0)
|
"i", &new_id) < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
type_name = pw_protocol_native0_name_from_v2(resource->client, type);
|
type_name = pw_protocol_native0_name_from_v2(client, type);
|
||||||
if (type_name == NULL)
|
if (type_name == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
@ -827,7 +830,7 @@ static void module_marshal_info(void *object, const struct pw_module_info *info)
|
||||||
static void factory_marshal_info(void *object, const struct pw_factory_info *info)
|
static void factory_marshal_info(void *object, const struct pw_factory_info *info)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_builder *b;
|
struct spa_pod_builder *b;
|
||||||
struct spa_pod_frame f;
|
struct spa_pod_frame f;
|
||||||
uint32_t i, n_items, type, version;
|
uint32_t i, n_items, type, version;
|
||||||
|
|
@ -908,7 +911,7 @@ static void node_marshal_param(void *object, int seq, uint32_t id, uint32_t inde
|
||||||
static int node_demarshal_enum_params(void *object, const struct pw_protocol_native_message *msg)
|
static int node_demarshal_enum_params(void *object, const struct pw_protocol_native_message *msg)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_parser prs;
|
struct spa_pod_parser prs;
|
||||||
uint32_t id, index, num;
|
uint32_t id, index, num;
|
||||||
struct spa_pod *filter;
|
struct spa_pod *filter;
|
||||||
|
|
@ -960,7 +963,7 @@ static void port_marshal_param(void *object, int seq, uint32_t id, uint32_t inde
|
||||||
const struct spa_pod *param)
|
const struct spa_pod *param)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_builder *b;
|
struct spa_pod_builder *b;
|
||||||
|
|
||||||
b = pw_protocol_native_begin_resource(resource, PW_PORT_V0_EVENT_PARAM, NULL);
|
b = pw_protocol_native_begin_resource(resource, PW_PORT_V0_EVENT_PARAM, NULL);
|
||||||
|
|
@ -975,7 +978,7 @@ static void port_marshal_param(void *object, int seq, uint32_t id, uint32_t inde
|
||||||
static int port_demarshal_enum_params(void *object, const struct pw_protocol_native_message *msg)
|
static int port_demarshal_enum_params(void *object, const struct pw_protocol_native_message *msg)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = pw_resource_get_client(resource);
|
||||||
struct spa_pod_parser prs;
|
struct spa_pod_parser prs;
|
||||||
uint32_t id, index, num;
|
uint32_t id, index, num;
|
||||||
struct spa_pod *filter;
|
struct spa_pod *filter;
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,15 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <spa/utils/result.h>
|
||||||
#include <pipewire/impl.h>
|
#include <pipewire/impl.h>
|
||||||
|
|
||||||
#include <extensions/session-manager.h>
|
#include <extensions/session-manager.h>
|
||||||
|
|
||||||
#include "client-endpoint.h"
|
#include "client-endpoint.h"
|
||||||
#include "endpoint.h"
|
#include "endpoint.h"
|
||||||
#include "endpoint-stream.h"
|
#include "endpoint-stream.h"
|
||||||
|
|
||||||
#include <pipewire/private.h>
|
|
||||||
|
|
||||||
#define NAME "client-endpoint"
|
#define NAME "client-endpoint"
|
||||||
|
|
||||||
struct factory_data {
|
struct factory_data {
|
||||||
|
|
@ -184,8 +184,10 @@ static void *create_object(void *data,
|
||||||
if (!properties)
|
if (!properties)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", owner->global->id);
|
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
|
||||||
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d", factory->global->id);
|
pw_impl_client_get_info(owner)->id);
|
||||||
|
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d",
|
||||||
|
pw_impl_factory_get_info(factory)->id);
|
||||||
|
|
||||||
this->resource = pw_resource_new(owner, new_id, PW_PERM_RWX, type, version, 0);
|
this->resource = pw_resource_new(owner, new_id, PW_PERM_RWX, type, version, 0);
|
||||||
if (this->resource == NULL)
|
if (this->resource == NULL)
|
||||||
|
|
@ -235,7 +237,7 @@ static void module_registered(void *data)
|
||||||
char id[16];
|
char id[16];
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
snprintf(id, sizeof(id), "%d", module->global->id);
|
snprintf(id, sizeof(id), "%d", pw_impl_module_get_info(module)->id);
|
||||||
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
|
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
|
||||||
pw_impl_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
|
pw_impl_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <spa/utils/result.h>
|
||||||
|
|
||||||
#include <pipewire/impl.h>
|
#include <pipewire/impl.h>
|
||||||
#include <extensions/session-manager.h>
|
#include <extensions/session-manager.h>
|
||||||
|
|
||||||
|
|
@ -33,8 +35,6 @@
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "endpoint-link.h"
|
#include "endpoint-link.h"
|
||||||
|
|
||||||
#include <pipewire/private.h>
|
|
||||||
|
|
||||||
#define NAME "client-session"
|
#define NAME "client-session"
|
||||||
|
|
||||||
struct factory_data {
|
struct factory_data {
|
||||||
|
|
@ -183,8 +183,10 @@ static void *create_object(void *data,
|
||||||
if (!properties)
|
if (!properties)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", owner->global->id);
|
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
|
||||||
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d", factory->global->id);
|
pw_impl_client_get_info(owner)->id);
|
||||||
|
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d",
|
||||||
|
pw_impl_factory_get_info(factory)->id);
|
||||||
|
|
||||||
this->resource = pw_resource_new(owner, new_id, PW_PERM_RWX, type, version, 0);
|
this->resource = pw_resource_new(owner, new_id, PW_PERM_RWX, type, version, 0);
|
||||||
if (this->resource == NULL)
|
if (this->resource == NULL)
|
||||||
|
|
@ -234,7 +236,7 @@ static void module_registered(void *data)
|
||||||
char id[16];
|
char id[16];
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
snprintf(id, sizeof(id), "%d", module->global->id);
|
snprintf(id, sizeof(id), "%d", pw_impl_module_get_info(module)->id);
|
||||||
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
|
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
|
||||||
pw_impl_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
|
pw_impl_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/impl.h>
|
||||||
#include <extensions/session-manager.h>
|
#include <extensions/session-manager.h>
|
||||||
|
|
||||||
#include <spa/pod/filter.h>
|
#include <spa/pod/filter.h>
|
||||||
|
|
@ -34,13 +34,10 @@
|
||||||
#include "endpoint-link.h"
|
#include "endpoint-link.h"
|
||||||
#include "client-session.h"
|
#include "client-session.h"
|
||||||
|
|
||||||
#include <pipewire/private.h>
|
|
||||||
|
|
||||||
#define NAME "endpoint-link"
|
#define NAME "endpoint-link"
|
||||||
|
|
||||||
struct resource_data {
|
struct resource_data {
|
||||||
struct endpoint_link *link;
|
struct endpoint_link *link;
|
||||||
struct spa_hook resource_listener;
|
|
||||||
struct spa_hook object_listener;
|
struct spa_hook object_listener;
|
||||||
uint32_t n_subscribe_ids;
|
uint32_t n_subscribe_ids;
|
||||||
uint32_t subscribe_ids[32];
|
uint32_t subscribe_ids[32];
|
||||||
|
|
@ -104,7 +101,7 @@ static int endpoint_link_subscribe_params (void *object, uint32_t *ids, uint32_t
|
||||||
for (i = 0; i < n_ids; i++) {
|
for (i = 0; i < n_ids; i++) {
|
||||||
data->subscribe_ids[i] = ids[i];
|
data->subscribe_ids[i] = ids[i];
|
||||||
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
||||||
data->link, resource->id, ids[i]);
|
data->link, pw_resource_get_id(resource), ids[i]);
|
||||||
endpoint_link_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
endpoint_link_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -143,30 +140,54 @@ static const struct pw_endpoint_link_methods methods = {
|
||||||
.request_state = endpoint_link_request_state,
|
.request_state = endpoint_link_request_state,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct emit_param_data {
|
||||||
|
struct endpoint_link *this;
|
||||||
|
struct spa_pod *param;
|
||||||
|
uint32_t id;
|
||||||
|
uint32_t index;
|
||||||
|
uint32_t next;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int emit_param(void *_data, struct pw_resource *resource)
|
||||||
|
{
|
||||||
|
struct emit_param_data *d = _data;
|
||||||
|
struct resource_data *data;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
data = pw_resource_get_user_data(resource);
|
||||||
|
for (i = 0; i < data->n_subscribe_ids; i++) {
|
||||||
|
if (data->subscribe_ids[i] == d->id) {
|
||||||
|
pw_endpoint_link_resource_param(resource, 1,
|
||||||
|
d->id, d->index, d->next, d->param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void endpoint_link_notify_subscribed(struct endpoint_link *this,
|
static void endpoint_link_notify_subscribed(struct endpoint_link *this,
|
||||||
uint32_t index, uint32_t next)
|
uint32_t index, uint32_t next)
|
||||||
{
|
{
|
||||||
struct pw_global *global = this->global;
|
struct pw_global *global = this->global;
|
||||||
struct pw_resource *resource;
|
struct emit_param_data data;
|
||||||
struct resource_data *data;
|
|
||||||
struct spa_pod *param = this->params[index];
|
struct spa_pod *param = this->params[index];
|
||||||
uint32_t id;
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
if (!param || !spa_pod_is_object (param))
|
if (!param || !spa_pod_is_object (param))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
id = SPA_POD_OBJECT_ID (param);
|
data.this = this;
|
||||||
|
data.param = param;
|
||||||
|
data.id = SPA_POD_OBJECT_ID (param);
|
||||||
|
data.index = index;
|
||||||
|
data.next = next;
|
||||||
|
|
||||||
spa_list_for_each(resource, &global->resource_list, link) {
|
pw_global_for_each_resource(global, emit_param, &data);
|
||||||
data = pw_resource_get_user_data(resource);
|
}
|
||||||
for (i = 0; i < data->n_subscribe_ids; i++) {
|
|
||||||
if (data->subscribe_ids[i] == id) {
|
static int emit_info(void *data, struct pw_resource *resource)
|
||||||
pw_endpoint_link_resource_param(resource, 1,
|
{
|
||||||
id, index, next, param);
|
struct endpoint_link *this = data;
|
||||||
}
|
pw_endpoint_link_resource_info(resource, &this->info);
|
||||||
}
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int endpoint_link_update(struct endpoint_link *this,
|
int endpoint_link_update(struct endpoint_link *this,
|
||||||
|
|
@ -197,8 +218,6 @@ int endpoint_link_update(struct endpoint_link *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_mask & PW_CLIENT_SESSION_UPDATE_INFO) {
|
if (change_mask & PW_CLIENT_SESSION_UPDATE_INFO) {
|
||||||
struct pw_resource *resource;
|
|
||||||
|
|
||||||
if (info->change_mask & PW_ENDPOINT_LINK_CHANGE_MASK_STATE) {
|
if (info->change_mask & PW_ENDPOINT_LINK_CHANGE_MASK_STATE) {
|
||||||
this->info.state = info->state;
|
this->info.state = info->state;
|
||||||
free(this->info.error);
|
free(this->info.error);
|
||||||
|
|
@ -229,9 +248,7 @@ int endpoint_link_update(struct endpoint_link *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
this->info.change_mask = info->change_mask;
|
this->info.change_mask = info->change_mask;
|
||||||
spa_list_for_each(resource, &this->global->resource_list, link) {
|
pw_global_for_each_resource(this->global, emit_info, this);
|
||||||
pw_endpoint_link_resource_info(resource, &this->info);
|
|
||||||
}
|
|
||||||
this->info.change_mask = 0;
|
this->info.change_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,17 +261,6 @@ int endpoint_link_update(struct endpoint_link *this,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void endpoint_link_unbind(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = endpoint_link_unbind,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int endpoint_link_bind(void *_data, struct pw_impl_client *client,
|
static int endpoint_link_bind(void *_data, struct pw_impl_client *client,
|
||||||
uint32_t permissions, uint32_t version, uint32_t id)
|
uint32_t permissions, uint32_t version, uint32_t id)
|
||||||
{
|
{
|
||||||
|
|
@ -263,20 +269,18 @@ static int endpoint_link_bind(void *_data, struct pw_impl_client *client,
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
struct resource_data *data;
|
struct resource_data *data;
|
||||||
|
|
||||||
resource = pw_resource_new(client, id, permissions, global->type, version, sizeof(*data));
|
resource = pw_resource_new(client, id, permissions,
|
||||||
|
pw_global_get_type(global), version, sizeof(*data));
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
data = pw_resource_get_user_data(resource);
|
data = pw_resource_get_user_data(resource);
|
||||||
data->link = this;
|
data->link = this;
|
||||||
pw_resource_add_listener(resource, &data->resource_listener,
|
|
||||||
&resource_events, resource);
|
|
||||||
pw_resource_add_object_listener(resource, &data->object_listener,
|
pw_resource_add_object_listener(resource, &data->object_listener,
|
||||||
&methods, resource);
|
&methods, resource);
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, pw_resource_get_id(resource));
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
|
|
||||||
this->info.change_mask = PW_ENDPOINT_LINK_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_ENDPOINT_LINK_CHANGE_MASK_ALL;
|
||||||
pw_endpoint_link_resource_info(resource, &this->info);
|
pw_endpoint_link_resource_info(resource, &this->info);
|
||||||
|
|
@ -316,10 +320,11 @@ int endpoint_link_init(struct endpoint_link *this,
|
||||||
if (!this->global)
|
if (!this->global)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u", this->global->id);
|
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u",
|
||||||
|
pw_global_get_id(this->global));
|
||||||
|
|
||||||
this->info.version = PW_VERSION_ENDPOINT_LINK_INFO;
|
this->info.version = PW_VERSION_ENDPOINT_LINK_INFO;
|
||||||
this->info.id = this->global->id;
|
this->info.id = pw_global_get_id(this->global);
|
||||||
this->info.session_id = session_id;
|
this->info.session_id = session_id;
|
||||||
this->info.props = &this->props->dict;
|
this->info.props = &this->props->dict;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,10 @@
|
||||||
#include "endpoint-stream.h"
|
#include "endpoint-stream.h"
|
||||||
#include "client-endpoint.h"
|
#include "client-endpoint.h"
|
||||||
|
|
||||||
#include <pipewire/private.h>
|
|
||||||
|
|
||||||
#define NAME "endpoint-stream"
|
#define NAME "endpoint-stream"
|
||||||
|
|
||||||
struct resource_data {
|
struct resource_data {
|
||||||
struct endpoint_stream *stream;
|
struct endpoint_stream *stream;
|
||||||
struct spa_hook resource_listener;
|
|
||||||
struct spa_hook object_listener;
|
struct spa_hook object_listener;
|
||||||
uint32_t n_subscribe_ids;
|
uint32_t n_subscribe_ids;
|
||||||
uint32_t subscribe_ids[32];
|
uint32_t subscribe_ids[32];
|
||||||
|
|
@ -104,7 +101,7 @@ static int endpoint_stream_subscribe_params (void *object, uint32_t *ids, uint32
|
||||||
for (i = 0; i < n_ids; i++) {
|
for (i = 0; i < n_ids; i++) {
|
||||||
data->subscribe_ids[i] = ids[i];
|
data->subscribe_ids[i] = ids[i];
|
||||||
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
||||||
data->stream, resource->id, ids[i]);
|
data->stream, pw_resource_get_id(resource), ids[i]);
|
||||||
endpoint_stream_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
endpoint_stream_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -130,30 +127,54 @@ static const struct pw_endpoint_stream_methods methods = {
|
||||||
.set_param = endpoint_stream_set_param,
|
.set_param = endpoint_stream_set_param,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct emit_param_data {
|
||||||
|
struct endpoint_stream *this;
|
||||||
|
struct spa_pod *param;
|
||||||
|
uint32_t id;
|
||||||
|
uint32_t index;
|
||||||
|
uint32_t next;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int emit_param(void *_data, struct pw_resource *resource)
|
||||||
|
{
|
||||||
|
struct emit_param_data *d = _data;
|
||||||
|
struct resource_data *data;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
data = pw_resource_get_user_data(resource);
|
||||||
|
for (i = 0; i < data->n_subscribe_ids; i++) {
|
||||||
|
if (data->subscribe_ids[i] == d->id) {
|
||||||
|
pw_endpoint_stream_resource_param(resource, 1,
|
||||||
|
d->id, d->index, d->next, d->param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void endpoint_stream_notify_subscribed(struct endpoint_stream *this,
|
static void endpoint_stream_notify_subscribed(struct endpoint_stream *this,
|
||||||
uint32_t index, uint32_t next)
|
uint32_t index, uint32_t next)
|
||||||
{
|
{
|
||||||
struct pw_global *global = this->global;
|
struct pw_global *global = this->global;
|
||||||
struct pw_resource *resource;
|
struct emit_param_data data;
|
||||||
struct resource_data *data;
|
|
||||||
struct spa_pod *param = this->params[index];
|
struct spa_pod *param = this->params[index];
|
||||||
uint32_t id;
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
if (!param || !spa_pod_is_object (param))
|
if (!param || !spa_pod_is_object (param))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
id = SPA_POD_OBJECT_ID (param);
|
data.this = this;
|
||||||
|
data.param = param;
|
||||||
|
data.id = SPA_POD_OBJECT_ID (param);
|
||||||
|
data.index = index;
|
||||||
|
data.next = next;
|
||||||
|
|
||||||
spa_list_for_each(resource, &global->resource_list, link) {
|
pw_global_for_each_resource(global, emit_param, &data);
|
||||||
data = pw_resource_get_user_data(resource);
|
}
|
||||||
for (i = 0; i < data->n_subscribe_ids; i++) {
|
|
||||||
if (data->subscribe_ids[i] == id) {
|
static int emit_info(void *data, struct pw_resource *resource)
|
||||||
pw_endpoint_stream_resource_param(resource, 1,
|
{
|
||||||
id, index, next, param);
|
struct endpoint_stream *this = data;
|
||||||
}
|
pw_endpoint_stream_resource_info(resource, &this->info);
|
||||||
}
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int endpoint_stream_update(struct endpoint_stream *this,
|
int endpoint_stream_update(struct endpoint_stream *this,
|
||||||
|
|
@ -184,8 +205,6 @@ int endpoint_stream_update(struct endpoint_stream *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_mask & PW_CLIENT_ENDPOINT_UPDATE_INFO) {
|
if (change_mask & PW_CLIENT_ENDPOINT_UPDATE_INFO) {
|
||||||
struct pw_resource *resource;
|
|
||||||
|
|
||||||
if (info->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS) {
|
if (info->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS) {
|
||||||
free(this->info.link_params);
|
free(this->info.link_params);
|
||||||
this->info.link_params = spa_pod_copy(info->link_params);
|
this->info.link_params = spa_pod_copy(info->link_params);
|
||||||
|
|
@ -211,9 +230,7 @@ int endpoint_stream_update(struct endpoint_stream *this,
|
||||||
this->info.name = info->name ? strdup(info->name) : NULL;
|
this->info.name = info->name ? strdup(info->name) : NULL;
|
||||||
|
|
||||||
this->info.change_mask = info->change_mask;
|
this->info.change_mask = info->change_mask;
|
||||||
spa_list_for_each(resource, &this->global->resource_list, link) {
|
pw_global_for_each_resource(this->global, emit_info, this);
|
||||||
pw_endpoint_stream_resource_info(resource, &this->info);
|
|
||||||
}
|
|
||||||
this->info.change_mask = 0;
|
this->info.change_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,17 +243,6 @@ int endpoint_stream_update(struct endpoint_stream *this,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void endpoint_stream_unbind(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = endpoint_stream_unbind,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int endpoint_stream_bind(void *_data, struct pw_impl_client *client,
|
static int endpoint_stream_bind(void *_data, struct pw_impl_client *client,
|
||||||
uint32_t permissions, uint32_t version, uint32_t id)
|
uint32_t permissions, uint32_t version, uint32_t id)
|
||||||
{
|
{
|
||||||
|
|
@ -245,20 +251,18 @@ static int endpoint_stream_bind(void *_data, struct pw_impl_client *client,
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
struct resource_data *data;
|
struct resource_data *data;
|
||||||
|
|
||||||
resource = pw_resource_new(client, id, permissions, global->type, version, sizeof(*data));
|
resource = pw_resource_new(client, id, permissions,
|
||||||
|
pw_global_get_type(global), version, sizeof(*data));
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
data = pw_resource_get_user_data(resource);
|
data = pw_resource_get_user_data(resource);
|
||||||
data->stream = this;
|
data->stream = this;
|
||||||
pw_resource_add_listener(resource, &data->resource_listener,
|
|
||||||
&resource_events, resource);
|
|
||||||
pw_resource_add_object_listener(resource, &data->object_listener,
|
pw_resource_add_object_listener(resource, &data->object_listener,
|
||||||
&methods, resource);
|
&methods, resource);
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, pw_resource_get_id(resource));
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
|
|
||||||
this->info.change_mask = PW_ENDPOINT_STREAM_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_ENDPOINT_STREAM_CHANGE_MASK_ALL;
|
||||||
pw_endpoint_stream_resource_info(resource, &this->info);
|
pw_endpoint_stream_resource_info(resource, &this->info);
|
||||||
|
|
@ -298,10 +302,11 @@ int endpoint_stream_init(struct endpoint_stream *this,
|
||||||
if (!this->global)
|
if (!this->global)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u", this->global->id);
|
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u",
|
||||||
|
pw_global_get_id(this->global));
|
||||||
|
|
||||||
this->info.version = PW_VERSION_ENDPOINT_STREAM_INFO;
|
this->info.version = PW_VERSION_ENDPOINT_STREAM_INFO;
|
||||||
this->info.id = this->global->id;
|
this->info.id = pw_global_get_id(this->global);
|
||||||
this->info.endpoint_id = endpoint_id;
|
this->info.endpoint_id = endpoint_id;
|
||||||
this->info.props = &this->props->dict;
|
this->info.props = &this->props->dict;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,10 @@
|
||||||
#include "endpoint.h"
|
#include "endpoint.h"
|
||||||
#include "client-endpoint.h"
|
#include "client-endpoint.h"
|
||||||
|
|
||||||
#include <pipewire/private.h>
|
|
||||||
|
|
||||||
#define NAME "endpoint"
|
#define NAME "endpoint"
|
||||||
|
|
||||||
struct resource_data {
|
struct resource_data {
|
||||||
struct endpoint *endpoint;
|
struct endpoint *endpoint;
|
||||||
struct spa_hook resource_listener;
|
|
||||||
struct spa_hook object_listener;
|
struct spa_hook object_listener;
|
||||||
uint32_t n_subscribe_ids;
|
uint32_t n_subscribe_ids;
|
||||||
uint32_t subscribe_ids[32];
|
uint32_t subscribe_ids[32];
|
||||||
|
|
@ -106,7 +103,7 @@ static int endpoint_subscribe_params (void *object, uint32_t *ids, uint32_t n_id
|
||||||
for (i = 0; i < n_ids; i++) {
|
for (i = 0; i < n_ids; i++) {
|
||||||
data->subscribe_ids[i] = ids[i];
|
data->subscribe_ids[i] = ids[i];
|
||||||
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
||||||
data->endpoint, resource->id, ids[i]);
|
data->endpoint, pw_resource_get_id(resource), ids[i]);
|
||||||
endpoint_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
endpoint_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -147,30 +144,54 @@ static const struct pw_endpoint_methods methods = {
|
||||||
.create_link = endpoint_create_link,
|
.create_link = endpoint_create_link,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct emit_param_data {
|
||||||
|
struct endpoint *this;
|
||||||
|
struct spa_pod *param;
|
||||||
|
uint32_t id;
|
||||||
|
uint32_t index;
|
||||||
|
uint32_t next;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int emit_param(void *_data, struct pw_resource *resource)
|
||||||
|
{
|
||||||
|
struct emit_param_data *d = _data;
|
||||||
|
struct resource_data *data;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
data = pw_resource_get_user_data(resource);
|
||||||
|
for (i = 0; i < data->n_subscribe_ids; i++) {
|
||||||
|
if (data->subscribe_ids[i] == d->id) {
|
||||||
|
pw_endpoint_resource_param(resource, 1,
|
||||||
|
d->id, d->index, d->next, d->param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void endpoint_notify_subscribed(struct endpoint *this,
|
static void endpoint_notify_subscribed(struct endpoint *this,
|
||||||
uint32_t index, uint32_t next)
|
uint32_t index, uint32_t next)
|
||||||
{
|
{
|
||||||
struct pw_global *global = this->global;
|
struct pw_global *global = this->global;
|
||||||
struct pw_resource *resource;
|
struct emit_param_data data;
|
||||||
struct resource_data *data;
|
|
||||||
struct spa_pod *param = this->params[index];
|
struct spa_pod *param = this->params[index];
|
||||||
uint32_t id;
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
if (!param || !spa_pod_is_object (param))
|
if (!param || !spa_pod_is_object (param))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
id = SPA_POD_OBJECT_ID (param);
|
data.this = this;
|
||||||
|
data.param = param;
|
||||||
|
data.id = SPA_POD_OBJECT_ID (param);
|
||||||
|
data.index = index;
|
||||||
|
data.next = next;
|
||||||
|
|
||||||
spa_list_for_each(resource, &global->resource_list, link) {
|
pw_global_for_each_resource(global, emit_param, &data);
|
||||||
data = pw_resource_get_user_data(resource);
|
}
|
||||||
for (i = 0; i < data->n_subscribe_ids; i++) {
|
|
||||||
if (data->subscribe_ids[i] == id) {
|
static int emit_info(void *data, struct pw_resource *resource)
|
||||||
pw_endpoint_resource_param(resource, 1, id,
|
{
|
||||||
index, next, param);
|
struct endpoint *this = data;
|
||||||
}
|
pw_endpoint_resource_info(resource, &this->info);
|
||||||
}
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int endpoint_update(struct endpoint *this,
|
int endpoint_update(struct endpoint *this,
|
||||||
|
|
@ -201,8 +222,6 @@ int endpoint_update(struct endpoint *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_mask & PW_CLIENT_ENDPOINT_UPDATE_INFO) {
|
if (change_mask & PW_CLIENT_ENDPOINT_UPDATE_INFO) {
|
||||||
struct pw_resource *resource;
|
|
||||||
|
|
||||||
if (info->change_mask & PW_ENDPOINT_CHANGE_MASK_STREAMS)
|
if (info->change_mask & PW_ENDPOINT_CHANGE_MASK_STREAMS)
|
||||||
this->info.n_streams = info->n_streams;
|
this->info.n_streams = info->n_streams;
|
||||||
|
|
||||||
|
|
@ -233,9 +252,7 @@ int endpoint_update(struct endpoint *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
this->info.change_mask = info->change_mask;
|
this->info.change_mask = info->change_mask;
|
||||||
spa_list_for_each(resource, &this->global->resource_list, link) {
|
pw_global_for_each_resource(this->global, emit_info, this);
|
||||||
pw_endpoint_resource_info(resource, &this->info);
|
|
||||||
}
|
|
||||||
this->info.change_mask = 0;
|
this->info.change_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,17 +265,6 @@ int endpoint_update(struct endpoint *this,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void endpoint_unbind(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = endpoint_unbind,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int endpoint_bind(void *_data, struct pw_impl_client *client,
|
static int endpoint_bind(void *_data, struct pw_impl_client *client,
|
||||||
uint32_t permissions, uint32_t version, uint32_t id)
|
uint32_t permissions, uint32_t version, uint32_t id)
|
||||||
{
|
{
|
||||||
|
|
@ -267,20 +273,18 @@ static int endpoint_bind(void *_data, struct pw_impl_client *client,
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
struct resource_data *data;
|
struct resource_data *data;
|
||||||
|
|
||||||
resource = pw_resource_new(client, id, permissions, global->type, version, sizeof(*data));
|
resource = pw_resource_new(client, id, permissions,
|
||||||
|
pw_global_get_type(global), version, sizeof(*data));
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
data = pw_resource_get_user_data(resource);
|
data = pw_resource_get_user_data(resource);
|
||||||
data->endpoint = this;
|
data->endpoint = this;
|
||||||
pw_resource_add_listener(resource, &data->resource_listener,
|
|
||||||
&resource_events, resource);
|
|
||||||
pw_resource_add_object_listener(resource, &data->object_listener,
|
pw_resource_add_object_listener(resource, &data->object_listener,
|
||||||
&methods, resource);
|
&methods, resource);
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, pw_resource_get_id(resource));
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
|
|
||||||
this->info.change_mask = PW_ENDPOINT_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_ENDPOINT_CHANGE_MASK_ALL;
|
||||||
pw_endpoint_resource_info(resource, &this->info);
|
pw_endpoint_resource_info(resource, &this->info);
|
||||||
|
|
@ -333,13 +337,14 @@ int endpoint_init(struct endpoint *this,
|
||||||
if (!this->global)
|
if (!this->global)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u", this->global->id);
|
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u",
|
||||||
|
pw_global_get_id(this->global));
|
||||||
|
|
||||||
this->info.version = PW_VERSION_ENDPOINT_INFO;
|
this->info.version = PW_VERSION_ENDPOINT_INFO;
|
||||||
this->info.id = this->global->id;
|
this->info.id = pw_global_get_id(this->global);
|
||||||
this->info.props = &this->props->dict;
|
this->info.props = &this->props->dict;
|
||||||
|
|
||||||
pw_resource_set_bound_id(client_ep->resource, this->global->id);
|
pw_resource_set_bound_id(client_ep->resource, this->info.id);
|
||||||
|
|
||||||
return pw_global_register(this->global);
|
return pw_global_register(this->global);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/impl.h>
|
||||||
#include <extensions/session-manager.h>
|
#include <extensions/session-manager.h>
|
||||||
|
|
||||||
#include <spa/pod/filter.h>
|
#include <spa/pod/filter.h>
|
||||||
|
|
@ -34,13 +34,10 @@
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "client-session.h"
|
#include "client-session.h"
|
||||||
|
|
||||||
#include <pipewire/private.h>
|
|
||||||
|
|
||||||
#define NAME "session"
|
#define NAME "session"
|
||||||
|
|
||||||
struct resource_data {
|
struct resource_data {
|
||||||
struct session *session;
|
struct session *session;
|
||||||
struct spa_hook resource_listener;
|
|
||||||
struct spa_hook object_listener;
|
struct spa_hook object_listener;
|
||||||
uint32_t n_subscribe_ids;
|
uint32_t n_subscribe_ids;
|
||||||
uint32_t subscribe_ids[32];
|
uint32_t subscribe_ids[32];
|
||||||
|
|
@ -104,7 +101,7 @@ static int session_subscribe_params (void *object, uint32_t *ids, uint32_t n_ids
|
||||||
for (i = 0; i < n_ids; i++) {
|
for (i = 0; i < n_ids; i++) {
|
||||||
data->subscribe_ids[i] = ids[i];
|
data->subscribe_ids[i] = ids[i];
|
||||||
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
||||||
data->session, resource->id, ids[i]);
|
data->session, pw_resource_get_id(resource), ids[i]);
|
||||||
session_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
session_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -130,30 +127,54 @@ static const struct pw_session_methods methods = {
|
||||||
.set_param = session_set_param,
|
.set_param = session_set_param,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct emit_param_data {
|
||||||
|
struct session *this;
|
||||||
|
struct spa_pod *param;
|
||||||
|
uint32_t id;
|
||||||
|
uint32_t index;
|
||||||
|
uint32_t next;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int emit_param(void *_data, struct pw_resource *resource)
|
||||||
|
{
|
||||||
|
struct emit_param_data *d = _data;
|
||||||
|
struct resource_data *data;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
data = pw_resource_get_user_data(resource);
|
||||||
|
for (i = 0; i < data->n_subscribe_ids; i++) {
|
||||||
|
if (data->subscribe_ids[i] == d->id) {
|
||||||
|
pw_session_resource_param(resource, 1,
|
||||||
|
d->id, d->index, d->next, d->param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void session_notify_subscribed(struct session *this,
|
static void session_notify_subscribed(struct session *this,
|
||||||
uint32_t index, uint32_t next)
|
uint32_t index, uint32_t next)
|
||||||
{
|
{
|
||||||
struct pw_global *global = this->global;
|
struct pw_global *global = this->global;
|
||||||
struct pw_resource *resource;
|
struct emit_param_data data;
|
||||||
struct resource_data *data;
|
|
||||||
struct spa_pod *param = this->params[index];
|
struct spa_pod *param = this->params[index];
|
||||||
uint32_t id;
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
if (!param || !spa_pod_is_object (param))
|
if (!param || !spa_pod_is_object (param))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
id = SPA_POD_OBJECT_ID (param);
|
data.this = this;
|
||||||
|
data.param = param;
|
||||||
|
data.id = SPA_POD_OBJECT_ID (param);
|
||||||
|
data.index = index;
|
||||||
|
data.next = next;
|
||||||
|
|
||||||
spa_list_for_each(resource, &global->resource_list, link) {
|
pw_global_for_each_resource(global, emit_param, &data);
|
||||||
data = pw_resource_get_user_data(resource);
|
}
|
||||||
for (i = 0; i < data->n_subscribe_ids; i++) {
|
|
||||||
if (data->subscribe_ids[i] == id) {
|
static int emit_info(void *data, struct pw_resource *resource)
|
||||||
pw_session_resource_param(resource, 1, id,
|
{
|
||||||
index, next, param);
|
struct session *this = data;
|
||||||
}
|
pw_session_resource_info(resource, &this->info);
|
||||||
}
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int session_update(struct session *this,
|
int session_update(struct session *this,
|
||||||
|
|
@ -184,8 +205,6 @@ int session_update(struct session *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_mask & PW_CLIENT_SESSION_UPDATE_INFO) {
|
if (change_mask & PW_CLIENT_SESSION_UPDATE_INFO) {
|
||||||
struct pw_resource *resource;
|
|
||||||
|
|
||||||
if (info->change_mask & PW_SESSION_CHANGE_MASK_PROPS)
|
if (info->change_mask & PW_SESSION_CHANGE_MASK_PROPS)
|
||||||
pw_properties_update(this->props, info->props);
|
pw_properties_update(this->props, info->props);
|
||||||
|
|
||||||
|
|
@ -203,9 +222,7 @@ int session_update(struct session *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
this->info.change_mask = info->change_mask;
|
this->info.change_mask = info->change_mask;
|
||||||
spa_list_for_each(resource, &this->global->resource_list, link) {
|
pw_global_for_each_resource(this->global, emit_info, this);
|
||||||
pw_session_resource_info(resource, &this->info);
|
|
||||||
}
|
|
||||||
this->info.change_mask = 0;
|
this->info.change_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,17 +235,6 @@ int session_update(struct session *this,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void session_unbind(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = session_unbind,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int session_bind(void *_data, struct pw_impl_client *client,
|
static int session_bind(void *_data, struct pw_impl_client *client,
|
||||||
uint32_t permissions, uint32_t version, uint32_t id)
|
uint32_t permissions, uint32_t version, uint32_t id)
|
||||||
{
|
{
|
||||||
|
|
@ -237,20 +243,19 @@ static int session_bind(void *_data, struct pw_impl_client *client,
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
struct resource_data *data;
|
struct resource_data *data;
|
||||||
|
|
||||||
resource = pw_resource_new(client, id, permissions, global->type, version, sizeof(*data));
|
resource = pw_resource_new(client, id, permissions,
|
||||||
|
pw_global_get_type(global), version, sizeof(*data));
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
data = pw_resource_get_user_data(resource);
|
data = pw_resource_get_user_data(resource);
|
||||||
data->session = this;
|
data->session = this;
|
||||||
pw_resource_add_listener(resource, &data->resource_listener,
|
|
||||||
&resource_events, resource);
|
|
||||||
pw_resource_add_object_listener(resource, &data->object_listener,
|
pw_resource_add_object_listener(resource, &data->object_listener,
|
||||||
&methods, resource);
|
&methods, resource);
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, pw_resource_get_id(resource));
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
|
|
||||||
this->info.change_mask = PW_SESSION_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_SESSION_CHANGE_MASK_ALL;
|
||||||
pw_session_resource_info(resource, &this->info);
|
pw_session_resource_info(resource, &this->info);
|
||||||
|
|
@ -294,13 +299,14 @@ int session_init(struct session *this,
|
||||||
if (!this->global)
|
if (!this->global)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u", this->global->id);
|
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u",
|
||||||
|
pw_global_get_id(this->global));
|
||||||
|
|
||||||
this->info.version = PW_VERSION_SESSION_INFO;
|
this->info.version = PW_VERSION_SESSION_INFO;
|
||||||
this->info.id = this->global->id;
|
this->info.id = pw_global_get_id(this->global);
|
||||||
this->info.props = &this->props->dict;
|
this->info.props = &this->props->dict;
|
||||||
|
|
||||||
pw_resource_set_bound_id(client_sess->resource, this->global->id);
|
pw_resource_set_bound_id(client_sess->resource, this->info.id);
|
||||||
|
|
||||||
return pw_global_register(this->global);
|
return pw_global_register(this->global);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
#include "spa-device.h"
|
#include "spa-device.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_impl_device *this;
|
struct pw_impl_device *this;
|
||||||
|
|
@ -84,7 +83,7 @@ pw_spa_device_new(struct pw_context *context,
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
impl = this->user_data;
|
impl = pw_impl_device_get_user_data(this);
|
||||||
impl->this = this;
|
impl->this = this;
|
||||||
impl->device = device;
|
impl->device = device;
|
||||||
impl->handle = handle;
|
impl->handle = handle;
|
||||||
|
|
@ -110,7 +109,7 @@ error_register:
|
||||||
|
|
||||||
void *pw_spa_device_get_user_data(struct pw_impl_device *device)
|
void *pw_spa_device_get_user_data(struct pw_impl_device *device)
|
||||||
{
|
{
|
||||||
struct impl *impl = device->user_data;
|
struct impl *impl = pw_impl_device_get_user_data(device);
|
||||||
return impl->user_data;
|
return impl->user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@
|
||||||
|
|
||||||
#include <spa/node/node.h>
|
#include <spa/node/node.h>
|
||||||
#include <spa/node/utils.h>
|
#include <spa/node/utils.h>
|
||||||
|
#include <spa/utils/result.h>
|
||||||
#include <spa/param/props.h>
|
#include <spa/param/props.h>
|
||||||
#include <spa/pod/iter.h>
|
#include <spa/pod/iter.h>
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
#include "spa-node.h"
|
#include "spa-node.h"
|
||||||
#include "pipewire/private.h"
|
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_impl_node *this;
|
struct pw_impl_node *this;
|
||||||
|
|
@ -119,7 +119,7 @@ pw_spa_node_new(struct pw_context *context,
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl = this->user_data;
|
impl = pw_impl_node_get_user_data(this);
|
||||||
impl->this = this;
|
impl->this = this;
|
||||||
impl->node = node;
|
impl->node = node;
|
||||||
impl->handle = handle;
|
impl->handle = handle;
|
||||||
|
|
@ -152,7 +152,7 @@ error_exit:
|
||||||
|
|
||||||
void *pw_spa_node_get_user_data(struct pw_impl_node *node)
|
void *pw_spa_node_get_user_data(struct pw_impl_node *node)
|
||||||
{
|
{
|
||||||
struct impl *impl = node->user_data;
|
struct impl *impl = pw_impl_node_get_user_data(node);
|
||||||
return impl->user_data;
|
return impl->user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -273,7 +273,7 @@ struct pw_impl_node *pw_spa_node_load(struct pw_context *context,
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl = this->user_data;
|
impl = pw_impl_node_get_user_data(this);
|
||||||
impl->factory_name = strdup(factory_name);
|
impl->factory_name = strdup(factory_name);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,31 @@ uint32_t pw_global_get_id(struct pw_global *global)
|
||||||
return global->id;
|
return global->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPA_EXPORT
|
||||||
|
int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource)
|
||||||
|
{
|
||||||
|
resource->global = global;
|
||||||
|
pw_log_debug(NAME" %p: resource %p id:%d global:%d", global, resource,
|
||||||
|
resource->id, global->id);
|
||||||
|
spa_list_append(&global->resource_list, &resource->link);
|
||||||
|
pw_resource_set_bound_id(resource, global->id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPA_EXPORT
|
||||||
|
int pw_global_for_each_resource(struct pw_global *global,
|
||||||
|
int (*callback) (void *data, struct pw_resource *resource),
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
struct pw_resource *resource, *t;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
spa_list_for_each_safe(resource, t, &global->resource_list, link)
|
||||||
|
if ((res = callback(data, resource)) != 0)
|
||||||
|
return res;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
void pw_global_add_listener(struct pw_global *global,
|
void pw_global_add_listener(struct pw_global *global,
|
||||||
struct spa_hook *listener,
|
struct spa_hook *listener,
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,17 @@ void *pw_global_get_object(struct pw_global *global);
|
||||||
/** Get the unique id of the global */
|
/** Get the unique id of the global */
|
||||||
uint32_t pw_global_get_id(struct pw_global *global);
|
uint32_t pw_global_get_id(struct pw_global *global);
|
||||||
|
|
||||||
|
/** Add a resource to a global */
|
||||||
|
int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource);
|
||||||
|
|
||||||
|
/** Iterate all resources added to the global The callback should return
|
||||||
|
* 0 to fetch the next item, any other value stops the iteration and returns
|
||||||
|
* the value. When all callbacks return 0, this function returns 0 when all
|
||||||
|
* items are iterated. */
|
||||||
|
int pw_global_for_each_resource(struct pw_global *global,
|
||||||
|
int (*callback) (void *data, struct pw_resource *resource),
|
||||||
|
void *data);
|
||||||
|
|
||||||
/** Let a client bind to a global */
|
/** Let a client bind to a global */
|
||||||
int pw_global_bind(struct pw_global *global,
|
int pw_global_bind(struct pw_global *global,
|
||||||
struct pw_impl_client *client,
|
struct pw_impl_client *client,
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,6 @@ static void client_unbind_func(void *data)
|
||||||
struct pw_resource *resource = data;
|
struct pw_resource *resource = data;
|
||||||
if (resource->id == 1)
|
if (resource->id == 1)
|
||||||
resource->client->client_resource = NULL;
|
resource->client->client_resource = NULL;
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
static const struct pw_resource_events resource_events = {
|
||||||
|
|
@ -206,9 +205,7 @@ global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions,
|
||||||
&client_methods, resource);
|
&client_methods, resource);
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
pw_resource_set_bound_id(resource, global->id);
|
|
||||||
|
|
||||||
if (resource->id == 1)
|
if (resource->id == 1)
|
||||||
client->client_resource = resource;
|
client->client_resource = resource;
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,6 @@ static void core_unbind_func(void *data)
|
||||||
struct pw_resource *resource = data;
|
struct pw_resource *resource = data;
|
||||||
if (resource->id == 0)
|
if (resource->id == 0)
|
||||||
resource->client->core_resource = NULL;
|
resource->client->core_resource = NULL;
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_resource_events core_resource_events = {
|
static const struct pw_resource_events core_resource_events = {
|
||||||
|
|
@ -483,8 +482,7 @@ global_bind(void *_data,
|
||||||
&data->object_listener,
|
&data->object_listener,
|
||||||
&core_methods, resource);
|
&core_methods, resource);
|
||||||
|
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
pw_global_add_resource(global, resource);
|
||||||
pw_resource_set_bound_id(resource, global->id);
|
|
||||||
|
|
||||||
if (resource->id == 0) {
|
if (resource->id == 0) {
|
||||||
client->core_resource = resource;
|
client->core_resource = resource;
|
||||||
|
|
|
||||||
|
|
@ -197,13 +197,6 @@ void pw_impl_device_destroy(struct pw_impl_device *device)
|
||||||
free(device);
|
free(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_unbind_func(void *data)
|
|
||||||
{
|
|
||||||
struct resource_data *d = data;
|
|
||||||
struct pw_resource *resource = d->resource;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void device_pong(void *data, int seq)
|
static void device_pong(void *data, int seq)
|
||||||
{
|
{
|
||||||
struct resource_data *d = data;
|
struct resource_data *d = data;
|
||||||
|
|
@ -214,7 +207,6 @@ static void device_pong(void *data, int seq)
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
static const struct pw_resource_events resource_events = {
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
PW_VERSION_RESOURCE_EVENTS,
|
||||||
.destroy = device_unbind_func,
|
|
||||||
.pong = device_pong,
|
.pong = device_pong,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -371,9 +363,7 @@ global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions,
|
||||||
&device_methods, data);
|
&device_methods, data);
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
pw_resource_set_bound_id(resource, global->id);
|
|
||||||
|
|
||||||
this->info.change_mask = PW_DEVICE_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_DEVICE_CHANGE_MASK_ALL;
|
||||||
pw_device_resource_info(resource, &this->info);
|
pw_device_resource_info(resource, &this->info);
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,6 @@
|
||||||
|
|
||||||
#define pw_factory_resource_info(r,...) pw_resource_call(r,struct pw_factory_events,info,0,__VA_ARGS__)
|
#define pw_factory_resource_info(r,...) pw_resource_call(r,struct pw_factory_events,info,0,__VA_ARGS__)
|
||||||
|
|
||||||
struct resource_data {
|
|
||||||
struct spa_hook resource_listener;
|
|
||||||
};
|
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
struct pw_impl_factory *pw_context_create_factory(struct pw_context *context,
|
struct pw_impl_factory *pw_context_create_factory(struct pw_context *context,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
|
@ -105,17 +101,6 @@ void pw_impl_factory_destroy(struct pw_impl_factory *factory)
|
||||||
free(factory);
|
free(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void factory_unbind_func(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = factory_unbind_func,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
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)
|
||||||
|
|
@ -123,19 +108,13 @@ global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions,
|
||||||
struct pw_impl_factory *this = _data;
|
struct pw_impl_factory *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;
|
|
||||||
|
|
||||||
resource = pw_resource_new(client, id, permissions, global->type, version, sizeof(*data));
|
resource = pw_resource_new(client, id, permissions, global->type, version, 0);
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
goto error_resource;
|
goto error_resource;
|
||||||
|
|
||||||
data = pw_resource_get_user_data(resource);
|
|
||||||
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, resource);
|
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
pw_resource_set_bound_id(resource, global->id);
|
|
||||||
|
|
||||||
this->info.change_mask = ~0;
|
this->info.change_mask = ~0;
|
||||||
pw_factory_resource_info(resource, &this->info);
|
pw_factory_resource_info(resource, &this->info);
|
||||||
|
|
@ -249,6 +228,12 @@ void *pw_impl_factory_get_user_data(struct pw_impl_factory *factory)
|
||||||
return factory->user_data;
|
return factory->user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPA_EXPORT
|
||||||
|
const struct pw_factory_info *pw_impl_factory_get_info(struct pw_impl_factory *factory)
|
||||||
|
{
|
||||||
|
return &factory->info;
|
||||||
|
}
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
struct pw_global *pw_impl_factory_get_global(struct pw_impl_factory *factory)
|
struct pw_global *pw_impl_factory_get_global(struct pw_impl_factory *factory)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,9 @@ struct pw_impl_factory *pw_context_create_factory(struct pw_context *context,
|
||||||
/** Get the factory properties */
|
/** Get the factory properties */
|
||||||
const struct pw_properties *pw_impl_factory_get_properties(struct pw_impl_factory *factory);
|
const struct pw_properties *pw_impl_factory_get_properties(struct pw_impl_factory *factory);
|
||||||
|
|
||||||
|
/** Get the factory info */
|
||||||
|
const struct pw_factory_info *pw_impl_factory_get_info(struct pw_impl_factory *factory);
|
||||||
|
|
||||||
/** Update the factory properties */
|
/** Update the factory properties */
|
||||||
int pw_impl_factory_update_properties(struct pw_impl_factory *factory, const struct spa_dict *dict);
|
int pw_impl_factory_update_properties(struct pw_impl_factory *factory, const struct spa_dict *dict);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,6 @@ struct impl {
|
||||||
struct pw_impl_node *inode, *onode;
|
struct pw_impl_node *inode, *onode;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct resource_data {
|
|
||||||
struct spa_hook resource_listener;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** \endcond */
|
/** \endcond */
|
||||||
|
|
||||||
static void debug_link(struct pw_impl_link *link)
|
static void debug_link(struct pw_impl_link *link)
|
||||||
|
|
@ -791,17 +787,6 @@ int pw_impl_link_deactivate(struct pw_impl_link *this)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void link_unbind_func(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = link_unbind_func,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
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)
|
||||||
|
|
@ -809,19 +794,13 @@ global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions,
|
||||||
struct pw_impl_link *this = _data;
|
struct pw_impl_link *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;
|
|
||||||
|
|
||||||
resource = pw_resource_new(client, id, permissions, global->type, version, sizeof(*data));
|
resource = pw_resource_new(client, id, permissions, global->type, version, 0);
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
goto error_resource;
|
goto error_resource;
|
||||||
|
|
||||||
data = pw_resource_get_user_data(resource);
|
|
||||||
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, resource);
|
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
pw_resource_set_bound_id(resource, global->id);
|
|
||||||
|
|
||||||
this->info.change_mask = ~0;
|
this->info.change_mask = ~0;
|
||||||
pw_link_resource_info(resource, &this->info);
|
pw_link_resource_info(resource, &this->info);
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,6 @@ struct impl {
|
||||||
|
|
||||||
#define pw_module_resource_info(r,...) pw_resource_call(r,struct pw_module_events,info,0,__VA_ARGS__)
|
#define pw_module_resource_info(r,...) pw_resource_call(r,struct pw_module_events,info,0,__VA_ARGS__)
|
||||||
|
|
||||||
struct resource_data {
|
|
||||||
struct spa_hook resource_listener;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** \endcond */
|
/** \endcond */
|
||||||
|
|
||||||
|
|
@ -105,17 +101,6 @@ static char *find_module(const char *path, const char *name)
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void module_unbind_func(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = module_unbind_func,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
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)
|
||||||
|
|
@ -123,19 +108,13 @@ global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions,
|
||||||
struct pw_impl_module *this = _data;
|
struct pw_impl_module *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;
|
|
||||||
|
|
||||||
resource = pw_resource_new(client, id, permissions, global->type, version, sizeof(*data));
|
resource = pw_resource_new(client, id, permissions, global->type, version, 0);
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
goto error_resource;
|
goto error_resource;
|
||||||
|
|
||||||
data = pw_resource_get_user_data(resource);
|
|
||||||
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, resource);
|
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
pw_resource_set_bound_id(resource, global->id);
|
|
||||||
|
|
||||||
this->info.change_mask = ~0;
|
this->info.change_mask = ~0;
|
||||||
pw_module_resource_info(resource, &this->info);
|
pw_module_resource_info(resource, &this->info);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ struct resource_data {
|
||||||
struct pw_impl_node *node;
|
struct pw_impl_node *node;
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
|
||||||
struct spa_hook resource_listener;
|
|
||||||
struct spa_hook object_listener;
|
struct spa_hook object_listener;
|
||||||
|
|
||||||
uint32_t subscribe_ids[MAX_PARAMS];
|
uint32_t subscribe_ids[MAX_PARAMS];
|
||||||
|
|
@ -346,11 +345,6 @@ static int suspend_node(struct pw_impl_node *this)
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
static void node_unbind_func(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clear_info(struct pw_impl_node *this)
|
clear_info(struct pw_impl_node *this)
|
||||||
|
|
@ -359,11 +353,6 @@ clear_info(struct pw_impl_node *this)
|
||||||
free((char*)this->info.error);
|
free((char*)this->info.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = node_unbind_func,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int reply_param(void *data, int seq, uint32_t id,
|
static int reply_param(void *data, int seq, uint32_t id,
|
||||||
uint32_t index, uint32_t next, struct spa_pod *param)
|
uint32_t index, uint32_t next, struct spa_pod *param)
|
||||||
{
|
{
|
||||||
|
|
@ -505,17 +494,12 @@ global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions,
|
||||||
data->resource = resource;
|
data->resource = resource;
|
||||||
data->end = -1;
|
data->end = -1;
|
||||||
|
|
||||||
pw_resource_add_listener(resource,
|
|
||||||
&data->resource_listener,
|
|
||||||
&resource_events, resource);
|
|
||||||
pw_resource_add_object_listener(resource,
|
pw_resource_add_object_listener(resource,
|
||||||
&data->object_listener,
|
&data->object_listener,
|
||||||
&node_methods, resource);
|
&node_methods, resource);
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
pw_resource_set_bound_id(resource, global->id);
|
|
||||||
|
|
||||||
this->info.change_mask = PW_NODE_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_NODE_CHANGE_MASK_ALL;
|
||||||
pw_node_resource_info(resource, &this->info);
|
pw_node_resource_info(resource, &this->info);
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,8 @@ pw_impl_node_find_port(struct pw_impl_node *node, enum pw_direction direction, u
|
||||||
/** Get a free unused port_id from the node */
|
/** Get a free unused port_id from the node */
|
||||||
uint32_t pw_impl_node_get_free_port_id(struct pw_impl_node *node, enum pw_direction direction);
|
uint32_t pw_impl_node_get_free_port_id(struct pw_impl_node *node, enum pw_direction direction);
|
||||||
|
|
||||||
|
int pw_impl_node_initialized(struct pw_impl_node *node);
|
||||||
|
|
||||||
/** Set a node active. This will start negotiation with all linked active
|
/** Set a node active. This will start negotiation with all linked active
|
||||||
* nodes and start data transport */
|
* nodes and start data transport */
|
||||||
int pw_impl_node_set_active(struct pw_impl_node *node, bool active);
|
int pw_impl_node_set_active(struct pw_impl_node *node, bool active);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ struct resource_data {
|
||||||
struct pw_impl_port *port;
|
struct pw_impl_port *port;
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
|
||||||
struct spa_hook resource_listener;
|
|
||||||
struct spa_hook object_listener;
|
struct spa_hook object_listener;
|
||||||
|
|
||||||
uint32_t subscribe_ids[MAX_PARAMS];
|
uint32_t subscribe_ids[MAX_PARAMS];
|
||||||
|
|
@ -656,17 +655,6 @@ static int check_param_io(void *data, int seq, uint32_t id,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void port_unbind_func(void *data)
|
|
||||||
{
|
|
||||||
struct pw_resource *resource = data;
|
|
||||||
spa_list_remove(&resource->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pw_resource_events resource_events = {
|
|
||||||
PW_VERSION_RESOURCE_EVENTS,
|
|
||||||
.destroy = port_unbind_func,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int reply_param(void *data, int seq, uint32_t id,
|
static int reply_param(void *data, int seq, uint32_t id,
|
||||||
uint32_t index, uint32_t next, struct spa_pod *param)
|
uint32_t index, uint32_t next, struct spa_pod *param)
|
||||||
{
|
{
|
||||||
|
|
@ -741,17 +729,12 @@ global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions,
|
||||||
data->port = this;
|
data->port = this;
|
||||||
data->resource = resource;
|
data->resource = resource;
|
||||||
|
|
||||||
pw_resource_add_listener(resource,
|
|
||||||
&data->resource_listener,
|
|
||||||
&resource_events, resource);
|
|
||||||
pw_resource_add_object_listener(resource,
|
pw_resource_add_object_listener(resource,
|
||||||
&data->object_listener,
|
&data->object_listener,
|
||||||
&port_methods, resource);
|
&port_methods, resource);
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
pw_global_add_resource(global, resource);
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
|
||||||
pw_resource_set_bound_id(resource, global->id);
|
|
||||||
|
|
||||||
this->info.change_mask = PW_PORT_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_PORT_CHANGE_MASK_ALL;
|
||||||
pw_port_resource_info(resource, &this->info);
|
pw_port_resource_info(resource, &this->info);
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,15 @@ struct pw_impl_port_events {
|
||||||
void (*control_removed) (void *data, struct pw_control *control);
|
void (*control_removed) (void *data, struct pw_control *control);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Create a new port \memberof pw_impl_port
|
||||||
|
* \return a newly allocated port */
|
||||||
|
struct pw_impl_port *
|
||||||
|
pw_context_create_port(struct pw_context *context,
|
||||||
|
enum pw_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
const struct spa_port_info *info,
|
||||||
|
size_t user_data_size);
|
||||||
|
|
||||||
/** Get the port direction */
|
/** Get the port direction */
|
||||||
enum pw_direction pw_impl_port_get_direction(struct pw_impl_port *port);
|
enum pw_direction pw_impl_port_get_direction(struct pw_impl_port *port);
|
||||||
|
|
||||||
|
|
@ -104,6 +113,12 @@ uint32_t pw_impl_port_get_id(struct pw_impl_port *port);
|
||||||
/** Get the port parent node or NULL when not yet set */
|
/** Get the port parent node or NULL when not yet set */
|
||||||
struct pw_impl_node *pw_impl_port_get_node(struct pw_impl_port *port);
|
struct pw_impl_node *pw_impl_port_get_node(struct pw_impl_port *port);
|
||||||
|
|
||||||
|
/** check is a port has links, return 0 if not, 1 if it is linked */
|
||||||
|
int pw_impl_port_is_linked(struct pw_impl_port *port);
|
||||||
|
|
||||||
|
/** Add a port to a node \memberof pw_impl_port */
|
||||||
|
int pw_impl_port_add(struct pw_impl_port *port, struct pw_impl_node *node);
|
||||||
|
|
||||||
/** Add an event listener on the port */
|
/** Add an event listener on the port */
|
||||||
void pw_impl_port_add_listener(struct pw_impl_port *port,
|
void pw_impl_port_add_listener(struct pw_impl_port *port,
|
||||||
struct spa_hook *listener,
|
struct spa_hook *listener,
|
||||||
|
|
|
||||||
|
|
@ -701,6 +701,7 @@ struct pw_resource {
|
||||||
struct spa_interface impl; /**< object implementation */
|
struct spa_interface impl; /**< object implementation */
|
||||||
|
|
||||||
struct pw_context *context; /**< the context object */
|
struct pw_context *context; /**< the context object */
|
||||||
|
struct pw_global *global; /**< global of resource */
|
||||||
struct spa_list link; /**< link in global resource_list */
|
struct spa_list link; /**< link in global resource_list */
|
||||||
|
|
||||||
struct pw_impl_client *client; /**< owner client */
|
struct pw_impl_client *client; /**< owner client */
|
||||||
|
|
@ -921,23 +922,12 @@ const struct pw_export_type *pw_context_find_export_type(struct pw_context *cont
|
||||||
|
|
||||||
int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version);
|
int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version);
|
||||||
|
|
||||||
int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor);
|
|
||||||
void pw_proxy_remove(struct pw_proxy *proxy);
|
void pw_proxy_remove(struct pw_proxy *proxy);
|
||||||
|
|
||||||
int pw_resource_install_marshal(struct pw_resource *resource, bool implementor);
|
|
||||||
void pw_resource_remove(struct pw_resource *resource);
|
void pw_resource_remove(struct pw_resource *resource);
|
||||||
|
|
||||||
int pw_context_recalc_graph(struct pw_context *context);
|
int pw_context_recalc_graph(struct pw_context *context);
|
||||||
|
|
||||||
/** Create a new port \memberof pw_impl_port
|
|
||||||
* \return a newly allocated port */
|
|
||||||
struct pw_impl_port *
|
|
||||||
pw_context_create_port(struct pw_context *context,
|
|
||||||
enum pw_direction direction,
|
|
||||||
uint32_t port_id,
|
|
||||||
const struct spa_port_info *info,
|
|
||||||
size_t user_data_size);
|
|
||||||
|
|
||||||
void pw_impl_port_update_info(struct pw_impl_port *port, const struct spa_port_info *info);
|
void pw_impl_port_update_info(struct pw_impl_port *port, const struct spa_port_info *info);
|
||||||
|
|
||||||
int pw_impl_port_register(struct pw_impl_port *port,
|
int pw_impl_port_register(struct pw_impl_port *port,
|
||||||
|
|
@ -948,9 +938,6 @@ void * pw_impl_port_get_user_data(struct pw_impl_port *port);
|
||||||
|
|
||||||
int pw_impl_port_set_mix(struct pw_impl_port *port, struct spa_node *node, uint32_t flags);
|
int pw_impl_port_set_mix(struct pw_impl_port *port, struct spa_node *node, uint32_t flags);
|
||||||
|
|
||||||
/** Add a port to a node \memberof pw_impl_port */
|
|
||||||
int pw_impl_port_add(struct pw_impl_port *port, struct pw_impl_node *node);
|
|
||||||
|
|
||||||
int pw_impl_port_init_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix);
|
int pw_impl_port_init_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix);
|
||||||
int pw_impl_port_release_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix);
|
int pw_impl_port_release_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix);
|
||||||
|
|
||||||
|
|
@ -993,9 +980,6 @@ int pw_impl_port_for_each_link(struct pw_impl_port *port,
|
||||||
int (*callback) (void *data, struct pw_impl_link *link),
|
int (*callback) (void *data, struct pw_impl_link *link),
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
/** check is a port has links, return 0 if not, 1 if it is linked */
|
|
||||||
int pw_impl_port_is_linked(struct pw_impl_port *port);
|
|
||||||
|
|
||||||
/** Set a param on a port \memberof pw_impl_port, use SPA_ID_INVALID for mix_id to set
|
/** Set a param on a port \memberof pw_impl_port, use SPA_ID_INVALID for mix_id to set
|
||||||
* the param on all mix ports */
|
* the param on all mix ports */
|
||||||
int pw_impl_port_set_param(struct pw_impl_port *port,
|
int pw_impl_port_set_param(struct pw_impl_port *port,
|
||||||
|
|
@ -1013,8 +997,6 @@ int pw_impl_node_set_param(struct pw_impl_node *node,
|
||||||
|
|
||||||
int pw_impl_node_update_ports(struct pw_impl_node *node);
|
int pw_impl_node_update_ports(struct pw_impl_node *node);
|
||||||
|
|
||||||
int pw_impl_node_initialized(struct pw_impl_node *node);
|
|
||||||
|
|
||||||
int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driver);
|
int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driver);
|
||||||
|
|
||||||
/** Prepare a link \memberof pw_impl_link
|
/** Prepare a link \memberof pw_impl_link
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,9 @@ struct spa_hook_list *pw_proxy_get_object_listeners(struct pw_proxy *proxy);
|
||||||
/** Get the marshal functions for the proxy */
|
/** Get the marshal functions for the proxy */
|
||||||
const struct pw_protocol_marshal *pw_proxy_get_marshal(struct pw_proxy *proxy);
|
const struct pw_protocol_marshal *pw_proxy_get_marshal(struct pw_proxy *proxy);
|
||||||
|
|
||||||
|
/** Install a marshal function on a proxy */
|
||||||
|
int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor);
|
||||||
|
|
||||||
#define pw_proxy_notify(p,type,event,version,...) \
|
#define pw_proxy_notify(p,type,event,version,...) \
|
||||||
spa_hook_list_call(pw_proxy_get_object_listeners(p), \
|
spa_hook_list_call(pw_proxy_get_object_listeners(p), \
|
||||||
type, event, version, ## __VA_ARGS__)
|
type, event, version, ## __VA_ARGS__)
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,11 @@ void pw_resource_destroy(struct pw_resource *resource)
|
||||||
{
|
{
|
||||||
struct pw_impl_client *client = resource->client;
|
struct pw_impl_client *client = resource->client;
|
||||||
|
|
||||||
|
if (resource->global) {
|
||||||
|
spa_list_remove(&resource->link);
|
||||||
|
resource->global = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: destroy %u", resource, resource->id);
|
pw_log_debug(NAME" %p: destroy %u", resource, resource->id);
|
||||||
pw_resource_emit_destroy(resource);
|
pw_resource_emit_destroy(resource);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,9 @@ struct spa_hook_list *pw_resource_get_object_listeners(struct pw_resource *resou
|
||||||
/** Get the marshal functions for the resource */
|
/** Get the marshal functions for the resource */
|
||||||
const struct pw_protocol_marshal *pw_resource_get_marshal(struct pw_resource *resource);
|
const struct pw_protocol_marshal *pw_resource_get_marshal(struct pw_resource *resource);
|
||||||
|
|
||||||
|
/** install a marshal function on a resource */
|
||||||
|
int pw_resource_install_marshal(struct pw_resource *resource, bool implementor);
|
||||||
|
|
||||||
#define pw_resource_notify(r,type,event,version,...) \
|
#define pw_resource_notify(r,type,event,version,...) \
|
||||||
spa_hook_list_call(pw_resource_get_object_listeners(r), \
|
spa_hook_list_call(pw_resource_get_object_listeners(r), \
|
||||||
type, event, version, ## __VA_ARGS__)
|
type, event, version, ## __VA_ARGS__)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue