audio-dsp: improve properties

This commit is contained in:
Wim Taymans 2018-11-28 13:24:33 +01:00
parent 0c9dc75cb3
commit 7c54b4b89c
6 changed files with 37 additions and 34 deletions

View file

@ -128,7 +128,7 @@ static int emit_node(struct impl *this, snd_pcm_info_t *pcminfo)
static int emit_info(struct impl *this) static int emit_info(struct impl *this)
{ {
int err = 0, dev; int err = 0, dev;
struct spa_dict_item items[8]; struct spa_dict_item items[10];
snd_ctl_t *ctl_hndl; snd_ctl_t *ctl_hndl;
snd_ctl_card_info_t *info; snd_ctl_card_info_t *info;
snd_pcm_info_t *pcminfo; snd_pcm_info_t *pcminfo;
@ -147,17 +147,19 @@ static int emit_info(struct impl *this)
goto exit; goto exit;
} }
items[0] = SPA_DICT_ITEM_INIT("device.path", (char *)this->props.device); items[0] = SPA_DICT_ITEM_INIT("device.api", "alsa");
items[1] = SPA_DICT_ITEM_INIT("media.class", "Audio/Device"); items[1] = SPA_DICT_ITEM_INIT("device.path", (char *)this->props.device);
items[2] = SPA_DICT_ITEM_INIT("alsa.card.id", snd_ctl_card_info_get_id(info)); items[2] = SPA_DICT_ITEM_INIT("device.nick", snd_ctl_card_info_get_id(info));
items[3] = SPA_DICT_ITEM_INIT("alsa.card.components", snd_ctl_card_info_get_components(info)); items[3] = SPA_DICT_ITEM_INIT("media.class", "Audio/Device");
items[4] = SPA_DICT_ITEM_INIT("alsa.card.driver", snd_ctl_card_info_get_driver(info)); items[4] = SPA_DICT_ITEM_INIT("alsa.card.id", snd_ctl_card_info_get_id(info));
items[5] = SPA_DICT_ITEM_INIT("alsa.card.name", snd_ctl_card_info_get_name(info)); items[5] = SPA_DICT_ITEM_INIT("alsa.card.components", snd_ctl_card_info_get_components(info));
items[6] = SPA_DICT_ITEM_INIT("alsa.card.longname", snd_ctl_card_info_get_longname(info)); items[6] = SPA_DICT_ITEM_INIT("alsa.card.driver", snd_ctl_card_info_get_driver(info));
items[7] = SPA_DICT_ITEM_INIT("alsa.card.mixername", snd_ctl_card_info_get_mixername(info)); items[7] = SPA_DICT_ITEM_INIT("alsa.card.name", snd_ctl_card_info_get_name(info));
items[8] = SPA_DICT_ITEM_INIT("alsa.card.longname", snd_ctl_card_info_get_longname(info));
items[9] = SPA_DICT_ITEM_INIT("alsa.card.mixername", snd_ctl_card_info_get_mixername(info));
if (this->callbacks->info) if (this->callbacks->info)
this->callbacks->info(this->callbacks_data, &SPA_DICT_INIT(items, 8)); this->callbacks->info(this->callbacks_data, &SPA_DICT_INIT(items, 10));
snd_pcm_info_alloca(&pcminfo); snd_pcm_info_alloca(&pcminfo);
dev = -1; dev = -1;

View file

