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

@ -63,11 +63,13 @@ typedef struct {
typedef struct {
uint32_t node;
uint32_t format;
SpaMediaTypes media_types;
SpaMediaSubtypes media_subtypes;
SpaPropAudio prop_audio;
SpaAudioFormats audio_formats;
SpaNodeEvents node_events;
SpaNodeCommands node_commands;
} URI;
struct _SpaVolume {
@ -178,8 +180,8 @@ spa_volume_node_set_props (SpaNode *node,
}
static SpaResult
spa_volume_node_send_command (SpaNode *node,
SpaNodeCommand *command)
spa_volume_node_send_command (SpaNode *node,
SpaCommand *command)
{
SpaVolume *this;
@ -188,24 +190,15 @@ spa_volume_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaVolume, node);
switch (SPA_NODE_COMMAND_TYPE (command)) {
case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND;
case SPA_NODE_COMMAND_START:
update_state (this, SPA_NODE_STATE_STREAMING);
break;
case SPA_NODE_COMMAND_PAUSE:
update_state (this, SPA_NODE_STATE_PAUSED);
break;
case SPA_NODE_COMMAND_FLUSH:
case SPA_NODE_COMMAND_DRAIN:
case SPA_NODE_COMMAND_MARKER:
case SPA_NODE_COMMAND_CLOCK_UPDATE:
return SPA_RESULT_NOT_IMPLEMENTED;
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
update_state (this, SPA_NODE_STATE_STREAMING);
}
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
update_state (this, SPA_NODE_STATE_PAUSED);
}
else
return SPA_RESULT_NOT_IMPLEMENTED;
return SPA_RESULT_OK;
}
@ -312,7 +305,7 @@ next:
switch (index++) {
case 0:
spa_pod_builder_format (&b, &f[0],
spa_pod_builder_format (&b, &f[0], this->uri.format,
this->uri.media_types.audio, this->uri.media_subtypes.raw,
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3,
this->uri.audio_formats.S16,
@ -629,7 +622,7 @@ static SpaResult
spa_volume_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
SpaCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -844,10 +837,13 @@ volume_init (const SpaHandleFactory *factory,
return SPA_RESULT_ERROR;
}
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->uri.format = spa_id_map_get_id (this->map, SPA_FORMAT_URI);
spa_media_types_fill (&this->uri.media_types, this->map);
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
spa_prop_audio_map (this->map, &this->uri.prop_audio);
spa_audio_formats_map (this->map, &this->uri.audio_formats);
spa_node_events_map (this->map, &this->uri.node_events);
spa_node_commands_map (this->map, &this->uri.node_commands);
this->node = volume_node;
reset_volume_props (&this->props);