Commit dd23afb6 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller

sys: remove sunaudio plugin

Even though hooked up to the build system, it's clear that no one
has ever built or used this with GStreamer 1.x. It wants to link
against libgstinterfaces, which no longer exists. And uses 0.10-style
raw audio caps. And the last meaningful change was done in 2009.
Let's just remove it.
parent 2271fee7
......@@ -138,7 +138,7 @@ PLATFORMS
- Linux is of course fully supported
- FreeBSD is reported to work; other BSDs should work too
- Solaris is reported to work; a specific sunaudiosink plugin has been written
- Solaris is reported to work
- MacOSX works, binary 1.x packages can be built using the cerbero build tool
- Windows works; binary 1.x packages can be built using the cerbero build tool
- MSys/MinGW builds
......
......@@ -454,12 +454,6 @@ AG_GST_CHECK_FEATURE(OSS4, [Open Sound System 4], oss4, [
[OSS4_MISSING_HEADER="yes";HAVE_OSS4="no"])
])
dnl *** Sun Audio ***
translit(dnm, m, l) AM_CONDITIONAL(USE_SUNAUDIO, true)
AG_GST_CHECK_FEATURE(SUNAUDIO, [Sun Audio], sunaudio, [
AC_CHECK_HEADER(sys/audioio.h, HAVE_SUNAUDIO="yes", HAVE_SUNAUDIO="no")
])
dnl *** OSX Audio ***
translit(dnm, m, l) AM_CONDITIONAL(USE_OSX_AUDIO, true)
HAVE_IOS="no"
......@@ -888,7 +882,6 @@ AM_CONDITIONAL(USE_PULSE, false)
AM_CONDITIONAL(USE_SHOUT2, false)
AM_CONDITIONAL(USE_SOUP, false)
AM_CONDITIONAL(USE_SPEEX, false)
AM_CONDITIONAL(USE_SUNAUDIO, false)
AM_CONDITIONAL(USE_TAGLIB, false)
AM_CONDITIONAL(USE_VPX, false)
AM_CONDITIONAL(USE_WAVEFORM, false)
......@@ -1035,7 +1028,6 @@ sys/oss/Makefile
sys/oss4/Makefile
sys/osxaudio/Makefile
sys/osxvideo/Makefile
sys/sunaudio/Makefile
sys/v4l2/Makefile
sys/waveform/Makefile
sys/ximage/Makefile
......
......@@ -100,16 +100,10 @@ check_functions = [
['HAVE_ISINF', 'isinf', '#include<math.h>'],
# check token HAVE_LIBV4L2
['HAVE_MMAP', 'mmap', '#include<sys/mman.h>'],
# check token HAVE_OSS
# check token HAVE_OSS4
# check token HAVE_OSS_INCLUDE_IN_MACHINE
# check token HAVE_OSS_INCLUDE_IN_ROOT
# check token HAVE_OSS_INCLUDE_IN_SYS
# check token HAVE_OSX_AUDIO
# check token HAVE_OSX_VIDEO
# check token HAVE_RDTSC
['HAVE_SINH', 'sinh', '#include<math.h>'],
# check token HAVE_SUNAUDIO
# check token HAVE_WAVEFORM
]
......
......@@ -18,8 +18,6 @@ sys/oss4/oss4-source.c
sys/oss/gstosssink.c
sys/oss/gstosssrc.c
sys/osxaudio/gstosxaudioringbuffer.c
sys/sunaudio/gstsunaudiomixeroptions.c
sys/sunaudio/gstsunaudiomixertrack.c
sys/v4l2/gstv4l2bufferpool.c
sys/v4l2/gstv4l2object.c
sys/v4l2/gstv4l2radio.c
......
# if USE_DXR3
# DXR3_DIR=dxr3
# else
# DXR3_DIR=
# endif
if USE_OSS
OSS_DIR=oss
else
......@@ -16,7 +10,6 @@ else
OSS4_DIR=
endif
if USE_DIRECTSOUND
DIRECTSOUND_DIR=directsound
else
......@@ -29,12 +22,6 @@ else
WAVEFORM_DIR=
endif
if USE_SUNAUDIO
SUNAUDIO_DIR=sunaudio
else
SUNAUDIO_DIR=
endif
if USE_OSX_AUDIO
OSX_AUDIO_DIR=osxaudio
else
......@@ -47,44 +34,20 @@ else
OSX_VIDEO_DIR=
endif
# if USE_QCAM
# QCAM_DIR=qcam
# else
# QCAM_DIR=
# endif
if USE_GST_V4L2
V4L2_DIR=v4l2
else
V4L2_DIR=
endif
# if USE_VCD
# VCD_DIR=vcd
# else
# VCD_DIR=
# endif
# if USE_CDROM
# CDROM_DIR=cdrom
# else
# CDROM_DIR=
# endif
# if USE_OPENGL
# GL_DIR=glsink
# else
# GL_DIR=
# endif
if USE_X
XIMAGE_DIR=ximage
else
XIMAGE_DIR=
endif
SUBDIRS=$(DIRECTSOUND_DIR) $(WAVEFORM_DIR) $(OSS_DIR) $(OSS4_DIR) $(OSX_AUDIO_DIR) $(OSX_VIDEO_DIR) $(SUNAUDIO_DIR) $(V4L2_DIR) $(XIMAGE_DIR)
SUBDIRS=$(DIRECTSOUND_DIR) $(WAVEFORM_DIR) $(OSS_DIR) $(OSS4_DIR) $(OSX_AUDIO_DIR) $(OSX_VIDEO_DIR) $(V4L2_DIR) $(XIMAGE_DIR)
DIST_SUBDIRS=directsound oss oss4 osxaudio osxvideo sunaudio v4l2 waveform ximage
DIST_SUBDIRS=directsound oss oss4 osxaudio osxvideo v4l2 waveform ximage
include $(top_srcdir)/common/parallel-subdirs.mak
......@@ -7,5 +7,4 @@ subdir('ximage')
# FIXME: Implement these
#subdir('osxaudio')
#subdir('osxvideo')
#subdir('sunaudio')
#subdir('waveform')
plugin_LTLIBRARIES = libgstsunaudio.la
libgstsunaudio_la_SOURCES = gstsunaudio.c \
gstsunaudiosink.c \
gstsunaudiomixerctrl.c \
gstsunaudiomixer.c \
gstsunaudiomixertrack.c \
gstsunaudiomixeroptions.c \
gstsunaudiosrc.c
libgstsunaudio_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstsunaudio_la_LIBADD = \
-lgstinterfaces-@GST_API_VERSION@ \
-lgstaudio-@GST_API_VERSION@ \
$(GST_PLUGINS_BASE_LIBS) \
$(GST_LIBS)
libgstsunaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstsunaudiosink.h \
gstsunaudiomixer.h \
gstsunaudiomixerctrl.h \
gstsunaudiomixertrack.h \
gstsunaudiomixeroptions.h \
gstsunaudiosrc.h
/*
* GStreamer - SunAudio plugin
* Copyright (C) 2005,2006 Sun Microsystems, Inc.,
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gst/gst-i18n-plugin.h"
#include "gstsunaudiomixer.h"
#include "gstsunaudiosink.h"
#include "gstsunaudiosrc.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) ||
!gst_element_register (plugin, "sunaudiosrc", GST_RANK_SECONDARY,
GST_TYPE_SUNAUDIO_SRC)) {
return FALSE;
}
GST_DEBUG_CATEGORY_INIT (sunaudio_debug, "sunaudio", 0, "sunaudio elements");
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#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 - SunAudio mixer
* Copyright (C) 2005,2006 Sun Microsystems, Inc.,
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:element-sunaudiomixer
*
* sunaudiomixer is an mixer that controls the sound input and output
* levels with the Sun Audio interface available in Solaris.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstsunaudiomixer.h"
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_static_metadata (GST_ELEMENT_CLASS (klass),
"Sun Audio Mixer", "Generic/Audio",
"Control sound input and output levels with Sun Audio",
"Brian Cameron <brian.cameron@sun.com>");
}
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 ("%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 - SunAudio mixer
* Copyright (C) 2005,2006 Sun Microsystems, Inc.,
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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(klass) (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 - SunAudio mixer interface element
* Copyright (C) 2005,2006,2008,2009 Sun Microsystems, Inc.,
* Brian Cameron <brian.cameron@sun.com>
* Copyright (C) 2008 Sun Microsystems, Inc.,
* Jan Schmidt <jan.schmidt@sun.com>
* Copyright (C) 2009 Sun Microsystems, Inc.,
* Garrett D'Amore <garrett.damore@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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, 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 <sys/audio.h>
#include <sys/mixer.h>
#include <gst/gst-i18n-plugin.h>
#include "gstsunaudiomixerctrl.h"
#include "gstsunaudiomixertrack.h"
#include "gstsunaudiomixeroptions.h"
GST_DEBUG_CATEGORY_EXTERN (sunaudio_debug);
#define GST_CAT_DEFAULT sunaudio_debug
static gboolean
gst_sunaudiomixer_ctrl_open (GstSunAudioMixerCtrl * mixer)
{
int fd;
/* First try to open non-blocking */
fd = open (mixer->device, O_RDWR | O_NONBLOCK);
if (fd >= 0) {
close (fd);
fd = open (mixer->device, O_WRONLY);
}
if (fd == -1) {
GST_DEBUG_OBJECT (mixer,
"Failed to open mixer device %s, mixing disabled: %s", mixer->device,
strerror (errno));
return FALSE;
}
mixer->mixer_fd = fd;
/* Try to set the multiple open flag if we can, but ignore errors */
ioctl (mixer->mixer_fd, AUDIO_MIXER_MULTIPLE_OPEN);
GST_DEBUG_OBJECT (mixer, "Opened mixer device %s", mixer->device);
return TRUE;
}
void
gst_sunaudiomixer_ctrl_build_list (GstSunAudioMixerCtrl * mixer)
{
GstMixerTrack *track;
GstMixerOptions *options;
struct audio_info audioinfo;
/*
* Do not continue appending the same 3 static tracks onto the list
*/
if (mixer->tracklist == NULL) {
g_return_if_fail (mixer->mixer_fd != -1);
/* query available ports */
if (ioctl (mixer->mixer_fd, AUDIO_GETINFO, &audioinfo) < 0) {
g_warning ("Error getting audio device volume");
return;
}
/* Output & should be MASTER when it's the only one. */
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_OUTPUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
/* Input */
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_RECORD);
mixer->tracklist = g_list_append (mixer->tracklist, track);
/* Monitor */
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_MONITOR);
mixer->tracklist = g_list_append (mixer->tracklist, track);
if (audioinfo.play.avail_ports & AUDIO_SPEAKER) {
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_SPEAKER);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
if (audioinfo.play.avail_ports & AUDIO_HEADPHONE) {
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_HP);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
if (audioinfo.play.avail_ports & AUDIO_LINE_OUT) {
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_LINEOUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
if (audioinfo.play.avail_ports & AUDIO_SPDIF_OUT) {
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_SPDIFOUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
if (audioinfo.play.avail_ports & AUDIO_AUX1_OUT) {
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_AUX1OUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
if (audioinfo.play.avail_ports & AUDIO_AUX2_OUT) {
track = gst_sunaudiomixer_track_new (GST_SUNAUDIO_TRACK_AUX2OUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
if (audioinfo.record.avail_ports != AUDIO_NONE) {
options =
gst_sunaudiomixer_options_new (mixer, GST_SUNAUDIO_TRACK_RECSRC);
mixer->tracklist = g_list_append (mixer->tracklist, options);
}
}
}
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;
ret->tracklist = NULL;
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);
}
GstMixerFlags
gst_sunaudiomixer_ctrl_get_mixer_flags (GstSunAudioMixerCtrl * mixer)
{
return GST_MIXER_FLAG_HAS_WHITELIST | GST_MIXER_FLAG_GROUPING;
}
const GList *
gst_sunaudiomixer_ctrl_list_tracks (GstSunAudioMixerCtrl * mixer)
{
gst_sunaudiomixer_ctrl_build_list (mixer);
return (const GList *) mixer->tracklist;
}
void
gst_sunaudiomixer_ctrl_get_volume (GstSunAudioMixerCtrl * mixer,
GstMixerTrack * track, gint * volumes)
{
gint gain, balance;
float ratio;
struct audio_info audioinfo;
GstSunAudioMixerTrack *sunaudiotrack;
g_return_if_fail (GST_IS_SUNAUDIO_MIXER_TRACK (track));
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;
}
balance = AUDIO_MID_BALANCE;
gain = 0;
switch (sunaudiotrack->track_num) {
case GST_SUNAUDIO_TRACK_OUTPUT:
gain = (int) audioinfo.play.gain;
balance = audioinfo.play.balance;
break;
case GST_SUNAUDIO_TRACK_RECORD:
gain = (int) audioinfo.record.gain;
balance = audioinfo.record.balance;
break;
case GST_SUNAUDIO_TRACK_MONITOR:
gain = (int) audioinfo.monitor_gain;
balance = audioinfo.record.balance;
break;
case GST_SUNAUDIO_TRACK_SPEAKER:
if (audioinfo.play.port & AUDIO_SPEAKER)
gain = AUDIO_MAX_GAIN;
break;
case GST_SUNAUDIO_TRACK_HP:
if (audioinfo.play.port & AUDIO_HEADPHONE)
gain = AUDIO_MAX_GAIN;
break;
case GST_SUNAUDIO_TRACK_LINEOUT:
if (audioinfo.play.port & AUDIO_LINE_OUT)
gain = AUDIO_MAX_GAIN;
break;
case GST_SUNAUDIO_TRACK_SPDIFOUT:
if (audioinfo.play.port & AUDIO_SPDIF_OUT)
gain = AUDIO_MAX_GAIN;
break;
case GST_SUNAUDIO_TRACK_AUX1OUT:
if (audioinfo.play.port & AUDIO_AUX1_OUT)
gain = AUDIO_MAX_GAIN;
break;
case GST_SUNAUDIO_TRACK_AUX2OUT:
if (audioinfo.play.port & AUDIO_AUX2_OUT)
gain = AUDIO_MAX_GAIN;
break;
default:
break;
}
switch (track->num_channels) {
case 2:
if (balance == AUDIO_MID_BALANCE) {
volumes[0] = gain;
volumes[1] = gain;
} else if (balance < AUDIO_MID_BALANCE) {
volumes[0] = gain;
ratio = 1 - (float) (AUDIO_MID_BALANCE - balance) /
(float) AUDIO_MID_BALANCE;
volumes[1] = (int) ((float) gain * ratio + 0.5);
} else {
volumes[1] = gain;
ratio = 1 - (float) (balance - AUDIO_MID_BALANCE) /
(float) AUDIO_MID_BALANCE;
volumes[0] = (int) ((float) gain * ratio + 0.5);
}
break;
case 1:
volumes[0] = gain;
break;
}
/* Likewise reset MUTE */
if ((sunaudiotrack->track_num == GST_SUNAUDIO_TRACK_OUTPUT
&& audioinfo.output_muted == 1)
|| (sunaudiotrack->track_num != GST_SUNAUDIO_TRACK_OUTPUT && gain == 0)) {
/*
* If MUTE is set, then gain is always 0, so don't bother
* resetting our internal value.
*/
track->flags |= GST_MIXER_TRACK_MUTE;
} else {
sunaudiotrack->gain = gain;
sunaudiotrack->balance = balance;
track->flags &= ~GST_MIXER_TRACK_MUTE;
}
}
void
gst_sunaudiomixer_ctrl_set_volume (GstSunAudioMixerCtrl * mixer,
GstMixerTrack * track, gint * volumes)
{
gint gain;
gint balance;
gint l_real_gain;
gint r_real_gain;
float ratio;
struct audio_info audioinfo;
GstSunAudioMixerTrack *sunaudiotrack = GST_SUNAUDIO_MIXER_TRACK (track);
l_real_gain = volumes[0];
r_real_gain = volumes[1];
if (l_real_gain == r_real_gain) {
gain = l_real_gain;
balance = AUDIO_MID_BALANCE;
} else if (l_real_gain < r_real_gain) {
gain = r_real_gain;
ratio = (float) l_real_gain / (float) r_real_gain;
balance =
AUDIO_RIGHT_BALANCE - (int) (ratio * (float) AUDIO_MID_BALANCE + 0.5);
} else {
gain = l_real_gain;
ratio = (float) r_real_gain / (float) l_real_gain;
balance =
AUDIO_LEFT_BALANCE + (int) (ratio * (float) AUDIO_MID_BALANCE + 0.5);
}
sunaudiotrack->gain = gain;
sunaudiotrack->balance = balance;
if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MUTE)) {
if (sunaudiotrack->track_num == GST_SUNAUDIO_TRACK_OUTPUT) {
return;
} else if (gain == 0) {
return;
} else {
/*
* If the volume is set to a non-zero value for LINE_IN
* or MONITOR, then unset MUTE.
*/