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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
#include <glib/gi18n-lib.h>
30
#include <pulse/pulseaudio.h>
32
#include "gvc-mixer-source.h"
33
#include "gvc-mixer-stream-private.h"
34
#include "gvc-channel-map-private.h"
36
#define GVC_MIXER_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SOURCE, GvcMixerSourcePrivate))
38
struct GvcMixerSourcePrivate
43
static void gvc_mixer_source_class_init (GvcMixerSourceClass *klass);
44
static void gvc_mixer_source_init (GvcMixerSource *mixer_source);
45
static void gvc_mixer_source_finalize (GObject *object);
47
G_DEFINE_TYPE (GvcMixerSource, gvc_mixer_source, GVC_TYPE_MIXER_STREAM)
50
gvc_mixer_source_push_volume (GvcMixerStream *stream, gpointer *op)
54
const GvcChannelMap *map;
58
index = gvc_mixer_stream_get_index (stream);
60
map = gvc_mixer_stream_get_channel_map (stream);
63
cv = gvc_channel_map_get_cvolume (map);
65
context = gvc_mixer_stream_get_pa_context (stream);
67
o = pa_context_set_source_volume_by_index (context,
74
g_warning ("pa_context_set_source_volume_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
84
gvc_mixer_source_change_is_muted (GvcMixerStream *stream,
91
index = gvc_mixer_stream_get_index (stream);
92
context = gvc_mixer_stream_get_pa_context (stream);
94
o = pa_context_set_source_mute_by_index (context,
101
g_warning ("pa_context_set_source_mute_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
105
pa_operation_unref(o);
111
gvc_mixer_source_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_source_port_by_index (context,
128
g_warning ("pa_context_set_source_port_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
132
pa_operation_unref(o);
138
gvc_mixer_source_class_init (GvcMixerSourceClass *klass)
140
GObjectClass *object_class = G_OBJECT_CLASS (klass);
141
GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
143
object_class->finalize = gvc_mixer_source_finalize;
145
stream_class->push_volume = gvc_mixer_source_push_volume;
146
stream_class->change_is_muted = gvc_mixer_source_change_is_muted;
147
stream_class->change_port = gvc_mixer_source_change_port;
149
g_type_class_add_private (klass, sizeof (GvcMixerSourcePrivate));
153
gvc_mixer_source_init (GvcMixerSource *source)
155
source->priv = GVC_MIXER_SOURCE_GET_PRIVATE (source);
159
gvc_mixer_source_finalize (GObject *object)
161
GvcMixerSource *mixer_source;
163
g_return_if_fail (object != NULL);
164
g_return_if_fail (GVC_IS_MIXER_SOURCE (object));
166
mixer_source = GVC_MIXER_SOURCE (object);
168
g_return_if_fail (mixer_source->priv != NULL);
169
G_OBJECT_CLASS (gvc_mixer_source_parent_class)->finalize (object);
173
* gvc_mixer_source_new: (skip)
182
gvc_mixer_source_new (pa_context *context,
184
GvcChannelMap *channel_map)
189
object = g_object_new (GVC_TYPE_MIXER_SOURCE,
190
"pa-context", context,
192
"channel-map", channel_map,
195
return GVC_MIXER_STREAM (object);