mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
Use int counters for iterating items
Use counters instead of void* to iterate items. This simplifies some things and makes it easier to do over the wire. Add format description to NodeInfo and use this to add format descriptions to pinos devices. Small fixes to fix leaks and crashes.
This commit is contained in:
parent
8b84d8fde6
commit
b38ecafe81
38 changed files with 363 additions and 330 deletions
|
|
@ -472,13 +472,12 @@ spa_proxy_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaProxy *this;
|
||||
SpaProxyPort *port;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaProxy, node);
|
||||
|
|
@ -488,13 +487,10 @@ spa_proxy_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
if (index >= port->n_formats)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*format = port->formats[index];
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
PinosLinkImpl *impl = SPA_CONTAINER_OF (this, PinosLinkImpl, this);
|
||||
SpaResult res;
|
||||
SpaFormat *filter = NULL, *format;
|
||||
void *istate = NULL, *ostate = NULL;
|
||||
unsigned int iidx = 0, oidx = 0;
|
||||
char *error = NULL;
|
||||
|
||||
if (in_state != SPA_NODE_STATE_CONFIGURE && out_state != SPA_NODE_STATE_CONFIGURE)
|
||||
|
|
@ -95,8 +95,8 @@ again:
|
|||
this->input->port_id,
|
||||
&filter,
|
||||
NULL,
|
||||
&istate)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END && istate != NULL) {
|
||||
iidx)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END && iidx != 0) {
|
||||
asprintf (&error, "error input enum formats: %d", res);
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -110,9 +110,10 @@ again:
|
|||
this->output->port_id,
|
||||
&format,
|
||||
filter,
|
||||
&ostate)) < 0) {
|
||||
oidx)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END) {
|
||||
ostate = NULL;
|
||||
oidx = 0;
|
||||
iidx++;
|
||||
goto again;
|
||||
}
|
||||
asprintf (&error, "error output enum formats: %d", res);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/client/serialize.h"
|
||||
|
||||
#include "pinos/server/node.h"
|
||||
#include "pinos/server/data-loop.h"
|
||||
|
|
@ -423,8 +424,44 @@ node_bind_func (PinosGlobal *global,
|
|||
info.name = this->name;
|
||||
info.max_inputs = this->transport->area->max_inputs;
|
||||
info.n_inputs = this->transport->area->n_inputs;
|
||||
info.input_formats = NULL;
|
||||
for (info.n_input_formats = 0; ; info.n_input_formats++) {
|
||||
SpaFormat *fmt;
|
||||
void *p;
|
||||
|
||||
if (spa_node_port_enum_formats (this->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
0,
|
||||
&fmt,
|
||||
NULL,
|
||||
info.n_input_formats) < 0)
|
||||
break;
|
||||
|
||||
info.input_formats = realloc (info.input_formats, sizeof (SpaFormat*) * (info.n_input_formats + 1));
|
||||
|
||||
p = malloc (pinos_serialize_format_get_size (fmt));
|
||||
info.input_formats[info.n_input_formats] = pinos_serialize_format_copy_into (p, fmt);
|
||||
}
|
||||
info.max_outputs = this->transport->area->max_outputs;
|
||||
info.n_outputs = this->transport->area->n_outputs;
|
||||
info.output_formats = NULL;
|
||||
for (info.n_output_formats = 0; ; info.n_output_formats++) {
|
||||
SpaFormat *fmt;
|
||||
void *p;
|
||||
|
||||
if (spa_node_port_enum_formats (this->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
0,
|
||||
&fmt,
|
||||
NULL,
|
||||
info.n_output_formats) < 0)
|
||||
break;
|
||||
|
||||
info.output_formats = realloc (info.output_formats, sizeof (SpaFormat*) * (info.n_output_formats + 1));
|
||||
|
||||
p = malloc (pinos_serialize_format_get_size (fmt));
|
||||
info.output_formats[info.n_output_formats] = pinos_serialize_format_copy_into (p, fmt);
|
||||
}
|
||||
info.state = this->state;
|
||||
info.error = this->error;
|
||||
info.props = this->properties ? &this->properties->dict : NULL;
|
||||
|
|
@ -667,9 +704,9 @@ pinos_node_destroy (PinosNode * this)
|
|||
* @node: a #PinosNode
|
||||
* @direction: a #PinosDirection
|
||||
*
|
||||
* Find a new unused port id in @node with @direction
|
||||
* Find a new unused port in @node with @direction
|
||||
*
|
||||
* Returns: the new port id or %SPA_ID_INVALID on error
|
||||
* Returns: the new port or %NULL on error
|
||||
*/
|
||||
PinosPort *
|
||||
pinos_node_get_free_port (PinosNode *node,
|
||||
|
|
@ -698,12 +735,8 @@ pinos_node_get_free_port (PinosNode *node,
|
|||
}
|
||||
}
|
||||
|
||||
if (port == NULL) {
|
||||
if (!spa_list_is_empty (ports))
|
||||
port = spa_list_first (ports, PinosPort, link);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
if (port == NULL && !spa_list_is_empty (ports))
|
||||
port = spa_list_first (ports, PinosPort, link);
|
||||
|
||||
return port;
|
||||
|
||||
|
|
@ -812,7 +845,7 @@ pinos_node_update_state (PinosNode *node,
|
|||
|
||||
spa_zero (info);
|
||||
m.info = &info;
|
||||
info.change_mask = 1 << 1;
|
||||
info.change_mask = 1 << 5;
|
||||
info.state = node->state;
|
||||
info.error = node->error;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue