command: make commands dynamic

Ensure format object type.
This commit is contained in:
Wim Taymans 2017-03-22 10:04:24 +01:00
parent 4d9f2c5161
commit c44a7c9735
36 changed files with 549 additions and 604 deletions

View file

@ -185,11 +185,12 @@ send_have_output (SpaProxy *this)
}
static SpaResult
spa_proxy_node_send_command (SpaNode *node,
SpaNodeCommand *command)
spa_proxy_node_send_command (SpaNode *node,
SpaCommand *command)
{
SpaProxy *this;
SpaResult res = SPA_RESULT_OK;
PinosCore *core;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -199,30 +200,22 @@ spa_proxy_node_send_command (SpaNode *node,
if (this->resource == NULL)
return SPA_RESULT_OK;
switch (SPA_NODE_COMMAND_TYPE (command)) {
case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND;
core = this->pnode->core;
case SPA_NODE_COMMAND_START:
case SPA_NODE_COMMAND_PAUSE:
case SPA_NODE_COMMAND_FLUSH:
case SPA_NODE_COMMAND_DRAIN:
case SPA_NODE_COMMAND_MARKER:
/* send start */
pinos_client_node_notify_node_command (this->resource,
this->seq,
command);
if (SPA_NODE_COMMAND_TYPE (command) == SPA_NODE_COMMAND_START)
send_need_input (this);
if (SPA_COMMAND_TYPE (command) == core->uri.node_commands.ClockUpdate) {
pinos_client_node_notify_node_command (this->resource,
this->seq++,
command);
}
else {
/* send start */
pinos_client_node_notify_node_command (this->resource,
this->seq,
command);
if (SPA_COMMAND_TYPE (command) == core->uri.node_commands.Start)
send_need_input (this);
res = SPA_RESULT_RETURN_ASYNC (this->seq++);
break;
case SPA_NODE_COMMAND_CLOCK_UPDATE:
pinos_client_node_notify_node_command (this->resource,
this->seq++,
command);
break;
res = SPA_RESULT_RETURN_ASYNC (this->seq++);
}
return res;
}
@ -790,33 +783,17 @@ static SpaResult
spa_proxy_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
SpaCommand *command)
{
SpaProxy *this;
SpaResult res = SPA_RESULT_OK;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
switch (SPA_NODE_COMMAND_TYPE (command)) {
case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND;
case SPA_NODE_COMMAND_START:
case SPA_NODE_COMMAND_PAUSE:
case SPA_NODE_COMMAND_FLUSH:
case SPA_NODE_COMMAND_DRAIN:
case SPA_NODE_COMMAND_MARKER:
break;
default:
spa_log_warn (this->log, "unhandled command %d", SPA_NODE_COMMAND_TYPE (command));
res = SPA_RESULT_NOT_IMPLEMENTED;
break;
}
return res;
spa_log_warn (this->log, "unhandled command %d", SPA_COMMAND_TYPE (command));
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult

View file

@ -21,6 +21,8 @@
#include <stdlib.h>
#include <errno.h>
#include "spa/include/spa/node-command.h"
#include "pinos/client/pinos.h"
#include "pinos/client/interfaces.h"
@ -167,7 +169,7 @@ pause_node (PinosNode *this)
pinos_log_debug ("node %p: pause node", this);
{
SpaNodeCommand cmd = SPA_NODE_COMMAND_INIT (SPA_NODE_COMMAND_PAUSE);
SpaCommand cmd = SPA_COMMAND_INIT (this->core->uri.node_commands.Pause);
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
pinos_log_debug ("got error %d", res);
}
@ -181,7 +183,7 @@ start_node (PinosNode *this)
pinos_log_debug ("node %p: start node", this);
{
SpaNodeCommand cmd = SPA_NODE_COMMAND_INIT (SPA_NODE_COMMAND_START);
SpaCommand cmd = SPA_COMMAND_INIT (this->core->uri.node_commands.Start);
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
pinos_log_debug ("got error %d", res);
}
@ -224,6 +226,7 @@ send_clock_update (PinosNode *this)
SpaResult res;
SpaNodeCommandClockUpdate cu =
SPA_NODE_COMMAND_CLOCK_UPDATE_INIT(
this->core->uri.node_commands.ClockUpdate,
SPA_NODE_COMMAND_CLOCK_UPDATE_TIME |
SPA_NODE_COMMAND_CLOCK_UPDATE_SCALE |
SPA_NODE_COMMAND_CLOCK_UPDATE_STATE |
@ -245,7 +248,7 @@ send_clock_update (PinosNode *this)
&cu.body.monotonic_time.value);
}
if ((res = spa_node_send_command (this->node, (SpaNodeCommand *)&cu)) < 0)
if ((res = spa_node_send_command (this->node, (SpaCommand *)&cu)) < 0)
pinos_log_debug ("got error %d", res);
}

View file

@ -29,6 +29,7 @@ extern "C" {
typedef struct _PinosNode PinosNode;
#include <spa/include/spa/clock.h>
#include <spa/include/spa/node.h>
#include <pinos/client/mem.h>

View file

@ -206,7 +206,7 @@ no_mem:
static SpaResult
pinos_port_pause (PinosPort *port)
{
SpaNodeCommand cmd = SPA_NODE_COMMAND_INIT (SPA_NODE_COMMAND_PAUSE);
SpaCommand cmd = SPA_COMMAND_INIT (port->node->core->uri.node_commands.Pause);
return spa_node_port_send_command (port->node->node,
port->direction,
port->port_id,

View file

@ -742,9 +742,9 @@ client_node_marshal_use_buffers (void *object,
}
static void
client_node_marshal_node_command (void *object,
uint32_t seq,
const SpaNodeCommand *command)
client_node_marshal_node_command (void *object,
uint32_t seq,
const SpaCommand *command)
{
PinosResource *resource = object;
PinosConnection *connection = resource->client->protocol_private;
@ -761,9 +761,9 @@ client_node_marshal_node_command (void *object,
}
static void
client_node_marshal_port_command (void *object,
uint32_t port_id,
const SpaNodeCommand *command)
client_node_marshal_port_command (void *object,
uint32_t port_id,
const SpaCommand *command)
{
PinosResource *resource = object;
PinosConnection *connection = resource->client->protocol_private;