No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | gvc/gvc-mixer-sink.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2008 William Jon McCann
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 #include "config.h"
22
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <unistd.h>
26
27 #include <glib.h>
28 #include <glib/gi18n-lib.h>
29
30 #include <pulse/pulseaudio.h>
31
32 #include "gvc-mixer-sink.h"
33 #include "gvc-mixer-stream-private.h"
34 #include "gvc-channel-map-private.h"
35
36 #define GVC_MIXER_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SINK, GvcMixerSinkPrivate))
37
38 struct GvcMixerSinkPrivate
39 {
40 gpointer dummy;
41 };
42
43 static void gvc_mixer_sink_class_init (GvcMixerSinkClass *klass);
44 static void gvc_mixer_sink_init (GvcMixerSink *mixer_sink);
45 static void gvc_mixer_sink_finalize (GObject *object);
46
47 G_DEFINE_TYPE (GvcMixerSink, gvc_mixer_sink, GVC_TYPE_MIXER_STREAM)
48
49 static gboolean
50 gvc_mixer_sink_push_volume (GvcMixerStream *stream, gpointer *op)
51 {
52 pa_operation *o;
53 guint index;
54 const GvcChannelMap *map;
55 pa_context *context;
56 const pa_cvolume *cv;
57
58 index = gvc_mixer_stream_get_index (stream);
59
60 map = gvc_mixer_stream_get_channel_map (stream);
61
62 /* set the volume */
63 cv = gvc_channel_map_get_cvolume(map);
64
65 context = gvc_mixer_stream_get_pa_context (stream);
66
67 o = pa_context_set_sink_volume_by_index (context,
68 index,
69 cv,
70 NULL,
71 NULL);
72
73 if (o == NULL) {
74 g_warning ("pa_context_set_sink_volume_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
75 return FALSE;
76 }
77
78 *op = o;
79
80 return TRUE;
81 }
82
83 static gboolean
84 gvc_mixer_sink_change_is_muted (GvcMixerStream *stream,
85 gboolean is_muted)
86 {
87 pa_operation *o;
88 guint index;
89 pa_context *context;
90
91 index = gvc_mixer_stream_get_index (stream);
92 context = gvc_mixer_stream_get_pa_context (stream);
93
94 o = pa_context_set_sink_mute_by_index (context,
95 index,
96 is_muted,
97 NULL,
98 NULL);
99
100 if (o == NULL) {
101 g_warning ("pa_context_set_sink_mute_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
102 return FALSE;
103 }
104
105 pa_operation_unref(o);
106
107 return TRUE;
108 }
109
110 static gboolean
111 gvc_mixer_sink_change_port (GvcMixerStream *stream,
112 const char *port)
113 {
114 #if PA_MICRO > 15
115 pa_operation *o;
116 guint index;
117 pa_context *context;
118
119 index = gvc_mixer_stream_get_index (stream);
120 context = gvc_mixer_stream_get_pa_context (stream);
121
122 o = pa_context_set_sink_port_by_index (context,
123 index,
124 port,
125 NULL,
126 NULL);
127
128 if (o == NULL) {
129 g_warning ("pa_context_set_sink_port_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
130 return FALSE;
131 }
132
133 pa_operation_unref(o);
134
135 return TRUE;
136 #else
137 return FALSE;
138 #endif /* PA_MICRO > 15 */
139 }
140
141 static void
142 gvc_mixer_sink_class_init (GvcMixerSinkClass *klass)
143 {
144 GObjectClass *object_class = G_OBJECT_CLASS (klass);
145 GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
146
147 object_class->finalize = gvc_mixer_sink_finalize;
148
149 stream_class->push_volume = gvc_mixer_sink_push_volume;
150 stream_class->change_port = gvc_mixer_sink_change_port;
151 stream_class->change_is_muted = gvc_mixer_sink_change_is_muted;
152
153 g_type_class_add_private (klass, sizeof (GvcMixerSinkPrivate));
154 }
155
156 static void
157 gvc_mixer_sink_init (GvcMixerSink *sink)
158 {
159 sink->priv = GVC_MIXER_SINK_GET_PRIVATE (sink);
160 }
161
162 static void
163 gvc_mixer_sink_finalize (GObject *object)
164 {
165 GvcMixerSink *mixer_sink;
166
167 g_return_if_fail (object != NULL);
168 g_return_if_fail (GVC_IS_MIXER_SINK (object));
169
170 mixer_sink = GVC_MIXER_SINK (object);
171
172 g_return_if_fail (mixer_sink->priv != NULL);
173 G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->finalize (object);
174 }
175
176 /**
177 * gvc_mixer_sink_new: (skip)
178 * @context:
179 * @index:
180 * @map:
181 *
182 * Returns:
183 */
184 GvcMixerStream *
185 gvc_mixer_sink_new (pa_context *context,
186 guint index,
187 GvcChannelMap *channel_map)
188
189 {
190 GObject *object;
191
192 object = g_object_new (GVC_TYPE_MIXER_SINK,
193 "pa-context", context,
194 "index", index,
195 "channel-map", channel_map,
196 NULL);
197
198 return GVC_MIXER_STREAM (object);
199 }