spa: don't use typedef for struct and enum

This commit is contained in:
Wim Taymans 2017-05-25 13:28:15 +02:00
parent 83964cec87
commit 11f23a3ffa
163 changed files with 6510 additions and 8264 deletions

View file

@ -26,34 +26,34 @@
#include <spa/audio/format.h>
#include <lib/props.h>
#define NAME "alsa-source"
#include "alsa-utils.h"
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
typedef struct _SpaALSAState SpaALSASource;
static const char default_device[] = "hw:0";
static const uint32_t default_min_latency = 1024;
static void
reset_alsa_props (SpaALSAProps *props)
reset_props (struct props *props)
{
strncpy (props->device, default_device, 64);
props->min_latency = default_min_latency;
}
static SpaResult
spa_alsa_source_node_get_props (SpaNode *node,
SpaProps **props)
static int
impl_node_get_props (struct spa_node *node,
struct spa_props **props)
{
SpaALSASource *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
struct state *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
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);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
@ -63,23 +63,23 @@ spa_alsa_source_node_get_props (SpaNode *node,
PROP (&f[1], this->type.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)),
PROP_MM (&f[1], this->type.prop_min_latency, SPA_POD_TYPE_INT, this->props.min_latency, 1, INT32_MAX));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props);
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_set_props (SpaNode *node,
const SpaProps *props)
static int
impl_node_set_props (struct spa_node *node,
const struct spa_props *props)
{
SpaALSASource *this;
struct state *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
if (props == NULL) {
reset_alsa_props (&this->props);
reset_props (&this->props);
return SPA_RESULT_OK;
} else {
spa_props_query (props,
@ -91,31 +91,31 @@ spa_alsa_source_node_set_props (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
do_send_event (SpaLoop *loop,
bool async,
uint32_t seq,
size_t size,
void *data,
void *user_data)
static int
do_send_event (struct spa_loop *loop,
bool async,
uint32_t seq,
size_t size,
void *data,
void *user_data)
{
SpaALSASource *this = user_data;
struct state *this = user_data;
this->callbacks.event (&this->node, data, this->user_data);
return SPA_RESULT_OK;
}
static SpaResult
do_start (SpaLoop *loop,
bool async,
uint32_t seq,
size_t size,
void *data,
void *user_data)
static int
do_start (struct spa_loop *loop,
bool async,
uint32_t seq,
size_t size,
void *data,
void *user_data)
{
SpaALSASource *this = user_data;
SpaResult res;
struct state *this = user_data;
int res;
res = spa_alsa_start (this, false);
@ -123,7 +123,7 @@ do_start (SpaLoop *loop,
spa_loop_invoke (this->main_loop,
do_send_event,
SPA_ID_INVALID,
sizeof (SpaEventNodeAsyncComplete),
sizeof (struct spa_event_node_async_complete),
&SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
seq, res),
this);
@ -131,16 +131,16 @@ do_start (SpaLoop *loop,
return res;
}
static SpaResult
do_pause (SpaLoop *loop,
bool async,
uint32_t seq,
size_t size,
void *data,
void *user_data)
static int
do_pause (struct spa_loop *loop,
bool async,
uint32_t seq,
size_t size,
void *data,
void *user_data)
{
SpaALSASource *this = user_data;
SpaResult res;
struct state *this = user_data;
int res;
res = spa_alsa_pause (this, false);
@ -148,7 +148,7 @@ do_pause (SpaLoop *loop,
spa_loop_invoke (this->main_loop,
do_send_event,
SPA_ID_INVALID,
sizeof (SpaEventNodeAsyncComplete),
sizeof (struct spa_event_node_async_complete),
&SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
seq, res),
this);
@ -156,16 +156,16 @@ do_pause (SpaLoop *loop,
return res;
}
static SpaResult
spa_alsa_source_node_send_command (SpaNode *node,
SpaCommand *command)
static int
impl_node_send_command (struct spa_node *node,
struct spa_command *command)
{
SpaALSASource *this;
struct state *this;
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);
this = SPA_CONTAINER_OF (node, struct state, node);
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
if (!this->have_format)
@ -201,17 +201,17 @@ spa_alsa_source_node_send_command (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
static int
impl_node_set_callbacks (struct spa_node *node,
const struct spa_node_callbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaALSASource *this;
struct state *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
this->callbacks = *callbacks;
this->user_data = user_data;
@ -219,8 +219,8 @@ spa_alsa_source_node_set_callbacks (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_get_n_ports (SpaNode *node,
static int
impl_node_get_n_ports (struct spa_node *node,
uint32_t *n_input_ports,
uint32_t *max_input_ports,
uint32_t *n_output_ports,
@ -240,8 +240,8 @@ spa_alsa_source_node_get_n_ports (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_get_port_ids (SpaNode *node,
static int
impl_node_get_port_ids (struct spa_node *node,
uint32_t n_input_ports,
uint32_t *input_ids,
uint32_t n_output_ports,
@ -256,36 +256,36 @@ spa_alsa_source_node_get_port_ids (SpaNode *node,
}
static SpaResult
spa_alsa_source_node_add_port (SpaNode *node,
SpaDirection direction,
static int
impl_node_add_port (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_alsa_source_node_remove_port (SpaNode *node,
SpaDirection direction,
static int
impl_node_remove_port (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_alsa_source_node_port_enum_formats (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_enum_formats (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
SpaFormat **format,
const SpaFormat *filter,
struct spa_format **format,
const struct spa_format *filter,
uint32_t index)
{
SpaALSASource *this;
struct state *this;
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);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -293,11 +293,11 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
}
static void
recycle_buffer (SpaALSASource *this, uint32_t buffer_id)
recycle_buffer (struct state *this, uint32_t buffer_id)
{
SpaALSABuffer *b;
struct buffer *b;
spa_log_trace (this->log, "alsa-source %p: recycle buffer %u", this, buffer_id);
spa_log_trace (this->log, NAME " %p: recycle buffer %u", this, buffer_id);
b = &this->buffers[buffer_id];
spa_return_if_fail (b->outstanding);
@ -306,8 +306,8 @@ recycle_buffer (SpaALSASource *this, uint32_t buffer_id)
spa_list_insert (this->free.prev, &b->link);
}
static SpaResult
spa_alsa_clear_buffers (SpaALSASource *this)
static int
clear_buffers (struct state *this)
{
if (this->n_buffers > 0) {
spa_list_init (&this->free);
@ -317,29 +317,29 @@ spa_alsa_clear_buffers (SpaALSASource *this)
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_port_set_format (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_set_format (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
const struct spa_format *format)
{
SpaALSASource *this;
struct state *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (format == NULL) {
spa_alsa_pause (this, false);
spa_alsa_clear_buffers (this);
clear_buffers (this);
spa_alsa_close (this);
this->have_format = false;
} else {
SpaAudioInfo info = { SPA_FORMAT_MEDIA_TYPE (format),
SPA_FORMAT_MEDIA_SUBTYPE (format), };
struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE (format),
SPA_FORMAT_MEDIA_SUBTYPE (format), };
if (info.media_type != this->type.media_type.audio ||
info.media_subtype != this->type.media_subtype.raw)
@ -364,20 +364,20 @@ spa_alsa_source_node_port_set_format (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_port_get_format (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_get_format (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const SpaFormat **format)
const struct spa_format **format)
{
SpaALSASource *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
struct state *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
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);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -391,23 +391,23 @@ spa_alsa_source_node_port_get_format (SpaNode *node,
PROP (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate),
PROP (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels));
*format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
*format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format);
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_port_get_info (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_get_info (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const SpaPortInfo **info)
const struct spa_port_info **info)
{
SpaALSASource *this;
struct state *this;
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);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -416,21 +416,21 @@ spa_alsa_source_node_port_get_info (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_port_enum_params (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_enum_params (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
uint32_t index,
SpaParam **param)
struct spa_param **param)
{
SpaALSASource *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
struct state *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -449,41 +449,41 @@ spa_alsa_source_node_port_enum_params (SpaNode *node,
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_port_set_param (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_set_param (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const SpaParam *param)
const struct spa_param *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_alsa_source_node_port_use_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaBuffer **buffers,
uint32_t n_buffers)
static int
impl_node_port_use_buffers (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_buffer **buffers,
uint32_t n_buffers)
{
SpaALSASource *this;
SpaResult res;
struct state *this;
int res;
int i;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -492,12 +492,12 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
if (this->n_buffers > 0) {
spa_alsa_pause (this, false);
if ((res = spa_alsa_clear_buffers (this)) < 0)
if ((res = clear_buffers (this)) < 0)
return res;
}
for (i = 0; i < n_buffers; i++) {
SpaALSABuffer *b = &this->buffers[i];
SpaData *d = buffers[i]->datas;
struct buffer *b = &this->buffers[i];
struct spa_data *d = buffers[i]->datas;
b->outbuf = buffers[i];
b->outstanding = false;
@ -508,7 +508,7 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
d[0].type == this->type.data.DmaBuf ||
d[0].type == this->type.data.MemPtr) &&
d[0].data != NULL)) {
spa_log_error (this->log, "alsa-source: need mapped memory");
spa_log_error (this->log, NAME " %p: need mapped memory", this);
return SPA_RESULT_ERROR;
}
spa_list_insert (this->free.prev, &b->link);
@ -519,21 +519,21 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
}
static SpaResult
spa_alsa_source_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaParam **params,
uint32_t n_params,
SpaBuffer **buffers,
uint32_t *n_buffers)
static int
impl_node_port_alloc_buffers (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_param **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)
{
SpaALSASource *this;
struct state *this;
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);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -543,17 +543,17 @@ spa_alsa_source_node_port_alloc_buffers (SpaNode *node,
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_alsa_source_node_port_set_io (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_set_io (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
SpaPortIO *io)
struct spa_port_io *io)
{
SpaALSASource *this;
struct state *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -562,16 +562,16 @@ spa_alsa_source_node_port_set_io (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_port_reuse_buffer (SpaNode *node,
static int
impl_node_port_reuse_buffer (struct spa_node *node,
uint32_t port_id,
uint32_t buffer_id)
{
SpaALSASource *this;
struct state *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (port_id == 0, SPA_RESULT_INVALID_PORT);
@ -586,18 +586,18 @@ spa_alsa_source_node_port_reuse_buffer (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_alsa_source_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaCommand *command)
static int
impl_node_port_send_command (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_command *command)
{
SpaALSASource *this;
SpaResult res;
struct state *this;
int res;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -611,21 +611,21 @@ spa_alsa_source_node_port_send_command (SpaNode *node,
return res;
}
static SpaResult
spa_alsa_source_node_process_input (SpaNode *node)
static int
impl_node_process_input (struct spa_node *node)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_alsa_source_node_process_output (SpaNode *node)
static int
impl_node_process_output (struct spa_node *node)
{
SpaALSASource *this;
SpaPortIO *io;
struct state *this;
struct spa_port_io *io;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this = SPA_CONTAINER_OF (node, struct state, node);
io = this->io;
spa_return_val_if_fail (io != NULL, SPA_RESULT_WRONG_STATE);
@ -639,57 +639,57 @@ spa_alsa_source_node_process_output (SpaNode *node)
return SPA_RESULT_OK;
}
static const SpaNode alsasource_node = {
sizeof (SpaNode),
static const struct spa_node impl_node = {
sizeof (struct spa_node),
NULL,
spa_alsa_source_node_get_props,
spa_alsa_source_node_set_props,
spa_alsa_source_node_send_command,
spa_alsa_source_node_set_callbacks,
spa_alsa_source_node_get_n_ports,
spa_alsa_source_node_get_port_ids,
spa_alsa_source_node_add_port,
spa_alsa_source_node_remove_port,
spa_alsa_source_node_port_enum_formats,
spa_alsa_source_node_port_set_format,
spa_alsa_source_node_port_get_format,
spa_alsa_source_node_port_get_info,
spa_alsa_source_node_port_enum_params,
spa_alsa_source_node_port_set_param,
spa_alsa_source_node_port_use_buffers,
spa_alsa_source_node_port_alloc_buffers,
spa_alsa_source_node_port_set_io,
spa_alsa_source_node_port_reuse_buffer,
spa_alsa_source_node_port_send_command,
spa_alsa_source_node_process_input,
spa_alsa_source_node_process_output,
impl_node_get_props,
impl_node_set_props,
impl_node_send_command,
impl_node_set_callbacks,
impl_node_get_n_ports,
impl_node_get_port_ids,
impl_node_add_port,
impl_node_remove_port,
impl_node_port_enum_formats,
impl_node_port_set_format,
impl_node_port_get_format,
impl_node_port_get_info,
impl_node_port_enum_params,
impl_node_port_set_param,
impl_node_port_use_buffers,
impl_node_port_alloc_buffers,
impl_node_port_set_io,
impl_node_port_reuse_buffer,
impl_node_port_send_command,
impl_node_process_input,
impl_node_process_output,
};
static SpaResult
spa_alsa_source_clock_get_props (SpaClock *clock,
SpaProps **props)
static int
impl_clock_get_props (struct spa_clock *clock,
struct spa_props **props)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_alsa_source_clock_set_props (SpaClock *clock,
const SpaProps *props)
static int
impl_clock_set_props (struct spa_clock *clock,
const struct spa_props *props)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_alsa_source_clock_get_time (SpaClock *clock,
static int
impl_clock_get_time (struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time)
{
SpaALSASource *this;
struct state *this;
spa_return_val_if_fail (clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (clock, SpaALSASource, clock);
this = SPA_CONTAINER_OF (clock, struct state, clock);
if (rate)
*rate = SPA_USEC_PER_SEC;
@ -701,26 +701,26 @@ spa_alsa_source_clock_get_time (SpaClock *clock,
return SPA_RESULT_OK;
}
static const SpaClock alsasource_clock = {
sizeof (SpaClock),
static const struct spa_clock impl_clock = {
sizeof (struct spa_clock),
NULL,
SPA_CLOCK_STATE_STOPPED,
spa_alsa_source_clock_get_props,
spa_alsa_source_clock_set_props,
spa_alsa_source_clock_get_time,
impl_clock_get_props,
impl_clock_set_props,
impl_clock_get_time,
};
static SpaResult
spa_alsa_source_get_interface (SpaHandle *handle,
static int
impl_get_interface (struct spa_handle *handle,
uint32_t interface_id,
void **interface)
{
SpaALSASource *this;
struct state *this;
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;
this = (struct state *) handle;
if (interface_id == this->type.node)
*interface = &this->node;
@ -732,29 +732,29 @@ spa_alsa_source_get_interface (SpaHandle *handle,
return SPA_RESULT_OK;
}
static SpaResult
alsa_source_clear (SpaHandle *handle)
static int
impl_clear (struct spa_handle *handle)
{
return SPA_RESULT_OK;
}
static SpaResult
alsa_source_init (const SpaHandleFactory *factory,
SpaHandle *handle,
const SpaDict *info,
const SpaSupport *support,
static int
impl_init (const struct spa_handle_factory *factory,
struct spa_handle *handle,
const struct spa_dict *info,
const struct spa_support *support,
uint32_t n_support)
{
SpaALSASource *this;
struct state *this;
uint32_t i;
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;
handle->get_interface = impl_get_interface;
handle->clear = impl_clear;
this = (SpaALSASource *) handle;
this = (struct state *) handle;
for (i = 0; i < n_support; i++) {
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
@ -780,10 +780,10 @@ alsa_source_init (const SpaHandleFactory *factory,
}
init_type (&this->type, this->map);
this->node = alsasource_node;
this->clock = alsasource_clock;
this->node = impl_node;
this->clock = impl_clock;
this->stream = SND_PCM_STREAM_CAPTURE;
reset_alsa_props (&this->props);
reset_props (&this->props);
spa_list_init (&this->free);
spa_list_init (&this->ready);
@ -796,32 +796,32 @@ alsa_source_init (const SpaHandleFactory *factory,
return SPA_RESULT_OK;
}
static const SpaInterfaceInfo alsa_source_interfaces[] =
static const struct spa_interface_info impl_interfaces[] =
{
{ SPA_TYPE__Node, },
{ SPA_TYPE__Clock, },
};
static SpaResult
alsa_source_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
static int
impl_enum_interface_info (const struct spa_handle_factory *factory,
const struct spa_interface_info **info,
uint32_t index)
{
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))
if (index < 0 || index >= SPA_N_ELEMENTS (impl_interfaces))
return SPA_RESULT_ENUM_END;
*info = &alsa_source_interfaces[index];
*info = &impl_interfaces[index];
return SPA_RESULT_OK;
}
const SpaHandleFactory spa_alsa_source_factory =
{ "alsa-source",
const struct spa_handle_factory spa_alsa_source_factory =
{ NAME,
NULL,
sizeof (SpaALSASource),
alsa_source_init,
alsa_source_enum_interface_info,
sizeof (struct state),
impl_init,
impl_enum_interface_info,
};