diff options
author | Jan Schmidt <jan.schmidt@sun.com> | 2009-06-04 12:27:19 +0100 |
---|---|---|
committer | Jan Schmidt <jan.schmidt@sun.com> | 2009-06-05 10:47:53 +0100 |
commit | 0fc43060e5e10e5a9fc24487d9fcb3e2865c0895 (patch) | |
tree | a3b2d302dcefdd91a26a55609351525a3ad4a6d5 /sys/sunaudio/gstsunaudiomixeroptions.c | |
parent | 29111fa1f8208c3ae1896d5934e5a2ff5839aa98 (diff) |
sunaudio: Support new flags for options and actions
Use new audio mixer flags added in Base 0.10.23 to expose flags and options
on the SunAudio devices.
Fixes: #583593
Patch By: Brian Cameron <brian.cameron@sun.com>
Patch By: Garrett D'Amore <garrett.damore@sun.com>
Diffstat (limited to 'sys/sunaudio/gstsunaudiomixeroptions.c')
-rw-r--r-- | sys/sunaudio/gstsunaudiomixeroptions.c | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/sys/sunaudio/gstsunaudiomixeroptions.c b/sys/sunaudio/gstsunaudiomixeroptions.c new file mode 100644 index 00000000..0c0d95dc --- /dev/null +++ b/sys/sunaudio/gstsunaudiomixeroptions.c @@ -0,0 +1,149 @@ +/* + * GStreamer SunAudio mixer track implementation + * Copyright (C) 2009 Sun Microsystems, Inc., + * Brian Cameron <brian.cameron@sun.com> + * Garrett D'Amore <garrett.damore@sun.com> + * + * gstsunaudiomixeroptions.c: Sun Audio mixer options object + * + * 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 <sys/audio.h> +#include <sys/mixer.h> + +#include <gst/gst-i18n-plugin.h> + +#include "gstsunaudiomixeroptions.h" +#include "gstsunaudiomixertrack.h" + +static void gst_sunaudiomixer_options_init (GstSunAudioMixerOptions * sun_opts); +static void gst_sunaudiomixer_options_class_init (gpointer g_class, + gpointer class_data); + +static GstMixerOptionsClass *parent_class = NULL; + +GType +gst_sunaudiomixer_options_get_type (void) +{ + static GType opts_type = 0; + + if (!opts_type) { + static const GTypeInfo opts_info = { + sizeof (GstSunAudioMixerOptionsClass), + NULL, + NULL, + gst_sunaudiomixer_options_class_init, + NULL, + NULL, + sizeof (GstSunAudioMixerOptions), + 0, + (GInstanceInitFunc) gst_sunaudiomixer_options_init, + }; + + opts_type = + g_type_register_static (GST_TYPE_MIXER_OPTIONS, + "GstSunAudioMixerOptions", &opts_info, 0); + } + + return opts_type; +} + +static void +gst_sunaudiomixer_options_class_init (gpointer g_class, gpointer class_data) +{ + parent_class = g_type_class_peek_parent (g_class); +} + +static void +gst_sunaudiomixer_options_init (GstSunAudioMixerOptions * sun_opts) +{ +} + +GstMixerOptions * +gst_sunaudiomixer_options_new (GstSunAudioMixerCtrl * mixer, gint track_num) +{ + GstMixerOptions *opts; + GstSunAudioMixerOptions *sun_opts; + GstMixerTrack *track; + const gchar *label; + gint i; + struct audio_info audioinfo; + + if ((mixer == NULL) || (mixer->mixer_fd == -1)) { + g_warning ("mixer not initialized"); + return NULL; + } + + if (track_num != GST_SUNAUDIO_TRACK_RECSRC) { + g_warning ("invalid options track"); + return (NULL); + } + + label = N_("Record Source"); + + opts = g_object_new (GST_TYPE_SUNAUDIO_MIXER_OPTIONS, + "untranslated-label", label, NULL); + sun_opts = GST_SUNAUDIO_MIXER_OPTIONS (opts); + track = GST_MIXER_TRACK (opts); + + /* save off names for the record sources */ + sun_opts->names[0] = g_quark_from_string (_("Microphone")); + sun_opts->names[1] = g_quark_from_string (_("Line In")); + sun_opts->names[2] = g_quark_from_string (_("Internal CD")); + sun_opts->names[3] = g_quark_from_string (_("SPDIF In")); + sun_opts->names[4] = g_quark_from_string (_("AUX 1 In")); + sun_opts->names[5] = g_quark_from_string (_("AUX 2 In")); + sun_opts->names[6] = g_quark_from_string (_("Codec Loopback")); + sun_opts->names[7] = g_quark_from_string (_("SunVTS Loopback")); + + /* set basic information */ + track->label = g_strdup (_(label)); + track->num_channels = 0; + track->min_volume = 0; + track->max_volume = 0; + track->flags = + GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_WHITELIST | + GST_MIXER_TRACK_NO_RECORD; + + if (ioctl (mixer->mixer_fd, AUDIO_GETINFO, &audioinfo) < 0) { + g_warning ("Error getting audio device settings"); + g_object_unref (G_OBJECT (sun_opts)); + return NULL; + } + + sun_opts->avail = audioinfo.record.avail_ports; + sun_opts->track_num = track_num; + + for (i = 0; i < 8; i++) { + if ((1 << i) & audioinfo.record.avail_ports) { + const char *s = g_quark_to_string (sun_opts->names[i]); + opts->values = g_list_append (opts->values, g_strdup (s)); + } + } + + return opts; +} |