mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
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
This commit is contained in:
parent
2534ded87b
commit
730ff79841
3 changed files with 430 additions and 651 deletions
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
This plugin was originally written by Thomas Nyberg <thomas@codefactory.se> for
|
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
|
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
|
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
|
these devices are stereo. The alsasink and alsasrc elements correspond to the
|
||||||
default alsa devices.
|
default alsa devices.
|
||||||
|
|
||||||
3.0 License
|
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
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
ALSA 0.9.x isn't very well documented, so I had to rely on a number of different
|
This plugin is licensed under the Lesser General Public License (LGPL). See the
|
||||||
sources for guidance. One of the main sources of inspiration was Paul Davis'
|
file COPYING in the top source directory.
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1000
ext/alsa/gstalsa.c
1000
ext/alsa/gstalsa.c
File diff suppressed because it is too large
Load diff
|
@ -2,6 +2,7 @@
|
||||||
* Copyright (C) 2001 CodeFactory AB
|
* Copyright (C) 2001 CodeFactory AB
|
||||||
* Copyright (C) 2001 Thomas Nyberg <thomas@codefactory.se>
|
* Copyright (C) 2001 Thomas Nyberg <thomas@codefactory.se>
|
||||||
* Copyright (C) 2001-2002 Andy Wingo <apwingo@eos.ncsu.edu>
|
* 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
|
* 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
|
||||||
|
@ -21,11 +22,16 @@
|
||||||
#ifndef __GST_ALSA_H__
|
#ifndef __GST_ALSA_H__
|
||||||
#define __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 <alsa/asoundlib.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/bytestream/bytestream.h>
|
#include <gst/bytestream/bytestream.h>
|
||||||
#include <glib.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(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_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)
|
#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_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_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
|
/* 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. */
|
* 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,
|
GST_ALSA_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef gboolean (*GstAlsaProcessFunc) (GstAlsa *, snd_pcm_uframes_t frames);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gint channel;
|
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
GstByteStream *bs;
|
GstByteStream *bs;
|
||||||
|
guint8 *data;
|
||||||
/* 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;
|
|
||||||
} GstAlsaPad;
|
} GstAlsaPad;
|
||||||
|
|
||||||
struct _GstAlsa {
|
struct _GstAlsa {
|
||||||
GstElement parent;
|
GstElement parent;
|
||||||
|
|
||||||
/* list of GstAlsaPads */
|
/* array of GstAlsaPads */
|
||||||
GList *pads;
|
GstAlsaPad pads[GST_ALSA_MAX_CHANNELS];
|
||||||
|
|
||||||
gchar *device;
|
gchar *device;
|
||||||
snd_pcm_stream_t stream;
|
snd_pcm_stream_t stream;
|
||||||
snd_pcm_t *handle;
|
snd_pcm_t *handle;
|
||||||
snd_output_t *out;
|
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;
|
snd_pcm_format_t format;
|
||||||
guint rate;
|
guint rate;
|
||||||
gint channels;
|
gint channels;
|
||||||
guint32 mute; /* bitmask. */
|
|
||||||
|
|
||||||
/* the gstreamer data */
|
/* latency / performance parameters */
|
||||||
gboolean data_interleaved;
|
snd_pcm_uframes_t period_size;
|
||||||
gboolean autorecover;
|
unsigned int period_count;
|
||||||
|
|
||||||
/* access to the hardware */
|
gboolean autorecover;
|
||||||
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;
|
|
||||||
|
|
||||||
gboolean debug;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAlsaClass {
|
struct _GstAlsaClass {
|
||||||
|
|
Loading…
Reference in a new issue