Commit 9b94e383 authored by Christian Schaller's avatar Christian Schaller
Browse files

add Sun Audio plugin. Verified that nothing breaks and that make check works.

Original commit message from CVS:
add Sun Audio plugin. Verified that nothing breaks and that make check works.
Don't think the docs gets properly built yet, but I don't understand exactly how to enable that.
parent 8189a4da
2006-01-09 Brian Cameron <brian.cameron@sun.com>
reviewed by: Christian Schaller <uraeus@gnome.org>
Add SunAudio plugin - tested to make sure it doesn't break
the build under GNU/Linux.
* configure.ac:
* gst-plugins-good.spec.in:
* sys/Makefile.am:
* sys/sunaudio/Makefile.am:
* sys/sunaudio/gstsunaudio.c: (plugin_init):
* sys/sunaudio/gstsunaudiomixer.c: (gst_sunaudiomixer_base_init),
(gst_sunaudiomixer_class_init), (gst_sunaudiomixer_init),
(gst_sunaudiomixer_change_state):
* sys/sunaudio/gstsunaudiomixer.h:
* sys/sunaudio/gstsunaudiomixerctrl.c:
(gst_sunaudiomixer_ctrl_open), (gst_sunaudiomixer_ctrl_build_list),
(gst_sunaudiomixer_ctrl_new), (gst_sunaudiomixer_ctrl_free),
(gst_sunaudiomixer_ctrl_list_tracks),
(gst_sunaudiomixer_ctrl_get_volume),
(gst_sunaudiomixer_ctrl_set_volume),
(gst_sunaudiomixer_ctrl_set_mute),
(gst_sunaudiomixer_ctrl_set_record):
* sys/sunaudio/gstsunaudiomixerctrl.h:
* sys/sunaudio/gstsunaudiomixertrack.c:
(gst_sunaudiomixer_track_class_init),
(gst_sunaudiomixer_track_init), (fill_labels),
(gst_sunaudiomixer_track_new):
* sys/sunaudio/gstsunaudiomixertrack.h:
* sys/sunaudio/gstsunaudiosink.c: (gst_sunaudiosink_get_type),
(gst_sunaudiosink_dispose), (gst_sunaudiosink_base_init),
(gst_sunaudiosink_set_property), (gst_sunaudiosink_get_property),
(gst_sunaudiosink_getcaps), (gst_sunaudiosink_open),
(gst_sunaudiosink_close), (gst_sunaudiosink_prepare),
(gst_sunaudiosink_unprepare), (gst_sunaudiosink_write),
(gst_sunaudiosink_delay), (gst_sunaudiosink_reset):
* sys/sunaudio/gstsunaudiosink.h:
2005-01-07 Philippe Khalaf <philippe.kalaf@collabora.co.uk>
* gst-plugins-good/gst/udp/gstdynudpsink.c:
......
......@@ -168,6 +168,10 @@ AC_CHECK_HEADERS([netinet/in.h])
AC_CHECK_HEADERS([winsock2.h])
AM_CONDITIONAL(HAVE_WINSOCK2_H, test "x$HAVE_WINSOCK2_H" = "xyes")
dnl Check for FIONREAD ioctl declaration. This check is needed
dnl for the UDP plugin to build on Solaris
GST_CHECK_FIONREAD()
dnl *** checks for compiler characteristics ***
dnl FIXME: check if this is used; was used for floatcast.h in base
......@@ -297,6 +301,12 @@ dnl Some old BSD versions and also newer OpenBSD versions :
])
])
dnl *** Sun Audio ***
translit(dnm, m, l) AM_CONDITIONAL(USE_SUNAUDIO, true)
GST_CHECK_FEATURE(SUNAUDIO, [Sun Audio], sunaudiosink, [
AC_CHECK_HEADER(sys/audioio.h, HAVE_SUNAUDIO="yes", HAVE_SUNAUDIO="no")
])
dnl *** ext plug-ins ***
dnl keep this list sorted alphabetically !
......@@ -597,6 +607,7 @@ ext/shout2/Makefile
ext/speex/Makefile
sys/Makefile
sys/oss/Makefile
sys/sunaudio/Makefile
po/Makefile.in
gconf/Makefile
gconf/gstreamer.schemas
......
......@@ -19,6 +19,8 @@
<xi:include href="xml/element-goom.xml" />
<xi:include href="xml/element-id3demux.xml" />
<xi:include href="xml/element-level.xml" />
<xi:include href="xml/element-sunaudiomixer.xml" />
<xi:include href="xml/element-sunaudiosink.xml" />
<xi:include href="xml/element-multipartmux.xml" />
<xi:include href="xml/element-multipartdemux.xml" />
<xi:include href="xml/element-videomixer.xml" />
......@@ -60,6 +62,7 @@
<xi:include href="xml/plugin-shout2send.xml" />
<xi:include href="xml/plugin-smpte.xml" />
<xi:include href="xml/plugin-speex.xml" />
<xi:include href="xml/plugin-sunaudio.xml" />
<xi:include href="xml/plugin-udp.xml" />
<xi:include href="xml/plugin-videobox.xml" />
<xi:include href="xml/plugin-videoflip.xml" />
......
......@@ -13,7 +13,7 @@
# correct User entry for the Host entry for the DOC_SERVER
# these variables define the location of the online docs
DOC_SERVER=freedesktop.org
DOC_SERVER=uraeus@freedesktop.org
DOC_BASE=/srv/gstreamer.freedesktop.org/www/data/doc
DOC_URL=$(DOC_SERVER):$(DOC_BASE)
GST_VERSION_NANO = $(GST_PLUGINS_GOOD_VERSION_NANO)
......
......@@ -110,6 +110,7 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/gstreamer-%{majorminor}/libgstvideomixer.so
%{_libdir}/gstreamer-%{majorminor}/libgstcutter.so
%{_libdir}/gstreamer-%{majorminor}/libgstmultipart.so
%{_libdir}/gstreamer-%{majorminor}/libgstid3demux.so
# gstreamer-plugins with external dependencies but in the main package
@USE_LIBCACA_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstcacasink.so
......
......@@ -10,6 +10,12 @@ else
OSS_DIR=
endif
if USE_SUNAUDIO
SUNAUDIO_DIR=sunaudio
else
SUNAUDIO_DIR=
endif
# if USE_OSX_AUDIO
# OSX_AUDIO_DIR=osxaudio
# else
......@@ -28,12 +34,6 @@ endif
# QCAM_DIR=
# endif
# if USE_SUNAUDIO
# SUNAUDIO_DIR=sunaudio
# else
# SUNAUDIO_DIR=
# endif
# if USE_GST_V4L2
# V4L2_DIR=v4l2
# else
......@@ -58,6 +58,6 @@ endif
# GL_DIR=
# endif
SUBDIRS=$(OSS_DIR)
SUBDIRS=$(OSS_DIR) $(SUNAUDIO_DIR)
DIST_SUBDIRS=oss
DIST_SUBDIRS=oss sunaudio
plugin_LTLIBRARIES = libgstsunaudio.la
libgstsunaudio_la_SOURCES = gstsunaudio.c \
gstsunaudiosink.c \
gstsunaudiomixerctrl.c \
gstsunaudiomixer.c \
gstsunaudiomixertrack.c
libgstsunaudio_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstsunaudio_la_LIBADD = \
-lgstinterfaces-@GST_MAJORMINOR@ \
-lgstaudio-@GST_MAJORMINOR@ \
$(GST_PLUGINS_BASE_LIBS) \
$(GST_LIBS)
libgstsunaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstsunaudiosink.h \
gstsunaudiomixer.h \
gstsunaudiomixerctrl.h \
gstsunaudiomixertrack.h
/*
* GStreamer
* Copyright (C) <2005> Brian Cameron <brian.cameron@sun.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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gst/gst-i18n-plugin.h"
#include "gstsunaudiomixer.h"
#include "gstsunaudiosink.h"
extern gchar *__gst_oss_plugin_dir;
GST_DEBUG_CATEGORY (sunaudio_debug);
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "sunaudiomixer", GST_RANK_NONE,
GST_TYPE_SUNAUDIO_MIXER) ||
!gst_element_register (plugin, "sunaudiosink", GST_RANK_SECONDARY,
GST_TYPE_SUNAUDIO_SINK)) {
return FALSE;
}
GST_DEBUG_CATEGORY_INIT (sunaudio_debug, "sunaudio", 0, "sunaudio elements");
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif /* ENABLE_NLS */
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"sunaudio",
"Sun Audio support for GStreamer",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
/*
* GStreamer
* Copyright (C) 2005 Brian Cameron <brian.cameron@sun.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-sunaudiomixer
*
* <refsect2>
* <para>
* sunaudiomixer is an mixer that controls the sound input and output
* levels with the Sun Audio interface available in Solaris.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstsunaudiomixer.h"
static GstElementDetails gst_sunaudiomixer_details =
GST_ELEMENT_DETAILS ("Sun Audio Mixer",
"Generic/Audio",
"Control sound input and output levels with Sun Audio",
"Brian Cameron <brian.cameron@sun.com>");
GST_BOILERPLATE_WITH_INTERFACE (GstSunAudioMixer, gst_sunaudiomixer,
GstElement, GST_TYPE_ELEMENT, GstMixer, GST_TYPE_MIXER, gst_sunaudiomixer)
GST_IMPLEMENT_SUNAUDIO_MIXER_CTRL_METHODS (GstSunAudioMixer, gst_sunaudiomixer)
static GstStateChangeReturn gst_sunaudiomixer_change_state (GstElement *
element, GstStateChange transition);
static void gst_sunaudiomixer_base_init (gpointer klass)
{
gst_element_class_set_details (GST_ELEMENT_CLASS (klass),
&gst_sunaudiomixer_details);
}
static void
gst_sunaudiomixer_class_init (GstSunAudioMixerClass * klass)
{
GstElementClass *element_class;
element_class = (GstElementClass *) klass;
element_class->change_state = gst_sunaudiomixer_change_state;
}
static void
gst_sunaudiomixer_init (GstSunAudioMixer * this,
GstSunAudioMixerClass * g_class)
{
this->mixer = NULL;
}
static GstStateChangeReturn
gst_sunaudiomixer_change_state (GstElement * element, GstStateChange transition)
{
GstSunAudioMixer *this = GST_SUNAUDIO_MIXER (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
if (!this->mixer) {
const char *audiodev;
audiodev = g_getenv ("AUDIODEV");
if (audiodev == NULL) {
this->mixer = gst_sunaudiomixer_ctrl_new ("/dev/audioctl");
} else {
gchar *device = g_strdup_printf ("/dev/%sctl", audiodev);
this->mixer = gst_sunaudiomixer_ctrl_new (device);
g_free (device);
}
}
break;
case GST_STATE_CHANGE_READY_TO_NULL:
if (this->mixer) {
gst_sunaudiomixer_ctrl_free (this->mixer);
this->mixer = NULL;
}
break;
default:
break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
return GST_STATE_CHANGE_SUCCESS;
}
/*
* GStreamer
* Copyright (C) 2005 Brian Cameron <brian.cameron@sun.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_SUNAUDIO_MIXER_H__
#define __GST_SUNAUDIO_MIXER_H__
#include "gstsunaudiomixerctrl.h"
G_BEGIN_DECLS
#define GST_SUNAUDIO_MIXER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SUNAUDIO_MIXER,GstSunAudioMixer))
#define GST_SUNAUDIO_MIXER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SUNAUDIO_MIXER,GstSunAudioMixerClass))
#define GST_IS_SUNAUDIO_MIXER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SUNAUDIO_MIXER))
#define GST_IS_SUNAUDIO_MIXER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SUNAUDIO_MIXER))
#define GST_TYPE_SUNAUDIO_MIXER (gst_sunaudiomixer_get_type())
typedef struct _GstSunAudioMixer GstSunAudioMixer;
typedef struct _GstSunAudioMixerClass GstSunAudioMixerClass;
struct _GstSunAudioMixer {
GstElement parent;
GstSunAudioMixerCtrl *mixer;
};
struct _GstSunAudioMixerClass {
GstElementClass parent;
};
GType gst_sunaudiomixer_get_type (void);
G_END_DECLS
#endif /* __GST_SUNAUDIO_MIXER_H__ */
/*
* GStreamer
* Copyright (C) 2005 Brian Cameron <brian.cameron@sun.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.
*/
#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>
#include <gst/gst-i18n-plugin.h>
#include "gstsunaudiomixerctrl.h"
#include "gstsunaudiomixertrack.h"
#define SCALE_FACTOR 2.55 /* 255/100 */
static gboolean
gst_sunaudiomixer_ctrl_open (GstSunAudioMixerCtrl * sunaudio)
{
int fd;
/* First try to open non-blocking */
fd = open (sunaudio->device, O_RDWR | O_NONBLOCK);
if (fd >= 0) {
close (fd);
fd = open (sunaudio->device, O_WRONLY);
}
if (fd == -1) {
GST_DEBUG_OBJECT (sunaudio,
"Failed to open mixer device %s, mixing disabled: %s", sunaudio->device,
strerror (errno));
return FALSE;
}
sunaudio->mixer_fd = fd;
return TRUE;
}
void
gst_sunaudiomixer_ctrl_build_list (GstSunAudioMixerCtrl * sunaudio)
{
GstMixerTrack *track;
g_return_if_fail (sunaudio->mixer_fd != -1);
track = gst_sunaudiomixer_track_new (0, 1, GST_MIXER_TRACK_OUTPUT);
sunaudio->tracklist = g_list_append (sunaudio->tracklist, track);
track = gst_sunaudiomixer_track_new (1, 1, 0);
sunaudio->tracklist = g_list_append (sunaudio->tracklist, track);
track = gst_sunaudiomixer_track_new (2, 1, 0);
sunaudio->tracklist = g_list_append (sunaudio->tracklist, track);
}
GstSunAudioMixerCtrl *
gst_sunaudiomixer_ctrl_new (const char *device)
{
GstSunAudioMixerCtrl *ret = NULL;
g_return_val_if_fail (device != NULL, NULL);
ret = g_new0 (GstSunAudioMixerCtrl, 1);
ret->device = g_strdup (device);
ret->mixer_fd = -1;
if (!gst_sunaudiomixer_ctrl_open (ret))
goto error;
return ret;
error:
if (ret)
gst_sunaudiomixer_ctrl_free (ret);
return NULL;
}
void
gst_sunaudiomixer_ctrl_free (GstSunAudioMixerCtrl * mixer)
{
g_return_if_fail (mixer != NULL);
if (mixer->device) {
g_free (mixer->device);
mixer->device = NULL;
}
if (mixer->tracklist) {
g_list_foreach (mixer->tracklist, (GFunc) g_object_unref, NULL);
g_list_free (mixer->tracklist);
mixer->tracklist = NULL;
}
if (mixer->mixer_fd != -1) {
close (mixer->mixer_fd);
mixer->mixer_fd = -1;
}
g_free (mixer);
}
const GList *
gst_sunaudiomixer_ctrl_list_tracks (GstSunAudioMixerCtrl * mixer)
{
gst_sunaudiomixer_ctrl_build_list (mixer);
return (const GList *) mixer->tracklist;
}
static void
gst_sunaudiomixer_ctrl_get_volume (GstSunAudioMixerCtrl * mixer,
GstMixerTrack * track, gint * volumes)
{
gint volume;
struct audio_info audioinfo;
GstSunAudioMixerTrack *sunaudiotrack = GST_SUNAUDIO_MIXER_TRACK (track);
g_return_if_fail (mixer->mixer_fd != -1);
if (ioctl (mixer->mixer_fd, AUDIO_GETINFO, &audioinfo) < 0) {
g_warning ("Error getting audio device volume");
return;
}
switch (sunaudiotrack->track_num) {
case 0:
sunaudiotrack->vol = volumes[0] =
(audioinfo.play.gain / SCALE_FACTOR) + 0.5;
break;
case 1:
sunaudiotrack->vol = volumes[0] =
(audioinfo.record.gain / SCALE_FACTOR) + 0.5;
break;
case 2:
sunaudiotrack->vol = volumes[0] =
(audioinfo.monitor_gain / SCALE_FACTOR) + 0.5;
break;
}
}
void
gst_sunaudiomixer_ctrl_set_volume (GstSunAudioMixerCtrl * mixer,
GstMixerTrack * track, gint * volumes)
{
gint volume;
gchar buf[100];
struct audio_info audioinfo;
GstSunAudioMixerTrack *sunaudiotrack = GST_SUNAUDIO_MIXER_TRACK (track);
g_return_if_fail (mixer->mixer_fd != -1);
volume = volumes[0] * SCALE_FACTOR + 0.5;
/* Set the volume */
AUDIO_INITINFO (&audioinfo);
switch (sunaudiotrack->track_num) {
case 0:
audioinfo.play.gain = volume;
break;
case 1:
audioinfo.record.gain = volume;
break;
case 2:
audioinfo.monitor_gain = volume;
break;
}
if (ioctl (mixer->mixer_fd, AUDIO_SETINFO, &audioinfo) < 0) {
g_warning ("Error setting audio device volume");
return;
}
sunaudiotrack->vol = volume;
}
static void
gst_sunaudiomixer_ctrl_set_mute (GstSunAudioMixerCtrl * sunaudio,
GstMixerTrack * track, gboolean mute)
{
struct audio_info audioinfo;
GstSunAudioMixerTrack *sunaudiotrack = GST_SUNAUDIO_MIXER_TRACK (track);
gint volume;
g_return_if_fail (sunaudio->mixer_fd != -1);
if (sunaudiotrack->track_num != 0)
return;
AUDIO_INITINFO (&audioinfo);
if (mute) {
audioinfo.output_muted = 1;
volume = 0;
} else {
audioinfo.output_muted = 0;
volume = sunaudiotrack->vol;
}
switch (sunaudiotrack->track_num) {
case 0:
audioinfo.play.gain = volume;
break;
case 1:
audioinfo.record.gain = volume;
break;
case 2:
audioinfo.monitor_gain = volume;
break;
}
if (ioctl (sunaudio->mixer_fd, AUDIO_SETINFO, &audioinfo) < 0) {
g_warning ("Error setting audio device volume");
return;
}
}