Commit 730ff798 authored by Benjamin Otte's avatar Benjamin Otte
Browse files

fixing alsa step 2: complete rewrite of data transfer. The whole stuff is...

fixing alsa step 2: complete rewrite of data transfer. The whole stuff is clean enough to go from there now.

Original commit message from CVS:
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
parent 2534ded8
......@@ -3,7 +3,8 @@
This plugin was originally written by Thomas Nyberg <thomas@codefactory.se> 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 @@ My particular card has 4 channel out and 2 channel in. As you can see, each of
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.
This diff is collapsed.
......@@ -2,6 +2,7 @@
* 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>
*
* 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 @@ enum {
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;
/* latency / performance parameters */
snd_pcm_uframes_t period_size;
unsigned int period_count;
guint buffer_frames;
guint period_count; /* 'number of fragments' in oss-speak */
guint period_frames;
gboolean debug;
gboolean autorecover;
};
struct _GstAlsaClass {
......
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