Add port direction again

simplify port numbering again by using 0->max_ports for bot input ports
and output ports. This means we need to tall what direction the port is.
Add port_info serialize functions
Copy metadata and data when we are not sharing buffers.
Make pinossink work again.
This commit is contained in:
Wim Taymans 2016-10-03 19:43:42 +02:00
parent b208e8b690
commit d828073bb8
26 changed files with 1104 additions and 648 deletions

View file

@ -93,6 +93,8 @@ struct _SpaAudioTestSrc {
SpaQueue ready;
};
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
#define DEFAULT_WAVE 0
#define DEFAULT_VOLUME 1.0
#define DEFAULT_FREQ 440.0
@ -470,6 +472,7 @@ 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;
@ -477,6 +480,7 @@ spa_audiotestsrc_node_add_port (SpaNode *node,
static SpaResult
spa_audiotestsrc_node_remove_port (SpaNode *node,
SpaDirection direction,
uint32_t port_id)
{
return SPA_RESULT_NOT_IMPLEMENTED;
@ -484,6 +488,7 @@ spa_audiotestsrc_node_remove_port (SpaNode *node,
static SpaResult
spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaFormat **format,
const SpaFormat *filter,
@ -497,7 +502,7 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
index = (*state == NULL ? 0 : *(int*)state);
@ -535,6 +540,7 @@ clear_buffers (SpaAudioTestSrc *this)
static SpaResult
spa_audiotestsrc_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
@ -547,7 +553,7 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (format == NULL) {
@ -590,6 +596,7 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node,
static SpaResult
spa_audiotestsrc_node_port_get_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaFormat **format)
{
@ -600,7 +607,7 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (!this->have_format)
@ -613,6 +620,7 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
static SpaResult
spa_audiotestsrc_node_port_get_info (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaPortInfo **info)
{
@ -623,7 +631,7 @@ spa_audiotestsrc_node_port_get_info (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
*info = &this->info;
@ -632,15 +640,17 @@ spa_audiotestsrc_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_audiotestsrc_node_port_get_props (SpaNode *node,
uint32_t port_id,
SpaProps **props)
spa_audiotestsrc_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_audiotestsrc_node_port_set_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
{
@ -649,6 +659,7 @@ spa_audiotestsrc_node_port_set_props (SpaNode *node,
static SpaResult
spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaBuffer **buffers,
uint32_t n_buffers)
@ -660,7 +671,7 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (!this->have_format)
@ -716,6 +727,7 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
static SpaResult
spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
uint32_t n_params,
@ -729,7 +741,7 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (!this->have_format)
@ -741,44 +753,9 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node,
uint32_t port_id,
uint32_t buffer_id)
{
SpaAudioTestSrc *this;
ATSBuffer *b;
if (node == NULL || node->handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
return SPA_RESULT_INVALID_PORT;
if (!this->have_buffers)
return SPA_RESULT_NO_BUFFERS;
if (buffer_id >= this->n_buffers)
return SPA_RESULT_INVALID_BUFFER_ID;
b = &this->buffers[buffer_id];
if (!b->outstanding)
return SPA_RESULT_OK;
b->outstanding = false;
b->next = NULL;
SPA_QUEUE_PUSH_TAIL (&this->empty, ATSBuffer, next, b);
if (this->empty.length == 1 && !this->props[1].live)
update_poll_enabled (this, true);
return SPA_RESULT_OK;
}
static SpaResult
spa_audiotestsrc_node_port_get_status (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaPortStatus **status)
{
@ -789,7 +766,7 @@ spa_audiotestsrc_node_port_get_status (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (!this->have_format)
@ -808,6 +785,7 @@ spa_audiotestsrc_node_port_push_input (SpaNode *node,
{
return SPA_RESULT_INVALID_PORT;
}
static SpaResult
spa_audiotestsrc_node_port_pull_output (SpaNode *node,
unsigned int n_info,
@ -854,8 +832,45 @@ spa_audiotestsrc_node_port_pull_output (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node,
uint32_t port_id,
uint32_t buffer_id)
{
SpaAudioTestSrc *this;
ATSBuffer *b;
if (node == NULL || node->handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle;
if (port_id != 0)
return SPA_RESULT_INVALID_PORT;
if (!this->have_buffers)
return SPA_RESULT_NO_BUFFERS;
if (buffer_id >= this->n_buffers)
return SPA_RESULT_INVALID_BUFFER_ID;
b = &this->buffers[buffer_id];
if (!b->outstanding)
return SPA_RESULT_OK;
b->outstanding = false;
b->next = NULL;
SPA_QUEUE_PUSH_TAIL (&this->empty, ATSBuffer, next, b);
if (this->empty.length == 1 && !this->props[1].live)
update_poll_enabled (this, true);
return SPA_RESULT_OK;
}
static SpaResult
spa_audiotestsrc_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
{
@ -883,10 +898,10 @@ static const SpaNode audiotestsrc_node = {
spa_audiotestsrc_node_port_set_props,
spa_audiotestsrc_node_port_use_buffers,
spa_audiotestsrc_node_port_alloc_buffers,
spa_audiotestsrc_node_port_reuse_buffer,
spa_audiotestsrc_node_port_get_status,
spa_audiotestsrc_node_port_push_input,
spa_audiotestsrc_node_port_pull_output,
spa_audiotestsrc_node_port_reuse_buffer,
spa_audiotestsrc_node_port_push_event,
};