mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-09 13:30:06 -05:00
alsa: implement monitor and device
This commit is contained in:
parent
0a88805743
commit
e23c209a5f
11 changed files with 527 additions and 289 deletions
|
|
@ -253,10 +253,14 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
|
|||
struct pw_properties *pr;
|
||||
int i;
|
||||
|
||||
if ((api = pw_properties_get(props, "device.api")) == NULL)
|
||||
if ((api = pw_properties_get(props, "device.api")) == NULL) {
|
||||
pw_log_error("missing device.api property");
|
||||
goto error;
|
||||
if ((alias = pw_properties_get(props, "device.name")) == NULL)
|
||||
}
|
||||
if ((alias = pw_properties_get(props, "device.name")) == NULL) {
|
||||
pw_log_error("missing device.name property");
|
||||
goto error;
|
||||
}
|
||||
|
||||
snprintf(node_name, sizeof(node_name), "system_%s", alias);
|
||||
for (i = 0; node_name[i]; i++) {
|
||||
|
|
@ -287,8 +291,10 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
|
|||
PW_SPA_NODE_FLAG_ACTIVATE | PW_SPA_NODE_FLAG_NO_REGISTER,
|
||||
pr, sizeof(struct node) + user_data_size);
|
||||
|
||||
if (node == NULL)
|
||||
if (node == NULL) {
|
||||
pw_log_error("can't load spa node");
|
||||
goto error;
|
||||
}
|
||||
|
||||
n = pw_spa_node_get_user_data(node);
|
||||
n->core = core;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@
|
|||
#include <pipewire/device.h>
|
||||
|
||||
#include "spa-monitor.h"
|
||||
#include "spa-node.h"
|
||||
#include "spa-device.h"
|
||||
|
||||
struct monitor_item {
|
||||
|
|
@ -81,7 +80,6 @@ static struct monitor_item *add_item(struct pw_spa_monitor *this,
|
|||
enum spa_monitor_item_state state;
|
||||
struct spa_pod *info = NULL;
|
||||
const struct spa_support *support;
|
||||
enum pw_spa_node_flags flags;
|
||||
uint32_t n_support, type;
|
||||
|
||||
if (spa_pod_object_parse(item,
|
||||
|
|
@ -147,13 +145,6 @@ static struct monitor_item *add_item(struct pw_spa_monitor *this,
|
|||
mitem->type = type;
|
||||
|
||||
switch (type) {
|
||||
case SPA_TYPE_INTERFACE_Node:
|
||||
flags = PW_SPA_NODE_FLAG_ACTIVATE;
|
||||
flags |= (state == SPA_MONITOR_ITEM_STATE_Available) ? 0 : PW_SPA_NODE_FLAG_DISABLE;
|
||||
mitem->object = pw_spa_node_new(impl->core, NULL, impl->parent, name,
|
||||
flags,
|
||||
iface, handle, props, 0);
|
||||
break;
|
||||
case SPA_TYPE_INTERFACE_Device:
|
||||
mitem->object = pw_spa_device_new(impl->core, NULL, impl->parent, name,
|
||||
0, iface, handle, props, 0);
|
||||
|
|
|
|||
|
|
@ -202,7 +202,8 @@ static void device_add(void *data, uint32_t id,
|
|||
uint32_t n_support;
|
||||
struct pw_node *node;
|
||||
struct node_data *nd;
|
||||
int res;
|
||||
struct pw_properties *props;
|
||||
int i, res;
|
||||
void *iface;
|
||||
|
||||
if (type != SPA_TYPE_INTERFACE_Node) {
|
||||
|
|
@ -213,9 +214,13 @@ static void device_add(void *data, uint32_t id,
|
|||
pw_log_debug("device %p: add node %d", device, id);
|
||||
support = pw_core_get_support(device->core, &n_support);
|
||||
|
||||
props = pw_properties_copy(device->properties);
|
||||
for (i = 0; info && i < info->n_items; i++)
|
||||
pw_properties_set(props, info->items[i].key, info->items[i].value);
|
||||
|
||||
node = pw_node_new(device->core,
|
||||
device->info.name,
|
||||
pw_properties_copy(device->properties),
|
||||
props,
|
||||
sizeof(struct node_data) +
|
||||
spa_handle_factory_get_size(factory, info));
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ struct pw_properties *pw_properties_copy(const struct pw_properties *properties)
|
|||
* \memberof pw_properties
|
||||
*/
|
||||
struct pw_properties *pw_properties_merge(const struct pw_properties *oldprops,
|
||||
struct pw_properties *newprops)
|
||||
const struct pw_properties *newprops)
|
||||
{
|
||||
struct pw_properties *res = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ pw_properties_copy(const struct pw_properties *properties);
|
|||
|
||||
struct pw_properties *
|
||||
pw_properties_merge(const struct pw_properties *oldprops,
|
||||
struct pw_properties *newprops);
|
||||
const struct pw_properties *newprops);
|
||||
|
||||
void
|
||||
pw_properties_free(struct pw_properties *properties);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue