mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	modules: remove include of private.h
Remove some includes of private.h Add some methods to get the mempool of client and context so that we can remove direct access. Move some things around. Use methods to get pw_loop variables. See #3243
This commit is contained in:
		
							parent
							
								
									dc07c2321b
								
							
						
					
					
						commit
						5e2a7dbc4e
					
				
					 17 changed files with 104 additions and 66 deletions
				
			
		| 
						 | 
				
			
			@ -86,6 +86,7 @@ struct impl {
 | 
			
		|||
	struct pw_impl_client_node this;
 | 
			
		||||
 | 
			
		||||
	struct pw_context *context;
 | 
			
		||||
	struct pw_mempool *context_pool;
 | 
			
		||||
 | 
			
		||||
	struct spa_node node;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -98,6 +99,7 @@ struct impl {
 | 
			
		|||
 | 
			
		||||
	struct pw_resource *resource;
 | 
			
		||||
	struct pw_impl_client *client;
 | 
			
		||||
	struct pw_mempool *client_pool;
 | 
			
		||||
 | 
			
		||||
	struct spa_source data_source;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -236,7 +238,7 @@ static void clear_data(struct impl *impl, struct spa_data *d)
 | 
			
		|||
		struct pw_memblock *m;
 | 
			
		||||
 | 
			
		||||
		id = SPA_PTR_TO_UINT32(d->data);
 | 
			
		||||
		m = pw_mempool_find_id(impl->client->pool, id);
 | 
			
		||||
		m = pw_mempool_find_id(impl->client_pool, id);
 | 
			
		||||
		if (m) {
 | 
			
		||||
			pw_log_debug("%p: mem %d", impl, m->id);
 | 
			
		||||
			pw_memblock_unref(m);
 | 
			
		||||
| 
						 | 
				
			
			@ -354,11 +356,11 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
 | 
			
		|||
	if (impl->this.flags & 1)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	old = pw_mempool_find_tag(impl->client->pool, tag, sizeof(tag));
 | 
			
		||||
	old = pw_mempool_find_tag(impl->client_pool, tag, sizeof(tag));
 | 
			
		||||
 | 
			
		||||
	if (data) {
 | 
			
		||||
		mm = pw_mempool_import_map(impl->client->pool,
 | 
			
		||||
				impl->context->pool, data, size, tag);
 | 
			
		||||
		mm = pw_mempool_import_map(impl->client_pool,
 | 
			
		||||
				impl->context_pool, data, size, tag);
 | 
			
		||||
		if (mm == NULL)
 | 
			
		||||
			return -errno;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -657,11 +659,11 @@ static int do_port_set_io(struct impl *impl,
 | 
			
		|||
	if ((mix = find_mix(port, mix_id)) == NULL || !mix->valid)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	old = pw_mempool_find_tag(impl->client->pool, tag, sizeof(tag));
 | 
			
		||||
	old = pw_mempool_find_tag(impl->client_pool, tag, sizeof(tag));
 | 
			
		||||
 | 
			
		||||
	if (data) {
 | 
			
		||||
		mm = pw_mempool_import_map(impl->client->pool,
 | 
			
		||||
				impl->context->pool, data, size, tag);
 | 
			
		||||
		mm = pw_mempool_import_map(impl->client_pool,
 | 
			
		||||
				impl->context_pool, data, size, tag);
 | 
			
		||||
		if (mm == NULL)
 | 
			
		||||
			return -errno;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -761,7 +763,7 @@ do_port_use_buffers(struct impl *impl,
 | 
			
		|||
		else
 | 
			
		||||
			return -EINVAL;
 | 
			
		||||
 | 
			
		||||
		if ((mem = pw_mempool_find_ptr(impl->context->pool, baseptr)) == NULL)
 | 
			
		||||
		if ((mem = pw_mempool_find_ptr(impl->context_pool, baseptr)) == NULL)
 | 
			
		||||
			return -EINVAL;
 | 
			
		||||
 | 
			
		||||
		endptr = SPA_PTROFF(baseptr, buffers[i]->n_datas * sizeof(struct spa_chunk), void);
 | 
			
		||||
| 
						 | 
				
			
			@ -771,7 +773,7 @@ do_port_use_buffers(struct impl *impl,
 | 
			
		|||
		for (j = 0; j < buffers[i]->n_datas; j++) {
 | 
			
		||||
			struct spa_data *d = &buffers[i]->datas[j];
 | 
			
		||||
			if (d->type == SPA_DATA_MemPtr) {
 | 
			
		||||
				if ((m = pw_mempool_find_ptr(impl->context->pool, d->data)) == NULL ||
 | 
			
		||||
				if ((m = pw_mempool_find_ptr(impl->context_pool, d->data)) == NULL ||
 | 
			
		||||
				    m != mem)
 | 
			
		||||
					return -EINVAL;
 | 
			
		||||
				endptr = SPA_MAX(endptr, SPA_PTROFF(d->data, d->maxsize, void));
 | 
			
		||||
| 
						 | 
				
			
			@ -780,7 +782,7 @@ do_port_use_buffers(struct impl *impl,
 | 
			
		|||
		if (endptr > SPA_PTROFF(baseptr, mem->size, void))
 | 
			
		||||
			return -EINVAL;
 | 
			
		||||
 | 
			
		||||
		m = pw_mempool_import_block(impl->client->pool, mem);
 | 
			
		||||
		m = pw_mempool_import_block(impl->client_pool, mem);
 | 
			
		||||
		if (m == NULL)
 | 
			
		||||
			return -errno;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -818,7 +820,7 @@ do_port_use_buffers(struct impl *impl,
 | 
			
		|||
					flags |= PW_MEMBLOCK_FLAG_WRITABLE;
 | 
			
		||||
 | 
			
		||||
				spa_log_debug(impl->log, "mem %d type:%d fd:%d", j, d->type, (int)d->fd);
 | 
			
		||||
				m = pw_mempool_import(impl->client->pool,
 | 
			
		||||
				m = pw_mempool_import(impl->client_pool,
 | 
			
		||||
					flags, d->type, d->fd);
 | 
			
		||||
				if (m == NULL)
 | 
			
		||||
					return -errno;
 | 
			
		||||
| 
						 | 
				
			
			@ -1201,7 +1203,7 @@ static void node_peer_added(void *data, struct pw_impl_node *peer)
 | 
			
		|||
	struct impl *impl = data;
 | 
			
		||||
	struct pw_memblock *m;
 | 
			
		||||
 | 
			
		||||
	m = pw_mempool_import_block(impl->client->pool, peer->activation);
 | 
			
		||||
	m = pw_mempool_import_block(impl->client_pool, peer->activation);
 | 
			
		||||
	if (m == NULL) {
 | 
			
		||||
		pw_log_warn("%p: can't ensure mem: %m", impl);
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -1226,7 +1228,7 @@ static void node_peer_removed(void *data, struct pw_impl_node *peer)
 | 
			
		|||
	struct impl *impl = data;
 | 
			
		||||
	struct pw_memblock *m;
 | 
			
		||||
 | 
			
		||||
	m = pw_mempool_find_fd(impl->client->pool, peer->activation->fd);
 | 
			
		||||
	m = pw_mempool_find_fd(impl->client_pool, peer->activation->fd);
 | 
			
		||||
	if (m == NULL) {
 | 
			
		||||
		pw_log_warn("%p: unknown peer %p fd:%d", impl, peer,
 | 
			
		||||
			peer->source.fd);
 | 
			
		||||
| 
						 | 
				
			
			@ -1256,7 +1258,7 @@ void pw_impl_client_node_registered(struct pw_impl_client_node *this, struct pw_
 | 
			
		|||
 | 
			
		||||
	pw_log_debug("%p: %d", &impl->node, node_id);
 | 
			
		||||
 | 
			
		||||
	impl->activation = pw_mempool_import_block(client->pool, node->activation);
 | 
			
		||||
	impl->activation = pw_mempool_import_block(impl->client_pool, node->activation);
 | 
			
		||||
	if (impl->activation == NULL) {
 | 
			
		||||
		pw_log_debug("%p: can't import block: %m", &impl->node);
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -1290,7 +1292,7 @@ static int add_area(struct impl *impl)
 | 
			
		|||
 | 
			
		||||
	size = sizeof(struct spa_io_buffers) * AREA_SIZE;
 | 
			
		||||
 | 
			
		||||
	area = pw_mempool_alloc(impl->context->pool,
 | 
			
		||||
	area = pw_mempool_alloc(impl->context_pool,
 | 
			
		||||
			PW_MEMBLOCK_FLAG_READWRITE |
 | 
			
		||||
			PW_MEMBLOCK_FLAG_MAP |
 | 
			
		||||
			PW_MEMBLOCK_FLAG_SEAL,
 | 
			
		||||
| 
						 | 
				
			
			@ -1343,7 +1345,7 @@ static void node_free(void *data)
 | 
			
		|||
 | 
			
		||||
	spa_hook_remove(&impl->node_listener);
 | 
			
		||||
 | 
			
		||||
	while ((mm = pw_mempool_find_tag(impl->client->pool, tag, sizeof(uint32_t))) != NULL)
 | 
			
		||||
	while ((mm = pw_mempool_find_tag(impl->client_pool, tag, sizeof(uint32_t))) != NULL)
 | 
			
		||||
		pw_memmap_free(mm);
 | 
			
		||||
 | 
			
		||||
	if (impl->activation)
 | 
			
		||||
| 
						 | 
				
			
			@ -1670,6 +1672,7 @@ struct pw_impl_client_node *pw_impl_client_node_new(struct pw_resource *resource
 | 
			
		|||
	this = &impl->this;
 | 
			
		||||
 | 
			
		||||
	impl->context = context;
 | 
			
		||||
	impl->context_pool = pw_context_get_mempool(context);
 | 
			
		||||
	impl->data_source.fd = -1;
 | 
			
		||||
	pw_log_debug("%p: new", &impl->node);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1677,6 +1680,7 @@ struct pw_impl_client_node *pw_impl_client_node_new(struct pw_resource *resource
 | 
			
		|||
	impl_init(impl, NULL, support, n_support);
 | 
			
		||||
	impl->resource = resource;
 | 
			
		||||
	impl->client = client;
 | 
			
		||||
	impl->client_pool = pw_impl_client_get_mempool(client);
 | 
			
		||||
	this->flags = do_register ? 0 : 1;
 | 
			
		||||
 | 
			
		||||
	pw_map_init(&impl->ports[0], 64, 64);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,13 +15,14 @@
 | 
			
		|||
#include <spa/node/node.h>
 | 
			
		||||
#include <spa/node/utils.h>
 | 
			
		||||
#include <spa/node/io.h>
 | 
			
		||||
#include <spa/node/type-info.h>
 | 
			
		||||
#include <spa/pod/filter.h>
 | 
			
		||||
#include <spa/utils/keys.h>
 | 
			
		||||
#include <spa/utils/result.h>
 | 
			
		||||
 | 
			
		||||
#define PW_ENABLE_DEPRECATED
 | 
			
		||||
 | 
			
		||||
#include "pipewire/pipewire.h"
 | 
			
		||||
#include "pipewire/private.h"
 | 
			
		||||
 | 
			
		||||
#include "pipewire/context.h"
 | 
			
		||||
#include "modules/spa/spa-node.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -130,6 +131,7 @@ struct impl {
 | 
			
		|||
	bool client_reuse;
 | 
			
		||||
 | 
			
		||||
	struct pw_context *context;
 | 
			
		||||
	struct pw_mempool *context_pool;
 | 
			
		||||
 | 
			
		||||
	struct node node;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -335,7 +337,7 @@ static inline void do_flush(struct node *this)
 | 
			
		|||
 | 
			
		||||
static int send_clock_update(struct node *this)
 | 
			
		||||
{
 | 
			
		||||
	struct pw_impl_client *client = this->resource->client;
 | 
			
		||||
	struct pw_impl_client *client = pw_resource_get_client(this->resource);
 | 
			
		||||
	uint32_t type = pw_protocol_native0_name_to_v2(client, SPA_TYPE_INFO_NODE_COMMAND_BASE "ClockUpdate");
 | 
			
		||||
	struct timespec ts;
 | 
			
		||||
	int64_t now;
 | 
			
		||||
| 
						 | 
				
			
			@ -468,7 +470,7 @@ do_update_port(struct node *this,
 | 
			
		|||
		}
 | 
			
		||||
		for (i = 0; i < port->n_params; i++) {
 | 
			
		||||
			port->params[i] = params[i] ?
 | 
			
		||||
				pw_protocol_native0_pod_from_v2(this->resource->client, params[i]) : NULL;
 | 
			
		||||
				pw_protocol_native0_pod_from_v2(pw_resource_get_client(this->resource), params[i]) : NULL;
 | 
			
		||||
 | 
			
		||||
			if (port->params[i] && spa_pod_is_object_id(port->params[i], SPA_PARAM_Format))
 | 
			
		||||
				port->have_format = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -661,7 +663,7 @@ impl_node_port_set_io(void *object,
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
	if (data) {
 | 
			
		||||
		if ((mem = pw_mempool_find_ptr(impl->context->pool, data)) == NULL)
 | 
			
		||||
		if ((mem = pw_mempool_find_ptr(impl->context_pool, data)) == NULL)
 | 
			
		||||
			return -EINVAL;
 | 
			
		||||
 | 
			
		||||
		mem_offset = SPA_PTRDIFF(data, mem->map->ptr);
 | 
			
		||||
| 
						 | 
				
			
			@ -744,7 +746,7 @@ impl_node_port_use_buffers(void *object,
 | 
			
		|||
		else
 | 
			
		||||
			return -EINVAL;
 | 
			
		||||
 | 
			
		||||
		if ((mem = pw_mempool_find_ptr(impl->context->pool, baseptr)) == NULL)
 | 
			
		||||
		if ((mem = pw_mempool_find_ptr(impl->context_pool, baseptr)) == NULL)
 | 
			
		||||
			return -EINVAL;
 | 
			
		||||
 | 
			
		||||
		data_size = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -910,8 +912,7 @@ static int impl_node_process(void *object)
 | 
			
		|||
	struct node *this = object;
 | 
			
		||||
	struct impl *impl = this->impl;
 | 
			
		||||
	struct pw_impl_node *n = impl->this.node;
 | 
			
		||||
 | 
			
		||||
	return impl_node_process_input(n->node);
 | 
			
		||||
	return impl_node_process_input(pw_impl_node_get_implementation(n));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int handle_node_message(struct node *this, struct pw_client_node0_message *message)
 | 
			
		||||
| 
						 | 
				
			
			@ -1363,9 +1364,10 @@ struct pw_impl_client_node0 *pw_impl_client_node0_new(struct pw_resource *resour
 | 
			
		|||
	}
 | 
			
		||||
	convert_properties(properties);
 | 
			
		||||
 | 
			
		||||
	pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id);
 | 
			
		||||
	pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", pw_global_get_id(pw_impl_client_get_global(client)));
 | 
			
		||||
 | 
			
		||||
	impl->context = context;
 | 
			
		||||
	impl->context_pool = pw_context_get_mempool(context);
 | 
			
		||||
	impl->fds[0] = impl->fds[1] = -1;
 | 
			
		||||
	pw_log_debug("client-node %p: new", impl);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,6 +43,16 @@ struct spa_command_node0_clock_update {
 | 
			
		|||
	struct spa_command_node0_clock_update_body body;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum spa_node0_event {
 | 
			
		||||
	SPA_NODE0_EVENT_START	= SPA_TYPE_VENDOR_PipeWire,
 | 
			
		||||
	SPA_NODE0_EVENT_RequestClockUpdate,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum spa_node0_command {
 | 
			
		||||
	SPA_NODE0_COMMAND_START	= SPA_TYPE_VENDOR_PipeWire,
 | 
			
		||||
	SPA_NODE0_COMMAND_ClockUpdate,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define SPA_COMMAND_NODE0_CLOCK_UPDATE_INIT(type,change_mask,rate,ticks,monotonic_time,offset,scale,state,flags,latency)  \
 | 
			
		||||
	SPA_COMMAND_INIT_FULL(struct spa_command_node0_clock_update,			\
 | 
			
		||||
                        sizeof(struct spa_command_node0_clock_update_body), 0, type,	\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,6 @@
 | 
			
		|||
#include <spa/node/io.h>
 | 
			
		||||
 | 
			
		||||
#include <pipewire/impl.h>
 | 
			
		||||
#include <pipewire/private.h>
 | 
			
		||||
 | 
			
		||||
#include "ext-client-node.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +189,7 @@ pw_client_node0_transport_new(struct pw_context *context,
 | 
			
		|||
	trans = &impl->trans;
 | 
			
		||||
	impl->offset = 0;
 | 
			
		||||
 | 
			
		||||
	impl->mem = pw_mempool_alloc(context->pool,
 | 
			
		||||
	impl->mem = pw_mempool_alloc(pw_context_get_mempool(context),
 | 
			
		||||
			PW_MEMBLOCK_FLAG_READWRITE |
 | 
			
		||||
			PW_MEMBLOCK_FLAG_MAP |
 | 
			
		||||
			PW_MEMBLOCK_FLAG_SEAL,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue