1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2008 William Jon McCann
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
28
#include <glib/gi18n-lib.h>
30
#include <pulse/pulseaudio.h>
32
#include "gvc-mixer-sink.h"
34
#define GVC_MIXER_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SINK, GvcMixerSinkPrivate))
36
struct GvcMixerSinkPrivate
41
static void gvc_mixer_sink_class_init (GvcMixerSinkClass *klass);
42
static void gvc_mixer_sink_init (GvcMixerSink *mixer_sink);
43
static void gvc_mixer_sink_finalize (GObject *object);
44
static void gvc_mixer_sink_dispose (GObject *object);
46
G_DEFINE_TYPE (GvcMixerSink, gvc_mixer_sink, GVC_TYPE_MIXER_STREAM)
49
gvc_mixer_sink_push_volume (GvcMixerStream *stream, gpointer *op)
53
const GvcChannelMap *map;
57
index = gvc_mixer_stream_get_index (stream);
59
map = gvc_mixer_stream_get_channel_map (stream);
62
cv = gvc_channel_map_get_cvolume(map);
64
context = gvc_mixer_stream_get_pa_context (stream);
66
o = pa_context_set_sink_volume_by_index (context,
73
g_warning ("pa_context_set_sink_volume_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
83
gvc_mixer_sink_change_is_muted (GvcMixerStream *stream,
90
index = gvc_mixer_stream_get_index (stream);
91
context = gvc_mixer_stream_get_pa_context (stream);
93
o = pa_context_set_sink_mute_by_index (context,
100
g_warning ("pa_context_set_sink_mute_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
104
pa_operation_unref(o);
110
gvc_mixer_sink_change_port (GvcMixerStream *stream,
118
index = gvc_mixer_stream_get_index (stream);
119
context = gvc_mixer_stream_get_pa_context (stream);
121
o = pa_context_set_sink_port_by_index (context,
128
g_warning ("pa_context_set_sink_port_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
132
pa_operation_unref(o);
137
#endif /* PA_MICRO > 15 */
141
gvc_mixer_sink_constructor (GType type,
142
guint n_construct_properties,
143
GObjectConstructParam *construct_params)
148
object = G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->constructor (type, n_construct_properties, construct_params);
150
self = GVC_MIXER_SINK (object);
156
gvc_mixer_sink_class_init (GvcMixerSinkClass *klass)
158
GObjectClass *object_class = G_OBJECT_CLASS (klass);
159
GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
161
object_class->constructor = gvc_mixer_sink_constructor;
162
object_class->dispose = gvc_mixer_sink_dispose;
163
object_class->finalize = gvc_mixer_sink_finalize;
165
stream_class->push_volume = gvc_mixer_sink_push_volume;
166
stream_class->change_port = gvc_mixer_sink_change_port;
167
stream_class->change_is_muted = gvc_mixer_sink_change_is_muted;
169
g_type_class_add_private (klass, sizeof (GvcMixerSinkPrivate));
173
gvc_mixer_sink_init (GvcMixerSink *sink)
175
sink->priv = GVC_MIXER_SINK_GET_PRIVATE (sink);
179
gvc_mixer_sink_dispose (GObject *object)
181
GvcMixerSink *mixer_sink;
183
g_return_if_fail (object != NULL);
184
g_return_if_fail (GVC_IS_MIXER_SINK (object));
186
mixer_sink = GVC_MIXER_SINK (object);
188
G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->dispose (object);
192
gvc_mixer_sink_finalize (GObject *object)
194
GvcMixerSink *mixer_sink;
196
g_return_if_fail (object != NULL);
197
g_return_if_fail (GVC_IS_MIXER_SINK (object));
199
mixer_sink = GVC_MIXER_SINK (object);
201
g_return_if_fail (mixer_sink->priv != NULL);
202
G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->finalize (object);
206
gvc_mixer_sink_new (pa_context *context,
208
GvcChannelMap *channel_map)
213
object = g_object_new (GVC_TYPE_MIXER_SINK,
214
"pa-context", context,
216
"channel-map", channel_map,
219
return GVC_MIXER_STREAM (object);