mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
added alsa
Original commit message from CVS: added alsa
This commit is contained in:
parent
30479f6ad7
commit
0a6cc4d112
7 changed files with 1646 additions and 2 deletions
1
TODO
1
TODO
|
@ -17,3 +17,4 @@
|
||||||
|
|
||||||
* check options in a52, it has some arch stuff and some opti stuff that
|
* check options in a52, it has some arch stuff and some opti stuff that
|
||||||
looks dodgy
|
looks dodgy
|
||||||
|
|
||||||
|
|
|
@ -1152,6 +1152,7 @@ sys/xvideo/Makefile
|
||||||
ext/Makefile
|
ext/Makefile
|
||||||
ext/a52/Makefile
|
ext/a52/Makefile
|
||||||
ext/aalib/Makefile
|
ext/aalib/Makefile
|
||||||
|
ext/alsa/Makefile
|
||||||
ext/audiofile/Makefile
|
ext/audiofile/Makefile
|
||||||
ext/esd/Makefile
|
ext/esd/Makefile
|
||||||
ext/lame/Makefile
|
ext/lame/Makefile
|
||||||
|
|
|
@ -10,6 +10,12 @@ else
|
||||||
AALIB_DIR=
|
AALIB_DIR=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if USE_ALSA
|
||||||
|
ALSA_DIR=alsa
|
||||||
|
else
|
||||||
|
ALSA_DIR=
|
||||||
|
endif
|
||||||
|
|
||||||
if USE_AUDIOFILE
|
if USE_AUDIOFILE
|
||||||
AUDIOFILE_DIR=audiofile
|
AUDIOFILE_DIR=audiofile
|
||||||
else
|
else
|
||||||
|
@ -47,8 +53,8 @@ VORBIS_DIR=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
SUBDIRS=$(A52_DIR) $(AALIB_DIR) $(AUDIOFILE_DIR) $(ESD_DIR) \
|
SUBDIRS=$(A52_DIR) $(AALIB_DIR) $(ALSA_DIR) $(AUDIOFILE_DIR) $(ESD_DIR) \
|
||||||
$(LAME_DIR) $(MAD_DIR) \
|
$(LAME_DIR) $(MAD_DIR) \
|
||||||
$(SDL_DIR) $(VORBIS_DIR)
|
$(SDL_DIR) $(VORBIS_DIR)
|
||||||
|
|
||||||
DIST_SUBDIRS=a52 aalib audiofile esd lame mad sdl vorbis
|
DIST_SUBDIRS=a52 aalib alsa audiofile esd lame mad sdl vorbis
|
||||||
|
|
13
ext/alsa/Makefile.am
Normal file
13
ext/alsa/Makefile.am
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
plugindir = $(libdir)/gst
|
||||||
|
|
||||||
|
plugin_LTLIBRARIES = libgstalsa.la
|
||||||
|
|
||||||
|
libgstalsa_la_SOURCES = gstalsa.c
|
||||||
|
|
||||||
|
noinst_HEADERS = gstalsa.h
|
||||||
|
|
||||||
|
libgstalsa_la_CFLAGS = $(ALSA_CFLAGS) $(GST_CFLAGS)
|
||||||
|
libgstalsa_la_LIBADD = $(ALSA_LIBS)
|
||||||
|
|
||||||
|
EXTRA_DIST = README
|
||||||
|
|
64
ext/alsa/README
Normal file
64
ext/alsa/README
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
0.0 History
|
||||||
|
-----------
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
1.0 Introduction
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This plugin was designed for use with ALSA 0.9.x, using other versions most
|
||||||
|
assuredly will not work.
|
||||||
|
|
||||||
|
The plugin will probe which cards and pcm-devices that are availible, and then
|
||||||
|
it tries to determine their capabilities. This will allow the use of multiple
|
||||||
|
cards with multiple pcm-devices - at the same time! Since I only have one card
|
||||||
|
on my system, as of yet, I haven't had the chance to try this out.
|
||||||
|
|
||||||
|
2.0 How to use it
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Since we can have multiple soundcards, each having the same name - and also
|
||||||
|
multiple pcm-devices on each card, a problem with naming occurs. When
|
||||||
|
the alsa-plugins are initialized, a factory is created for each card and
|
||||||
|
pcm-device on the system.
|
||||||
|
|
||||||
|
On my desktop, I have the following:
|
||||||
|
|
||||||
|
wingo@cebreiro:~/src/gstreamer$ gstreamer-inspect alsa
|
||||||
|
INFO ( 339:-1) Initializing GStreamer Core Library
|
||||||
|
INFO ( 339:-1) CPU features: (808009bf) MMX 3DNOW
|
||||||
|
Plugin Details:
|
||||||
|
Name: alsa
|
||||||
|
Long Name: Alsa plugin library
|
||||||
|
Filename: /usr/lib/gst/libalsa.so
|
||||||
|
|
||||||
|
ES1370/1_sink: ES1370 DAC2/ADC
|
||||||
|
ES1370/2_sink: ES1370 DAC1
|
||||||
|
ES1370/1_src: ES1370 DAC2/ADC
|
||||||
|
alsasink: default alsa sink
|
||||||
|
alsasrc: default alsa src
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1433
ext/alsa/gstalsa.c
Normal file
1433
ext/alsa/gstalsa.c
Normal file
File diff suppressed because it is too large
Load diff
126
ext/alsa/gstalsa.h
Normal file
126
ext/alsa/gstalsa.h
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2001 CodeFactory AB
|
||||||
|
Copyright (C) 2001 Thomas Nyberg <thomas@codefactory.se>
|
||||||
|
Copyright (C) 2001 Andy Wingo <apwingo@eos.ncsu.edu>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
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
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GST_ALSA_H__
|
||||||
|
#define __GST_ALSA_H__
|
||||||
|
|
||||||
|
#include <sys/asoundlib.h>
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <libs/bytestream/gstbytestream.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#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)
|
||||||
|
#define GST_IS_ALSA_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA)
|
||||||
|
#define GST_TYPE_ALSA gst_alsa_get_type()
|
||||||
|
|
||||||
|
#define GST_ALSA_SINK(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA_SINK, GstAlsa)
|
||||||
|
#define GST_ALSA_SINK_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA_SINK, GstAlsaClass)
|
||||||
|
#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_ALSA_SRC(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA_SRC, GstAlsa)
|
||||||
|
#define GST_ALSA_SRC_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA_SRC, GstAlsaClass)
|
||||||
|
#define GST_IS_ALSA_SRC(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, 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_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. */
|
||||||
|
|
||||||
|
typedef struct _GstAlsa GstAlsa;
|
||||||
|
typedef struct _GstAlsaClass GstAlsaClass;
|
||||||
|
typedef GstAlsa GstAlsaSink;
|
||||||
|
typedef GstAlsaClass GstAlsaSinkClass;
|
||||||
|
typedef GstAlsa GstAlsaSrc;
|
||||||
|
typedef GstAlsaClass GstAlsaSrcClass;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
GST_ALSA_OPEN = GST_ELEMENT_FLAG_LAST,
|
||||||
|
GST_ALSA_RUNNING,
|
||||||
|
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;
|
||||||
|
/* pointer to where we can access mmap_areas */
|
||||||
|
char *access_addr;
|
||||||
|
char *buf;
|
||||||
|
/* how much of the buffer we have used */
|
||||||
|
snd_pcm_uframes_t offset;
|
||||||
|
} GstAlsaPad;
|
||||||
|
|
||||||
|
struct _GstAlsa {
|
||||||
|
GstElement parent;
|
||||||
|
|
||||||
|
/* list of GstAlsaPads */
|
||||||
|
GList *pads;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstAlsaClass {
|
||||||
|
GstElementClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gst_alsa_get_type (void);
|
||||||
|
GType gst_alsa_sink_get_type (void);
|
||||||
|
GType gst_alsa_src_get_type (void);
|
||||||
|
|
||||||
|
#endif /* __ALSA_H__ */
|
Loading…
Reference in a new issue