Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / sys / oss4 / oss4-mixer.h
1 /* GStreamer OSS4 mixer implementation
2  * Copyright (C) 2007-2008 Tim-Philipp Müller <tim centricular net>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifndef OSS4_MIXER_H
21 #define OSS4_MIXER_H
22
23 #include <gst/gst.h>
24
25 #include "oss4-soundcard.h"
26
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())
33
34 #define GST_OSS4_MIXER_IS_OPEN(obj)      (GST_OSS4_MIXER(obj)->fd != -1)
35
36 typedef struct _GstOss4Mixer GstOss4Mixer;
37 typedef struct _GstOss4MixerClass GstOss4MixerClass;
38
39 struct _GstOss4Mixer {
40   GstElement            element;
41
42   /*< private >*/
43
44   /* element bits'n'bops */ 
45   gchar               * device;
46
47   /* mixer details */
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              */
51
52   GList               * tracks;         /* list of available tracks          */
53   GList               * controls;       /* list of available controls        */
54   gboolean              need_update;    /* re-read list of available tracks? */
55
56   oss_mixext            last_mixext;    /* we keep this around so we can
57                                          * easily check if the mixer
58                                          * interface has changed             */
59
60   GThread             * watch_thread;   /* thread watching for value changes */
61   GCond               * watch_cond;
62   gint                  watch_shutdown;
63   gint                  modify_counter; /* from MIXERINFO */
64
65   /* for property probe interface */
66   GList               * property_probe_list;
67 };
68
69 struct _GstOss4MixerClass {
70   GstElementClass       element_class;
71 };
72
73 /* helper struct holding info about one control */
74 typedef struct _GstOss4MixerControl GstOss4MixerControl;
75
76 struct _GstOss4MixerControl {
77   oss_mixext           mixext;
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)  */
82
83   GQuark              *enum_vals;      /* 0-terminated array of values or NULL */
84   int                  enum_version;   /* 0 = list won't change                */
85
86   int                  last_val;       /* last value seen                      */
87
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 */
97
98   gboolean             changed      : 1; /* transient flag used by watch thread */
99   gboolean             list_changed : 1; /* transient flag used by watch thread */
100 };
101
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)
104
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)
108
109 #define MIXEXT_HAS_DESCRIPTION(me) (((me).flags & MIXF_DESCR) != 0)
110
111 #define MIXEXT_ENUM_IS_AVAILABLE(me,num) \
112     (((me).enum_present[num/8]) & (1 << (num % 8)))
113
114
115 GType     gst_oss4_mixer_get_type (void);
116
117 gboolean  gst_oss4_mixer_get_control_val (GstOss4Mixer        * mixer,
118                                           GstOss4MixerControl * mc,
119                                           int                 * val);
120
121 gboolean  gst_oss4_mixer_set_control_val (GstOss4Mixer        * mixer,
122                                           GstOss4MixerControl * mc,
123                                           int                   val);
124
125 G_END_DECLS
126
127 #endif /* OSS4_MIXER_H */
128