From: Thibault Saunier Date: Fri, 31 Aug 2018 21:33:43 +0000 (-0300) Subject: alsa: Implement a DeviceProvider X-Git-Tag: 1.19.3~511^2~1263 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69c3c31608ecebfadd9717e950d8c708988563e3;p=platform%2Fupstream%2Fgstreamer.git alsa: Implement a DeviceProvider Removing gstalsadeviceprobe.[ch] as it was a relique from the 0.10 century. --- diff --git a/ext/alsa/Makefile.am b/ext/alsa/Makefile.am index c942a52..ddbc417 100644 --- a/ext/alsa/Makefile.am +++ b/ext/alsa/Makefile.am @@ -1,7 +1,7 @@ plugin_LTLIBRARIES = libgstalsa.la libgstalsa_la_SOURCES = \ - gstalsadeviceprobe.c \ + gstalsadeviceprovider.c \ gstalsaplugin.c \ gstalsasink.c \ gstalsasrc.c \ @@ -22,7 +22,7 @@ libgstalsa_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) noinst_HEADERS = \ gstalsa.h \ - gstalsadeviceprobe.h \ + gstalsadeviceprovider.h \ gstalsasrc.h \ gstalsasink.h \ gstalsamidisrc.h diff --git a/ext/alsa/gstalsadeviceprobe.c b/ext/alsa/gstalsadeviceprobe.c deleted file mode 100644 index 2f678e5..0000000 --- a/ext/alsa/gstalsadeviceprobe.c +++ /dev/null @@ -1,215 +0,0 @@ -/* Copyright (C) 2001 CodeFactory AB - * Copyright (C) 2001 Thomas Nyberg - * Copyright (C) 2001-2002 Andy Wingo - * Copyright (C) 2003 Benjamin Otte - * Copyright (C) 2005 Tim-Philipp Müller - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray - * with newer GLib versions (>= 2.31.0) */ -#define GLIB_DISABLE_DEPRECATION_WARNINGS - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstalsadeviceprobe.h" - -#if 0 -G_LOCK_DEFINE_STATIC (probe_lock); - -static const GList * -gst_alsa_device_property_probe_get_properties (GstPropertyProbe * probe) -{ - GObjectClass *klass = G_OBJECT_GET_CLASS (probe); - static GList *list = NULL; - - G_LOCK (probe_lock); - - if (!list) { - GParamSpec *pspec; - - pspec = g_object_class_find_property (klass, "device"); - list = g_list_append (NULL, pspec); - } - - G_UNLOCK (probe_lock); - - return list; -} - -static GList * -gst_alsa_get_device_list (snd_pcm_stream_t stream) -{ - snd_ctl_t *handle; - int card, dev; - snd_ctl_card_info_t *info; - snd_pcm_info_t *pcminfo; - gboolean mixer = (stream == -1); - GList *list = NULL; - - if (stream == -1) - stream = 0; - - snd_ctl_card_info_malloc (&info); - snd_pcm_info_malloc (&pcminfo); - card = -1; - - if (snd_card_next (&card) < 0 || card < 0) { - /* no soundcard found */ - GST_WARNING ("No soundcard found"); - goto beach; - } - - while (card >= 0) { - gchar name[32]; - - g_snprintf (name, sizeof (name), "hw:%d", card); - if (snd_ctl_open (&handle, name, 0) < 0) { - goto next_card; - } - if (snd_ctl_card_info (handle, info) < 0) { - snd_ctl_close (handle); - goto next_card; - } - - if (mixer) { - list = g_list_append (list, g_strdup (name)); - } else { - dev = -1; - while (1) { - gchar *gst_device; - - snd_ctl_pcm_next_device (handle, &dev); - - if (dev < 0) - break; - snd_pcm_info_set_device (pcminfo, dev); - snd_pcm_info_set_subdevice (pcminfo, 0); - snd_pcm_info_set_stream (pcminfo, stream); - if (snd_ctl_pcm_info (handle, pcminfo) < 0) { - continue; - } - - gst_device = g_strdup_printf ("hw:%d,%d", card, dev); - list = g_list_append (list, gst_device); - } - } - snd_ctl_close (handle); - next_card: - if (snd_card_next (&card) < 0) { - break; - } - } - -beach: - snd_ctl_card_info_free (info); - snd_pcm_info_free (pcminfo); - - return list; -} - -static void -gst_alsa_device_property_probe_probe_property (GstPropertyProbe * probe, - guint prop_id, const GParamSpec * pspec) -{ - if (!g_str_equal (pspec->name, "device")) { - G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec); - } -} - -static gboolean -gst_alsa_device_property_probe_needs_probe (GstPropertyProbe * probe, - guint prop_id, const GParamSpec * pspec) -{ - /* don't cache probed data */ - return TRUE; -} - -static GValueArray * -gst_alsa_device_property_probe_get_values (GstPropertyProbe * probe, - guint prop_id, const GParamSpec * pspec) -{ - GstElementClass *klass; - const GList *templates; - snd_pcm_stream_t mode = -1; - GValueArray *array; - GValue value = { 0, }; - GList *l, *list; - - if (!g_str_equal (pspec->name, "device")) { - G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec); - return NULL; - } - - klass = GST_ELEMENT_GET_CLASS (GST_ELEMENT (probe)); - - /* I'm pretty sure ALSA has a good way to do this. However, their cool - * auto-generated documentation is pretty much useless if you try to - * do function-wise look-ups. */ - /* we assume one pad template at max [zero=mixer] */ - templates = gst_element_class_get_pad_template_list (klass); - if (templates) { - if (GST_PAD_TEMPLATE_DIRECTION (templates->data) == GST_PAD_SRC) - mode = SND_PCM_STREAM_CAPTURE; - else - mode = SND_PCM_STREAM_PLAYBACK; - } - - list = gst_alsa_get_device_list (mode); - - if (list == NULL) { - GST_LOG_OBJECT (probe, "No devices found"); - return NULL; - } - - array = g_value_array_new (g_list_length (list)); - g_value_init (&value, G_TYPE_STRING); - for (l = list; l != NULL; l = l->next) { - GST_LOG_OBJECT (probe, "Found device: %s", (gchar *) l->data); - g_value_take_string (&value, (gchar *) l->data); - l->data = NULL; - g_value_array_append (array, &value); - } - g_value_unset (&value); - g_list_free (list); - - return array; -} - -static void -gst_alsa_property_probe_interface_init (GstPropertyProbeInterface * iface) -{ - iface->get_properties = gst_alsa_device_property_probe_get_properties; - iface->probe_property = gst_alsa_device_property_probe_probe_property; - iface->needs_probe = gst_alsa_device_property_probe_needs_probe; - iface->get_values = gst_alsa_device_property_probe_get_values; -} - -void -gst_alsa_type_add_device_property_probe_interface (GType type) -{ - static const GInterfaceInfo probe_iface_info = { - (GInterfaceInitFunc) gst_alsa_property_probe_interface_init, - NULL, - NULL, - }; - - g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE, - &probe_iface_info); -} -#endif diff --git a/ext/alsa/gstalsadeviceprobe.h b/ext/alsa/gstalsadeviceprobe.h deleted file mode 100644 index 20bf117..0000000 --- a/ext/alsa/gstalsadeviceprobe.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2001 CodeFactory AB - * Copyright (C) 2001 Thomas Nyberg - * Copyright (C) 2001-2002 Andy Wingo - * Copyright (C) 2003 Benjamin Otte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_ALSA_DEVICE_PROBE_H__ -#define __GST_ALSA_DEVICE_PROBE_H__ - -#include "gstalsa.h" - -G_BEGIN_DECLS - -#if 0 -void gst_alsa_type_add_device_property_probe_interface (GType type); -#endif - -G_END_DECLS - -#endif /* __GST_ALSA_DEVICE_PROBE_H__ */ - diff --git a/ext/alsa/gstalsadeviceprovider.c b/ext/alsa/gstalsadeviceprovider.c new file mode 100644 index 0000000..a05b8ce --- /dev/null +++ b/ext/alsa/gstalsadeviceprovider.c @@ -0,0 +1,365 @@ +/* GStreamer + * Copyright (C) 2018 Thibault Saunier + * + * alsadeviceprovider.c: alsa device probing and monitoring + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gstalsadeviceprovider.h" +#include +#include + + +static GstDevice *gst_alsa_device_new (const gchar * device_name, + GstCaps * caps, const gchar * internal_name, snd_pcm_stream_t stream, + GstStructure * properties); + +G_DEFINE_TYPE (GstAlsaDeviceProvider, gst_alsa_device_provider, + GST_TYPE_DEVICE_PROVIDER); + +static void gst_alsa_device_provider_finalize (GObject * object); +static void gst_alsa_device_provider_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void gst_alsa_device_provider_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); + + +static GList *gst_alsa_device_provider_probe (GstDeviceProvider * provider); + +static gboolean +gst_alsa_device_provider_start (GstDeviceProvider * provider) +{ + g_list_free_full (gst_alsa_device_provider_probe (provider), + gst_object_unref); + return TRUE; +} + +static void +gst_alsa_device_provider_stop (GstDeviceProvider * provider) +{ + return; +} + +enum +{ + PROP_0, + PROP_LAST +}; + + +static void +gst_alsa_device_provider_class_init (GstAlsaDeviceProviderClass * klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GstDeviceProviderClass *dm_class = GST_DEVICE_PROVIDER_CLASS (klass); + + gobject_class->set_property = gst_alsa_device_provider_set_property; + gobject_class->get_property = gst_alsa_device_provider_get_property; + gobject_class->finalize = gst_alsa_device_provider_finalize; + + dm_class->probe = gst_alsa_device_provider_probe; + dm_class->start = gst_alsa_device_provider_start; + dm_class->stop = gst_alsa_device_provider_stop; + + gst_device_provider_class_set_static_metadata (dm_class, + "Alsa Device Provider", "Sink/Source/Audio", + "List and provider Alsa source and sink devices", + "Thibault Saunier "); +} + +static void +gst_alsa_device_provider_init (GstAlsaDeviceProvider * self) +{ +} + +static void +gst_alsa_device_provider_finalize (GObject * object) +{ + // GstAlsaDeviceProvider *self = GST_ALSA_DEVICE_PROVIDER (object); + + G_OBJECT_CLASS (gst_alsa_device_provider_parent_class)->finalize (object); +} + + +static void +gst_alsa_device_provider_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec) +{ + // GstAlsaDeviceProvider *self = GST_ALSA_DEVICE_PROVIDER (object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_alsa_device_provider_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) +{ + // GstAlsaDeviceProvider *self = GST_ALSA_DEVICE_PROVIDER (object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static GstDevice * +add_device (GstDeviceProvider * provider, snd_ctl_t * info, + snd_pcm_stream_t stream, gchar * internal_name) +{ + GstCaps *caps; + GstDevice *dev; + + caps = gst_caps_new_simple ("audio/x-raw", NULL, NULL); + + dev = gst_alsa_device_new ("Alsa device", + caps, internal_name, stream, gst_structure_new_empty ("alsa-proplist")); + + gst_device_provider_device_add (provider, gst_object_ref (dev)); + + return dev; +} + +static GList * +gst_alsa_device_provider_probe (GstDeviceProvider * provider) +{ + snd_ctl_t *handle; + int card, dev; + snd_ctl_card_info_t *info; + snd_pcm_info_t *pcminfo; + GList *list = NULL; + gint i; + gint streams[] = { SND_PCM_STREAM_CAPTURE, SND_PCM_STREAM_PLAYBACK }; + snd_pcm_stream_t stream; + + GST_INFO_OBJECT (provider, "Probing alsa devices"); + snd_ctl_card_info_malloc (&info); + snd_pcm_info_malloc (&pcminfo); + card = -1; + + if (snd_card_next (&card) < 0 || card < 0) { + /* no soundcard found */ + GST_WARNING ("No soundcard found"); + goto beach; + } + + for (i = 0; i < G_N_ELEMENTS (streams); i++) { + stream = streams[i]; + + while (card >= 0) { + gchar name[32]; + + g_snprintf (name, sizeof (name), "hw:%d", card); + if (snd_ctl_open (&handle, name, 0) < 0) { + goto next_card; + } + if (snd_ctl_card_info (handle, info) < 0) { + snd_ctl_close (handle); + goto next_card; + } + + dev = -1; + while (1) { + gchar *gst_device; + + snd_ctl_pcm_next_device (handle, &dev); + + if (dev < 0) + break; + snd_pcm_info_set_device (pcminfo, dev); + snd_pcm_info_set_subdevice (pcminfo, 0); + snd_pcm_info_set_stream (pcminfo, stream); + if (snd_ctl_pcm_info (handle, pcminfo) < 0) { + continue; + } + + gst_device = g_strdup_printf ("hw:%d,%d", card, dev); + list = + g_list_prepend (list, add_device (provider, handle, stream, + gst_device)); + } + snd_ctl_close (handle); + next_card: + if (snd_card_next (&card) < 0) { + break; + } + } + } + +beach: + snd_ctl_card_info_free (info); + snd_pcm_info_free (pcminfo); + + return list; +} + +enum +{ + PROP_INTERNAL_NAME = 1, +}; + + +G_DEFINE_TYPE (GstAlsaDevice, gst_alsa_device, GST_TYPE_DEVICE); + +static void gst_alsa_device_finalize (GObject * object); +static GstElement *gst_alsa_device_create_element (GstDevice * device, + const gchar * name); +static gboolean gst_alsa_device_reconfigure_element (GstDevice * device, + GstElement * element); + +static void +gst_alsa_device_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstAlsaDevice *device; + + device = GST_ALSA_DEVICE_CAST (object); + + switch (prop_id) { + case PROP_INTERNAL_NAME: + g_value_set_string (value, device->internal_name); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_alsa_device_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstAlsaDevice *device; + + device = GST_ALSA_DEVICE_CAST (object); + + switch (prop_id) { + case PROP_INTERNAL_NAME: + device->internal_name = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void +gst_alsa_device_class_init (GstAlsaDeviceClass * klass) +{ + GstDeviceClass *dev_class = GST_DEVICE_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + dev_class->create_element = gst_alsa_device_create_element; + dev_class->reconfigure_element = gst_alsa_device_reconfigure_element; + + object_class->get_property = gst_alsa_device_get_property; + object_class->set_property = gst_alsa_device_set_property; + object_class->finalize = gst_alsa_device_finalize; + + g_object_class_install_property (object_class, PROP_INTERNAL_NAME, + g_param_spec_string ("internal-name", "Internal AlsaAudio device name", + "The internal name of the AlsaAudio device", "", + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); +} + +static void +gst_alsa_device_finalize (GObject * object) +{ + GstAlsaDevice *device = GST_ALSA_DEVICE (object); + + g_free (device->internal_name); + + G_OBJECT_CLASS (gst_alsa_device_parent_class)->finalize (object); +} + +static void +gst_alsa_device_init (GstAlsaDevice * device) +{ +} + +static GstElement * +gst_alsa_device_create_element (GstDevice * device, const gchar * name) +{ + GstAlsaDevice *alsa_dev = GST_ALSA_DEVICE (device); + GstElement *elem; + + elem = gst_element_factory_make (alsa_dev->element, name); + g_object_set (elem, "device", alsa_dev->internal_name, NULL); + + return elem; +} + +static gboolean +gst_alsa_device_reconfigure_element (GstDevice * device, GstElement * element) +{ + GstAlsaDevice *alsa_dev = GST_ALSA_DEVICE (device); + + g_object_set (element, "device", alsa_dev->internal_name, NULL); + + return TRUE; +} + +/* Takes ownership of @caps and @props */ +static GstDevice * +gst_alsa_device_new (const gchar * device_name, + GstCaps * caps, const gchar * internal_name, snd_pcm_stream_t stream, + GstStructure * props) +{ + GstAlsaDevice *gstdev; + const gchar *element = NULL; + const gchar *klass = NULL; + + g_return_val_if_fail (device_name, NULL); + g_return_val_if_fail (internal_name, NULL); + g_return_val_if_fail (caps, NULL); + + switch (stream) { + case SND_PCM_STREAM_CAPTURE: + element = "alsasrc"; + klass = "Audio/Source"; + break; + case SND_PCM_STREAM_PLAYBACK: + element = "alsasink"; + klass = "Audio/Sink"; + break; + default: + g_assert_not_reached (); + break; + } + + + gstdev = g_object_new (GST_TYPE_ALSA_DEVICE, + "display-name", device_name, "caps", caps, "device-class", klass, + "internal-name", internal_name, "properties", props, NULL); + + gstdev->stream = stream; + gstdev->element = element; + + gst_structure_free (props); + gst_caps_unref (caps); + + return GST_DEVICE (gstdev); +} diff --git a/ext/alsa/gstalsadeviceprovider.h b/ext/alsa/gstalsadeviceprovider.h new file mode 100644 index 0000000..52d7b69 --- /dev/null +++ b/ext/alsa/gstalsadeviceprovider.h @@ -0,0 +1,85 @@ +/* GStreamer + * Copyright (C) 2018 Thibault Saunier + * + * alsadeviceprovider.c: alsa device probing and monitoring + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#ifndef __GST_ALSA_DEVICE_PROVIDER_H__ +#define __GST_ALSA_DEVICE_PROVIDER_H__ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gstalsa.h" +#include + +G_BEGIN_DECLS + +typedef struct _GstAlsaDeviceProvider GstAlsaDeviceProvider; +typedef struct _GstAlsaDeviceProviderClass GstAlsaDeviceProviderClass; + +#define GST_TYPE_ALSA_DEVICE_PROVIDER (gst_alsa_device_provider_get_type()) +#define GST_IS_ALSA_DEVICE_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ALSA_DEVICE_PROVIDER)) +#define GST_IS_ALSA_DEVICE_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ALSA_DEVICE_PROVIDER)) +#define GST_ALSA_DEVICE_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ALSA_DEVICE_PROVIDER, GstAlsaDeviceProviderClass)) +#define GST_ALSA_DEVICE_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ALSA_DEVICE_PROVIDER, GstAlsaDeviceProvider)) +#define GST_ALSA_DEVICE_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE_PROVIDER, GstAlsaDeviceProviderClass)) +#define GST_ALSA_DEVICE_PROVIDER_CAST(obj) ((GstAlsaDeviceProvider *)(obj)) + +struct _GstAlsaDeviceProvider { + GstDeviceProvider parent; +}; + +struct _GstAlsaDeviceProviderClass { + GstDeviceProviderClass parent_class; +}; + +GType gst_alsa_device_provider_get_type (void); + + +typedef struct _GstAlsaDevice GstAlsaDevice; +typedef struct _GstAlsaDeviceClass GstAlsaDeviceClass; + +#define GST_TYPE_ALSA_DEVICE (gst_alsa_device_get_type()) +#define GST_IS_ALSA_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ALSA_DEVICE)) +#define GST_IS_ALSA_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ALSA_DEVICE)) +#define GST_ALSA_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ALSA_DEVICE, GstAlsaDeviceClass)) +#define GST_ALSA_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ALSA_DEVICE, GstAlsaDevice)) +#define GST_ALSA_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE, GstAlsaDeviceClass)) +#define GST_ALSA_DEVICE_CAST(obj) ((GstAlsaDevice *)(obj)) + +struct _GstAlsaDevice { + GstDevice parent; + + snd_pcm_stream_t stream; + gchar *internal_name; + const gchar *element; +}; + +struct _GstAlsaDeviceClass { + GstDeviceClass parent_class; +}; + +GType gst_alsa_device_get_type (void); + +G_END_DECLS + +#endif /* __GST_ALSA_DEVICE_PROVIDER_H__ */ + diff --git a/ext/alsa/gstalsaplugin.c b/ext/alsa/gstalsaplugin.c index 6c1a67c..90899fe 100644 --- a/ext/alsa/gstalsaplugin.c +++ b/ext/alsa/gstalsaplugin.c @@ -26,6 +26,7 @@ #include "gstalsasink.h" #include "gstalsasrc.h" #include "gstalsamidisrc.h" +#include "gstalsadeviceprovider.h" #include @@ -46,7 +47,7 @@ gst_alsa_error_wrapper (const char *file, int line, const char *function, va_start (args, fmt); str = g_strdup_vprintf (fmt, args); va_end (args); - /* FIXME: use GST_LEVEL_ERROR here? Currently warning is used because we're + /* FIXME: use GST_LEVEL_ERROR here? Currently warning is used because we're * able to catch enough of the errors that would be printed otherwise */ gst_debug_log (alsa_debug, GST_LEVEL_WARNING, file, function, line, NULL, @@ -70,6 +71,9 @@ plugin_init (GstPlugin * plugin) if (!gst_element_register (plugin, "alsamidisrc", GST_RANK_PRIMARY, GST_TYPE_ALSA_MIDI_SRC)) return FALSE; + if (!gst_device_provider_register (plugin, "alsadeviceprovider", + GST_RANK_PRIMARY, GST_TYPE_ALSA_DEVICE_PROVIDER)) + return FALSE; GST_DEBUG_CATEGORY_INIT (alsa_debug, "alsa", 0, "alsa plugins"); diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index e1bb7d7..2194be5 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -49,7 +49,6 @@ #include "gstalsa.h" #include "gstalsasink.h" -#include "gstalsadeviceprobe.h" #include #include diff --git a/ext/alsa/gstalsasrc.c b/ext/alsa/gstalsasrc.c index 6ee0ca8..647b00b 100644 --- a/ext/alsa/gstalsasrc.c +++ b/ext/alsa/gstalsasrc.c @@ -46,7 +46,6 @@ #include #include "gstalsasrc.h" -#include "gstalsadeviceprobe.h" #include diff --git a/ext/alsa/meson.build b/ext/alsa/meson.build index 7ad4ed7..04ee862 100644 --- a/ext/alsa/meson.build +++ b/ext/alsa/meson.build @@ -1,6 +1,6 @@ alsa_sources = [ 'gstalsa.c', - 'gstalsadeviceprobe.c', + 'gstalsadeviceprovider.c', 'gstalsamidisrc.c', 'gstalsaplugin.c', 'gstalsasink.c',