1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2008 Red Hat, Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  */
20 
21 #ifndef __GVC_MIXER_CONTROL_H
22 #define __GVC_MIXER_CONTROL_H
23 
24 #include <glib-object.h>
25 #include "gvc-mixer-stream.h"
26 #include "gvc-mixer-card.h"
27 #include "gvc-mixer-ui-device.h"
28 
29 G_BEGIN_DECLS
30 
31 typedef enum
32 {
33         GVC_STATE_CLOSED,
34         GVC_STATE_READY,
35         GVC_STATE_CONNECTING,
36         GVC_STATE_FAILED
37 } GvcMixerControlState;
38 
39 typedef enum
40 {
41         GVC_HEADSET_PORT_CHOICE_NONE        = 0,
42         GVC_HEADSET_PORT_CHOICE_HEADPHONES  = 1 << 0,
43         GVC_HEADSET_PORT_CHOICE_HEADSET     = 1 << 1,
44         GVC_HEADSET_PORT_CHOICE_MIC         = 1 << 2
45 } GvcHeadsetPortChoice;
46 
47 #define GVC_TYPE_MIXER_CONTROL         (gvc_mixer_control_get_type ())
48 #define GVC_MIXER_CONTROL(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_CONTROL, GvcMixerControl))
49 #define GVC_MIXER_CONTROL_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_CONTROL, GvcMixerControlClass))
50 #define GVC_IS_MIXER_CONTROL(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_CONTROL))
51 #define GVC_IS_MIXER_CONTROL_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_CONTROL))
52 #define GVC_MIXER_CONTROL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_CONTROL, GvcMixerControlClass))
53 
54 typedef struct GvcMixerControlPrivate GvcMixerControlPrivate;
55 
56 typedef struct
57 {
58         GObject                 parent;
59         GvcMixerControlPrivate *priv;
60 } GvcMixerControl;
61 
62 typedef struct
63 {
64         GObjectClass            parent_class;
65 
66         void (*state_changed)          (GvcMixerControl      *control,
67                                         GvcMixerControlState  new_state);
68         void (*stream_added)           (GvcMixerControl *control,
69                                         guint            id);
70         void (*stream_changed)         (GvcMixerControl *control,
71                                         guint            id);
72         void (*stream_removed)         (GvcMixerControl *control,
73                                         guint            id);
74         void (*card_added)             (GvcMixerControl *control,
75                                         guint            id);
76         void (*card_removed)           (GvcMixerControl *control,
77                                         guint            id);
78         void (*default_sink_changed)   (GvcMixerControl *control,
79                                         guint            id);
80         void (*default_source_changed) (GvcMixerControl *control,
81                                         guint            id);
82         void (*active_output_update)   (GvcMixerControl *control,
83                                         guint            id);
84         void (*active_input_update)    (GvcMixerControl *control,
85                                         guint            id);
86         void (*output_added)           (GvcMixerControl *control,
87                                         guint            id);
88         void (*input_added)            (GvcMixerControl *control,
89                                         guint            id);
90         void (*output_removed)         (GvcMixerControl *control,
91                                         guint            id);
92         void (*input_removed)          (GvcMixerControl *control,
93                                         guint            id);
94         void (*audio_device_selection_needed)
95                                        (GvcMixerControl      *control,
96                                         guint                 id,
97                                         gboolean              show_dialog,
98                                         GvcHeadsetPortChoice  choices);
99 } GvcMixerControlClass;
100 
101 GType               gvc_mixer_control_get_type            (void);
102 
103 GvcMixerControl *   gvc_mixer_control_new                 (const char *name);
104 
105 gboolean            gvc_mixer_control_open                (GvcMixerControl *control);
106 gboolean            gvc_mixer_control_close               (GvcMixerControl *control);
107 
108 GSList *            gvc_mixer_control_get_cards           (GvcMixerControl *control);
109 GSList *            gvc_mixer_control_get_streams         (GvcMixerControl *control);
110 GSList *            gvc_mixer_control_get_sinks           (GvcMixerControl *control);
111 GSList *            gvc_mixer_control_get_sources         (GvcMixerControl *control);
112 GSList *            gvc_mixer_control_get_sink_inputs     (GvcMixerControl *control);
113 GSList *            gvc_mixer_control_get_source_outputs  (GvcMixerControl *control);
114 
115 GvcMixerStream *        gvc_mixer_control_lookup_stream_id          (GvcMixerControl *control,
116                                                                      guint            id);
117 GvcMixerCard   *        gvc_mixer_control_lookup_card_id            (GvcMixerControl *control,
118                                                                      guint            id);
119 GvcMixerUIDevice *      gvc_mixer_control_lookup_output_id          (GvcMixerControl *control,
120                                                                      guint            id);
121 GvcMixerUIDevice *      gvc_mixer_control_lookup_input_id           (GvcMixerControl *control,
122                                                                      guint            id);
123 GvcMixerUIDevice *      gvc_mixer_control_lookup_device_from_stream (GvcMixerControl *control,
124                                                                      GvcMixerStream *stream);
125 
126 GvcMixerStream *        gvc_mixer_control_get_default_sink     (GvcMixerControl *control);
127 GvcMixerStream *        gvc_mixer_control_get_default_source   (GvcMixerControl *control);
128 GvcMixerStream *        gvc_mixer_control_get_event_sink_input (GvcMixerControl *control);
129 
130 gboolean                gvc_mixer_control_set_default_sink     (GvcMixerControl *control,
131                                                                 GvcMixerStream  *stream);
132 gboolean                gvc_mixer_control_set_default_source   (GvcMixerControl *control,
133                                                                 GvcMixerStream  *stream);
134 
135 gdouble                 gvc_mixer_control_get_vol_max_norm                  (GvcMixerControl *control);
136 gdouble                 gvc_mixer_control_get_vol_max_amplified             (GvcMixerControl *control);
137 void                    gvc_mixer_control_change_output                     (GvcMixerControl *control,
138                                                                              GvcMixerUIDevice* output);
139 void                    gvc_mixer_control_change_input                      (GvcMixerControl *control,
140                                                                              GvcMixerUIDevice* input);
141 GvcMixerStream*         gvc_mixer_control_get_stream_from_device            (GvcMixerControl *control,
142                                                                              GvcMixerUIDevice *device);
143 gboolean                gvc_mixer_control_change_profile_on_selected_device (GvcMixerControl *control,
144                                                                              GvcMixerUIDevice *device,
145                                                                              const gchar* profile);
146 
147 void                    gvc_mixer_control_set_headset_port                  (GvcMixerControl      *control,
148                                                                              guint                 id,
149                                                                              GvcHeadsetPortChoice  choices);
150 
151 GvcMixerControlState gvc_mixer_control_get_state            (GvcMixerControl *control);
152 
153 G_END_DECLS
154 
155 #endif /* __GVC_MIXER_CONTROL_H */
156