pass the client object around

Pass the client object around, it's easier to deal with than the sender
id.
Fix the ASYNC return check
Don't overwrite the fds of a pollitem, instead keep an index of their
position in the global fd array.
This commit is contained in:
Wim Taymans 2016-09-27 16:59:45 +02:00
parent 7b53fa8685
commit c6861845a7
14 changed files with 123 additions and 79 deletions

View file

@ -99,7 +99,7 @@ struct _SpaAudioTestSrc {
#define DEFAULT_WAVE 0
#define DEFAULT_VOLUME 1.0
#define DEFAULT_FREQ 440.0
#define DEFAULT_LIVE false
#define DEFAULT_LIVE true
static const double min_volume = 0.0;
static const double max_volume = 10.0;
@ -534,6 +534,9 @@ clear_buffers (SpaAudioTestSrc *this)
this->alloc_buffers = NULL;
this->n_buffers = 0;
this->have_buffers = false;
this->info.flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
SPA_QUEUE_INIT (&this->empty);
SPA_QUEUE_INIT (&this->ready);
}
return SPA_RESULT_OK;
}
@ -719,6 +722,9 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
}
this->n_buffers = n_buffers;
this->have_buffers = true;
this->info.flags |= SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
} else {
this->info.flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
}
if (this->have_buffers) {
@ -739,6 +745,7 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
uint32_t *n_buffers)
{
SpaAudioTestSrc *this;
unsigned int i;
if (node == NULL || node->handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -754,7 +761,12 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
if (!this->have_buffers)
return SPA_RESULT_NO_BUFFERS;
return SPA_RESULT_NOT_IMPLEMENTED;
*n_buffers = SPA_MIN (*n_buffers, this->n_buffers);
for (i = 0; i < *n_buffers; i++)
buffers[i] = this->alloc_buffers[i].outbuf;
return SPA_RESULT_OK;
}
static SpaResult