Commit 851547e3 authored by Wim Taymans's avatar Wim Taymans

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.
parent 235ea598
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>
* gst-libs/gst/audio/Makefile.am:
......
......@@ -3,18 +3,18 @@ plugin_LTLIBRARIES = libgstalsa.la
libgstalsa_la_SOURCES = \
gstalsaplugin.c \
gstalsa.c \
gstalsaclock.c \
gstalsasink.c \
gstalsasrc.c \
gstalsamixer.c \
gstalsamixertrack.c \
gstalsamixeroptions.c
gstalsasink.c
#gstalsamixer.c
#gstalsamixertrack.c
#gstalsamixeroptions.c
#gstalsa.c
#gstalsaclock.c
#gstalsasrc.c
libgstalsa_la_CFLAGS = $(GST_CFLAGS) $(ALSA_CFLAGS)
libgstalsa_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstalsa_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) \
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
noinst_HEADERS = \
......
......@@ -215,9 +215,6 @@ gst_alsa_init (GstAlsa * this)
{
this->device = g_strdup ("default");
this->cached_caps = NULL;
GST_FLAG_SET (this, GST_ELEMENT_EVENT_AWARE);
GST_FLAG_SET (this, GST_ELEMENT_THREAD_SUGGESTED);
}
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);
result = gst_caps_intersect (try, caps);
gst_caps_free (try);
gst_caps_unref (try);
if (gst_caps_is_empty (result)) {
gst_caps_free (result);
gst_caps_unref (result);
return NULL;
}
if (gst_caps_is_subset (caps, result)) {
/* we didn't reduce caps */
gst_caps_free (result);
gst_caps_unref (result);
return NULL;
}
return result;
......@@ -1180,18 +1177,18 @@ gst_alsa_fixate_field_nearest_int (const GstCaps * caps,
}
}
if (!gst_caps_is_empty (equal)) {
gst_caps_free (bigger);
gst_caps_free (smaller);
gst_caps_unref (bigger);
gst_caps_unref (smaller);
result = equal;
} else {
gst_caps_free (equal);
gst_caps_unref (equal);
if (!gst_caps_is_empty (bigger)) {
gst_caps_free (smaller);
gst_caps_unref (smaller);
result = bigger;
} else {
gst_caps_free (bigger);
gst_caps_unref (bigger);
if (gst_caps_is_empty (smaller)) {
gst_caps_free (smaller);
gst_caps_unref (smaller);
return NULL;
}
result = smaller;
......@@ -1199,7 +1196,7 @@ gst_alsa_fixate_field_nearest_int (const GstCaps * caps,
}
if (gst_caps_is_subset (caps, result)) {
/* we didn't reduce caps */
gst_caps_free (result);
gst_caps_unref (result);
return NULL;
}
return result;
......@@ -1296,13 +1293,13 @@ gst_alsa_link (GstPad * pad, const GstCaps * caps)
old) == GST_PAD_LINK_REFUSED) {
GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
("could not reset caps to a sane value"));
gst_caps_free (old);
gst_caps_unref (old);
break;
} else {
/* FIXME: unset caps on pads somehow */
}
}
gst_caps_free (old);
gst_caps_unref (old);
ret = GST_PAD_LINK_REFUSED;
goto out;
}
......@@ -1928,7 +1925,7 @@ gst_alsa_close_audio (GstAlsa * this)
GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_SYNC_START, 0);
GST_FLAG_UNSET (this, GST_ALSA_OPEN);
if (this->cached_caps) {
gst_caps_free (this->cached_caps);
gst_caps_unref (this->cached_caps);
this->cached_caps = NULL;
}
......
......@@ -56,12 +56,14 @@ plugin_init (GstPlugin * plugin)
{
int err;
if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE,
GST_TYPE_ALSA_MIXER))
return FALSE;
if (!gst_element_register (plugin, "alsasrc", GST_RANK_NONE,
GST_TYPE_ALSA_SRC))
return FALSE;
/*
if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE,
GST_TYPE_ALSA_MIXER))
return FALSE;
if (!gst_element_register (plugin, "alsasrc", GST_RANK_NONE,
GST_TYPE_ALSA_SRC))
return FALSE;
*/
if (!gst_element_register (plugin, "alsasink", GST_RANK_NONE,
GST_TYPE_ALSA_SINK))
return FALSE;
......
This diff is collapsed.
/*
* Copyright (C) 2001 CodeFactory AB
* Copyright (C) 2001 Thomas Nyberg <thomas@codefactory.se>
* Copyright (C) 2001-2002 Andy Wingo <apwingo@eos.ncsu.edu>
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
/* GStreamer
* Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
*
* gstalsasink.h:
*
* This library is free software; you can redistribute it and/or
* 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,
* 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.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
* 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_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
#define GST_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA_SINK, GstAlsaSink))
#define GST_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA_SINK, GstAlsaSinkClass))
#define GST_IS_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA_SINK))
#define GST_IS_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA_SINK))
#define GST_TYPE_ALSA_SINK (gst_alsa_sink_get_type())
#define GST_TYPE_ALSA_SINK (gst_alsasink_get_type())
#define GST_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_SINK,GstAlsaSink))
#define GST_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_SINK,GstAlsaSinkClass))
#define GST_IS_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_SINK))
#define GST_IS_ALSA_SINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_SINK))
typedef struct _GstAlsaSink GstAlsaSink;
typedef struct _GstAlsaSinkClass GstAlsaSinkClass;
struct _GstAlsaSink {
GstAlsaMixer parent;
/* array of the data on the channels */
guint8 *buf_data[GST_ALSA_MAX_TRACKS]; /* pointer into buffer */
guint size[GST_ALSA_MAX_TRACKS]; /* sink: bytes left in buffer */
GstData *gst_data[GST_ALSA_MAX_TRACKS]; /* current data */
guint behaviour[GST_ALSA_MAX_TRACKS]; /* 0 = data points into buffer (so unref when size == 0),
1 = data should be freed, use buffer after that */
GstAudioSink sink;
gchar *device;
snd_pcm_t *handle;
snd_pcm_hw_params_t *hwparams;
snd_pcm_sw_params_t *swparams;
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 {
GstAlsaMixerClass parent_class;
GstAudioSinkClass parent_class;
};
GType gst_alsa_sink_get_type (void);
gboolean gst_alsa_sink_factory_init (GstPlugin *plugin);
GType gst_alsasink_get_type(void);
G_END_DECLS
#endif /* __GST_ALSA_SINK_H__ */
#endif /* __GST_ALSASINK_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment