mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
spa: don't use typedef for struct and enum
This commit is contained in:
parent
83964cec87
commit
11f23a3ffa
163 changed files with 6510 additions and 8264 deletions
|
|
@ -33,33 +33,33 @@
|
|||
#include <spa/monitor.h>
|
||||
#include <lib/debug.h>
|
||||
|
||||
extern const SpaHandleFactory spa_alsa_sink_factory;
|
||||
extern const SpaHandleFactory spa_alsa_source_factory;
|
||||
#define NAME "alsa-monitor"
|
||||
|
||||
typedef struct _SpaALSAMonitor SpaALSAMonitor;
|
||||
extern const struct spa_handle_factory spa_alsa_sink_factory;
|
||||
extern const struct spa_handle_factory spa_alsa_source_factory;
|
||||
|
||||
typedef struct {
|
||||
struct type {
|
||||
uint32_t handle_factory;
|
||||
SpaTypeMonitor monitor;
|
||||
} Type;
|
||||
struct spa_type_monitor monitor;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->handle_factory = spa_type_map_get_id (map, SPA_TYPE__HandleFactory);
|
||||
spa_type_monitor_map (map, &type->monitor);
|
||||
}
|
||||
|
||||
struct _SpaALSAMonitor {
|
||||
SpaHandle handle;
|
||||
SpaMonitor monitor;
|
||||
struct impl {
|
||||
struct spa_handle handle;
|
||||
struct spa_monitor monitor;
|
||||
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
SpaLoop *main_loop;
|
||||
struct type type;
|
||||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
|
||||
SpaEventMonitorCallback event_cb;
|
||||
struct spa_monitor_callbacks callbacks;
|
||||
void *user_data;
|
||||
|
||||
struct udev* udev;
|
||||
|
|
@ -69,7 +69,7 @@ struct _SpaALSAMonitor {
|
|||
struct udev_list_entry *devices;
|
||||
|
||||
uint8_t item_buffer[4096];
|
||||
SpaMonitorItem *item;
|
||||
struct spa_monitor_item *item;
|
||||
|
||||
snd_ctl_t *ctl_hndl;
|
||||
struct udev_device *dev;
|
||||
|
|
@ -78,11 +78,11 @@ struct _SpaALSAMonitor {
|
|||
int stream_idx;
|
||||
|
||||
int fd;
|
||||
SpaSource source;
|
||||
struct spa_source source;
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
alsa_udev_open (SpaALSAMonitor *this)
|
||||
static int
|
||||
impl_udev_open (struct impl *this)
|
||||
{
|
||||
if (this->udev != NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -110,15 +110,15 @@ path_get_card_id (const char *path)
|
|||
}
|
||||
|
||||
static int
|
||||
fill_item (SpaALSAMonitor *this,
|
||||
fill_item (struct impl *this,
|
||||
snd_ctl_card_info_t *card_info,
|
||||
snd_pcm_info_t *dev_info,
|
||||
struct udev_device *dev)
|
||||
{
|
||||
const char *str, *name, *klass = NULL;
|
||||
SpaPODBuilder b = SPA_POD_BUILDER_INIT (this->item_buffer, sizeof (this->item_buffer));
|
||||
const SpaHandleFactory *factory = NULL;
|
||||
SpaPODFrame f[3];
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT (this->item_buffer, sizeof (this->item_buffer));
|
||||
const struct spa_handle_factory *factory = NULL;
|
||||
struct spa_pod_frame f[3];
|
||||
char card_name[64];
|
||||
|
||||
switch (snd_pcm_info_get_stream (dev_info)) {
|
||||
|
|
@ -229,13 +229,13 @@ fill_item (SpaALSAMonitor *this,
|
|||
-SPA_POD_TYPE_OBJECT, &f[0],
|
||||
0);
|
||||
|
||||
this->item = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaMonitorItem);
|
||||
this->item = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_monitor_item);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
close_card (SpaALSAMonitor *this)
|
||||
close_card (struct impl *this)
|
||||
{
|
||||
if (this->ctl_hndl)
|
||||
snd_ctl_close (this->ctl_hndl);
|
||||
|
|
@ -243,7 +243,7 @@ close_card (SpaALSAMonitor *this)
|
|||
}
|
||||
|
||||
static int
|
||||
open_card (SpaALSAMonitor *this, struct udev_device *dev)
|
||||
open_card (struct impl *this, struct udev_device *dev)
|
||||
{
|
||||
int err;
|
||||
const char *str;
|
||||
|
|
@ -274,7 +274,7 @@ open_card (SpaALSAMonitor *this, struct udev_device *dev)
|
|||
}
|
||||
|
||||
static int
|
||||
get_next_device (SpaALSAMonitor *this, struct udev_device *dev)
|
||||
get_next_device (struct impl *this, struct udev_device *dev)
|
||||
{
|
||||
int err;
|
||||
snd_pcm_info_t *dev_info;
|
||||
|
|
@ -324,9 +324,9 @@ again:
|
|||
}
|
||||
|
||||
static void
|
||||
alsa_on_fd_events (SpaSource *source)
|
||||
impl_on_fd_events (struct spa_source *source)
|
||||
{
|
||||
SpaALSAMonitor *this = source->data;
|
||||
struct impl *this = source->data;
|
||||
struct udev_device *dev;
|
||||
const char *action;
|
||||
uint32_t type;
|
||||
|
|
@ -350,37 +350,38 @@ alsa_on_fd_events (SpaSource *source)
|
|||
|
||||
while (true) {
|
||||
uint8_t buffer[4096];
|
||||
SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
|
||||
SpaPODFrame f[1];
|
||||
SpaEventMonitor *event;
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
|
||||
struct spa_pod_frame f[1];
|
||||
struct spa_event *event;
|
||||
|
||||
if (get_next_device (this, dev) < 0)
|
||||
break;
|
||||
|
||||
spa_pod_builder_object (&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->item);
|
||||
event = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaEventMonitor);
|
||||
this->event_cb (&this->monitor, event, this->user_data);
|
||||
event = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_event);
|
||||
this->callbacks.event (&this->monitor, event, this->user_data);
|
||||
}
|
||||
close_card (this);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_monitor_set_event_callback (SpaMonitor *monitor,
|
||||
SpaEventMonitorCallback callback,
|
||||
void *user_data)
|
||||
static int
|
||||
impl_monitor_set_callbacks (struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
{
|
||||
SpaResult res;
|
||||
SpaALSAMonitor *this;
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF (monitor, SpaALSAMonitor, monitor);
|
||||
this = SPA_CONTAINER_OF (monitor, struct impl, monitor);
|
||||
|
||||
this->event_cb = callback;
|
||||
this->user_data = user_data;
|
||||
if (callbacks) {
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
if (callback) {
|
||||
if ((res = alsa_udev_open (this)) < 0)
|
||||
if ((res = impl_udev_open (this)) < 0)
|
||||
return res;
|
||||
|
||||
this->umonitor = udev_monitor_new_from_netlink (this->udev, "udev");
|
||||
|
|
@ -393,33 +394,34 @@ spa_alsa_monitor_set_event_callback (SpaMonitor *monitor,
|
|||
|
||||
udev_monitor_enable_receiving (this->umonitor);
|
||||
|
||||
this->source.func = alsa_on_fd_events;
|
||||
this->source.func = impl_on_fd_events;
|
||||
this->source.data = this;
|
||||
this->source.fd = udev_monitor_get_fd (this->umonitor);;
|
||||
this->source.mask = SPA_IO_IN | SPA_IO_ERR;
|
||||
|
||||
spa_loop_add_source (this->main_loop, &this->source);
|
||||
} else {
|
||||
spa_zero (this->callbacks);
|
||||
spa_loop_remove_source (this->main_loop, &this->source);
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_monitor_enum_items (SpaMonitor *monitor,
|
||||
SpaMonitorItem **item,
|
||||
static int
|
||||
impl_monitor_enum_items (struct spa_monitor *monitor,
|
||||
struct spa_monitor_item **item,
|
||||
uint32_t index)
|
||||
{
|
||||
SpaResult res;
|
||||
SpaALSAMonitor *this;
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
||||
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);
|
||||
this = SPA_CONTAINER_OF (monitor, struct impl, monitor);
|
||||
|
||||
if ((res = alsa_udev_open (this)) < 0)
|
||||
if ((res = impl_udev_open (this)) < 0)
|
||||
return res;
|
||||
|
||||
if (index == 0 || this->index > index) {
|
||||
|
|
@ -465,24 +467,24 @@ next:
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaMonitor alsamonitor = {
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
NULL,
|
||||
sizeof (SpaMonitor),
|
||||
spa_alsa_monitor_set_event_callback,
|
||||
spa_alsa_monitor_enum_items,
|
||||
sizeof (struct spa_monitor),
|
||||
impl_monitor_set_callbacks,
|
||||
impl_monitor_enum_items,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_monitor_get_interface (SpaHandle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
{
|
||||
SpaALSAMonitor *this;
|
||||
struct impl *this;
|
||||
|
||||
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;
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.monitor.Monitor)
|
||||
*interface = &this->monitor;
|
||||
|
|
@ -492,29 +494,29 @@ spa_alsa_monitor_get_interface (SpaHandle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
alsa_monitor_clear (SpaHandle *handle)
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
alsa_monitor_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)
|
||||
{
|
||||
SpaALSAMonitor *this;
|
||||
struct impl *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_monitor_get_interface;
|
||||
handle->clear = alsa_monitor_clear,
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear,
|
||||
|
||||
this = (SpaALSAMonitor *) handle;
|
||||
this = (struct impl *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
|
|
@ -535,35 +537,36 @@ alsa_monitor_init (const SpaHandleFactory *factory,
|
|||
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->monitor = alsamonitor;
|
||||
this->monitor = impl_monitor;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaInterfaceInfo alsa_monitor_interfaces[] =
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
{ SPA_TYPE__Monitor, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
alsa_monitor_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_monitor_interfaces))
|
||||
if (index < 0 || index >= SPA_N_ELEMENTS (impl_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &alsa_monitor_interfaces[index];
|
||||
*info = &impl_interfaces[index];
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const SpaHandleFactory spa_alsa_monitor_factory =
|
||||
{ "alsa-monitor",
|
||||
const struct spa_handle_factory spa_alsa_monitor_factory =
|
||||
{
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof (SpaALSAMonitor),
|
||||
alsa_monitor_init,
|
||||
alsa_monitor_enum_interface_info,
|
||||
sizeof (struct impl),
|
||||
impl_init,
|
||||
impl_enum_interface_info,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,34 +25,34 @@
|
|||
#include <spa/audio/format.h>
|
||||
#include <lib/props.h>
|
||||
|
||||
#define NAME "alsa-sink"
|
||||
|
||||
#include "alsa-utils.h"
|
||||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0)
|
||||
|
||||
typedef struct _SpaALSAState SpaALSASink;
|
||||
|
||||
static const char default_device[] = "default";
|
||||
static const uint32_t default_min_latency = 1024;
|
||||
|
||||
static void
|
||||
reset_alsa_sink_props (SpaALSAProps *props)
|
||||
reset_props (struct props *props)
|
||||
{
|
||||
strncpy (props->device, default_device, 64);
|
||||
props->min_latency = default_min_latency;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_get_props (SpaNode *node,
|
||||
SpaProps **props)
|
||||
static int
|
||||
impl_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
{
|
||||
SpaALSASink *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, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
|
||||
|
|
@ -62,23 +62,23 @@ spa_alsa_sink_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_sink_node_set_props (SpaNode *node,
|
||||
const SpaProps *props)
|
||||
static int
|
||||
impl_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
if (props == NULL) {
|
||||
reset_alsa_sink_props (&this->props);
|
||||
reset_props (&this->props);
|
||||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
|
|
@ -89,32 +89,32 @@ spa_alsa_sink_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)
|
||||
{
|
||||
SpaALSASink *this = user_data;
|
||||
struct state *this = user_data;
|
||||
|
||||
this->callbacks.event (&this->node, data, this->user_data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
do_command (SpaLoop *loop,
|
||||
bool async,
|
||||
uint32_t seq,
|
||||
size_t size,
|
||||
void *data,
|
||||
void *user_data)
|
||||
static int
|
||||
do_command (struct spa_loop *loop,
|
||||
bool async,
|
||||
uint32_t seq,
|
||||
size_t size,
|
||||
void *data,
|
||||
void *user_data)
|
||||
{
|
||||
SpaALSASink *this = user_data;
|
||||
SpaResult res;
|
||||
SpaCommand *cmd = data;
|
||||
struct state *this = user_data;
|
||||
int res;
|
||||
struct spa_command *cmd = data;
|
||||
|
||||
if (SPA_COMMAND_TYPE (cmd) == this->type.command_node.Start ||
|
||||
SPA_COMMAND_TYPE (cmd) == this->type.command_node.Pause) {
|
||||
|
|
@ -130,7 +130,7 @@ do_command (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);
|
||||
|
|
@ -138,16 +138,16 @@ do_command (SpaLoop *loop,
|
|||
return res;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
static int
|
||||
impl_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
{
|
||||
SpaALSASink *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, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start ||
|
||||
SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
|
|
@ -169,17 +169,17 @@ spa_alsa_sink_node_send_command (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
|
|
@ -187,8 +187,8 @@ spa_alsa_sink_node_set_callbacks (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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,
|
||||
|
|
@ -208,8 +208,8 @@ spa_alsa_sink_node_get_n_ports (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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,
|
||||
|
|
@ -224,44 +224,44 @@ spa_alsa_sink_node_get_port_ids (SpaNode *node,
|
|||
}
|
||||
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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_sink_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_sink_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)
|
||||
{
|
||||
SpaALSASink *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, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
return spa_alsa_enum_format (this, format, filter, index);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_clear_buffers (SpaALSASink *this)
|
||||
static int
|
||||
clear_buffers (struct state *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
spa_list_init (&this->ready);
|
||||
|
|
@ -270,30 +270,30 @@ spa_alsa_clear_buffers (SpaALSASink *this)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, 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_log_info (this->log, "clear format");
|
||||
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)
|
||||
|
|
@ -318,20 +318,20 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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)
|
||||
{
|
||||
SpaALSASink *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, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
|
|
@ -345,23 +345,23 @@ spa_alsa_sink_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_sink_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)
|
||||
{
|
||||
SpaALSASink *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, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
|
|
@ -370,22 +370,22 @@ spa_alsa_sink_node_port_get_info (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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)
|
||||
{
|
||||
|
||||
SpaALSASink *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, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
|
|
@ -404,13 +404,13 @@ spa_alsa_sink_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;
|
||||
|
||||
case 2:
|
||||
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.Ringbuffer),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaRingbuffer)),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_ringbuffer)),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, this->period_frames * this->frame_size * 32),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1),
|
||||
|
|
@ -421,33 +421,33 @@ spa_alsa_sink_node_port_enum_params (SpaNode *node,
|
|||
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_sink_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_sink_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)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
struct state *this;
|
||||
int i;
|
||||
|
||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
|
|
@ -458,12 +458,12 @@ spa_alsa_sink_node_port_use_buffers (SpaNode *node,
|
|||
|
||||
if (n_buffers == 0) {
|
||||
spa_alsa_pause (this, false);
|
||||
spa_alsa_clear_buffers (this);
|
||||
clear_buffers (this);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_buffers; i++) {
|
||||
SpaALSABuffer *b = &this->buffers[i];
|
||||
struct buffer *b = &this->buffers[i];
|
||||
uint32_t type = buffers[i]->datas[0].type;
|
||||
|
||||
b->outbuf = buffers[i];
|
||||
|
|
@ -476,7 +476,7 @@ spa_alsa_sink_node_port_use_buffers (SpaNode *node,
|
|||
type == this->type.data.DmaBuf ||
|
||||
type == this->type.data.MemPtr) &&
|
||||
buffers[i]->datas[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;
|
||||
}
|
||||
}
|
||||
|
|
@ -485,21 +485,21 @@ spa_alsa_sink_node_port_use_buffers (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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)
|
||||
{
|
||||
SpaALSASink *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, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
|
|
@ -509,17 +509,17 @@ spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
|
|
@ -528,26 +528,26 @@ spa_alsa_sink_node_port_set_io (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_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)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
SpaResult res;
|
||||
struct state *this;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
|
|
@ -563,29 +563,29 @@ spa_alsa_sink_node_port_send_command (SpaNode *node,
|
|||
return res;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_process_input (SpaNode *node)
|
||||
static int
|
||||
impl_node_process_input (struct spa_node *node)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
SpaPortIO *input;
|
||||
struct state *this;
|
||||
struct spa_port_io *input;
|
||||
|
||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
this = SPA_CONTAINER_OF (node, struct state, node);
|
||||
input = this->io;
|
||||
spa_return_val_if_fail (input != NULL, SPA_RESULT_WRONG_STATE);
|
||||
|
||||
if (input->status == SPA_RESULT_HAVE_BUFFER &&
|
||||
input->buffer_id != SPA_ID_INVALID) {
|
||||
SpaALSABuffer *b = &this->buffers[input->buffer_id];
|
||||
struct buffer *b = &this->buffers[input->buffer_id];
|
||||
|
||||
if (!b->outstanding) {
|
||||
spa_log_warn (this->log, "alsa-sink %p: buffer %u in use", this, input->buffer_id);
|
||||
spa_log_warn (this->log, NAME " %p: buffer %u in use", this, input->buffer_id);
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
spa_log_trace (this->log, "alsa-sink %p: queue buffer %u", this, input->buffer_id);
|
||||
spa_log_trace (this->log, NAME " %p: queue buffer %u", this, input->buffer_id);
|
||||
|
||||
spa_list_insert (this->ready.prev, &b->link);
|
||||
b->outstanding = false;
|
||||
|
|
@ -595,50 +595,50 @@ spa_alsa_sink_node_process_input (SpaNode *node)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_process_output (SpaNode *node)
|
||||
static int
|
||||
impl_node_process_output (struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static const SpaNode alsasink_node = {
|
||||
sizeof (SpaNode),
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof (struct spa_node),
|
||||
NULL,
|
||||
spa_alsa_sink_node_get_props,
|
||||
spa_alsa_sink_node_set_props,
|
||||
spa_alsa_sink_node_send_command,
|
||||
spa_alsa_sink_node_set_callbacks,
|
||||
spa_alsa_sink_node_get_n_ports,
|
||||
spa_alsa_sink_node_get_port_ids,
|
||||
spa_alsa_sink_node_add_port,
|
||||
spa_alsa_sink_node_remove_port,
|
||||
spa_alsa_sink_node_port_enum_formats,
|
||||
spa_alsa_sink_node_port_set_format,
|
||||
spa_alsa_sink_node_port_get_format,
|
||||
spa_alsa_sink_node_port_get_info,
|
||||
spa_alsa_sink_node_port_enum_params,
|
||||
spa_alsa_sink_node_port_set_param,
|
||||
spa_alsa_sink_node_port_use_buffers,
|
||||
spa_alsa_sink_node_port_alloc_buffers,
|
||||
spa_alsa_sink_node_port_set_io,
|
||||
spa_alsa_sink_node_port_reuse_buffer,
|
||||
spa_alsa_sink_node_port_send_command,
|
||||
spa_alsa_sink_node_process_input,
|
||||
spa_alsa_sink_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_sink_get_interface (SpaHandle *handle,
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
{
|
||||
SpaALSASink *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 = (SpaALSASink *) handle;
|
||||
this = (struct state *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
|
|
@ -648,29 +648,29 @@ spa_alsa_sink_get_interface (SpaHandle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
alsa_sink_clear (SpaHandle *handle)
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
alsa_sink_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)
|
||||
{
|
||||
SpaALSASink *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_sink_get_interface;
|
||||
handle->clear = alsa_sink_clear;
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
||||
this = (SpaALSASink *) handle;
|
||||
this = (struct state *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
|
|
@ -696,9 +696,9 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
}
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = alsasink_node;
|
||||
this->node = impl_node;
|
||||
this->stream = SND_PCM_STREAM_PLAYBACK;
|
||||
reset_alsa_sink_props (&this->props);
|
||||
reset_props (&this->props);
|
||||
|
||||
spa_list_init (&this->ready);
|
||||
|
||||
|
|
@ -711,14 +711,14 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaInterfaceInfo alsa_sink_interfaces[] =
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
{ SPA_TYPE__Node, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
alsa_sink_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);
|
||||
|
|
@ -726,7 +726,7 @@ alsa_sink_enum_interface_info (const SpaHandleFactory *factory,
|
|||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &alsa_sink_interfaces[index];
|
||||
*info = &impl_interfaces[index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
|
@ -734,10 +734,10 @@ alsa_sink_enum_interface_info (const SpaHandleFactory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const SpaHandleFactory spa_alsa_sink_factory =
|
||||
{ "alsa-sink",
|
||||
const struct spa_handle_factory spa_alsa_sink_factory =
|
||||
{ NAME,
|
||||
NULL,
|
||||
sizeof (SpaALSASink),
|
||||
alsa_sink_init,
|
||||
alsa_sink_enum_interface_info,
|
||||
sizeof (struct state),
|
||||
impl_init,
|
||||
impl_enum_interface_info,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@
|
|||
#define CHECK(s,msg) if ((err = (s)) < 0) { spa_log_error (state->log, msg ": %s", snd_strerror(err)); return err; }
|
||||
|
||||
static int
|
||||
spa_alsa_open (SpaALSAState *state)
|
||||
spa_alsa_open (struct state *state)
|
||||
{
|
||||
int err;
|
||||
SpaALSAProps *props = &state->props;
|
||||
struct props *props = &state->props;
|
||||
|
||||
if (state->opened)
|
||||
return 0;
|
||||
|
|
@ -41,7 +41,7 @@ spa_alsa_open (SpaALSAState *state)
|
|||
}
|
||||
|
||||
int
|
||||
spa_alsa_close (SpaALSAState *state)
|
||||
spa_alsa_close (struct state *state)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
|
|
@ -57,24 +57,24 @@ spa_alsa_close (SpaALSAState *state)
|
|||
return err;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
struct format_info {
|
||||
off_t format_offset;
|
||||
snd_pcm_format_t format;
|
||||
} FormatInfo;
|
||||
};
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define _FORMAT_LE(fmt) offsetof(Type, audio_format. fmt ## _OE)
|
||||
#define _FORMAT_BE(fmt) offsetof(Type, audio_format. fmt)
|
||||
#define _FORMAT_LE(fmt) offsetof(struct type, audio_format. fmt ## _OE)
|
||||
#define _FORMAT_BE(fmt) offsetof(struct type, audio_format. fmt)
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define _FORMAT_LE(fmt) offsetof(Type, audio_format. fmt)
|
||||
#define _FORMAT_BE(fmt) offsetof(Type, audio_format. fmt ## _OE)
|
||||
#define _FORMAT_LE(fmt) offsetof(struct type, audio_format. fmt)
|
||||
#define _FORMAT_BE(fmt) offsetof(struct type, audio_format. fmt ## _OE)
|
||||
#endif
|
||||
|
||||
static const FormatInfo format_info[] =
|
||||
static const struct format_info format_info[] =
|
||||
{
|
||||
{ offsetof(Type, audio_format.UNKNOWN), SND_PCM_FORMAT_UNKNOWN },
|
||||
{ offsetof(Type, audio_format.S8), SND_PCM_FORMAT_S8 },
|
||||
{ offsetof(Type, audio_format.U8), SND_PCM_FORMAT_U8 },
|
||||
{ offsetof(struct type, audio_format.UNKNOWN), SND_PCM_FORMAT_UNKNOWN },
|
||||
{ offsetof(struct type, audio_format.S8), SND_PCM_FORMAT_S8 },
|
||||
{ offsetof(struct type, audio_format.U8), SND_PCM_FORMAT_U8 },
|
||||
{ _FORMAT_LE (S16), SND_PCM_FORMAT_S16_LE },
|
||||
{ _FORMAT_BE (S16), SND_PCM_FORMAT_S16_BE },
|
||||
{ _FORMAT_LE (U16), SND_PCM_FORMAT_U16_LE },
|
||||
|
|
@ -98,7 +98,7 @@ static const FormatInfo format_info[] =
|
|||
};
|
||||
|
||||
static snd_pcm_format_t
|
||||
spa_alsa_format_to_alsa (Type *map, uint32_t format)
|
||||
spa_alsa_format_to_alsa (struct type *map, uint32_t format)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -110,10 +110,10 @@ spa_alsa_format_to_alsa (Type *map, uint32_t format)
|
|||
return SND_PCM_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_alsa_enum_format (SpaALSAState *state,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
int
|
||||
spa_alsa_enum_format (struct state *state,
|
||||
struct spa_format **format,
|
||||
const struct spa_format *filter,
|
||||
uint32_t index)
|
||||
{
|
||||
snd_pcm_t *hndl;
|
||||
|
|
@ -122,11 +122,11 @@ spa_alsa_enum_format (SpaALSAState *state,
|
|||
int err, i, j, dir;
|
||||
unsigned int min, max;
|
||||
uint8_t buffer[4096];
|
||||
SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
|
||||
SpaPODFrame f[2];
|
||||
SpaPODProp *prop;
|
||||
SpaFormat *fmt;
|
||||
SpaResult res;
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
|
||||
struct spa_pod_frame f[2];
|
||||
struct spa_pod_prop *prop;
|
||||
struct spa_format *fmt;
|
||||
int res;
|
||||
bool opened;
|
||||
|
||||
if (index == 1)
|
||||
|
|
@ -150,10 +150,10 @@ spa_alsa_enum_format (SpaALSAState *state,
|
|||
spa_pod_builder_push_prop (&b, &f[1],
|
||||
state->type.format_audio.format,
|
||||
SPA_POD_PROP_RANGE_NONE);
|
||||
prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, SpaPODProp);
|
||||
prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, struct spa_pod_prop);
|
||||
|
||||
for (i = 1, j = 0; i < SPA_N_ELEMENTS (format_info); i++) {
|
||||
const FormatInfo *fi = &format_info[i];
|
||||
const struct format_info *fi = &format_info[i];
|
||||
|
||||
if (snd_pcm_format_mask_test (fmask, fi->format)) {
|
||||
uint32_t f = *SPA_MEMBER (&state->type, fi->format_offset, uint32_t);
|
||||
|
|
@ -172,7 +172,7 @@ spa_alsa_enum_format (SpaALSAState *state,
|
|||
spa_pod_builder_push_prop (&b, &f[1],
|
||||
state->type.format_audio.rate,
|
||||
SPA_POD_PROP_RANGE_NONE);
|
||||
prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, SpaPODProp);
|
||||
prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, struct spa_pod_prop);
|
||||
|
||||
spa_pod_builder_int (&b, SPA_CLAMP (44100, min, max));
|
||||
if (min != max) {
|
||||
|
|
@ -188,7 +188,7 @@ spa_alsa_enum_format (SpaALSAState *state,
|
|||
spa_pod_builder_push_prop (&b, &f[1],
|
||||
state->type.format_audio.channels,
|
||||
SPA_POD_PROP_RANGE_NONE);
|
||||
prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, SpaPODProp);
|
||||
prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, struct spa_pod_prop);
|
||||
|
||||
spa_pod_builder_int (&b, SPA_CLAMP (2, min, max));
|
||||
if (min != max) {
|
||||
|
|
@ -199,13 +199,13 @@ spa_alsa_enum_format (SpaALSAState *state,
|
|||
spa_pod_builder_pop (&b, &f[1]);
|
||||
spa_pod_builder_pop (&b, &f[0]);
|
||||
|
||||
fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
|
||||
fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format);
|
||||
|
||||
spa_pod_builder_init (&b, state->format_buffer, sizeof (state->format_buffer));
|
||||
if ((res = spa_format_filter (fmt, filter, &b)) < 0)
|
||||
return res;
|
||||
|
||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, struct spa_format);
|
||||
if (!opened)
|
||||
spa_alsa_close (state);
|
||||
|
||||
|
|
@ -213,14 +213,14 @@ spa_alsa_enum_format (SpaALSAState *state,
|
|||
}
|
||||
|
||||
int
|
||||
spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, uint32_t flags)
|
||||
spa_alsa_set_format (struct state *state, struct spa_audio_info *fmt, uint32_t flags)
|
||||
{
|
||||
unsigned int rrate, rchannels;
|
||||
snd_pcm_uframes_t period_size;
|
||||
int err, dir;
|
||||
snd_pcm_hw_params_t *params;
|
||||
snd_pcm_format_t format;
|
||||
SpaAudioInfoRaw *info = &fmt->info.raw;
|
||||
struct spa_audio_info_raw *info = &fmt->info.raw;
|
||||
snd_pcm_t *hndl;
|
||||
unsigned int periods;
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, uint32_t flags)
|
|||
}
|
||||
|
||||
static int
|
||||
set_swparams (SpaALSAState *state)
|
||||
set_swparams (struct state *state)
|
||||
{
|
||||
snd_pcm_t *hndl = state->hndl;
|
||||
int err = 0;
|
||||
|
|
@ -326,14 +326,14 @@ set_swparams (SpaALSAState *state)
|
|||
}
|
||||
|
||||
static inline snd_pcm_uframes_t
|
||||
pull_frames (SpaALSAState *state,
|
||||
pull_frames (struct state *state,
|
||||
const snd_pcm_channel_area_t *my_areas,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t frames,
|
||||
bool do_pull)
|
||||
{
|
||||
snd_pcm_uframes_t total_frames = 0, to_write = frames;
|
||||
SpaPortIO *io = state->io;
|
||||
struct spa_port_io *io = state->io;
|
||||
|
||||
if (spa_list_is_empty (&state->ready) && do_pull) {
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
|
|
@ -346,17 +346,17 @@ pull_frames (SpaALSAState *state,
|
|||
uint8_t *src, *dst;
|
||||
size_t n_bytes, n_frames, size;
|
||||
off_t offs;
|
||||
SpaALSABuffer *b;
|
||||
struct buffer *b;
|
||||
bool reuse = false;
|
||||
SpaData *d;
|
||||
struct spa_data *d;
|
||||
|
||||
b = spa_list_first (&state->ready, SpaALSABuffer, link);
|
||||
b = spa_list_first (&state->ready, struct buffer, link);
|
||||
d = b->outbuf->datas;
|
||||
|
||||
dst = SPA_MEMBER (my_areas[0].addr, offset * state->frame_size, uint8_t);
|
||||
|
||||
if (b->rb) {
|
||||
SpaRingbuffer *ringbuffer = &b->rb->ringbuffer;
|
||||
struct spa_ringbuffer *ringbuffer = &b->rb->ringbuffer;
|
||||
uint32_t index;
|
||||
int32_t avail;
|
||||
|
||||
|
|
@ -406,13 +406,13 @@ pull_frames (SpaALSAState *state,
|
|||
}
|
||||
|
||||
static snd_pcm_uframes_t
|
||||
push_frames (SpaALSAState *state,
|
||||
push_frames (struct state *state,
|
||||
const snd_pcm_channel_area_t *my_areas,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t frames)
|
||||
{
|
||||
snd_pcm_uframes_t total_frames = 0;
|
||||
SpaPortIO *io = state->io;
|
||||
struct spa_port_io *io = state->io;
|
||||
|
||||
if (spa_list_is_empty (&state->free)) {
|
||||
spa_log_trace (state->log, "no more buffers");
|
||||
|
|
@ -420,10 +420,10 @@ push_frames (SpaALSAState *state,
|
|||
else {
|
||||
uint8_t *src;
|
||||
size_t n_bytes;
|
||||
SpaALSABuffer *b;
|
||||
SpaData *d;
|
||||
struct buffer *b;
|
||||
struct spa_data *d;
|
||||
|
||||
b = spa_list_first (&state->free, SpaALSABuffer, link);
|
||||
b = spa_list_first (&state->free, struct buffer, link);
|
||||
spa_list_remove (&b->link);
|
||||
|
||||
if (b->h) {
|
||||
|
|
@ -455,7 +455,7 @@ push_frames (SpaALSAState *state,
|
|||
}
|
||||
|
||||
static int
|
||||
alsa_try_resume (SpaALSAState *state)
|
||||
alsa_try_resume (struct state *state)
|
||||
{
|
||||
int res;
|
||||
|
||||
|
|
@ -489,11 +489,11 @@ calc_timeout (size_t target,
|
|||
}
|
||||
|
||||
static void
|
||||
alsa_on_playback_timeout_event (SpaSource *source)
|
||||
alsa_on_playback_timeout_event (struct spa_source *source)
|
||||
{
|
||||
uint64_t exp;
|
||||
int res;
|
||||
SpaALSAState *state = source->data;
|
||||
struct state *state = source->data;
|
||||
snd_pcm_t *hndl = state->hndl;
|
||||
snd_pcm_sframes_t avail;
|
||||
struct itimerspec ts;
|
||||
|
|
@ -576,11 +576,11 @@ alsa_on_playback_timeout_event (SpaSource *source)
|
|||
|
||||
|
||||
static void
|
||||
alsa_on_capture_timeout_event (SpaSource *source)
|
||||
alsa_on_capture_timeout_event (struct spa_source *source)
|
||||
{
|
||||
uint64_t exp;
|
||||
int res;
|
||||
SpaALSAState *state = source->data;
|
||||
struct state *state = source->data;
|
||||
snd_pcm_t *hndl = state->hndl;
|
||||
snd_pcm_sframes_t avail;
|
||||
snd_pcm_uframes_t total_read = 0;
|
||||
|
|
@ -645,8 +645,8 @@ alsa_on_capture_timeout_event (SpaSource *source)
|
|||
timerfd_settime (state->timerfd, TFD_TIMER_ABSTIME, &ts, NULL);
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_alsa_start (SpaALSAState *state, bool xrun_recover)
|
||||
int
|
||||
spa_alsa_start (struct state *state, bool xrun_recover)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
|
@ -693,8 +693,8 @@ spa_alsa_start (SpaALSAState *state, bool xrun_recover)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_alsa_pause (SpaALSAState *state, bool xrun_recover)
|
||||
int
|
||||
spa_alsa_pause (struct state *state, bool xrun_recover)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,27 +39,24 @@ extern "C" {
|
|||
#include <spa/audio/format-utils.h>
|
||||
#include <spa/format-builder.h>
|
||||
|
||||
typedef struct _SpaALSAState SpaALSAState;
|
||||
typedef struct _SpaALSABuffer SpaALSABuffer;
|
||||
|
||||
typedef struct {
|
||||
struct props {
|
||||
char device[64];
|
||||
char device_name[128];
|
||||
char card_name[128];
|
||||
uint32_t min_latency;
|
||||
} SpaALSAProps;
|
||||
};
|
||||
|
||||
#define MAX_BUFFERS 64
|
||||
|
||||
struct _SpaALSABuffer {
|
||||
SpaBuffer *outbuf;
|
||||
SpaMetaHeader *h;
|
||||
SpaMetaRingbuffer *rb;
|
||||
struct buffer {
|
||||
struct spa_buffer *outbuf;
|
||||
struct spa_meta_header *h;
|
||||
struct spa_meta_ringbuffer *rb;
|
||||
bool outstanding;
|
||||
SpaList link;
|
||||
struct spa_list link;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct type {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
uint32_t format;
|
||||
|
|
@ -68,21 +65,21 @@ typedef struct {
|
|||
uint32_t prop_device_name;
|
||||
uint32_t prop_card_name;
|
||||
uint32_t prop_min_latency;
|
||||
SpaTypeMeta meta;
|
||||
SpaTypeData data;
|
||||
SpaTypeMediaType media_type;
|
||||
SpaTypeMediaSubtype media_subtype;
|
||||
SpaTypeMediaSubtypeAudio media_subtype_audio;
|
||||
SpaTypeFormatAudio format_audio;
|
||||
SpaTypeAudioFormat audio_format;
|
||||
SpaTypeEventNode event_node;
|
||||
SpaTypeCommandNode command_node;
|
||||
SpaTypeParamAllocBuffers param_alloc_buffers;
|
||||
SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
|
||||
} Type;
|
||||
struct spa_type_meta meta;
|
||||
struct spa_type_data data;
|
||||
struct spa_type_media_type media_type;
|
||||
struct spa_type_media_subtype media_subtype;
|
||||
struct spa_type_media_subtype_audio media_subtype_audio;
|
||||
struct spa_type_format_audio format_audio;
|
||||
struct spa_type_audio_format audio_format;
|
||||
struct spa_type_event_node event_node;
|
||||
struct spa_type_command_node command_node;
|
||||
struct spa_type_param_alloc_buffers param_alloc_buffers;
|
||||
struct spa_type_param_alloc_meta_enable param_alloc_meta_enable;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
|
||||
|
|
@ -106,33 +103,33 @@ init_type (Type *type, SpaTypeMap *map)
|
|||
spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
|
||||
}
|
||||
|
||||
struct _SpaALSAState {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
SpaClock clock;
|
||||
struct state {
|
||||
struct spa_handle handle;
|
||||
struct spa_node node;
|
||||
struct spa_clock clock;
|
||||
|
||||
uint32_t seq;
|
||||
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
SpaLoop *main_loop;
|
||||
SpaLoop *data_loop;
|
||||
struct type type;
|
||||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
struct spa_loop *data_loop;
|
||||
|
||||
snd_pcm_stream_t stream;
|
||||
snd_output_t *output;
|
||||
|
||||
SpaNodeCallbacks callbacks;
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
|
||||
uint8_t props_buffer[1024];
|
||||
SpaALSAProps props;
|
||||
struct props props;
|
||||
|
||||
bool opened;
|
||||
snd_pcm_t *hndl;
|
||||
|
||||
bool have_format;
|
||||
SpaAudioInfo current_format;
|
||||
struct spa_audio_info current_format;
|
||||
uint8_t format_buffer[1024];
|
||||
|
||||
snd_pcm_uframes_t buffer_frames;
|
||||
|
|
@ -142,20 +139,20 @@ struct _SpaALSAState {
|
|||
int channels;
|
||||
size_t frame_size;
|
||||
|
||||
SpaPortInfo info;
|
||||
struct spa_port_info info;
|
||||
uint32_t params[3];
|
||||
uint8_t params_buffer[1024];
|
||||
SpaPortIO *io;
|
||||
struct spa_port_io *io;
|
||||
|
||||
SpaALSABuffer buffers[MAX_BUFFERS];
|
||||
struct buffer buffers[MAX_BUFFERS];
|
||||
unsigned int n_buffers;
|
||||
|
||||
SpaList free;
|
||||
SpaList ready;
|
||||
struct spa_list free;
|
||||
struct spa_list ready;
|
||||
size_t ready_offset;
|
||||
|
||||
bool started;
|
||||
SpaSource source;
|
||||
struct spa_source source;
|
||||
int timerfd;
|
||||
bool alsa_started;
|
||||
int threshold;
|
||||
|
|
@ -178,19 +175,19 @@ struct _SpaALSAState {
|
|||
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
|
||||
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
|
||||
|
||||
SpaResult
|
||||
spa_alsa_enum_format (SpaALSAState *state,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
uint32_t index);
|
||||
int
|
||||
spa_alsa_enum_format (struct state *state,
|
||||
struct spa_format **format,
|
||||
const struct spa_format *filter,
|
||||
uint32_t index);
|
||||
|
||||
int spa_alsa_set_format (SpaALSAState *state,
|
||||
SpaAudioInfo *info,
|
||||
uint32_t flags);
|
||||
int spa_alsa_set_format (struct state *state,
|
||||
struct spa_audio_info *info,
|
||||
uint32_t flags);
|
||||
|
||||
SpaResult spa_alsa_start (SpaALSAState *state, bool xrun_recover);
|
||||
SpaResult spa_alsa_pause (SpaALSAState *state, bool xrun_recover);
|
||||
SpaResult spa_alsa_close (SpaALSAState *state);
|
||||
int spa_alsa_start (struct state *state, bool xrun_recover);
|
||||
int spa_alsa_pause (struct state *state, bool xrun_recover);
|
||||
int spa_alsa_close (struct state *state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@
|
|||
#include <spa/plugin.h>
|
||||
#include <spa/node.h>
|
||||
|
||||
extern const SpaHandleFactory spa_alsa_source_factory;
|
||||
extern const SpaHandleFactory spa_alsa_sink_factory;
|
||||
extern const SpaHandleFactory spa_alsa_monitor_factory;
|
||||
extern const struct spa_handle_factory spa_alsa_source_factory;
|
||||
extern const struct spa_handle_factory spa_alsa_sink_factory;
|
||||
extern const struct spa_handle_factory spa_alsa_monitor_factory;
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
int
|
||||
spa_handle_factory_enum (const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
{
|
||||
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue