node: remove node state

Remove the node state. The state of the node is based on the state
of the ports, which can be derived directly from calling the port
methods. Track this state in the Port instead.
Add a mixer module that puts a mixer in from of audio sinks. This allows
multiple clients to play on one sink (still has some bugs). do some
fixes in the mixer and the scheduler to make this work.
This commit is contained in:
Wim Taymans 2017-04-08 20:33:54 +02:00
parent 28389e05f3
commit d3682067fa
30 changed files with 618 additions and 509 deletions

View file

@ -47,7 +47,7 @@ typedef struct {
bool have_buffers;
FFMpegBuffer buffers[MAX_BUFFERS];
SpaPortInfo info;
void *io;
SpaPortIO *io;
} SpaFFMpegPort;
typedef struct {
@ -81,6 +81,8 @@ struct _SpaFFMpegDec {
SpaFFMpegPort in_ports[1];
SpaFFMpegPort out_ports[1];
bool started;
};
enum {
@ -101,12 +103,6 @@ spa_ffmpeg_dec_node_set_props (SpaNode *node,
return SPA_RESULT_NOT_IMPLEMENTED;
}
static void
update_state (SpaFFMpegDec *this, SpaNodeState state)
{
this->node.state = state;
}
static SpaResult
spa_ffmpeg_dec_node_send_command (SpaNode *node,
SpaCommand *command)
@ -119,10 +115,10 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
update_state (this, SPA_NODE_STATE_STREAMING);
this->started = true;
}
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
update_state (this, SPA_NODE_STATE_PAUSED);
this->started = false;
}
else
return SPA_RESULT_NOT_IMPLEMENTED;
@ -454,7 +450,6 @@ spa_ffmpeg_dec_node_port_send_command (SpaNode *node,
static const SpaNode ffmpeg_dec_node = {
sizeof (SpaNode),
NULL,
SPA_NODE_STATE_INIT,
spa_ffmpeg_dec_node_get_props,
spa_ffmpeg_dec_node_set_props,
spa_ffmpeg_dec_node_send_command,

View file

@ -86,18 +86,10 @@ struct _SpaFFMpegEnc {
SpaFFMpegPort in_ports[1];
SpaFFMpegPort out_ports[1];
};
enum {
PROP_ID_LAST,
bool started;
};
static void
update_state (SpaFFMpegEnc *this, SpaNodeState state)
{
this->node.state = state;
}
static SpaResult
spa_ffmpeg_enc_node_get_props (SpaNode *node,
SpaProps **props)
@ -124,10 +116,10 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
update_state (this, SPA_NODE_STATE_STREAMING);
this->started = true;
}
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
update_state (this, SPA_NODE_STATE_PAUSED);
this->started = false;
}
else
return SPA_RESULT_NOT_IMPLEMENTED;
@ -461,7 +453,6 @@ spa_ffmpeg_enc_node_process_output (SpaNode *node)
static const SpaNode ffmpeg_enc_node = {
sizeof (SpaNode),
NULL,
SPA_NODE_STATE_INIT,
spa_ffmpeg_enc_node_get_props,
spa_ffmpeg_enc_node_set_props,
spa_ffmpeg_enc_node_send_command,
@ -534,7 +525,5 @@ spa_ffmpeg_enc_init (SpaHandle *handle,
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
this->node.state = SPA_NODE_STATE_CONFIGURE;
return SPA_RESULT_OK;
}