ext/alsa/: Implement alsasink with simple open/write/close API.

Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
This commit is contained in:
Wim Taymans 2005-04-28 16:19:06 +00:00
parent 235ea5989c
commit 851547e321
6 changed files with 607 additions and 614 deletions

View file

@ -1,3 +1,21 @@
2005-04-28 Wim Taymans <wim@fluendo.com>
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 Wim Taymans <wim@fluendo.com> 2005-04-28 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/Makefile.am: * gst-libs/gst/audio/Makefile.am:

View file

@ -3,18 +3,18 @@ plugin_LTLIBRARIES = libgstalsa.la
libgstalsa_la_SOURCES = \ libgstalsa_la_SOURCES = \
gstalsaplugin.c \ gstalsaplugin.c \
gstalsa.c \ gstalsasink.c
gstalsaclock.c \ #gstalsamixer.c
gstalsasink.c \ #gstalsamixertrack.c
gstalsasrc.c \ #gstalsamixeroptions.c
gstalsamixer.c \ #gstalsa.c
gstalsamixertrack.c \ #gstalsaclock.c
gstalsamixeroptions.c #gstalsasrc.c
libgstalsa_la_CFLAGS = $(GST_CFLAGS) $(ALSA_CFLAGS) libgstalsa_la_CFLAGS = $(GST_CFLAGS) $(ALSA_CFLAGS)
libgstalsa_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstalsa_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) \
libgstalsa_la_LIBADD = $(ALSA_LIBS) \ libgstalsa_la_LIBADD = $(ALSA_LIBS) \
${top_builddir}/gst-libs/gst/libgstinterfaces-@GST_MAJORMINOR@.la \ ${top_builddir}/gst-libs/gst/libgstinterfaces-@GST_MAJORMINOR@.la \
${top_builddir}/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la ${top_builddir}/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la
noinst_HEADERS = \ noinst_HEADERS = \

View file

@ -215,9 +215,6 @@ gst_alsa_init (GstAlsa * this)
{ {
this->device = g_strdup ("default"); this->device = g_strdup ("default");
this->cached_caps = NULL; this->cached_caps = NULL;
GST_FLAG_SET (this, GST_ELEMENT_EVENT_AWARE);
GST_FLAG_SET (this, GST_ELEMENT_THREAD_SUGGESTED);
} }
static void static void
@ -1108,7 +1105,7 @@ gst_alsa_get_caps (GstPad * pad)
} }
} }
} }
gst_caps_free (caps); gst_caps_unref (caps);
} }
} }
} }
@ -1133,14 +1130,14 @@ gst_alsa_fixate_to_mimetype (const GstCaps * caps, const gchar * mime)
try = gst_caps_new_simple (mime, NULL); try = gst_caps_new_simple (mime, NULL);
result = gst_caps_intersect (try, caps); result = gst_caps_intersect (try, caps);
gst_caps_free (try); gst_caps_unref (try);
if (gst_caps_is_empty (result)) { if (gst_caps_is_empty (result)) {
gst_caps_free (result); gst_caps_unref (result);
return NULL; return NULL;
} }
if (gst_caps_is_subset (caps, result)) { if (gst_caps_is_subset (caps, result)) {
/* we didn't reduce caps */ /* we didn't reduce caps */
gst_caps_free (result); gst_caps_unref (result);
return NULL; return NULL;
} }
return result; return result;
@ -1180,18 +1177,18 @@ gst_alsa_fixate_field_nearest_int (const GstCaps * caps,
} }
} }
if (!gst_caps_is_empty (equal)) { if (!gst_caps_is_empty (equal)) {
gst_caps_free (bigger); gst_caps_unref (bigger);
gst_caps_free (smaller); gst_caps_unref (smaller);
result = equal; result = equal;
} else { } else {
gst_caps_free (equal); gst_caps_unref (equal);
if (!gst_caps_is_empty (bigger)) { if (!gst_caps_is_empty (bigger)) {
gst_caps_free (smaller); gst_caps_unref (smaller);
result = bigger; result = bigger;
} else { } else {
gst_caps_free (bigger); gst_caps_unref (bigger);
if (gst_caps_is_empty (smaller)) { if (gst_caps_is_empty (smaller)) {
gst_caps_free (smaller); gst_caps_unref (smaller);
return NULL; return NULL;
} }
result = smaller; result = smaller;
@ -1199,7 +1196,7 @@ gst_alsa_fixate_field_nearest_int (const GstCaps * caps,
} }
if (gst_caps_is_subset (caps, result)) { if (gst_caps_is_subset (caps, result)) {
/* we didn't reduce caps */ /* we didn't reduce caps */
gst_caps_free (result); gst_caps_unref (result);
return NULL; return NULL;
} }
return result; return result;
@ -1296,13 +1293,13 @@ gst_alsa_link (GstPad * pad, const GstCaps * caps)
old) == GST_PAD_LINK_REFUSED) { old) == GST_PAD_LINK_REFUSED) {
GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL), GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
("could not reset caps to a sane value")); ("could not reset caps to a sane value"));
gst_caps_free (old); gst_caps_unref (old);
break; break;
} else { } else {
/* FIXME: unset caps on pads somehow */ /* FIXME: unset caps on pads somehow */
} }
} }
gst_caps_free (old); gst_caps_unref (old);
ret = GST_PAD_LINK_REFUSED; ret = GST_PAD_LINK_REFUSED;
goto out; goto out;
} }
@ -1928,7 +1925,7 @@ gst_alsa_close_audio (GstAlsa * this)
GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_SYNC_START, 0); GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_SYNC_START, 0);
GST_FLAG_UNSET (this, GST_ALSA_OPEN); GST_FLAG_UNSET (this, GST_ALSA_OPEN);
if (this->cached_caps) { if (this->cached_caps) {
gst_caps_free (this->cached_caps); gst_caps_unref (this->cached_caps);
this->cached_caps = NULL; this->cached_caps = NULL;
} }

