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

@ -211,10 +211,10 @@ typedef struct {
PinosClientNodeBuffer *buffers);
void (*node_command) (void *object,
uint32_t seq,
const SpaNodeCommand *command);
const SpaCommand *command);
void (*port_command) (void *object,
uint32_t port_id,
const SpaNodeCommand *command);
const SpaCommand *command);
void (*transport) (void *object,
int memfd,
uint32_t offset,

View file

@ -836,7 +836,7 @@ client_node_demarshal_node_command (void *object,
{
PinosProxy *proxy = object;
SpaPODIter it;
const SpaNodeCommand *command;
const SpaCommand *command;
uint32_t seq;
if (!spa_pod_iter_struct (&it, data, size) ||
@ -857,7 +857,7 @@ client_node_demarshal_port_command (void *object,
{
PinosProxy *proxy = object;
SpaPODIter it;
const SpaNodeCommand *command;
const SpaCommand *command;
uint32_t port_id;
if (!spa_pod_iter_struct (&it, data, size) ||

View file

@ -573,58 +573,45 @@ handle_node_event (PinosStream *stream,
}
static bool
handle_node_command (PinosStream *stream,
uint32_t seq,
const SpaNodeCommand *command)
handle_node_command (PinosStream *stream,
uint32_t seq,
const SpaCommand *command)
{
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
PinosContext *context = stream->context;
switch (SPA_NODE_COMMAND_TYPE (command)) {
case SPA_NODE_COMMAND_INVALID:
break;
case SPA_NODE_COMMAND_PAUSE:
{
pinos_log_debug ("stream %p: pause %d", stream, seq);
if (SPA_COMMAND_TYPE (command) == context->uri.node_commands.Pause) {
pinos_log_debug ("stream %p: pause %d", stream, seq);
add_state_change (stream, SPA_NODE_STATE_PAUSED, false);
add_async_complete (stream, seq, SPA_RESULT_OK, true);
stream_set_state (stream, PINOS_STREAM_STATE_PAUSED, NULL);
break;
}
case SPA_NODE_COMMAND_START:
{
pinos_log_debug ("stream %p: start %d", stream, seq);
add_state_change (stream, SPA_NODE_STATE_STREAMING, false);
add_async_complete (stream, seq, SPA_RESULT_OK, true);
add_state_change (stream, SPA_NODE_STATE_PAUSED, false);
add_async_complete (stream, seq, SPA_RESULT_OK, true);
stream_set_state (stream, PINOS_STREAM_STATE_PAUSED, NULL);
}
else if (SPA_COMMAND_TYPE (command) == context->uri.node_commands.Start) {
pinos_log_debug ("stream %p: start %d", stream, seq);
add_state_change (stream, SPA_NODE_STATE_STREAMING, false);
add_async_complete (stream, seq, SPA_RESULT_OK, true);
if (impl->direction == SPA_DIRECTION_INPUT)
send_need_input (stream);
if (impl->direction == SPA_DIRECTION_INPUT)
send_need_input (stream);
stream_set_state (stream, PINOS_STREAM_STATE_STREAMING, NULL);
break;
}
case SPA_NODE_COMMAND_FLUSH:
case SPA_NODE_COMMAND_DRAIN:
case SPA_NODE_COMMAND_MARKER:
{
pinos_log_warn ("unhandled node command %d", SPA_NODE_COMMAND_TYPE (command));
add_async_complete (stream, seq, SPA_RESULT_NOT_IMPLEMENTED, true);
break;
}
case SPA_NODE_COMMAND_CLOCK_UPDATE:
{
SpaNodeCommandClockUpdate *cu = (SpaNodeCommandClockUpdate *) command;
if (cu->body.flags.value & SPA_NODE_COMMAND_CLOCK_UPDATE_FLAG_LIVE) {
pinos_properties_set (stream->properties,
"pinos.latency.is-live", "1");
pinos_properties_setf (stream->properties,
"pinos.latency.min", "%"PRId64, cu->body.latency.value);
}
impl->last_ticks = cu->body.ticks.value;
impl->last_rate = cu->body.rate.value;
impl->last_monotonic = cu->body.monotonic_time.value;
break;
stream_set_state (stream, PINOS_STREAM_STATE_STREAMING, NULL);
}
else if (SPA_COMMAND_TYPE (command) == context->uri.node_commands.ClockUpdate) {
SpaNodeCommandClockUpdate *cu = (SpaNodeCommandClockUpdate *) command;
if (cu->body.flags.value & SPA_NODE_COMMAND_CLOCK_UPDATE_FLAG_LIVE) {
pinos_properties_set (stream->properties,
"pinos.latency.is-live", "1");
pinos_properties_setf (stream->properties,
"pinos.latency.min", "%"PRId64, cu->body.latency.value);
}
impl->last_ticks = cu->body.ticks.value;
impl->last_rate = cu->body.rate.value;
impl->last_monotonic = cu->body.monotonic_time.value;
}
else {
pinos_log_warn ("unhandled node command %d", SPA_COMMAND_TYPE (command));
add_async_complete (stream, seq, SPA_RESULT_NOT_IMPLEMENTED, true);
}
return true;
}
@ -853,9 +840,9 @@ client_node_use_buffers (void *object,
}
static void
client_node_node_command (void *object,
uint32_t seq,
const SpaNodeCommand *command)
client_node_node_command (void *object,
uint32_t seq,
const SpaCommand *command)
{
PinosProxy *proxy = object;
PinosStream *stream = proxy->user_data;
@ -863,9 +850,9 @@ client_node_node_command (void *object,
}
static void
client_node_port_command (void *object,
uint32_t port_id,
const SpaNodeCommand *command)
client_node_port_command (void *object,
uint32_t port_id,
const SpaCommand *command)
{
pinos_log_warn ("port command not supported");
}

View file

@ -50,4 +50,5 @@ pinos_uri_init (PinosURI *uri)
uri->spa_monitor = spa_id_map_get_id (uri->map, SPA_MONITOR_URI);
spa_node_events_map (uri->map, &uri->node_events);
spa_node_commands_map (uri->map, &uri->node_commands);
}

View file

@ -55,6 +55,7 @@ struct _PinosURI {
uint32_t spa_monitor;
SpaNodeEvents node_events;
SpaNodeCommands node_commands;
};
void pinos_uri_init (PinosURI *uri);