mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
node: add driver position struct
Pass driver info to client use current buffersize and samplerate in client update the buffer size dynamically based on session
This commit is contained in:
parent
2c6ff2dad2
commit
bed26040ef
9 changed files with 168 additions and 11 deletions
|
|
@ -150,6 +150,8 @@ struct impl {
|
|||
|
||||
int fds[2];
|
||||
int other_fds[2];
|
||||
|
||||
struct pw_client_node_position *position;
|
||||
};
|
||||
|
||||
/** \endcond */
|
||||
|
|
@ -890,14 +892,21 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
static int impl_node_process(struct spa_node *node)
|
||||
{
|
||||
struct node *this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
struct impl *impl = this->impl;
|
||||
struct pw_driver_quantum *q;
|
||||
uint64_t cmd = 1;
|
||||
|
||||
if (this->impl->this.status != SPA_ID_INVALID) {
|
||||
spa_log_trace(this->log, "%p: return %d", this, this->impl->this.status);
|
||||
return this->impl->this.status;
|
||||
return impl->this.status;
|
||||
}
|
||||
|
||||
spa_log_trace(this->log, "%p: send process", this);
|
||||
spa_log_trace(this->log, "%p: send process %p", this, impl->this.node->driver_node);
|
||||
|
||||
q = impl->this.node->driver_node->rt.quantum;
|
||||
|
||||
impl->position->duration = q->size;
|
||||
impl->position->rate = q->rate;
|
||||
|
||||
if (write(this->writefd, &cmd, 8) != 8)
|
||||
spa_log_warn(this->log, "node %p: error %s", this, strerror(errno));
|
||||
|
|
@ -1148,6 +1157,8 @@ static void node_initialized(void *data)
|
|||
struct pw_type *t = impl->t;
|
||||
struct pw_global *global;
|
||||
uint32_t node_id;
|
||||
uint32_t area_size, size;
|
||||
struct mem *m;
|
||||
|
||||
if (this->resource == NULL)
|
||||
return;
|
||||
|
|
@ -1162,14 +1173,20 @@ static void node_initialized(void *data)
|
|||
spa_loop_add_source(impl->node.data_loop, &impl->node.data_source);
|
||||
pw_log_debug("client-node %p: transport fd %d %d", node, impl->fds[0], impl->fds[1]);
|
||||
|
||||
area_size = sizeof(struct spa_io_buffers) * MAX_AREAS;
|
||||
size = area_size + sizeof(struct pw_client_node_position);
|
||||
|
||||
if (pw_memblock_alloc(PW_MEMBLOCK_FLAG_WITH_FD |
|
||||
PW_MEMBLOCK_FLAG_MAP_READWRITE |
|
||||
PW_MEMBLOCK_FLAG_SEAL,
|
||||
sizeof(struct spa_io_buffers) * MAX_AREAS,
|
||||
size,
|
||||
&impl->io_areas) < 0)
|
||||
return;
|
||||
|
||||
ensure_mem(impl, impl->io_areas->fd, t->data.MemFd, impl->io_areas->flags);
|
||||
impl->position = SPA_MEMBER(impl->io_areas->ptr,
|
||||
area_size, struct pw_client_node_position);
|
||||
|
||||
m = ensure_mem(impl, impl->io_areas->fd, t->data.MemFd, impl->io_areas->flags);
|
||||
pw_log_debug("client-node %p: io areas %p", node, impl->io_areas->ptr);
|
||||
|
||||
if ((global = pw_node_get_global(node)) != NULL)
|
||||
|
|
@ -1181,6 +1198,11 @@ static void node_initialized(void *data)
|
|||
node_id,
|
||||
impl->other_fds[0],
|
||||
impl->other_fds[1]);
|
||||
|
||||
pw_client_node_resource_set_position(this->resource,
|
||||
m->id,
|
||||
area_size,
|
||||
sizeof(struct pw_client_node_position));
|
||||
}
|
||||
|
||||
static void node_free(void *data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue