plugins: use macros for input checks

That way we can compile them out if we want
This commit is contained in:
Wim Taymans 2017-04-04 09:00:49 +02:00
parent 32368d741d
commit b05d82d514
16 changed files with 296 additions and 415 deletions

View file

@ -302,8 +302,7 @@ spa_alsa_monitor_set_event_callback (SpaMonitor *monitor,
SpaResult res;
SpaALSAMonitor *this;
if (monitor == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (monitor, SpaALSAMonitor, monitor);
@ -346,8 +345,8 @@ spa_alsa_monitor_enum_items (SpaMonitor *monitor,
SpaALSAMonitor *this;
struct udev_device *dev;
if (monitor == NULL || item == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (item != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (monitor, SpaALSAMonitor, monitor);
@ -404,8 +403,8 @@ spa_alsa_monitor_get_interface (SpaHandle *handle,
{
SpaALSAMonitor *this;
if (handle == NULL || interface == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaALSAMonitor *) handle;
@ -433,8 +432,8 @@ alsa_monitor_init (const SpaHandleFactory *factory,
SpaALSAMonitor *this;
uint32_t i;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_alsa_monitor_get_interface;
handle->clear = alsa_monitor_clear,
@ -475,8 +474,8 @@ alsa_monitor_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (index < 0 || index >= SPA_N_ELEMENTS (alsa_monitor_interfaces))
return SPA_RESULT_ENUM_END;

View file

@ -68,8 +68,8 @@ spa_alsa_sink_node_get_props (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
@ -92,8 +92,7 @@ spa_alsa_sink_node_set_props (SpaNode *node,
{
SpaALSASink *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
@ -165,8 +164,8 @@ spa_alsa_sink_node_send_command (SpaNode *node,
{
SpaALSASink *this;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
@ -197,8 +196,7 @@ spa_alsa_sink_node_set_event_callback (SpaNode *node,
{
SpaALSASink *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
@ -215,8 +213,7 @@ spa_alsa_sink_node_get_n_ports (SpaNode *node,
uint32_t *n_output_ports,
uint32_t *max_output_ports)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports)
*n_input_ports = 1;
@ -237,8 +234,7 @@ spa_alsa_sink_node_get_port_ids (SpaNode *node,
uint32_t n_output_ports,
uint32_t *output_ids)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports > 0 && input_ids != NULL)
input_ids[0] = 0;
@ -278,13 +274,12 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
@ -341,13 +336,11 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (format == NULL) {
spa_log_info (this->log, "clear format");
@ -420,13 +413,12 @@ spa_alsa_sink_node_port_get_format (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -451,13 +443,12 @@ spa_alsa_sink_node_port_get_info (SpaNode *node,
{
SpaALSASink *this;
if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
*info = &this->info;
@ -492,14 +483,12 @@ spa_alsa_sink_node_port_use_buffers (SpaNode *node,
SpaALSASink *this;
int i;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
spa_log_info (this->log, "use buffers %d", n_buffers);
if (!this->have_format)
@ -553,14 +542,13 @@ spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
{
SpaALSASink *this;
if (node == NULL || buffers == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -575,13 +563,11 @@ spa_alsa_sink_node_port_set_io (SpaNode *node,
{
SpaALSASink *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
this->io = io;
@ -605,13 +591,11 @@ spa_alsa_sink_node_port_send_command (SpaNode *node,
SpaALSASink *this;
SpaResult res;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (port_id != 0)
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
@ -636,8 +620,7 @@ spa_alsa_sink_node_process_input (SpaNode *node)
SpaPortIO *input;
SpaALSABuffer *b;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
@ -677,7 +660,7 @@ spa_alsa_sink_node_process_input (SpaNode *node)
static SpaResult
spa_alsa_sink_node_process_output (SpaNode *node)
{
return SPA_RESULT_INVALID_PORT;
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -715,8 +698,8 @@ spa_alsa_sink_get_interface (SpaHandle *handle,
{
SpaALSASink *this;
if (handle == NULL || interface == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaALSASink *) handle;
@ -744,8 +727,8 @@ alsa_sink_init (const SpaHandleFactory *factory,
SpaALSASink *this;
uint32_t i;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_alsa_sink_get_interface;
handle->clear = alsa_sink_clear;
@ -803,8 +786,8 @@ alsa_sink_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -69,8 +69,8 @@ spa_alsa_source_node_get_props (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
@ -93,8 +93,7 @@ spa_alsa_source_node_set_props (SpaNode *node,
{
SpaALSASource *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
@ -188,8 +187,8 @@ spa_alsa_source_node_send_command (SpaNode *node,
{
SpaALSASource *this;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
@ -234,8 +233,7 @@ spa_alsa_source_node_set_event_callback (SpaNode *node,
{
SpaALSASource *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
@ -252,8 +250,7 @@ spa_alsa_source_node_get_n_ports (SpaNode *node,
uint32_t *n_output_ports,
uint32_t *max_output_ports)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports)
*n_input_ports = 0;
@ -274,8 +271,7 @@ spa_alsa_source_node_get_port_ids (SpaNode *node,
uint32_t n_output_ports,
uint32_t *output_ids)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_output_ports > 0 && output_ids != NULL)
output_ids[0] = 0;
@ -315,13 +311,12 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
@ -360,6 +355,8 @@ recycle_buffer (SpaALSASource *this, uint32_t buffer_id)
{
SpaALSABuffer *b;
spa_log_trace (this->log, "alsa-source %p: recycle buffer %u", this, buffer_id);
b = &this->buffers[buffer_id];
spa_return_if_fail (b->outstanding);
@ -389,13 +386,11 @@ spa_alsa_source_node_port_set_format (SpaNode *node,
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (format == NULL) {
spa_alsa_pause (this, false);
@ -460,13 +455,12 @@ spa_alsa_source_node_port_get_format (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -491,13 +485,12 @@ spa_alsa_source_node_port_get_info (SpaNode *node,
{
SpaALSASource *this;
if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
*info = &this->info;
@ -533,14 +526,12 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
SpaResult res;
int i;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -592,14 +583,13 @@ spa_alsa_source_node_port_alloc_buffers (SpaNode *node,
{
SpaALSASource *this;
if (node == NULL || buffers == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (this->n_buffers == 0)
return SPA_RESULT_NO_FORMAT;
@ -614,13 +604,11 @@ spa_alsa_source_node_port_set_io (SpaNode *node,
{
SpaALSASource *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
this->io = io;
@ -634,13 +622,11 @@ spa_alsa_source_node_port_reuse_buffer (SpaNode *node,
{
SpaALSASource *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (port_id != 0)
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (port_id == 0, SPA_RESULT_INVALID_PORT);
if (this->n_buffers == 0)
return SPA_RESULT_NO_BUFFERS;
@ -648,7 +634,6 @@ spa_alsa_source_node_port_reuse_buffer (SpaNode *node,
if (buffer_id >= this->n_buffers)
return SPA_RESULT_INVALID_BUFFER_ID;
spa_log_trace (this->log, "recycle buffer %u", buffer_id);
recycle_buffer (this, buffer_id);
return SPA_RESULT_OK;
@ -663,13 +648,11 @@ spa_alsa_source_node_port_send_command (SpaNode *node,
SpaALSASource *this;
SpaResult res;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (port_id != 0)
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
@ -757,8 +740,7 @@ spa_alsa_source_clock_get_time (SpaClock *clock,
{
SpaALSASource *this;
if (clock == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (clock, SpaALSASource, clock);
@ -788,8 +770,8 @@ spa_alsa_source_get_interface (SpaHandle *handle,
{
SpaALSASource *this;
if (handle == NULL || interface == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaALSASource *) handle;
@ -819,8 +801,8 @@ alsa_source_init (const SpaHandleFactory *factory,
SpaALSASource *this;
uint32_t i;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_alsa_source_get_interface;
handle->clear = alsa_source_clear;
@ -881,8 +863,8 @@ alsa_source_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (index < 0 || index >= SPA_N_ELEMENTS (alsa_source_interfaces))
return SPA_RESULT_ENUM_END;

View file

@ -408,19 +408,19 @@ calc_timeout (size_t target,
snd_htimestamp_t *now,
struct timespec *ts)
{
size_t to_sleep_usec;
size_t to_sleep_nsec;
ts->tv_sec = now->tv_sec;
if (target > current)
to_sleep_usec = (target - current) * 1000000 / rate;
to_sleep_nsec = (target - current) * SPA_NSEC_PER_SEC / rate;
else
to_sleep_usec = 0;
to_sleep_nsec = 0;
ts->tv_nsec = to_sleep_usec * 1000 + now->tv_nsec;
ts->tv_nsec = to_sleep_nsec + now->tv_nsec;
while (ts->tv_nsec > 1000000000L) {
while (ts->tv_nsec > SPA_NSEC_PER_SEC) {
ts->tv_sec++;
ts->tv_nsec -= 1000000000L;
ts->tv_nsec -= SPA_NSEC_PER_SEC;
}
}
@ -505,7 +505,7 @@ alsa_on_playback_timeout_event (SpaSource *source)
calc_timeout (total_written + filled, state->threshold, state->rate, &htstamp, &ts.it_value);
spa_log_debug (state->log, "timeout %ld %ld %ld %ld", total_written, filled,
spa_log_trace (state->log, "timeout %ld %ld %ld %ld", total_written, filled,
ts.it_value.tv_sec, ts.it_value.tv_nsec);
ts.it_interval.tv_sec = 0;
@ -580,7 +580,8 @@ alsa_on_capture_timeout_event (SpaSource *source)
}
calc_timeout (state->threshold, avail - total_read, state->rate, &htstamp, &ts.it_value);
// printf ("timeout %ld %ld %ld %ld\n", total_read, avail, ts.it_value.tv_sec, ts.it_value.tv_nsec);
spa_log_trace (state->log, "timeout %ld %ld %ld %ld", total_read, avail,
ts.it_value.tv_sec, ts.it_value.tv_nsec);
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 0;
timerfd_settime (state->timerfd, TFD_TIMER_ABSTIME, &ts, NULL);

View file

@ -28,8 +28,7 @@ SpaResult
spa_enum_handle_factory (const SpaHandleFactory **factory,
uint32_t index)
{
if (factory == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -128,8 +128,8 @@ spa_audiomixer_node_send_command (SpaNode *node,
{
SpaAudioMixer *this;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
@ -152,8 +152,7 @@ spa_audiomixer_node_set_event_callback (SpaNode *node,
{
SpaAudioMixer *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
@ -170,8 +169,7 @@ spa_audiomixer_node_get_n_ports (SpaNode *node,
uint32_t *n_output_ports,
uint32_t *max_output_ports)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports)
*n_input_ports = 0;
@ -195,8 +193,7 @@ spa_audiomixer_node_get_port_ids (SpaNode *node,
SpaAudioMixer *this;
int i, idx;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
@ -219,13 +216,11 @@ spa_audiomixer_node_add_port (SpaNode *node,
{
SpaAudioMixer *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_FREE_IN_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_FREE_IN_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
this->in_ports[port_id].valid = true;
this->port_count++;
@ -246,13 +241,11 @@ spa_audiomixer_node_remove_port (SpaNode *node,
SpaAudioMixer *this;
SpaPortIO *io;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_IN_PORT (this, SPA_DIRECTION_INPUT, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_IN_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
this->in_ports[port_id].valid = false;
this->port_count--;
@ -276,13 +269,12 @@ spa_audiomixer_node_port_enum_formats (SpaNode *node,
{
SpaAudioMixer *this;
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
switch (index) {
case 0:
@ -316,13 +308,11 @@ spa_audiomixer_node_port_set_format (SpaNode *node,
SpaAudioMixer *this;
SpaAudioMixerPort *port;
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[0];
@ -362,13 +352,12 @@ spa_audiomixer_node_port_get_format (SpaNode *node,
SpaAudioMixer *this;
SpaAudioMixerPort *port;
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[0];
@ -389,13 +378,12 @@ spa_audiomixer_node_port_get_info (SpaNode *node,
SpaAudioMixer *this;
SpaAudioMixerPort *port;
if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[0];
*info = &port->info;
@ -498,13 +486,11 @@ spa_audiomixer_node_port_set_io (SpaNode *node,
SpaAudioMixer *this;
SpaAudioMixerPort *port;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port->io = io;
@ -735,8 +721,8 @@ spa_audiomixer_get_interface (SpaHandle *handle,
{
SpaAudioMixer *this;
if (handle == NULL || interface == 0)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaAudioMixer *) handle;
@ -764,8 +750,8 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
SpaAudioMixer *this;
uint32_t i;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_audiomixer_get_interface;
handle->clear = spa_audiomixer_clear;
@ -804,8 +790,8 @@ audiomixer_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -26,8 +26,7 @@ SpaResult
spa_enum_handle_factory (const SpaHandleFactory **factory,
uint32_t index)
{
if (factory == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -183,8 +183,8 @@ spa_audiotestsrc_node_get_props (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
@ -210,8 +210,7 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
{
SpaAudioTestSrc *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
@ -237,7 +236,6 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
static SpaResult
send_have_output (SpaAudioTestSrc *this)
{
if (this->event_cb) {
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
this->event_cb (&this->node, &event, this->user_data);
@ -339,8 +337,8 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
{
SpaAudioTestSrc *this;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
@ -395,8 +393,7 @@ spa_audiotestsrc_node_set_event_callback (SpaNode *node,
{
SpaAudioTestSrc *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
@ -413,8 +410,7 @@ spa_audiotestsrc_node_get_n_ports (SpaNode *node,
uint32_t *n_output_ports,
uint32_t *max_output_ports)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports)
*n_input_ports = 0;
@ -435,8 +431,7 @@ spa_audiotestsrc_node_get_port_ids (SpaNode *node,
uint32_t n_output_ports,
uint32_t *output_ids)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_output_ports > 0 && output_ids != NULL)
output_ids[0] = 0;
@ -475,13 +470,12 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
@ -535,13 +529,11 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node,
{
SpaAudioTestSrc *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (format == NULL) {
this->have_format = false;
@ -617,13 +609,12 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -648,13 +639,12 @@ spa_audiotestsrc_node_port_get_info (SpaNode *node,
{
SpaAudioTestSrc *this;
if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
*info = &this->info;
@ -689,13 +679,11 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
SpaAudioTestSrc *this;
uint32_t i;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -747,13 +735,11 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
{
SpaAudioTestSrc *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -900,8 +886,7 @@ spa_audiotestsrc_clock_get_time (SpaClock *clock,
struct timespec now;
uint64_t tnow;
if (clock == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (rate)
*rate = SPA_NSEC_PER_SEC;
@ -933,8 +918,8 @@ spa_audiotestsrc_get_interface (SpaHandle *handle,
{
SpaAudioTestSrc *this;
if (handle == NULL || interface == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaAudioTestSrc *) handle;
@ -953,8 +938,7 @@ audiotestsrc_clear (SpaHandle *handle)
{
SpaAudioTestSrc *this;
if (handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaAudioTestSrc *) handle;
@ -975,8 +959,8 @@ audiotestsrc_init (const SpaHandleFactory *factory,
uint32_t i;
const char *str;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_audiotestsrc_get_interface;
handle->clear = audiotestsrc_clear;
@ -1048,8 +1032,8 @@ audiotestsrc_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -26,8 +26,7 @@ SpaResult
spa_enum_handle_factory (const SpaHandleFactory **factory,
uint32_t index)
{
if (factory == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -235,8 +235,7 @@ spa_v4l2_monitor_set_event_callback (SpaMonitor *monitor,
SpaResult res;
SpaV4l2Monitor *this;
if (monitor == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (monitor, SpaV4l2Monitor, monitor);
@ -278,8 +277,8 @@ spa_v4l2_monitor_enum_items (SpaMonitor *monitor,
SpaV4l2Monitor *this;
struct udev_device *dev;
if (monitor == NULL || item == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (item != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (monitor, SpaV4l2Monitor, monitor);
@ -335,8 +334,8 @@ spa_v4l2_monitor_get_interface (SpaHandle *handle,
{
SpaV4l2Monitor *this;
if (handle == NULL || interface == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaV4l2Monitor *) handle;
@ -364,8 +363,8 @@ v4l2_monitor_init (const SpaHandleFactory *factory,
SpaV4l2Monitor *this;
uint32_t i;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_v4l2_monitor_get_interface;
handle->clear = v4l2_monitor_clear,
@ -405,8 +404,8 @@ v4l2_monitor_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (index < 0 || index >= SPA_N_ELEMENTS (v4l2_monitor_interfaces))
return SPA_RESULT_ENUM_END;

View file

@ -196,8 +196,8 @@ spa_v4l2_source_node_get_props (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
@ -217,8 +217,7 @@ spa_v4l2_source_node_set_props (SpaNode *node,
{
SpaV4l2Source *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
@ -345,8 +344,8 @@ spa_v4l2_source_node_send_command (SpaNode *node,
{
SpaV4l2Source *this;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
@ -406,8 +405,7 @@ spa_v4l2_source_node_set_event_callback (SpaNode *node,
{
SpaV4l2Source *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
@ -424,8 +422,7 @@ spa_v4l2_source_node_get_n_ports (SpaNode *node,
uint32_t *n_output_ports,
uint32_t *max_output_ports)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports)
*n_input_ports = 0;
@ -446,8 +443,7 @@ spa_v4l2_source_node_get_port_ids (SpaNode *node,
uint32_t n_output_ports,
uint32_t *output_ids)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_output_ports > 0 && output_ids != NULL)
output_ids[0] = 0;
@ -483,13 +479,12 @@ spa_v4l2_source_node_port_enum_formats (SpaNode *node,
SpaV4l2Source *this;
SpaResult res;
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
res = spa_v4l2_enum_format (this, format, filter, index);
@ -507,13 +502,11 @@ spa_v4l2_source_node_port_set_format (SpaNode *node,
SpaV4l2State *state;
SpaVideoInfo info;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
state = &this->state[port_id];
@ -596,13 +589,12 @@ spa_v4l2_source_node_port_get_format (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
state = &this->state[port_id];
@ -653,13 +645,12 @@ spa_v4l2_source_node_port_get_info (SpaNode *node,
{
SpaV4l2Source *this;
if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
*info = &this->state[port_id].info;
@ -695,13 +686,11 @@ spa_v4l2_source_node_port_use_buffers (SpaNode *node,
SpaV4l2State *state;
SpaResult res;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
state = &this->state[port_id];
@ -739,13 +728,12 @@ spa_v4l2_source_node_port_alloc_buffers (SpaNode *node,
SpaV4l2State *state;
SpaResult res;
if (node == NULL || buffers == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
state = &this->state[port_id];
@ -772,13 +760,11 @@ spa_v4l2_source_node_port_set_io (SpaNode *node,
{
SpaV4l2Source *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
this->state[port_id].io = io;
@ -817,13 +803,11 @@ spa_v4l2_source_node_port_send_command (SpaNode *node,
SpaV4l2Source *this;
SpaResult res;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (port_id != 0)
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
res = spa_v4l2_port_set_enabled (this, false);
@ -840,7 +824,7 @@ spa_v4l2_source_node_port_send_command (SpaNode *node,
static SpaResult
spa_v4l2_source_node_process_input (SpaNode *node)
{
return SPA_RESULT_INVALID_PORT;
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
@ -850,8 +834,7 @@ spa_v4l2_source_node_process_output (SpaNode *node)
SpaResult res = SPA_RESULT_OK;
SpaPortIO *io;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
@ -914,8 +897,7 @@ spa_v4l2_source_clock_get_time (SpaClock *clock,
SpaV4l2Source *this;
SpaV4l2State *state;
if (clock == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (clock, SpaV4l2Source, clock);
state = &this->state[0];
@ -946,8 +928,8 @@ spa_v4l2_source_get_interface (SpaHandle *handle,
{
SpaV4l2Source *this;
if (handle == NULL || interface == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaV4l2Source *) handle;
@ -978,8 +960,8 @@ v4l2_source_init (const SpaHandleFactory *factory,
uint32_t i;
const char *str;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_v4l2_source_get_interface;
handle->clear = v4l2_source_clear,
@ -1040,8 +1022,8 @@ v4l2_source_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (index < 0 || index >= SPA_N_ELEMENTS (v4l2_source_interfaces))
return SPA_RESULT_ENUM_END;

View file

@ -27,8 +27,7 @@ SpaResult
spa_enum_handle_factory (const SpaHandleFactory **factory,
uint32_t index)
{
if (factory == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -26,8 +26,7 @@ SpaResult
spa_enum_handle_factory (const SpaHandleFactory **factory,
uint32_t index)
{
if (factory == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -92,8 +92,6 @@ struct _VTSBuffer {
SpaBuffer *outbuf;
bool outstanding;
SpaMetaHeader *h;
void *ptr;
size_t stride;
SpaList link;
};
@ -120,13 +118,13 @@ struct _SpaVideoTestSrc {
SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024];
int stride;
SpaPortIO *io;
bool have_format;
SpaVideoInfo current_format;
uint8_t format_buffer[1024];
size_t bpp;
int stride;
VTSBuffer buffers[MAX_BUFFERS];
uint32_t n_buffers;
@ -172,8 +170,8 @@ spa_videotestsrc_node_get_props (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
@ -196,8 +194,7 @@ spa_videotestsrc_node_set_props (SpaNode *node,
{
SpaVideoTestSrc *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
@ -221,7 +218,6 @@ spa_videotestsrc_node_set_props (SpaNode *node,
static SpaResult
send_have_output (SpaVideoTestSrc *this)
{
if (this->event_cb) {
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
this->event_cb (&this->node, &event, this->user_data);
@ -234,7 +230,7 @@ send_have_output (SpaVideoTestSrc *this)
static SpaResult
fill_buffer (SpaVideoTestSrc *this, VTSBuffer *b)
{
return draw (this, b->ptr);
return draw (this, b->outbuf->datas[0].data);
}
static void
@ -260,8 +256,9 @@ static SpaResult
videotestsrc_make_buffer (SpaVideoTestSrc *this)
{
VTSBuffer *b;
SpaPortIO *io;
SpaPortIO *io = this->io;
uint64_t expirations;
int n_bytes;
if (read (this->timer_source.fd, &expirations, sizeof (uint64_t)) < sizeof (uint64_t))
perror ("read timerfd");
@ -273,10 +270,17 @@ videotestsrc_make_buffer (SpaVideoTestSrc *this)
b = spa_list_first (&this->empty, VTSBuffer, link);
spa_list_remove (&b->link);
b->outstanding = true;
n_bytes = b->outbuf->datas[0].maxsize;
spa_log_trace (this->log, "videotestsrc %p: dequeue buffer %d", this, b->outbuf->id);
fill_buffer (this, b);
b->outbuf->datas[0].chunk->offset = 0;
b->outbuf->datas[0].chunk->size = n_bytes;
b->outbuf->datas[0].chunk->stride = this->stride;
if (b->h) {
b->h->seq = this->frame_count;
b->h->pts = this->start_time + this->elapsed_time;
@ -287,10 +291,10 @@ videotestsrc_make_buffer (SpaVideoTestSrc *this)
this->elapsed_time = FRAMES_TO_TIME (this, this->frame_count);
set_timer (this, true);
if ((io = this->io)) {
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_OK;
}
io->flags = 0;
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_OK;
return SPA_RESULT_HAVE_OUTPUT;
}
@ -318,8 +322,8 @@ spa_videotestsrc_node_send_command (SpaNode *node,
{
SpaVideoTestSrc *this;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
@ -374,8 +378,7 @@ spa_videotestsrc_node_set_event_callback (SpaNode *node,
{
SpaVideoTestSrc *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
@ -392,8 +395,7 @@ spa_videotestsrc_node_get_n_ports (SpaNode *node,
uint32_t *n_output_ports,
uint32_t *max_output_ports)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports)
*n_input_ports = 0;
@ -414,8 +416,7 @@ spa_videotestsrc_node_get_port_ids (SpaNode *node,
uint32_t n_output_ports,
uint32_t *output_ids)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_output_ports > 0 && output_ids != NULL)
output_ids[0] = 0;
@ -454,13 +455,12 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
@ -519,13 +519,11 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
{
SpaVideoTestSrc *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (format == NULL) {
this->have_format = false;
@ -541,6 +539,15 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
if (!spa_format_video_raw_parse (format, &info.info.raw, &this->type.format_video))
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (info.info.raw.format == this->type.video_format.RGB) {
this->bpp = 3;
}
else if (info.info.raw.format == this->type.video_format.UYVY) {
this->bpp = 2;
}
else
return SPA_RESULT_NOT_IMPLEMENTED;
this->current_format = info;
this->have_format = true;
}
@ -550,21 +557,11 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
if (raw_info->format == this->type.video_format.RGB) {
this->bpp = 3;
}
else if (raw_info->format == this->type.video_format.UYVY) {
this->bpp = 2;
}
else
return SPA_RESULT_NOT_IMPLEMENTED;
this->info.maxbuffering = -1;
this->info.latency = 0;
this->info.maxbuffering = -1;
this->info.n_params = 2;
this->info.params = this->params;
this->stride = SPA_ROUND_UP_N (this->bpp * raw_info->size.width, 4);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
@ -598,13 +595,12 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -628,13 +624,12 @@ spa_videotestsrc_node_port_get_info (SpaNode *node,
{
SpaVideoTestSrc *this;
if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
*info = &this->info;
@ -669,13 +664,11 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
SpaVideoTestSrc *this;
uint32_t i;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -699,8 +692,6 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
spa_log_error (this->log, "videotestsrc %p: invalid memory on buffer %p", this, buffers[i]);
continue;
}
b->ptr = SPA_MEMBER (d[0].data, d[0].chunk->offset, void);
b->stride = d[0].chunk->stride;
break;
default:
break;
@ -729,13 +720,11 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
{
SpaVideoTestSrc *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
@ -882,8 +871,7 @@ spa_videotestsrc_clock_get_time (SpaClock *clock,
struct timespec now;
uint64_t tnow;
if (clock == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (rate)
*rate = SPA_NSEC_PER_SEC;
@ -915,8 +903,8 @@ spa_videotestsrc_get_interface (SpaHandle *handle,
{
SpaVideoTestSrc *this;
if (handle == NULL || interface == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaVideoTestSrc *) handle;
@ -935,8 +923,7 @@ videotestsrc_clear (SpaHandle *handle)
{
SpaVideoTestSrc *this;
if (handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaVideoTestSrc *) handle;
@ -957,8 +944,8 @@ videotestsrc_init (const SpaHandleFactory *factory,
uint32_t i;
const char *str;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_videotestsrc_get_interface;
handle->clear = videotestsrc_clear;
@ -1030,8 +1017,8 @@ videotestsrc_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -26,8 +26,7 @@ SpaResult
spa_enum_handle_factory (const SpaHandleFactory **factory,
uint32_t index)
{
if (factory == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:

View file

@ -155,8 +155,8 @@ spa_volume_node_get_props (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
@ -176,8 +176,7 @@ spa_volume_node_set_props (SpaNode *node,
{
SpaVolume *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
@ -198,8 +197,8 @@ spa_volume_node_send_command (SpaNode *node,
{
SpaVolume *this;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
@ -222,8 +221,7 @@ spa_volume_node_set_event_callback (SpaNode *node,
{
SpaVolume *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
@ -240,8 +238,7 @@ spa_volume_node_get_n_ports (SpaNode *node,
uint32_t *n_output_ports,
uint32_t *max_output_ports)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports)
*n_input_ports = 1;
@ -262,8 +259,7 @@ spa_volume_node_get_port_ids (SpaNode *node,
uint32_t n_output_ports,
uint32_t *output_ids)
{
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
if (n_input_ports > 0 && input_ids)
input_ids[0] = 0;
@ -305,13 +301,12 @@ spa_volume_node_port_enum_formats (SpaNode *node,
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
@ -363,13 +358,11 @@ spa_volume_node_port_set_format (SpaNode *node,
SpaVolume *this;
SpaVolumePort *port;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
@ -431,13 +424,12 @@ spa_volume_node_port_get_format (SpaNode *node,
SpaVolume *this;
SpaVolumePort *port;
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
@ -458,13 +450,12 @@ spa_volume_node_port_get_info (SpaNode *node,
SpaVolume *this;
SpaVolumePort *port;
if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
*info = &port->info;
@ -501,13 +492,11 @@ spa_volume_node_port_use_buffers (SpaNode *node,
SpaVolumePort *port;
uint32_t i;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
@ -572,13 +561,11 @@ spa_volume_node_port_set_io (SpaNode *node,
SpaVolume *this;
SpaVolumePort *port;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port->io = io;
@ -595,13 +582,11 @@ spa_volume_node_port_reuse_buffer (SpaNode *node,
SpaVolumeBuffer *b;
SpaVolumePort *port;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
return SPA_RESULT_INVALID_PORT;
spa_return_val_if_fail (CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id), SPA_RESULT_INVALID_PORT);
port = &this->out_ports[port_id];
@ -705,8 +690,7 @@ spa_volume_node_process_input (SpaNode *node)
SpaVolumePort *in_port, *out_port;
SpaBuffer *dbuf, *sbuf;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVolume, node);
@ -791,8 +775,8 @@ spa_volume_get_interface (SpaHandle *handle,
{
SpaVolume *this;
if (handle == NULL || interface == 0)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaVolume *) handle;
@ -820,8 +804,8 @@ volume_init (const SpaHandleFactory *factory,
SpaVolume *this;
uint32_t i;
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
handle->get_interface = spa_volume_get_interface;
handle->clear = volume_clear;
@ -864,8 +848,8 @@ volume_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
uint32_t index)
{
if (factory == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0: