mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
alsa: clean up device info
This commit is contained in:
parent
417c1cd756
commit
72dee1686d
2 changed files with 15 additions and 16 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit e8dfd22a6bd9c784976985b78283734ac2b24e25
|
Subproject commit 08d60716933acf35690a088af4f3802c396360b8
|
||||||
|
|
@ -99,27 +99,26 @@ static const char *get_subclass(snd_pcm_info_t *pcminfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int emit_device(struct impl *this, snd_ctl_card_info_t *info, snd_pcm_info_t *pcminfo)
|
static int emit_node(struct impl *this, snd_ctl_card_info_t *info, snd_pcm_info_t *pcminfo)
|
||||||
{
|
{
|
||||||
struct spa_dict_item items[13];
|
struct spa_dict_item items[12];
|
||||||
const struct spa_handle_factory *factory;
|
const struct spa_handle_factory *factory;
|
||||||
char device_name[128];
|
char device_name[128];
|
||||||
|
|
||||||
snprintf(device_name, 128, "%s,%d", this->props.device, snd_pcm_info_get_device(pcminfo));
|
snprintf(device_name, 128, "%s,%d", this->props.device, snd_pcm_info_get_device(pcminfo));
|
||||||
|
|
||||||
items[0] = SPA_DICT_ITEM_INIT("alsa.card.id", snd_ctl_card_info_get_id(info));
|
items[0] = SPA_DICT_ITEM_INIT("alsa.device", device_name);
|
||||||
items[1] = SPA_DICT_ITEM_INIT("alsa.device", device_name);
|
items[1] = SPA_DICT_ITEM_INIT("alsa.card.id", snd_ctl_card_info_get_id(info));
|
||||||
items[2] = SPA_DICT_ITEM_INIT("alsa.card.components", snd_ctl_card_info_get_components(info));
|
items[2] = SPA_DICT_ITEM_INIT("alsa.card.components", snd_ctl_card_info_get_components(info));
|
||||||
items[3] = SPA_DICT_ITEM_INIT("alsa.card.driver", snd_ctl_card_info_get_driver(info));
|
items[3] = SPA_DICT_ITEM_INIT("alsa.card.driver", snd_ctl_card_info_get_driver(info));
|
||||||
items[4] = SPA_DICT_ITEM_INIT("alsa.card.name", snd_ctl_card_info_get_name(info));
|
items[4] = SPA_DICT_ITEM_INIT("alsa.card.name", snd_ctl_card_info_get_name(info));
|
||||||
items[5] = SPA_DICT_ITEM_INIT("alsa.card.longname", snd_ctl_card_info_get_longname(info));
|
items[5] = SPA_DICT_ITEM_INIT("alsa.card.longname", snd_ctl_card_info_get_longname(info));
|
||||||
items[6] = SPA_DICT_ITEM_INIT("alsa.card.mixername", snd_ctl_card_info_get_mixername(info));
|
items[6] = SPA_DICT_ITEM_INIT("alsa.card.mixername", snd_ctl_card_info_get_mixername(info));
|
||||||
items[7] = SPA_DICT_ITEM_INIT("device.name", snd_ctl_card_info_get_id(info));
|
items[7] = SPA_DICT_ITEM_INIT("alsa.pcm.id", snd_pcm_info_get_id(pcminfo));
|
||||||
items[8] = SPA_DICT_ITEM_INIT("alsa.pcm.id", snd_pcm_info_get_id(pcminfo));
|
items[8] = SPA_DICT_ITEM_INIT("alsa.pcm.name", snd_pcm_info_get_name(pcminfo));
|
||||||
items[9] = SPA_DICT_ITEM_INIT("alsa.pcm.name", snd_pcm_info_get_name(pcminfo));
|
items[9] = SPA_DICT_ITEM_INIT("alsa.pcm.subname", snd_pcm_info_get_subdevice_name(pcminfo));
|
||||||
items[10] = SPA_DICT_ITEM_INIT("alsa.pcm.subname", snd_pcm_info_get_subdevice_name(pcminfo));
|
items[10] = SPA_DICT_ITEM_INIT("alsa.pcm.class", get_class(pcminfo));
|
||||||
items[11] = SPA_DICT_ITEM_INIT("alsa.pcm.class", get_class(pcminfo));
|
items[11] = SPA_DICT_ITEM_INIT("alsa.pcm.subclass", get_subclass(pcminfo));
|
||||||
items[12] = SPA_DICT_ITEM_INIT("alsa.pcm.subclass", get_subclass(pcminfo));
|
|
||||||
|
|
||||||
if (snd_pcm_info_get_stream(pcminfo) == SND_PCM_STREAM_PLAYBACK)
|
if (snd_pcm_info_get_stream(pcminfo) == SND_PCM_STREAM_PLAYBACK)
|
||||||
factory = &spa_alsa_sink_factory;
|
factory = &spa_alsa_sink_factory;
|
||||||
|
|
@ -129,12 +128,12 @@ static int emit_device(struct impl *this, snd_ctl_card_info_t *info, snd_pcm_inf
|
||||||
this->callbacks->add(this->callbacks_data, 0,
|
this->callbacks->add(this->callbacks_data, 0,
|
||||||
factory,
|
factory,
|
||||||
SPA_TYPE_INTERFACE_Node,
|
SPA_TYPE_INTERFACE_Node,
|
||||||
&SPA_DICT_INIT(items, 13));
|
&SPA_DICT_INIT_ARRAY(items));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int emit_devices(struct impl *this)
|
static int emit_nodes(struct impl *this)
|
||||||
{
|
{
|
||||||
int err = 0, dev;
|
int err = 0, dev;
|
||||||
snd_ctl_card_info_t *info;
|
snd_ctl_card_info_t *info;
|
||||||
|
|
@ -173,7 +172,7 @@ static int emit_devices(struct impl *this)
|
||||||
spa_log_error(this->log, "error pcm info: %s", snd_strerror(err));
|
spa_log_error(this->log, "error pcm info: %s", snd_strerror(err));
|
||||||
}
|
}
|
||||||
if (err >= 0)
|
if (err >= 0)
|
||||||
emit_device(this, info, pcminfo);
|
emit_node(this, info, pcminfo);
|
||||||
|
|
||||||
snd_pcm_info_set_stream(pcminfo, SND_PCM_STREAM_CAPTURE);
|
snd_pcm_info_set_stream(pcminfo, SND_PCM_STREAM_CAPTURE);
|
||||||
if ((err = snd_ctl_pcm_info(this->ctl_hndl, pcminfo)) < 0) {
|
if ((err = snd_ctl_pcm_info(this->ctl_hndl, pcminfo)) < 0) {
|
||||||
|
|
@ -181,7 +180,7 @@ static int emit_devices(struct impl *this)
|
||||||
spa_log_error(this->log, "error pcm info: %s", snd_strerror(err));
|
spa_log_error(this->log, "error pcm info: %s", snd_strerror(err));
|
||||||
}
|
}
|
||||||
if (err >= 0)
|
if (err >= 0)
|
||||||
emit_device(this, info, pcminfo);
|
emit_node(this, info, pcminfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
@ -212,7 +211,7 @@ static int impl_set_callbacks(struct spa_device *device,
|
||||||
callbacks->info(data, &SPA_DICT_INIT_ARRAY(info_items));
|
callbacks->info(data, &SPA_DICT_INIT_ARRAY(info_items));
|
||||||
|
|
||||||
if (this->callbacks->add)
|
if (this->callbacks->add)
|
||||||
emit_devices(this);
|
emit_nodes(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue