mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
alsa: add method to retrieve the card name
Reuse an existing method to retrieve the card name.
This commit is contained in:
parent
1f19649695
commit
693919ff87
2 changed files with 34 additions and 19 deletions
|
@ -462,6 +462,7 @@ subroutine_error:
|
|||
}
|
||||
}
|
||||
|
||||
/* returns the card name when the device number is unknown or -1 */
|
||||
static gchar *
|
||||
gst_alsa_find_device_name_no_handle (GstObject * obj, const gchar * devcard,
|
||||
gint device_num, snd_pcm_stream_t stream)
|
||||
|
@ -480,6 +481,7 @@ gst_alsa_find_device_name_no_handle (GstObject * obj, const gchar * devcard,
|
|||
if (snd_ctl_card_info (ctl, info) < 0)
|
||||
goto done;
|
||||
|
||||
if (device_num != -1) {
|
||||
while (snd_ctl_pcm_next_device (ctl, &dev) == 0 && dev >= 0) {
|
||||
if (dev == device_num) {
|
||||
snd_pcm_info_t *pcminfo;
|
||||
|
@ -503,12 +505,13 @@ gst_alsa_find_device_name_no_handle (GstObject * obj, const gchar * devcard,
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == NULL) {
|
||||
char *name = NULL;
|
||||
gint card;
|
||||
|
||||
GST_LOG_OBJECT (obj, "no luck so far, trying backup");
|
||||
GST_LOG_OBJECT (obj, "trying card name");
|
||||
card = snd_ctl_card_info_get_card (info);
|
||||
snd_card_get_name (card, &name);
|
||||
ret = g_strdup (name);
|
||||
|
@ -522,6 +525,13 @@ done:
|
|||
return ret;
|
||||
}
|
||||
|
||||
gchar *
|
||||
gst_alsa_find_card_name (GstObject * obj, const gchar * devcard,
|
||||
snd_pcm_stream_t stream)
|
||||
{
|
||||
return gst_alsa_find_device_name_no_handle (obj, devcard, -1, stream);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gst_alsa_find_device_name (GstObject * obj, const gchar * device,
|
||||
snd_pcm_t * handle, snd_pcm_stream_t stream)
|
||||
|
|
|
@ -52,4 +52,9 @@ gchar * gst_alsa_find_device_name (GstObject * obj,
|
|||
snd_pcm_t * handle,
|
||||
snd_pcm_stream_t stream);
|
||||
|
||||
gchar * gst_alsa_find_card_name (GstObject * obj,
|
||||
const gchar * devcard,
|
||||
snd_pcm_stream_t stream);
|
||||
|
||||
|
||||
#endif /* __GST_ALSA_H__ */
|
||||
|
|
Loading…
Reference in a new issue