From: Benjamin O. <co...@us...> - 2003-02-09 22:47:47
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: company Date: Sun Feb 09 2003 14:47:46 PST Log message: fixing alsa step 2: complete rewrite of data transfer. The whole stuff is clean enough to go from there now. License change to LGPL, since no copied code is left now. Missing: - alsasrc - resetting format - corner cases - testsuite Modified files: ext/alsa : README gstalsa.c gstalsa.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/alsa/README.diff?r1=1.1&r2=1.2 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/alsa/gstalsa.c.diff?r1=1.29&r2=1.30 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/alsa/gstalsa.h.diff?r1=1.6&r2=1.7 ====Begin Diffs==== Index: README =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/alsa/README,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- README 23 Dec 2001 00:25:30 -0000 1.1 +++ README 9 Feb 2003 22:47:34 -0000 1.2 @@ -3,7 +3,8 @@ This plugin was originally written by Thomas Nyberg <th...@co...> for ALSA 0.5.x. It was updated and changed quite a bit in September 2001 by Andy -Wingo for use with ALSA 0.9.x. +Wingo for use with ALSA 0.9.x. It was rewritten in great part again by Benjamin +Otte in January/February 2003. 1.0 Introduction ---------------- @@ -44,21 +45,18 @@ these devices are stereo. The alsasink and alsasrc elements correspond to the default alsa devices. -3.0 License ------------ - -ALSA 0.9.x isn't very well documented, so I had to rely on a number of different -sources for guidance. One of the main sources of inspiration was Paul Davis' -audioengine (available in quasimodo's cvs tree, -http://quasimodo.sourceforge.net/), from which I took a large amount of code. -Since that project is licensed under the GPL, it was only right that I license -the updated version of this plugin under the GPL as well. What, in my -understanding, this means for the end user is that you cannot use the ALSA -plugin with a non-GPL program. If in doubt, please refer to the COPYING file -located in this directory. - - - +3.0 Where to look for other ALSA drivers +---------------------------------------- +ALSA 0.9 isn't very well documented, so we had to rely on a number of different +sources for guidance. Sources of inspiration include JACK's alsa driver +(available in jack's cvs tree, http://jack.sourceforge.net/), the alsa2 driver +of mplayer (http://www.mplayerhq.hu) and the pcm.c example from the ALSA library +itself. +(http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html) +4.0 License +----------- +This plugin is licensed under the Lesser General Public License (LGPL). See the +file COPYING in the top source directory. Index: gstalsa.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/alsa/gstalsa.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- gstalsa.c 30 Jan 2003 18:30:30 -0000 1.29 +++ gstalsa.c 9 Feb 2003 22:47:34 -0000 1.30 @@ -2,6 +2,7 @@ * Copyright (C) 2001 CodeFactory AB * Copyright (C) 2001 Thomas Nyberg <th...@co...> * Copyright (C) 2001-2002 Andy Wingo <ap...@eo...> + * Copyright (C) 2003 Benjamin Otte <in...@pu...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -22,6 +23,33 @@ #include <sys/time.h> #include "gstalsa.h" [...1294 lines suppressed...] /*** GSTREAMER PLUGIN *********************************************************/ @@ -1373,12 +1174,15 @@ if (!gst_library_load ("gstbytestream")) return FALSE; + /* FIXME: doesn't work */ + if (0) { factory = gst_element_factory_new ("alsasrc", GST_TYPE_ALSA_SRC, &gst_alsa_src_details); g_return_val_if_fail (factory != NULL, FALSE); gst_element_factory_add_pad_template (factory, gst_alsa_src_pad_factory ()); gst_element_factory_add_pad_template (factory, gst_alsa_src_request_pad_factory ()); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - + } + factory = gst_element_factory_new ("alsasink", GST_TYPE_ALSA_SINK, &gst_alsa_sink_details); g_return_val_if_fail (factory != NULL, FALSE); gst_element_factory_add_pad_template (factory, gst_alsa_sink_pad_factory ()); Index: gstalsa.h =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/alsa/gstalsa.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gstalsa.h 27 Jan 2003 12:59:24 -0000 1.6 +++ gstalsa.h 9 Feb 2003 22:47:34 -0000 1.7 @@ -2,6 +2,7 @@ * Copyright (C) 2001 CodeFactory AB * Copyright (C) 2001 Thomas Nyberg <th...@co...> * Copyright (C) 2001-2002 Andy Wingo <ap...@eo...> + * Copyright (C) 2003 Benjamin Otte <in...@pu...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,11 +22,16 @@ #ifndef __GST_ALSA_H__ #define __GST_ALSA_H__ +#define ALSA_PCM_NEW_HW_PARAMS_API +#define ALSA_PCM_NEW_SW_PARAMS_API + #include <alsa/asoundlib.h> #include <gst/gst.h> #include <gst/bytestream/bytestream.h> #include <glib.h> +#define GST_ALSA_MAX_CHANNELS 64 /* we don't support more than 64 channels */ + #define GST_ALSA(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA, GstAlsa) #define GST_ALSA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA, GstAlsaClass) #define GST_IS_ALSA(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA) @@ -44,8 +50,6 @@ #define GST_IS_ALSA_SRC_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA_SRC) #define GST_TYPE_ALSA_SRC gst_alsa_src_get_type() -#define GST_ALSA_PAD(obj) ((GstAlsaPad*)obj->data) /* obj is a GList */ - /* I would have preferred to avoid this variety of trickery, but without it i * can't tell whether I'm a source or a sink upon creation. */ @@ -62,59 +66,32 @@ GST_ALSA_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 3, }; -typedef gboolean (*GstAlsaProcessFunc) (GstAlsa *, snd_pcm_uframes_t frames); - typedef struct { - gint channel; GstPad *pad; GstByteStream *bs; - - /* buf and offset are only used for src elements to hold data from the sound - card, while we're waiting for an entire period_frames data. */ - char *buf; - snd_pcm_uframes_t offset; + guint8 *data; } GstAlsaPad; struct _GstAlsa { GstElement parent; - /* list of GstAlsaPads */ - GList *pads; + /* array of GstAlsaPads */ + GstAlsaPad pads[GST_ALSA_MAX_CHANNELS]; gchar *device; snd_pcm_stream_t stream; snd_pcm_t *handle; snd_output_t *out; - /* our mmap'd data areas */ - gboolean mmap_open; - const snd_pcm_channel_area_t *mmap_areas; - char **access_addr; - snd_pcm_uframes_t offset; - snd_pcm_sframes_t avail; - - GstAlsaProcessFunc process; - snd_pcm_format_t format; guint rate; gint channels; - guint32 mute; /* bitmask. */ - - /* the gstreamer data */ - gboolean data_interleaved; - gboolean autorecover; - - /* access to the hardware */ - gboolean access_interleaved; - guint sample_bytes; - guint interleave_unit; - guint interleave_skip; - guint buffer_frames; - guint period_count; /* 'number of fragments' in oss-speak */ - guint period_frames; + /* latency / performance parameters */ + snd_pcm_uframes_t period_size; + unsigned int period_count; - gboolean debug; + gboolean autorecover; }; struct _GstAlsaClass { |