@ -143,7 +143,6 @@ static int fill_item(struct impl *this, struct udev_device *dev,
spa_pod_builder_push_struct(builder), spa_pod_builder_push_struct(builder),
add_dict(builder, add_dict(builder,
"udev-probed", "1", "udev-probed", "1",
"device.api", "alsa",
"device.path", udev_device_get_devnode(dev), "device.path", udev_device_get_devnode(dev),
"alsa.card", str, "alsa.card", str,
NULL); NULL);

View file

@ -72,19 +72,20 @@ struct impl {
static int emit_info(struct impl *this) static int emit_info(struct impl *this)
{ {
int res; int res;
struct spa_dict_item items[5]; struct spa_dict_item items[6];
if ((res = spa_v4l2_open(&this->dev, this->props.device)) < 0) if ((res = spa_v4l2_open(&this->dev, this->props.device)) < 0)
return res; return res;
items[0] = SPA_DICT_ITEM_INIT("device.path", (char *)this->props.device); items[0] = SPA_DICT_ITEM_INIT("device.api", "v4l2");
items[1] = SPA_DICT_ITEM_INIT("media.class", "Video/Device"); items[1] = SPA_DICT_ITEM_INIT("device.path", (char *)this->props.device);
items[2] = SPA_DICT_ITEM_INIT("v4l2.driver", (char *)this->dev.cap.driver); items[2] = SPA_DICT_ITEM_INIT("media.class", "Video/Device");
items[3] = SPA_DICT_ITEM_INIT("v4l2.card", (char *)this->dev.cap.card); items[3] = SPA_DICT_ITEM_INIT("v4l2.driver", (char *)this->dev.cap.driver);
items[4] = SPA_DICT_ITEM_INIT("v4l2.bus", (char *)this->dev.cap.bus_info); items[4] = SPA_DICT_ITEM_INIT("v4l2.card", (char *)this->dev.cap.card);
items[5] = SPA_DICT_ITEM_INIT("v4l2.bus", (char *)this->dev.cap.bus_info);
if (this->callbacks->info) if (this->callbacks->info)
this->callbacks->info(this->callbacks_data, &SPA_DICT_INIT(items, 5)); this->callbacks->info(this->callbacks_data, &SPA_DICT_INIT(items, 6));
if (this->callbacks->add) { if (this->callbacks->add) {
if (spa_v4l2_is_capture(&this->dev)) { if (spa_v4l2_is_capture(&this->dev)) {

View file

@ -112,7 +112,6 @@ static void fill_item(struct impl *this, struct udev_device *dev,
spa_pod_builder_prop(builder, SPA_MONITOR_ITEM_info, 0); spa_pod_builder_prop(builder, SPA_MONITOR_ITEM_info, 0);
spa_pod_builder_push_struct(builder); spa_pod_builder_push_struct(builder);
add_dict(builder, "udev-probed", "1"); add_dict(builder, "udev-probed", "1");
add_dict(builder, "device.api", "v4l2");
add_dict(builder, "device.path", udev_device_get_devnode(dev)); add_dict(builder, "device.path", udev_device_get_devnode(dev));
if ((str = udev_device_get_property_value(dev, "USEC_INITIALIZED")) && *str) if ((str = udev_device_get_property_value(dev, "USEC_INITIALIZED")) && *str)

View file

@ -1149,6 +1149,7 @@ static void rescan_session(struct impl *impl, struct session *sess)
uint8_t buf[1024]; uint8_t buf[1024];
struct spa_pod_builder b = { 0, }; struct spa_pod_builder b = { 0, };
struct spa_pod *param; struct spa_pod *param;
const char *str;
if (node->info->props == NULL) if (node->info->props == NULL)
return; return;
@ -1160,7 +1161,9 @@ static void rescan_session(struct impl *impl, struct session *sess)
info = node->format; info = node->format;
props = pw_properties_new_dict(node->info->props); props = pw_properties_new_dict(node->info->props);
pw_properties_set(props, "device.name", node->info->name); if ((str = pw_properties_get(props, "device.nick")) == NULL)
str = node->info->name;
pw_properties_set(props, "audio-dsp.name", str);
pw_properties_setf(props, "audio-dsp.direction", "%d", sess->direction); pw_properties_setf(props, "audio-dsp.direction", "%d", sess->direction);
pw_properties_setf(props, "audio-dsp.maxbuffer", "%ld", MAX_QUANTUM_SIZE * sizeof(float)); pw_properties_setf(props, "audio-dsp.maxbuffer", "%ld", MAX_QUANTUM_SIZE * sizeof(float));

View file

@ -203,7 +203,7 @@ static void node_port_init(void *data, struct pw_port *port)
pw_properties_setf(new, "port.alias1", "%s_pcm:%s:%s%s", pw_properties_setf(new, "port.alias1", "%s_pcm:%s:%s%s",
pw_properties_get(n->props, "device.api"), pw_properties_get(n->props, "device.api"),
pw_properties_get(n->props, "device.name"), pw_properties_get(n->props, "audio-dsp.name"),
direction == PW_DIRECTION_INPUT ? "in" : "out", direction == PW_DIRECTION_INPUT ? "in" : "out",
str); str);
@ -248,17 +248,19 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
{ {
struct pw_node *node; struct pw_node *node;
struct node *n; struct node *n;
const char *api, *alias, *plugged, *str; const char *api, *alias, *str;
char node_name[128]; char node_name[128];
struct pw_properties *pr; struct pw_properties *pr;
int i; int i;
if ((api = pw_properties_get(props, "device.api")) == NULL) { pr = pw_properties_copy(props);
if ((api = pw_properties_get(pr, "device.api")) == NULL) {
pw_log_error("missing device.api property"); pw_log_error("missing device.api property");
goto error; goto error;
} }
if ((alias = pw_properties_get(props, "device.name")) == NULL) { if ((alias = pw_properties_get(pr, "audio-dsp.name")) == NULL) {
pw_log_error("missing device.name property"); pw_log_error("missing audio-dsp.name property");
goto error; goto error;
} }
@ -268,18 +270,14 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
node_name[i] = '_'; node_name[i] = '_';
} }
pr = pw_properties_new( pw_properties_set(pr,
"media.class", "media.class",
direction == PW_DIRECTION_OUTPUT ? direction == PW_DIRECTION_OUTPUT ?
"Audio/DSP/Playback" : "Audio/DSP/Playback" :
"Audio/DSP/Capture", "Audio/DSP/Capture");
"device.name", alias, pw_properties_set(pr, "node.driver", NULL);
"device.api", api,
NULL);
if ((plugged = pw_properties_get(props, "node.plugged")) != NULL) if ((str = pw_properties_get(pr, "node.id")) != NULL)
pw_properties_set(pr, "node.plugged", plugged);
if ((str = pw_properties_get(props, "node.id")) != NULL)
pw_properties_set(pr, "node.session", str); pw_properties_set(pr, "node.session", str);
node = pw_spa_node_load(core, NULL, NULL, node = pw_spa_node_load(core, NULL, NULL,
@ -300,7 +298,7 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
n->core = core; n->core = core;
n->node = node; n->node = node;
n->direction = direction; n->direction = direction;
n->props = pw_properties_copy(props); n->props = pw_properties_copy(pr);
spa_list_init(&n->ports); spa_list_init(&n->ports);
n->max_buffer_size = max_buffer_size; n->max_buffer_size = max_buffer_size;
@ -313,6 +311,7 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
return node; return node;
error: error:
pw_properties_free(pr);
return NULL; return NULL;
} }