Commit c4c3736e authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

oss: port to 0.11

parent ad5c3cd3
......@@ -310,7 +310,7 @@ dnl Non ported plugins (non-dependant, then dependant)
dnl Make sure you have a space before and after all plugins
GST_PLUGINS_NONPORTED="deinterlace \
cairo cairo_gobject gdk_pixbuf \
oss oss4 \
oss4 \
osx_video osx_audio "
AC_SUBST(GST_PLUGINS_NONPORTED)
......
......@@ -194,7 +194,6 @@ EXTRA_HFILES = \
$(top_srcdir)/sys/oss4/oss4-mixer.h \
$(top_srcdir)/sys/oss4/oss4-sink.h \
$(top_srcdir)/sys/oss4/oss4-source.h \
$(top_srcdir)/sys/oss/gstossmixerelement.h \
$(top_srcdir)/sys/oss/gstosssink.h \
$(top_srcdir)/sys/oss/gstosssrc.h \
$(top_srcdir)/sys/osxaudio/gstosxaudiosrc.h \
......
......@@ -114,7 +114,6 @@
<xi:include href="xml/element-oss4mixer.xml" />
<xi:include href="xml/element-oss4sink.xml" />
<xi:include href="xml/element-oss4src.xml" />
<xi:include href="xml/element-ossmixer.xml" />
<xi:include href="xml/element-osssink.xml" />
<xi:include href="xml/element-osssrc.xml" />
<xi:include href="xml/element-osxaudiosink.xml" />
......
......@@ -1457,20 +1457,6 @@ GstOss4SourceInput
GstOss4SourceInputClass
</SECTION>
<SECTION>
<FILE>element-ossmixer</FILE>
<TITLE>ossmixer</TITLE>
GstOssMixerElement
<SUBSECTION Standard>
GstOssMixerElementClass
GST_OSS_MIXER_ELEMENT
GST_OSS_MIXER_ELEMENT_CLASS
GST_IS_OSS_MIXER_ELEMENT
GST_IS_OSS_MIXER_ELEMENT_CLASS
GST_TYPE_OSS_MIXER_ELEMENT
gst_oss_mixer_element_get_type
</SECTION>
<SECTION>
<FILE>element-osssink</FILE>
<TITLE>osssink</TITLE>
......
......@@ -2,16 +2,12 @@ plugin_LTLIBRARIES = libgstossaudio.la
libgstossaudio_la_SOURCES = gstossaudio.c \
gstosshelper.c \
gstossmixer.c \
gstossmixerelement.c \
gstossmixertrack.c \
gstosssink.c \
gstosssrc.c
libgstossaudio_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgstossaudio_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) \
-lgstinterfaces-$(GST_API_VERSION) \
-lgstaudio-$(GST_API_VERSION) \
$(GST_BASE_LIBS) \
$(GST_LIBS)
......@@ -22,7 +18,4 @@ noinst_HEADERS = common.h \
gstosssink.h \
gstosssrc.h \
gstosshelper.h \
gstossdmabuffer.h \
gstossmixer.h \
gstossmixerelement.h \
gstossmixertrack.h
gstossdmabuffer.h
......@@ -23,7 +23,6 @@
#include "gst/gst-i18n-plugin.h"
#include "gstossmixerelement.h"
#include "gstosssink.h"
#include "gstosssrc.h"
......@@ -33,9 +32,7 @@ GST_DEBUG_CATEGORY (oss_debug);
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "ossmixer", GST_RANK_NONE,
GST_TYPE_OSS_MIXER_ELEMENT) ||
!gst_element_register (plugin, "osssrc", GST_RANK_SECONDARY,
if (!gst_element_register (plugin, "osssrc", GST_RANK_SECONDARY,
GST_TYPE_OSS_SRC) ||
!gst_element_register (plugin, "osssink", GST_RANK_SECONDARY,
GST_TYPE_OSSSINK)) {
......
......@@ -47,10 +47,7 @@
# endif /* HAVE_OSS_INCLUDE_IN_ROOT */
#endif /* HAVE_OSS_INCLUDE_IN_SYS */
#include <gst/interfaces/propertyprobe.h>
#include "gstosshelper.h"
#include "gstossmixer.h"
GST_DEBUG_CATEGORY_EXTERN (oss_debug);
#define GST_CAT_DEFAULT oss_debug
......@@ -176,19 +173,19 @@ gst_oss_helper_get_format_structure (unsigned int format_bit)
format = "U8";
break;
case AFMT_S16_LE:
format = "S16_LE";
format = "S16LE";
break;
case AFMT_S16_BE:
format = "S16_BE";
format = "S16BE";
break;
case AFMT_S8:
format = "S8";
break;
case AFMT_U16_LE:
format = "U16_LE";
format = "U16LE";
break;
case AFMT_U16_BE:
format = "U16_BE";
format = "U16BE";
break;
default:
g_assert_not_reached ();
......@@ -196,7 +193,8 @@ gst_oss_helper_get_format_structure (unsigned int format_bit)
}
structure = gst_structure_new ("audio/x-raw",
"format", G_TYPE_STRING, format, NULL);
"format", G_TYPE_STRING, format,
"layout", G_TYPE_STRING, "interleaved", NULL);
return structure;
}
......@@ -386,3 +384,41 @@ gst_oss_helper_rate_int_compare (gconstpointer a, gconstpointer b)
return 1;
return 0;
}
gchar *
gst_oss_helper_get_card_name (const gchar * mixer_name)
{
#ifdef SOUND_MIXER_INFO
struct mixer_info minfo;
#endif
gint fd;
gchar *name = NULL;
GST_INFO ("Opening mixer for device %s", mixer_name);
fd = open (mixer_name, O_RDWR);
if (fd == -1)
goto open_failed;
/* get name, not fatal */
#ifdef SOUND_MIXER_INFO
if (ioctl (fd, SOUND_MIXER_INFO, &minfo) == 0) {
name = g_strdup (minfo.name);
GST_INFO ("Card name = %s", GST_STR_NULL (name));
} else
#endif
{
name = g_strdup ("Unknown");
GST_INFO ("Unknown card name");
}
return name;
/* ERRORS */
open_failed:
{
/* this is valid. OSS devices don't need to expose a mixer */
GST_DEBUG ("Failed to open mixer device %s, mixing disabled: %s",
mixer_name, strerror (errno));
return NULL;
}
}
......@@ -36,6 +36,9 @@ G_BEGIN_DECLS
GstCaps* gst_oss_helper_probe_caps (gint fd);
gchar *gst_oss_helper_get_card_name (const gchar * mixer_name);
G_END_DECLS
......
This diff is collapsed.
/* GStreamer OSS Mixer implementation
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* gstossmixer.h: mixer interface implementation for OSS
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_OSS_MIXER_H__
#define __GST_OSS_MIXER_H__
#include <gst/gst.h>
#include <gst/interfaces/mixer.h>
#include "gstosshelper.h"
G_BEGIN_DECLS
#define GST_OSS_MIXER(obj) ((GstOssMixer*)(obj))
typedef enum {
GST_OSS_MIXER_CAPTURE = 1<<0,
GST_OSS_MIXER_PLAYBACK = 1<<1,
GST_OSS_MIXER_ALL = GST_OSS_MIXER_CAPTURE | GST_OSS_MIXER_PLAYBACK
} GstOssMixerDirection;
typedef struct _GstOssMixer GstOssMixer;
struct _GstOssMixer {
GList * tracklist; /* list of available tracks */
gint mixer_fd;
gchar * device;
gchar * cardname;
gint recmask;
gint recdevs;
gint stereomask;
gint devmask;
gint mixcaps;
GstOssMixerDirection dir;
};
GstOssMixer* gst_ossmixer_new (const gchar *device,
GstOssMixerDirection dir);
void gst_ossmixer_free (GstOssMixer *mixer);
const GList* gst_ossmixer_list_tracks (GstOssMixer * mixer);
void gst_ossmixer_set_volume (GstOssMixer * mixer,
GstMixerTrack * track,
gint * volumes);
void gst_ossmixer_get_volume (GstOssMixer * mixer,
GstMixerTrack * track,
gint * volumes);
void gst_ossmixer_set_record (GstOssMixer * mixer,
GstMixerTrack * track,
gboolean record);
void gst_ossmixer_set_mute (GstOssMixer * mixer,
GstMixerTrack * track,
gboolean mute);
#define GST_IMPLEMENT_OSS_MIXER_METHODS(Type, interface_as_function) \
static gboolean \
interface_as_function ## _supported (Type *this, GType iface_type) \
{ \
g_assert (iface_type == GST_TYPE_MIXER); \
\
return (this->mixer != NULL); \
} \
\
static const GList* \
interface_as_function ## _list_tracks (GstMixer * mixer) \
{ \
Type *this = (Type*) mixer; \
\
g_return_val_if_fail (this != NULL, NULL); \
g_return_val_if_fail (this->mixer != NULL, NULL); \
\
return gst_ossmixer_list_tracks (this->mixer); \
} \
\
static void \
interface_as_function ## _set_volume (GstMixer * mixer, GstMixerTrack * track, \
gint * volumes) \
{ \
Type *this = (Type*) mixer; \
\
g_return_if_fail (this != NULL); \
g_return_if_fail (this->mixer != NULL); \
\
gst_ossmixer_set_volume (this->mixer, track, volumes); \
} \
\
static void \
interface_as_function ## _get_volume (GstMixer * mixer, GstMixerTrack * track, \
gint * volumes) \
{ \
Type *this = (Type*) mixer; \
\
g_return_if_fail (this != NULL); \
g_return_if_fail (this->mixer != NULL); \
\
gst_ossmixer_get_volume (this->mixer, track, volumes); \
} \
\
static void \
interface_as_function ## _set_record (GstMixer * mixer, GstMixerTrack * track, \
gboolean record) \
{ \
Type *this = (Type*) mixer; \
\
g_return_if_fail (this != NULL); \
g_return_if_fail (this->mixer != NULL); \
\
gst_ossmixer_set_record (this->mixer, track, record); \
} \
\
static void \
interface_as_function ## _set_mute (GstMixer * mixer, GstMixerTrack * track, \
gboolean mute) \
{ \
Type *this = (Type*) mixer; \
\
g_return_if_fail (this != NULL); \
g_return_if_fail (this->mixer != NULL); \
\
gst_ossmixer_set_mute (this->mixer, track, mute); \
} \
\
static void \
interface_as_function ## _interface_init (GstMixerInterface * iface) \
{ \
GST_MIXER_TYPE (iface) = GST_MIXER_HARDWARE; \
\
/* set up the interface hooks */ \
iface->list_tracks = interface_as_function ## _list_tracks; \
iface->set_volume = interface_as_function ## _set_volume; \
iface->get_volume = interface_as_function ## _get_volume; \
iface->set_mute = interface_as_function ## _set_mute; \
iface->set_record = interface_as_function ## _set_record; \
}
G_END_DECLS
#endif /* __GST_OSS_MIXER_H__ */
/* OSS mixer interface element.
* Copyright (C) 2005 Andrew Vander Wingo <wingo@pobox.com>
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-ossmixer
*
* This element lets you adjust sound input and output levels with the
* Open Sound System (OSS). It supports the #GstMixer interface, which can be
* used to obtain a list of available mixer tracks. Set the mixer element to
* READY state before using the #GstMixer interface on it.
*
* <refsect2>
* <title>Example pipelines</title>
* <para>
* ossmixer can't be used in a sensible way in gst-launch.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstossmixerelement.h"
GST_DEBUG_CATEGORY_EXTERN (oss_debug);
#define GST_CAT_DEFAULT oss_debug
#define DEFAULT_DEVICE "/dev/mixer"
#define DEFAULT_DEVICE_NAME NULL
enum
{
PROP_0,
PROP_DEVICE,
PROP_DEVICE_NAME
};
GST_BOILERPLATE_WITH_INTERFACE (GstOssMixerElement, gst_oss_mixer_element,
GstElement, GST_TYPE_ELEMENT, GstMixer, GST_TYPE_MIXER,
gst_oss_mixer_element);
GST_IMPLEMENT_OSS_MIXER_METHODS (GstOssMixerElement, gst_oss_mixer_element);
static GstStateChangeReturn gst_oss_mixer_element_change_state (GstElement *
element, GstStateChange transition);
static void gst_oss_mixer_element_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_oss_mixer_element_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_oss_mixer_element_finalize (GObject * object);
static void
gst_oss_mixer_element_base_init (gpointer klass)
{
gst_element_class_set_static_metadata (GST_ELEMENT_CLASS (klass), "OSS Mixer",
"Generic/Audio",
"Control sound input and output levels with OSS",
"Andrew Vander Wingo <wingo@pobox.com>");
}
static void
gst_oss_mixer_element_class_init (GstOssMixerElementClass * klass)
{
GstElementClass *element_class;
GObjectClass *gobject_class;
element_class = (GstElementClass *) klass;
gobject_class = (GObjectClass *) klass;
gobject_class->finalize = gst_oss_mixer_element_finalize;
gobject_class->set_property = gst_oss_mixer_element_set_property;
gobject_class->get_property = gst_oss_mixer_element_get_property;
/**
* GstOssMixerElement:device
*
* OSS mixer device (usually /dev/mixer)
*
* Since: 0.10.5
**/
g_object_class_install_property (gobject_class, PROP_DEVICE,
g_param_spec_string ("device", "Device",
"OSS mixer device (usually /dev/mixer)", DEFAULT_DEVICE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
g_param_spec_string ("device-name", "Device name",
"Human-readable name of the sound device", DEFAULT_DEVICE_NAME,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_oss_mixer_element_change_state);
}
static void
gst_oss_mixer_element_finalize (GObject * obj)
{
GstOssMixerElement *this = GST_OSS_MIXER_ELEMENT (obj);
g_free (this->device);
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
static void
gst_oss_mixer_element_init (GstOssMixerElement * this,
GstOssMixerElementClass * g_class)
{
this->mixer = NULL;
this->device = g_strdup (DEFAULT_DEVICE);
}
static void
gst_oss_mixer_element_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstOssMixerElement *this = GST_OSS_MIXER_ELEMENT (object);
switch (prop_id) {
case PROP_DEVICE:
g_free (this->device);
this->device = g_value_dup_string (value);
/* make sure we never set NULL */
if (this->device == NULL) {
this->device = g_strdup (DEFAULT_DEVICE);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_oss_mixer_element_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstOssMixerElement *this = GST_OSS_MIXER_ELEMENT (object);
switch (prop_id) {
case PROP_DEVICE:
g_value_set_string (value, this->device);
break;
case PROP_DEVICE_NAME:
if (this->mixer) {
g_value_set_string (value, this->mixer->cardname);
} else {
g_value_set_string (value, NULL);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GstStateChangeReturn
gst_oss_mixer_element_change_state (GstElement * element,
GstStateChange transition)
{
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstOssMixerElement *this = GST_OSS_MIXER_ELEMENT (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
if (!this->mixer) {
this->mixer = gst_ossmixer_new (this->device, GST_OSS_MIXER_ALL);
if (!this->mixer)
goto open_failed;
}
break;
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
if (ret == GST_STATE_CHANGE_FAILURE)
return ret;
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
if (this->mixer) {
gst_ossmixer_free (this->mixer);
this->mixer = NULL;
}
break;
default:
break;
}
return ret;
/* ERRORS */
open_failed:
{
GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ_WRITE, (NULL),
("Failed to open oss mixer device '%s'", this->device));
return GST_STATE_CHANGE_FAILURE;
}
}
/* OSS mixer interface element.
* Copyright (C) 2005 Andrew Vander Wingo <wingo@pobox.com>
*
* 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_OSS_MIXER_ELEMENT_H__
#define __GST_OSS_MIXER_ELEMENT_H__
#include "gstossmixer.h"
G_BEGIN_DECLS
#define GST_OSS_MIXER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OSS_MIXER_ELEMENT,GstOssMixerElement))
#define GST_OSS_MIXER_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OSS_MIXER_ELEMENT,GstOssMixerElementClass))
#define GST_IS_OSS_MIXER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OSS_MIXER_ELEMENT))
#define GST_IS_OSS_MIXER_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OSS_MIXER_ELEMENT))
#define GST_TYPE_OSS_MIXER_ELEMENT (gst_oss_mixer_element_get_type())
typedef struct _GstOssMixerElement GstOssMixerElement;
typedef struct _GstOssMixerElementClass GstOssMixerElementClass;
struct _GstOssMixerElement {
GstElement parent;
gchar *device;
GstOssMixer *mixer;
};
struct _GstOssMixerElementClass {
GstElementClass parent;
};
GType gst_oss_mixer_element_get_type (void);
G_END_DECLS
#endif /* __GST_OSS_MIXER_ELEMENT_H__ */
/* GStreamer OSS Mixer implementation
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* gstossmixer.c: mixer interface implementation for OSS
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#ifdef HAVE_OSS_INCLUDE_IN_SYS
# include <sys/soundcard.h>
#else
# ifdef HAVE_OSS_INCLUDE_IN_ROOT
# include <soundcard.h>
# else
# ifdef HAVE_OSS_INCLUDE_IN_MACHINE
# include <machine/soundcard.h>
# else
# error "What to include?"
# endif /* HAVE_OSS_INCLUDE_IN_MACHINE */
# endif /* HAVE_OSS_INCLUDE_IN_ROOT */
#endif /* HAVE_OSS_INCLUDE_IN_SYS */
#include <gst/gst-i18n-plugin.h>
#include "gstossmixertrack.h"
GST_DEBUG_CATEGORY_EXTERN (oss_debug);
#define GST_CAT_DEFAULT oss_debug
#define MASK_BIT_IS_SET(mask, bit) \
(mask & (1 << bit))
G_DEFINE_TYPE (GstOssMixerTrack, gst_ossmixer_track, GST_TYPE_MIXER_TRACK);
static void
gst_ossmixer_track_class_init (GstOssMixerTrackClass * klass)
{
/* nop */
}
static void
gst_ossmixer_track_init (GstOssMixerTrack * track)
{
track->lvol = track->rvol = 0;
track->track_num = 0;
}
static const gchar **labels = NULL;
/* three functions: firstly, OSS has the nasty habit of inserting
* spaces in the labels, we want to get rid of them. Secondly,
* i18n is impossible with OSS' way of providing us with mixer
* labels, so we make a 'given' list of i18n'ed labels. Thirdly, I
* personally don't like the "1337" names that OSS gives to their
* labels ("Vol", "Mic", "Rec"), I'd rather see full names. */
static void
fill_labels (void)
{
gint i, pos;
const gchar *origs[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
const struct
{
const gchar *given;
const gchar *wanted;
}
cases[] = {
/* Note: this list is simply ripped from soundcard.h. For
* some people, some values might be missing (3D surround,
* etc.) - feel free to add them. That's the reason why
* I'm doing this in such a horribly complicated way. */
{
"Vol ", _("Volume")}, {
"Bass ", _("Bass")}, {
"Trebl", _("Treble")}, {
"Synth", _("Synth")}, {
"Pcm ", _("PCM")}, {
"Spkr ", _("Speaker")}, {
"Line ", _("Line-in")}, {
"Mic ", _("Microphone")}, {
"CD ", _("CD")}, {
"Mix ", _("Mixer")}, {
"Pcm2 ", _("PCM-2")}, {
"Rec ", _("Record")}, {
"IGain", _("In-gain")}, {