mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-24 08:56:47 -05:00
Remove direction
Direction is tied to the port id. Handle nodes with fixed ports.
This commit is contained in:
parent
7d8e2d53f7
commit
9485bd77e7
25 changed files with 246 additions and 165 deletions
|
|
@ -103,17 +103,15 @@ typedef struct {
|
|||
typedef struct {
|
||||
uint32_t port_id;
|
||||
uint32_t change_mask;
|
||||
SpaDirection direction;
|
||||
unsigned int n_possible_formats;
|
||||
SpaFormat **possible_formats;
|
||||
const SpaProps *props;
|
||||
const SpaPortInfo *info;
|
||||
} SpaControlCmdPortUpdate;
|
||||
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_DIRECTION (1 << 0)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS (1 << 1)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 2)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_INFO (1 << 3)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 1)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_INFO (1 << 2)
|
||||
|
||||
/* SPA_CONTROL_CMD_PORT_REMOVED */
|
||||
typedef struct {
|
||||
|
|
@ -141,7 +139,6 @@ typedef struct {
|
|||
/* SPA_CONTROL_CMD_ADD_PORT */
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
SpaDirection direction;
|
||||
} SpaControlCmdAddPort;
|
||||
|
||||
/* SPA_CONTROL_CMD_REMOVE_PORT */
|
||||
|
|
|
|||
|
|
@ -61,12 +61,6 @@ typedef enum {
|
|||
SPA_RESULT_WRONG_STATE = -29,
|
||||
} SpaResult;
|
||||
|
||||
typedef enum {
|
||||
SPA_DIRECTION_INVALID = 0,
|
||||
SPA_DIRECTION_INPUT,
|
||||
SPA_DIRECTION_OUTPUT
|
||||
} SpaDirection;
|
||||
|
||||
typedef void (*SpaNotify) (void *data);
|
||||
|
||||
#define SPA_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
||||
|
|
|
|||
|
|
@ -66,20 +66,32 @@ typedef enum {
|
|||
|
||||
struct _SpaEvent {
|
||||
SpaEventType type;
|
||||
uint32_t port_id;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
} SpaEventPortAdded;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaEventPortRemoved;
|
||||
|
||||
typedef struct {
|
||||
SpaNodeState state;
|
||||
} SpaEventStateChange;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaEventHaveOutput;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaEventNeedInput;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
uint32_t buffer_id;
|
||||
} SpaEventReuseBuffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -267,8 +267,22 @@ struct _SpaNode {
|
|||
unsigned int n_output_ports,
|
||||
uint32_t *output_ids);
|
||||
|
||||
/**
|
||||
* SpaNode::add_port:
|
||||
* @node: a #SpaNode
|
||||
* @port_id: an unused port id
|
||||
*
|
||||
* Make a new port with @port_id. The called should use get_port_ids() to
|
||||
* find an unused id.
|
||||
*
|
||||
* Input port ids should be between 0 and max_input_ports and output ports
|
||||
* between max_input_ports and max_input_ports + max_output_ports as obtained
|
||||
* from get_port_ids().
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
*/
|
||||
SpaResult (*add_port) (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id);
|
||||
SpaResult (*remove_port) (SpaNode *node,
|
||||
uint32_t port_id);
|
||||
|
|
|
|||
|
|
@ -225,7 +225,6 @@ spa_alsa_sink_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
|
@ -241,7 +240,6 @@ spa_alsa_sink_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_PAUSED;
|
||||
|
|
@ -316,7 +314,6 @@ spa_alsa_sink_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
|
|||
|
|
@ -225,11 +225,12 @@ static void
|
|||
pull_input (SpaALSASink *this, void *data, snd_pcm_uframes_t frames)
|
||||
{
|
||||
SpaEvent event;
|
||||
SpaEventNeedInput ni;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_NEED_INPUT;
|
||||
event.port_id = 0;
|
||||
event.size = 0;
|
||||
event.data = NULL;
|
||||
event.size = sizeof (ni);
|
||||
event.data = ∋
|
||||
ni.port_id = 0;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +345,6 @@ spa_alsa_start (SpaALSASink *this)
|
|||
}
|
||||
|
||||
event.type = SPA_EVENT_TYPE_ADD_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &state->poll;
|
||||
event.size = sizeof (state->poll);
|
||||
|
||||
|
|
@ -373,7 +373,6 @@ spa_alsa_stop (SpaALSASink *this)
|
|||
snd_pcm_drop (state->handle);
|
||||
|
||||
event.type = SPA_EVENT_TYPE_REMOVE_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &state->poll;
|
||||
event.size = sizeof (state->poll);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ spa_audiomixer_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
|
@ -167,7 +166,6 @@ spa_audiomixer_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_PAUSED;
|
||||
|
|
@ -253,7 +251,6 @@ spa_audiomixer_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
|
|
@ -263,9 +260,6 @@ spa_audiomixer_node_add_port (SpaNode *node,
|
|||
|
||||
this = (SpaAudioMixer *) node->handle;
|
||||
|
||||
if (direction != SPA_DIRECTION_INPUT)
|
||||
return SPA_RESULT_INVALID_DIRECTION;
|
||||
|
||||
if (port_id >= MAX_PORTS)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
|
|
@ -571,11 +565,12 @@ static void
|
|||
pull_port (SpaAudioMixer *this, uint32_t port_id, SpaOutputInfo *info, size_t pull_size)
|
||||
{
|
||||
SpaEvent event;
|
||||
SpaEventNeedInput ni;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_NEED_INPUT;
|
||||
event.port_id = port_id;
|
||||
event.size = 0;
|
||||
event.data = NULL;
|
||||
event.size = sizeof (ni);
|
||||
event.data = ∋
|
||||
ni.port_id = port_id;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
|
@ -188,7 +187,6 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_PAUSED;
|
||||
|
|
@ -263,7 +261,6 @@ spa_audiotestsrc_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,6 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
|
@ -162,7 +161,6 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_PAUSED;
|
||||
|
|
@ -240,7 +238,6 @@ spa_ffmpeg_dec_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static SpaResult
|
||||
spa_ffmpeg_dec_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,6 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
|
@ -162,7 +161,6 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_PAUSED;
|
||||
|
|
@ -240,7 +238,6 @@ spa_ffmpeg_enc_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@
|
|||
|
||||
#define CHECK_FREE_PORT_ID(this,id) ((id) < MAX_PORTS && !(this)->ports[id].valid)
|
||||
#define CHECK_PORT_ID(this,id) ((id) < MAX_PORTS && (this)->ports[id].valid)
|
||||
#define CHECK_PORT_ID_DIR(this,id,dir) (CHECK_PORT_ID(this,id) && (this)->ports[i].direction == (dir))
|
||||
#define CHECK_PORT_ID_IN(this,id) (CHECK_PORT_ID(this,id) && (id < this->max_inputs))
|
||||
#define CHECK_PORT_ID_OUT(this,id) (CHECK_PORT_ID(this,id) && (id >= this->max_inputs))
|
||||
|
||||
typedef struct _SpaProxy SpaProxy;
|
||||
|
||||
|
|
@ -50,7 +51,6 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
bool valid;
|
||||
SpaDirection direction;
|
||||
SpaPortInfo info;
|
||||
SpaFormat *format;
|
||||
unsigned int n_formats;
|
||||
|
|
@ -112,7 +112,6 @@ update_poll (SpaProxy *this, int socketfd)
|
|||
|
||||
if (p->socketfd != -1) {
|
||||
event.type = SPA_EVENT_TYPE_REMOVE_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &this->poll;
|
||||
event.size = sizeof (this->poll);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
|
@ -122,7 +121,6 @@ update_poll (SpaProxy *this, int socketfd)
|
|||
if (p->socketfd != -1) {
|
||||
this->fds[0].fd = p->socketfd;
|
||||
event.type = SPA_EVENT_TYPE_ADD_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &this->poll;
|
||||
event.size = sizeof (this->poll);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
|
@ -139,7 +137,6 @@ update_state (SpaProxy *this, SpaNodeState state)
|
|||
this->state = state;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = state;
|
||||
|
|
@ -318,17 +315,15 @@ spa_proxy_node_get_port_ids (SpaNode *node,
|
|||
this = (SpaProxy *) node->handle;
|
||||
|
||||
if (input_ids) {
|
||||
n_input_ports = SPA_MIN (n_input_ports, MAX_PORTS);
|
||||
for (c = 0, i = 0; i < n_input_ports; i++) {
|
||||
if (this->ports[i].valid && this->ports[i].direction == SPA_DIRECTION_INPUT)
|
||||
for (c = 0, i = 0; i < MAX_INPUTS && c < n_input_ports; i++) {
|
||||
if (this->ports[i].valid)
|
||||
input_ids[c++] = i;
|
||||
}
|
||||
}
|
||||
if (output_ids) {
|
||||
n_output_ports = SPA_MIN (n_output_ports, MAX_PORTS);
|
||||
for (c = 0, i = 0; i < n_output_ports; i++) {
|
||||
if (this->ports[i].valid && this->ports[i].direction == SPA_DIRECTION_OUTPUT)
|
||||
output_ids[c++] = i;
|
||||
for (c = 0, i = 0; i < MAX_OUTPUTS && c < n_output_ports; i++) {
|
||||
if (this->ports[MAX_INPUTS + i].valid)
|
||||
output_ids[c++] = MAX_INPUTS + i;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -361,21 +356,19 @@ do_update_port (SpaProxy *this,
|
|||
}
|
||||
|
||||
if (!port->valid) {
|
||||
fprintf (stderr, "%p: adding port %d, %d\n", this, pu->port_id, pu->direction);
|
||||
port->direction = pu->direction;
|
||||
fprintf (stderr, "%p: adding port %d\n", this, pu->port_id);
|
||||
port->format = NULL;
|
||||
port->valid = true;
|
||||
|
||||
if (pu->direction == SPA_DIRECTION_INPUT)
|
||||
if (pu->port_id < MAX_INPUTS)
|
||||
this->n_inputs++;
|
||||
else
|
||||
this->n_outputs++;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_PORT_ADDED;
|
||||
event.port_id = pu->port_id;
|
||||
event.data = &pa;
|
||||
event.size = sizeof (pa);
|
||||
pa.direction = pu->direction;
|
||||
event.data = &pa;
|
||||
pa.port_id = pu->port_id;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
}
|
||||
|
|
@ -386,31 +379,30 @@ do_uninit_port (SpaProxy *this,
|
|||
{
|
||||
SpaEvent event;
|
||||
SpaProxyPort *port;
|
||||
SpaEventPortRemoved pr;
|
||||
|
||||
fprintf (stderr, "%p: removing port %d\n", this, port_id);
|
||||
port = &this->ports[port_id];
|
||||
|
||||
if (port->direction == SPA_DIRECTION_INPUT)
|
||||
if (port_id < MAX_INPUTS)
|
||||
this->n_inputs--;
|
||||
else
|
||||
this->n_outputs--;
|
||||
|
||||
port->direction = SPA_DIRECTION_INVALID;
|
||||
port->valid = false;
|
||||
if (port->format)
|
||||
spa_format_unref (port->format);
|
||||
port->format = NULL;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_PORT_REMOVED;
|
||||
event.port_id = port_id;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
event.size = sizeof (pr);
|
||||
event.data = ≺
|
||||
pr.port_id = port_id;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_proxy_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
SpaProxy *this;
|
||||
|
|
@ -424,12 +416,10 @@ spa_proxy_node_add_port (SpaNode *node,
|
|||
if (!CHECK_FREE_PORT_ID (this, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
pu.change_mask = SPA_CONTROL_CMD_PORT_UPDATE_DIRECTION |
|
||||
SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
|
||||
pu.change_mask = SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
|
||||
SPA_CONTROL_CMD_PORT_UPDATE_PROPS |
|
||||
SPA_CONTROL_CMD_PORT_UPDATE_INFO;
|
||||
pu.port_id = port_id;
|
||||
pu.direction = direction;
|
||||
pu.n_possible_formats = 0;
|
||||
pu.possible_formats = NULL;
|
||||
pu.props = NULL;
|
||||
|
|
@ -793,7 +783,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
spa_control_builder_init_into (&builder, buf, sizeof(buf), NULL, 0);
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (!CHECK_PORT_ID_DIR (this, info[i].port_id, SPA_DIRECTION_INPUT)) {
|
||||
if (!CHECK_PORT_ID_IN (this, info[i].port_id)) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
|
|
@ -852,7 +842,7 @@ spa_proxy_node_port_pull_output (SpaNode *node,
|
|||
this = (SpaProxy *) node->handle;
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (!CHECK_PORT_ID_DIR (this, info[i].port_id, SPA_DIRECTION_OUTPUT)) {
|
||||
if (!CHECK_PORT_ID_OUT (this, info[i].port_id)) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
|
|
@ -901,7 +891,7 @@ spa_proxy_node_port_push_event (SpaNode *node,
|
|||
|
||||
/* send start */
|
||||
spa_control_builder_init_into (&builder, buf, sizeof (buf), NULL, 0);
|
||||
crb.port_id = event->port_id;
|
||||
crb.port_id = rb->port_id;
|
||||
crb.buffer_id = rb->buffer_id;
|
||||
spa_control_builder_add_cmd (&builder, SPA_CONTROL_CMD_REUSE_BUFFER, &crb);
|
||||
spa_control_builder_end (&builder, &control);
|
||||
|
|
@ -946,12 +936,13 @@ parse_control (SpaProxy *this,
|
|||
{
|
||||
SpaControlCmdNodeUpdate nu;
|
||||
|
||||
fprintf (stderr, "proxy %p: got node update %d\n", this, cmd);
|
||||
if (spa_control_iter_parse_cmd (&it, &nu) < 0)
|
||||
break;
|
||||
|
||||
this->max_inputs = nu.max_input_ports;
|
||||
this->max_outputs = nu.max_output_ports;
|
||||
fprintf (stderr, "proxy %p: got node update %d, %u, %u\n", this, cmd,
|
||||
this->max_inputs, this->max_outputs);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -967,8 +958,7 @@ parse_control (SpaProxy *this,
|
|||
if (pu.port_id >= MAX_PORTS)
|
||||
break;
|
||||
|
||||
remove = (pu.change_mask & SPA_CONTROL_CMD_PORT_UPDATE_DIRECTION) &&
|
||||
(pu.direction == SPA_DIRECTION_INVALID);
|
||||
remove = (pu.change_mask == 0);
|
||||
|
||||
if (remove) {
|
||||
do_uninit_port (this, pu.port_id);
|
||||
|
|
@ -1001,15 +991,16 @@ parse_control (SpaProxy *this,
|
|||
case SPA_CONTROL_CMD_HAVE_OUTPUT:
|
||||
{
|
||||
SpaEvent event;
|
||||
SpaEventHaveOutput hu;
|
||||
SpaControlCmdHaveOutput cmd;
|
||||
|
||||
if (spa_control_iter_parse_cmd (&it, &cmd) < 0)
|
||||
break;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_HAVE_OUTPUT;
|
||||
event.port_id = cmd.port_id;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
event.data = &hu;
|
||||
event.size = sizeof (hu);
|
||||
hu.port_id = cmd.port_id;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1043,9 +1034,9 @@ parse_control (SpaProxy *this,
|
|||
break;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_REUSE_BUFFER;
|
||||
event.port_id = crb.port_id;
|
||||
event.data = &rb;
|
||||
event.size = sizeof (rb);
|
||||
rb.port_id = crb.port_id;
|
||||
rb.buffer_id = crb.buffer_id;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ update_state (SpaV4l2Source *this, SpaNodeState state)
|
|||
this->node_state = state;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = state;
|
||||
|
|
@ -309,10 +308,10 @@ spa_v4l2_source_node_get_n_ports (SpaNode *node,
|
|||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
|
|
@ -338,7 +337,6 @@ spa_v4l2_source_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
@ -383,6 +381,8 @@ spa_v4l2_source_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
this = (SpaV4l2Source *) node->handle;
|
||||
|
||||
fprintf (stderr, "%d\n", port_id);
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
|
|
|
|||
|
|
@ -583,14 +583,15 @@ v4l2_on_fd_events (SpaPollNotifyData *data)
|
|||
{
|
||||
SpaV4l2Source *this = data->user_data;
|
||||
SpaEvent event;
|
||||
SpaEventHaveOutput ho;
|
||||
|
||||
if (mmap_read (this) < 0)
|
||||
return 0;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_HAVE_OUTPUT;
|
||||
event.port_id = 0;
|
||||
event.size = 0;
|
||||
event.data = NULL;
|
||||
event.size = sizeof (ho);
|
||||
event.data = &ho;
|
||||
ho.port_id = 0;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
||||
return 0;
|
||||
|
|
@ -856,7 +857,6 @@ spa_v4l2_start (SpaV4l2Source *this)
|
|||
}
|
||||
|
||||
event.type = SPA_EVENT_TYPE_ADD_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &state->poll;
|
||||
event.size = sizeof (state->poll);
|
||||
|
||||
|
|
@ -884,7 +884,6 @@ spa_v4l2_pause (SpaV4l2Source *this)
|
|||
SpaEvent event;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_REMOVE_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &state->poll;
|
||||
event.size = sizeof (state->poll);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,6 @@ spa_volume_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
|
@ -172,7 +171,6 @@ spa_volume_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_PAUSED;
|
||||
|
|
@ -250,7 +248,6 @@ spa_volume_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static SpaResult
|
||||
spa_volume_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
@ -524,9 +521,9 @@ release_buffer (SpaVolume *this, SpaBuffer *buffer)
|
|||
SpaEventReuseBuffer rb;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_REUSE_BUFFER;
|
||||
event.port_id = 0;
|
||||
event.data = &rb;
|
||||
event.size = sizeof (rb);
|
||||
rb.port_id = 0;
|
||||
rb.buffer_id = buffer->id;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,6 @@ spa_xv_sink_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
|
@ -197,7 +196,6 @@ spa_xv_sink_node_send_command (SpaNode *node,
|
|||
SpaEventStateChange sc;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_PAUSED;
|
||||
|
|
@ -273,7 +271,6 @@ spa_xv_sink_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_add_port (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
|
|||
|
|
@ -99,11 +99,12 @@ on_mix_event (SpaNode *node, SpaEvent *event, void *user_data)
|
|||
SpaInputInfo iinfo;
|
||||
SpaOutputInfo oinfo;
|
||||
SpaResult res;
|
||||
SpaEventNeedInput *ni = event->data;
|
||||
|
||||
oinfo.port_id = 0;
|
||||
oinfo.flags = SPA_OUTPUT_FLAG_NONE;
|
||||
|
||||
if (event->port_id == data->mix_ports[0]) {
|
||||
if (ni->port_id == data->mix_ports[0]) {
|
||||
if ((res = spa_node_port_pull_output (data->source1, 1, &oinfo)) < 0)
|
||||
printf ("got error %d\n", res);
|
||||
} else {
|
||||
|
|
@ -111,7 +112,7 @@ on_mix_event (SpaNode *node, SpaEvent *event, void *user_data)
|
|||
printf ("got error %d\n", res);
|
||||
}
|
||||
|
||||
iinfo.port_id = event->port_id;
|
||||
iinfo.port_id = ni->port_id;
|
||||
iinfo.flags = SPA_INPUT_FLAG_NONE;
|
||||
iinfo.buffer_id = oinfo.buffer_id;
|
||||
|
||||
|
|
@ -136,6 +137,7 @@ on_sink_event (SpaNode *node, SpaEvent *event, void *user_data)
|
|||
SpaInputInfo iinfo;
|
||||
SpaOutputInfo oinfo;
|
||||
SpaResult res;
|
||||
SpaEventNeedInput *ni = event->data;
|
||||
|
||||
oinfo.port_id = 0;
|
||||
oinfo.flags = SPA_OUTPUT_FLAG_PULL;
|
||||
|
|
@ -143,7 +145,7 @@ on_sink_event (SpaNode *node, SpaEvent *event, void *user_data)
|
|||
if ((res = spa_node_port_pull_output (data->mix, 1, &oinfo)) < 0)
|
||||
printf ("got error %d\n", res);
|
||||
|
||||
iinfo.port_id = event->port_id;
|
||||
iinfo.port_id = ni->port_id;
|
||||
iinfo.flags = SPA_INPUT_FLAG_NONE;
|
||||
iinfo.buffer_id = oinfo.buffer_id;
|
||||
|
||||
|
|
@ -251,7 +253,7 @@ negotiate_formats (AppData *data)
|
|||
return res;
|
||||
|
||||
data->mix_ports[0] = 0;
|
||||
if ((res = spa_node_add_port (data->mix, SPA_DIRECTION_INPUT, 0)) < 0)
|
||||
if ((res = spa_node_add_port (data->mix, 0)) < 0)
|
||||
return res;
|
||||
|
||||
if ((res = spa_node_port_set_format (data->mix, data->mix_ports[0], false, format)) < 0)
|
||||
|
|
@ -261,7 +263,7 @@ negotiate_formats (AppData *data)
|
|||
return res;
|
||||
|
||||
data->mix_ports[1] = 0;
|
||||
if ((res = spa_node_add_port (data->mix, SPA_DIRECTION_INPUT, 1)) < 0)
|
||||
if ((res = spa_node_add_port (data->mix, 1)) < 0)
|
||||
return res;
|
||||
|
||||
if ((res = spa_node_port_set_format (data->mix, data->mix_ports[1], false, format)) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue