1 /* GStreamer OSS4 mixer implementation
2 * Copyright (C) 2007-2008 Tim-Philipp Müller <tim centricular net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 #include "oss4-soundcard.h"
27 #define GST_OSS4_MIXER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OSS4_MIXER,GstOss4Mixer))
28 #define GST_OSS4_MIXER_CAST(obj) ((GstOss4Mixer *)(obj))
29 #define GST_OSS4_MIXER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OSS4_MIXER,GstOss4MixerClass))
30 #define GST_IS_OSS4_MIXER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OSS4_MIXER))
31 #define GST_IS_OSS4_MIXER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OSS4_MIXER))
32 #define GST_TYPE_OSS4_MIXER (gst_oss4_mixer_get_type())
34 #define GST_OSS4_MIXER_IS_OPEN(obj) (GST_OSS4_MIXER(obj)->fd != -1)
36 typedef struct _GstOss4Mixer GstOss4Mixer;
37 typedef struct _GstOss4MixerClass GstOss4MixerClass;
39 struct _GstOss4Mixer {
44 /* element bits'n'bops */
48 gint fd; /* file descriptor if open, or -1 */
49 gchar * device_name; /* device description, or NULL */
50 gchar * open_device; /* the device we opened */
52 GList * tracks; /* list of available tracks */
53 GList * controls; /* list of available controls */
54 gboolean need_update; /* re-read list of available tracks? */
56 oss_mixext last_mixext; /* we keep this around so we can
57 * easily check if the mixer
58 * interface has changed */
60 GThread * watch_thread; /* thread watching for value changes */
63 gint modify_counter; /* from MIXERINFO */
65 /* for property probe interface */
66 GList * property_probe_list;
69 struct _GstOss4MixerClass {
70 GstElementClass element_class;
73 /* helper struct holding info about one control */
74 typedef struct _GstOss4MixerControl GstOss4MixerControl;
76 struct _GstOss4MixerControl {
78 GstOss4MixerControl *parent; /* NULL if root */
79 GstOss4MixerControl *mute; /* sibling with mute function, or NULL */
80 GList *mute_group; /* group of mute controls, or NULL */
81 GList *children; /* GstOss4MixerControls (no ownership) */
83 GQuark *enum_vals; /* 0-terminated array of values or NULL */
84 int enum_version; /* 0 = list won't change */
86 int last_val; /* last value seen */
88 gboolean is_virtual : 1; /* is a vmix control with dynamic label */
89 gboolean is_master : 1;
90 gboolean is_slider : 1; /* represent as slider */
91 gboolean is_switch : 1; /* represent as switch */
92 gboolean is_enum : 1; /* represent as combo/enumeration */
93 gboolean no_list : 1; /* enumeration with no list available */
94 gboolean is_input : 1; /* is an input-related control */
95 gboolean is_output : 1; /* is an output-related control */
96 gboolean used : 1; /* whether we know what to do with this */
98 gboolean changed : 1; /* transient flag used by watch thread */
99 gboolean list_changed : 1; /* transient flag used by watch thread */
102 /* header says parent=-1 means root, but it can also be parent=ctrl */
103 #define MIXEXT_IS_ROOT(me) ((me).parent == -1 || (me).parent == (me).ctrl)
105 #define MIXEXT_IS_SLIDER(me) ((me).type == MIXT_MONOSLIDER || \
106 (me).type == MIXT_STEREOSLIDER || (me).type == MIXT_MONOSLIDER16 || \
107 (me).type == MIXT_STEREOSLIDER16 || (me).type == MIXT_SLIDER)
109 #define MIXEXT_HAS_DESCRIPTION(me) (((me).flags & MIXF_DESCR) != 0)
111 #define MIXEXT_ENUM_IS_AVAILABLE(me,num) \
112 (((me).enum_present[num/8]) & (1 << (num % 8)))
115 GType gst_oss4_mixer_get_type (void);
117 gboolean gst_oss4_mixer_get_control_val (GstOss4Mixer * mixer,
118 GstOss4MixerControl * mc,
121 gboolean gst_oss4_mixer_set_control_val (GstOss4Mixer * mixer,
122 GstOss4MixerControl * mc,
127 #endif /* OSS4_MIXER_H */