gnome-shell-3.6.3.1/src/gvc/gvc-mixer-source.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found gvc/gvc-mixer-source.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  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-source.h"
 33 #include "gvc-mixer-stream-private.h"
 34 #include "gvc-channel-map-private.h"
 35 
 36 #define GVC_MIXER_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SOURCE, GvcMixerSourcePrivate))
 37 
 38 struct GvcMixerSourcePrivate
 39 {
 40         gpointer dummy;
 41 };
 42 
 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);
 46 
 47 G_DEFINE_TYPE (GvcMixerSource, gvc_mixer_source, GVC_TYPE_MIXER_STREAM)
 48 
 49 static gboolean
 50 gvc_mixer_source_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_source_volume_by_index (context,
 68                                                    index,
 69                                                    cv,
 70                                                    NULL,
 71                                                    NULL);
 72 
 73         if (o == NULL) {
 74                 g_warning ("pa_context_set_source_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_source_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_source_mute_by_index (context,
 95                                                  index,
 96                                                  is_muted,
 97                                                  NULL,
 98                                                  NULL);
 99 
100         if (o == NULL) {
101                 g_warning ("pa_context_set_source_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_source_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_source_port_by_index (context,
123                                                  index,
124                                                  port,
125                                                  NULL,
126                                                  NULL);
127 
128         if (o == NULL) {
129                 g_warning ("pa_context_set_source_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_source_class_init (GvcMixerSourceClass *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_source_finalize;
148 
149         stream_class->push_volume = gvc_mixer_source_push_volume;
150         stream_class->change_is_muted = gvc_mixer_source_change_is_muted;
151         stream_class->change_port = gvc_mixer_source_change_port;
152 
153         g_type_class_add_private (klass, sizeof (GvcMixerSourcePrivate));
154 }
155 
156 static void
157 gvc_mixer_source_init (GvcMixerSource *source)
158 {
159         source->priv = GVC_MIXER_SOURCE_GET_PRIVATE (source);
160 }
161 
162 static void
163 gvc_mixer_source_finalize (GObject *object)
164 {
165         GvcMixerSource *mixer_source;
166 
167         g_return_if_fail (object != NULL);
168         g_return_if_fail (GVC_IS_MIXER_SOURCE (object));
169 
170         mixer_source = GVC_MIXER_SOURCE (object);
171 
172         g_return_if_fail (mixer_source->priv != NULL);
173         G_OBJECT_CLASS (gvc_mixer_source_parent_class)->finalize (object);
174 }
175 
176 /**
177  * gvc_mixer_source_new: (skip)
178  * @context:
179  * @index:
180  * @map:
181  *
182  * Returns:
183  */
184 GvcMixerStream *
185 gvc_mixer_source_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_SOURCE,
193                                "pa-context", context,
194                                "index", index,
195                                "channel-map", channel_map,
196                                NULL);
197 
198         return GVC_MIXER_STREAM (object);
199 }