View file

@ -56,12 +56,14 @@ plugin_init (GstPlugin * plugin)
{ {
int err; int err;
if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE, /*
GST_TYPE_ALSA_MIXER)) if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE,
return FALSE; GST_TYPE_ALSA_MIXER))
if (!gst_element_register (plugin, "alsasrc", GST_RANK_NONE, return FALSE;
GST_TYPE_ALSA_SRC)) if (!gst_element_register (plugin, "alsasrc", GST_RANK_NONE,
return FALSE; GST_TYPE_ALSA_SRC))
return FALSE;
*/
if (!gst_element_register (plugin, "alsasink", GST_RANK_NONE, if (!gst_element_register (plugin, "alsasink", GST_RANK_NONE,
GST_TYPE_ALSA_SINK)) GST_TYPE_ALSA_SINK))
return FALSE; return FALSE;

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,7 @@
/* /* GStreamer
* Copyright (C) 2001 CodeFactory AB * Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
* Copyright (C) 2001 Thomas Nyberg <thomas@codefactory.se> *
* Copyright (C) 2001-2002 Andy Wingo <apwingo@eos.ncsu.edu> * gstalsasink.h:
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -11,49 +10,63 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public * You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free * License along with this library; if not, write to the
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#ifndef __GST_ALSA_SINK_H__
#define __GST_ALSA_SINK_H__
#include "gstalsamixer.h" #ifndef __GST_ALSASINK_H__
#define __GST_ALSASINK_H__
#include <gst/gst.h>
#include <gst/audio/gstaudiosink.h>
#include <asoundlib.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA_SINK, GstAlsaSink)) #define GST_TYPE_ALSA_SINK (gst_alsasink_get_type())
#define GST_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA_SINK, GstAlsaSinkClass)) #define GST_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_SINK,GstAlsaSink))
#define GST_IS_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA_SINK)) #define GST_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_SINK,GstAlsaSinkClass))
#define GST_IS_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA_SINK)) #define GST_IS_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_SINK))
#define GST_TYPE_ALSA_SINK (gst_alsa_sink_get_type()) #define GST_IS_ALSA_SINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_SINK))
typedef struct _GstAlsaSink GstAlsaSink; typedef struct _GstAlsaSink GstAlsaSink;
typedef struct _GstAlsaSinkClass GstAlsaSinkClass; typedef struct _GstAlsaSinkClass GstAlsaSinkClass;
struct _GstAlsaSink { struct _GstAlsaSink {
GstAlsaMixer parent; GstAudioSink sink;
/* array of the data on the channels */ gchar *device;
guint8 *buf_data[GST_ALSA_MAX_TRACKS]; /* pointer into buffer */
guint size[GST_ALSA_MAX_TRACKS]; /* sink: bytes left in buffer */ snd_pcm_t *handle;
GstData *gst_data[GST_ALSA_MAX_TRACKS]; /* current data */ snd_pcm_hw_params_t *hwparams;
guint behaviour[GST_ALSA_MAX_TRACKS]; /* 0 = data points into buffer (so unref when size == 0), snd_pcm_sw_params_t *swparams;
1 = data should be freed, use buffer after that */
snd_pcm_access_t access;
snd_pcm_format_t format;
guint rate;
guint channels;
gint bytes_per_sample;
guint buffer_time;
guint period_time;
snd_pcm_sframes_t buffer_size;
snd_pcm_sframes_t period_size;
}; };
struct _GstAlsaSinkClass { struct _GstAlsaSinkClass {
GstAlsaMixerClass parent_class; GstAudioSinkClass parent_class;
}; };
GType gst_alsa_sink_get_type (void); GType gst_alsasink_get_type(void);
gboolean gst_alsa_sink_factory_init (GstPlugin *plugin);
G_END_DECLS G_END_DECLS
#endif /* __GST_ALSA_SINK_H__ */ #endif /* __GST_ALSASINK_H__ */