~nathwill-deactivatedaccount-deactivatedaccount/ubuntu/precise/gnome-control-center/fix-lp-978118

« back to all changes in this revision

Viewing changes to panels/sound-nua/gvc-mixer-ui-device.c

  • Committer: Package Import Robot
  • Author(s): Ken VanDine, Didier Roche, Ken VanDine
  • Date: 2012-02-09 16:44:44 UTC
  • Revision ID: package-import@ubuntu.com-20120209164444-nvlkg36obi95y6n0
Tags: 1:3.2.2-2ubuntu7
[ Didier Roche ]
* debian/patches/04_new_appearance_settings.patch:
  - fix a typo (LP: #929070)
  - new reveal sensitivity default is now 2.0

[ Ken VanDine ]
* debian/patches/96_sound_nua_panel.patch
  - Adding the new sound-nua panel for sound settings, only displayed 
    in Unity, the old sound panel will load in GNOME

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 
2
/*
 
3
 * gvc-mixer-ui-device.c
 
4
 * Copyright (C) Conor Curran 2011 <conor.curran@canonical.com>
 
5
 * 
 
6
 * gvc-mixer-ui-device.c is free software: you can redistribute it and/or modify it
 
7
 * under the terms of the GNU General Public License as published by the
 
8
 * Free Software Foundation, either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 * 
 
11
 * gvc-mixer-ui-device.c is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
14
 * See the GNU General Public License for more details.
 
15
 * 
 
16
 * You should have received a copy of the GNU General Public License along
 
17
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
 
 
21
#include "gvc-mixer-ui-device.h"
 
22
#include "gvc-mixer-card.h"
 
23
 
 
24
#define GVC_MIXER_UI_DEVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GVC_TYPE_MIXER_UI_DEVICE, GvcMixerUIDevicePrivate))
 
25
 
 
26
static guint32 output_serial = 1;
 
27
 
 
28
struct GvcMixerUIDevicePrivate
 
29
{
 
30
        gchar*                  first_line_desc;
 
31
        gchar*                  second_line_desc;
 
32
        gint                    card_id; 
 
33
        gchar*                  port_name;
 
34
        gint                    stream_id;
 
35
        guint                   id;
 
36
        gboolean                port_available;
 
37
        GList*                  supported_profiles;
 
38
        UiDeviceDirection       type;
 
39
        GHashTable*             profiles;
 
40
        gboolean                        disable_profile_swapping;
 
41
        gchar*                          user_preferred_profile;
 
42
};
 
43
 
 
44
enum
 
45
{
 
46
        PROP_0,
 
47
        PROP_DESC_LINE_1,
 
48
        PROP_DESC_LINE_2,
 
49
        PROP_CARD_ID,
 
50
        PROP_PORT_NAME, 
 
51
        PROP_STREAM_ID,
 
52
        PROP_UI_DEVICE_TYPE,
 
53
        PROP_PORT_AVAILABLE,
 
54
};
 
55
 
 
56
static void     gvc_mixer_ui_device_class_init (GvcMixerUIDeviceClass *klass);
 
57
static void     gvc_mixer_ui_device_init       (GvcMixerUIDevice      *op);
 
58
static void     gvc_mixer_ui_device_finalize   (GObject             *object);
 
59
 
 
60
G_DEFINE_TYPE (GvcMixerUIDevice, gvc_mixer_ui_device, G_TYPE_OBJECT);
 
61
 
 
62
static guint32
 
63
get_next_output_serial (void)
 
64
{
 
65
        guint32 serial;
 
66
 
 
67
        serial = output_serial++;
 
68
 
 
69
        if ((gint32)output_serial < 0) {
 
70
                output_serial = 1;
 
71
        }
 
72
        return serial;
 
73
}
 
74
 
 
75
static void
 
76
gvc_mixer_ui_device_get_property  (GObject       *object,
 
77
                                   guint         property_id,
 
78
                                   GValue        *value,
 
79
                                   GParamSpec    *pspec)
 
80
{
 
81
          GvcMixerUIDevice *self = GVC_MIXER_UI_DEVICE (object);
 
82
 
 
83
          switch (property_id)
 
84
                {
 
85
                case PROP_DESC_LINE_1:
 
86
                        g_value_set_string (value, self->priv->first_line_desc);
 
87
                        break;
 
88
                case PROP_DESC_LINE_2:
 
89
                        g_value_set_string (value, self->priv->second_line_desc);
 
90
                        break;
 
91
                case PROP_CARD_ID:
 
92
                        g_value_set_int (value, self->priv->card_id);
 
93
                        break;
 
94
                case PROP_PORT_NAME:
 
95
                        g_value_set_string (value, self->priv->port_name);
 
96
                        break;
 
97
                case PROP_STREAM_ID:
 
98
                        g_value_set_int (value, self->priv->stream_id);
 
99
                        break;
 
100
                case PROP_UI_DEVICE_TYPE:
 
101
                        g_value_set_uint (value, (guint)self->priv->type);
 
102
                        break;
 
103
                case PROP_PORT_AVAILABLE:
 
104
                        g_value_set_boolean (value, self->priv->port_available);
 
105
                        break;
 
106
                default:
 
107
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
108
                        break;
 
109
                }
 
110
}
 
111
 
 
112
static void
 
113
gvc_mixer_ui_device_set_property  (GObject      *object,
 
114
                                guint         property_id,
 
115
                                const GValue *value,
 
116
                                GParamSpec   *pspec)
 
117
{
 
118
          GvcMixerUIDevice *self = GVC_MIXER_UI_DEVICE (object);
 
119
 
 
120
          switch (property_id)
 
121
                {
 
122
                case PROP_DESC_LINE_1:
 
123
                        g_free (self->priv->first_line_desc);
 
124
                        self->priv->first_line_desc = g_value_dup_string (value);
 
125
                        /*g_print ("gvc-mixer-output-set-property - 1st line: %s\n",
 
126
                                 self->priv->first_line_desc);*/
 
127
                        break;
 
128
                case PROP_DESC_LINE_2:
 
129
                        g_free (self->priv->second_line_desc);
 
130
                        self->priv->second_line_desc = g_value_dup_string (value);
 
131
                        /*g_print ("gvc-mixer-output-set-property - 2nd line: %s\n",
 
132
                                 self->priv->second_line_desc);*/
 
133
                        break;  
 
134
                case PROP_CARD_ID:
 
135
                        self->priv->card_id = g_value_get_int (value);
 
136
                        /*g_print ("gvc-mixer-output-set-property - card id: %i\n",
 
137
                                 self->priv->gvc_card_id);*/
 
138
                        break;  
 
139
                case PROP_PORT_NAME:
 
140
                        g_free (self->priv->port_name);
 
141
                        self->priv->port_name = g_value_dup_string (value);
 
142
                        /*g_print ("gvc-mixer-output-set-property - card port name: %s\n",
 
143
                                 self->priv->card_port_name);*/
 
144
                        break;  
 
145
                case PROP_STREAM_ID:
 
146
                        self->priv->stream_id = g_value_get_int (value);
 
147
                        /*g_print ("gvc-mixer-output-set-property - sink id: %i\n",
 
148
                                 self->priv->stream_id);*/
 
149
                        break;  
 
150
                case PROP_UI_DEVICE_TYPE:
 
151
                        self->priv->type = (UiDeviceDirection)g_value_get_uint (value);
 
152
                        break;
 
153
                case PROP_PORT_AVAILABLE:
 
154
                        self->priv->port_available = g_value_get_boolean (value);
 
155
                        /*g_print ("gvc-mixer-output-set-property - port available %i, value passed in %i \n",
 
156
                                 self->priv->port_available, g_value_get_boolean (value));*/
 
157
                        break;                  
 
158
                default:
 
159
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
160
                        break;
 
161
            }
 
162
}
 
163
 
 
164
static GObject *
 
165
gvc_mixer_ui_device_constructor (GType                  type,
 
166
                                 guint                  n_construct_properties,
 
167
                                 GObjectConstructParam *construct_params)
 
168
{
 
169
        GObject         *object;
 
170
        GvcMixerUIDevice  *self;
 
171
 
 
172
        object = G_OBJECT_CLASS (gvc_mixer_ui_device_parent_class)->constructor (type, n_construct_properties, construct_params);
 
173
 
 
174
        self = GVC_MIXER_UI_DEVICE (object);
 
175
        self->priv->id = get_next_output_serial ();
 
176
        self->priv->profiles = g_hash_table_new_full (g_str_hash,
 
177
                                                      g_str_equal,
 
178
                                                      g_free,
 
179
                                                      NULL);
 
180
        self->priv->stream_id = GVC_MIXER_UI_DEVICE_INVALID;
 
181
        self->priv->card_id = GVC_MIXER_UI_DEVICE_INVALID;
 
182
        self->priv->port_name = NULL;
 
183
        self->priv->disable_profile_swapping = FALSE;
 
184
        self->priv->user_preferred_profile = NULL;
 
185
        return object;
 
186
}
 
187
 
 
188
static void
 
189
gvc_mixer_ui_device_init (GvcMixerUIDevice *object)
 
190
{
 
191
        object->priv  = GVC_MIXER_UI_DEVICE_GET_PRIVATE (object);       
 
192
}
 
193
 
 
194
static void 
 
195
gvc_mixer_ui_device_dispose (GObject *object)
 
196
{
 
197
        g_return_if_fail (object != NULL);
 
198
        g_return_if_fail (GVC_MIXER_UI_DEVICE (object));
 
199
 
 
200
        GvcMixerUIDevice *device;
 
201
        device = GVC_MIXER_UI_DEVICE (object);
 
202
        
 
203
        if (device->priv->port_name != NULL){
 
204
                g_free (device->priv->port_name);
 
205
                device->priv->port_name = NULL;
 
206
        }
 
207
        if (device->priv->first_line_desc != NULL){             
 
208
                g_free (device->priv->first_line_desc);
 
209
                device->priv->first_line_desc = NULL;
 
210
        }
 
211
        if (device->priv->second_line_desc != NULL){
 
212
                g_free (device->priv->second_line_desc);
 
213
                device->priv->second_line_desc = NULL;
 
214
        }
 
215
        if (device->priv->profiles != NULL){
 
216
                g_hash_table_destroy (device->priv->profiles);
 
217
                device->priv->profiles = NULL;
 
218
        }
 
219
        if (device->priv->user_preferred_profile != NULL){
 
220
                g_free (device->priv->user_preferred_profile);
 
221
                device->priv->user_preferred_profile = NULL;
 
222
        }
 
223
    G_OBJECT_CLASS (gvc_mixer_ui_device_parent_class)->dispose (object);        
 
224
}
 
225
 
 
226
static void
 
227
gvc_mixer_ui_device_finalize (GObject *object)
 
228
{
 
229
        G_OBJECT_CLASS (gvc_mixer_ui_device_parent_class)->finalize (object);
 
230
}
 
231
 
 
232
static void
 
233
gvc_mixer_ui_device_class_init (GvcMixerUIDeviceClass *klass)
 
234
{
 
235
        GObjectClass* object_class = G_OBJECT_CLASS (klass);
 
236
 
 
237
        object_class->constructor = gvc_mixer_ui_device_constructor;
 
238
        object_class->dispose = gvc_mixer_ui_device_dispose;        
 
239
        object_class->finalize = gvc_mixer_ui_device_finalize;
 
240
        object_class->set_property = gvc_mixer_ui_device_set_property;
 
241
        object_class->get_property = gvc_mixer_ui_device_get_property;
 
242
 
 
243
        GParamSpec *pspec;
 
244
 
 
245
        pspec = g_param_spec_string ("description",
 
246
                                "Description construct prop",
 
247
                                "Set first line description",
 
248
                                "no-name-set",
 
249
                                G_PARAM_READWRITE);
 
250
        g_object_class_install_property (object_class,
 
251
                                         PROP_DESC_LINE_1,
 
252
                                         pspec);        
 
253
                                 
 
254
        pspec = g_param_spec_string ("origin",
 
255
                                 "origin construct prop",
 
256
                                 "Set second line description name",
 
257
                                 "no-name-set",
 
258
                                  G_PARAM_READWRITE);
 
259
        g_object_class_install_property (object_class,
 
260
                                        PROP_DESC_LINE_2,
 
261
                                        pspec); 
 
262
 
 
263
        pspec = g_param_spec_int ("card-id",
 
264
                                  "Card id from pulse",
 
265
                                  "Set/Get card id",
 
266
                                  -1 ,
 
267
                                  1000 ,
 
268
                                  GVC_MIXER_UI_DEVICE_INVALID,
 
269
                                  G_PARAM_READWRITE);
 
270
 
 
271
        g_object_class_install_property (object_class,
 
272
                                         PROP_CARD_ID,
 
273
                                         pspec);
 
274
                                                                 
 
275
        pspec = g_param_spec_string ("port-name",
 
276
                                 "port-name construct prop",
 
277
                                 "Set port-name",
 
278
                                 NULL,
 
279
                                 G_PARAM_READWRITE);
 
280
        g_object_class_install_property (object_class,
 
281
                                         PROP_PORT_NAME,
 
282
                                         pspec);        
 
283
 
 
284
        pspec = g_param_spec_int ("stream-id",
 
285
                                  "stream id assigned by gvc-stream",
 
286
                                  "Set/Get stream id",
 
287
                                  -1,  
 
288
                                   10000, 
 
289
                                   GVC_MIXER_UI_DEVICE_INVALID,
 
290
                                   G_PARAM_READWRITE);
 
291
        g_object_class_install_property (object_class,
 
292
                                         PROP_STREAM_ID,
 
293
                                         pspec);
 
294
 
 
295
        pspec = g_param_spec_uint ("type",
 
296
                                   "ui-device type",
 
297
                                   "determine whether its an input and output",
 
298
                                0,
 
299
                                    1,
 
300
                                    0,
 
301
                                    G_PARAM_READWRITE);
 
302
        g_object_class_install_property (object_class,
 
303
                                         PROP_UI_DEVICE_TYPE,
 
304
                                         pspec);
 
305
 
 
306
        pspec = g_param_spec_boolean ( "port-available",
 
307
                                        "available",
 
308
                                        "determine whether this port is available",
 
309
                                        FALSE,
 
310
                                        G_PARAM_READWRITE);                                    
 
311
        g_object_class_install_property (object_class,
 
312
                                        PROP_PORT_AVAILABLE,
 
313
                                        pspec);        
 
314
                                 
 
315
        g_type_class_add_private (klass, sizeof (GvcMixerUIDevicePrivate));                                                                     
 
316
}
 
317
 
 
318
// TODO
 
319
// Optimise so as on the first pass you can 'choose' which profiles to hold on to and
 
320
// which are useles because they are essentially duplicates.
 
321
void
 
322
gvc_mixer_ui_device_set_profiles (GvcMixerUIDevice *device, const GList *in_profiles)
 
323
{
 
324
        gint profile_count;
 
325
        GList* t;
 
326
        GHashTable *profile_descriptions;
 
327
 
 
328
        device->priv->supported_profiles = in_profiles;
 
329
                
 
330
        profile_count = g_list_length (in_profiles);
 
331
        profile_descriptions = g_hash_table_new_full (g_str_hash,
 
332
                                                      g_str_equal,
 
333
                                                      g_free,
 
334
                                                      g_free);
 
335
 
 
336
        //debug
 
337
        gboolean is_input = device->priv->type != UiDeviceOutput;
 
338
        gboolean is_output = device->priv->type == UiDeviceOutput;
 
339
 
 
340
        // Store each profile in a hash with the shortened relevant string as the key
 
341
        for (t = in_profiles; t != NULL; t = t->next) {
 
342
 
 
343
                GvcMixerCardProfile* p;
 
344
                p = t->data;
 
345
 
 
346
 
 
347
                //g_print ("\n check if this %s has already passed %i", p->profile, g_hash_table_contains (profile_descriptions, p->profile));
 
348
 
 
349
                gchar** modified;
 
350
 
 
351
                modified = g_strsplit (p->profile, "+", 0);     
 
352
                guint count;
 
353
                
 
354
                count = g_strv_length (modified);
 
355
 
 
356
                if (count == 1){
 
357
                        g_print ("\n Single profile, %i, key %s against value %s for device %s \n",
 
358
                                 is_input,
 
359
                                 p->profile,
 
360
                                 modified[0],
 
361
                                 gvc_mixer_ui_device_get_description (device));
 
362
                        g_hash_table_insert (profile_descriptions,
 
363
                                             g_strdup (p->profile),
 
364
                                             g_strdup (modified[0]));
 
365
                        g_strfreev (modified);
 
366
                        continue;       
 
367
                }
 
368
 
 
369
                if (device->priv->type == UiDeviceOutput) {
 
370
                        if (g_str_has_prefix (modified[0], "output")){
 
371
                                g_print ("\n Found an output profile - storing key %s against value %s for device %s \n",
 
372
                                           p->profile, modified[0], gvc_mixer_ui_device_get_description (device));
 
373
                                g_hash_table_insert (profile_descriptions,
 
374
                                                     g_strdup (p->profile),
 
375
                                                     g_strdup (modified[0]));
 
376
                        }
 
377
                }
 
378
                else{
 
379
                        if (g_str_has_prefix (modified[1], "input")){
 
380
                                g_print ("\n Found an input profile - storing key %s against value %s for device %s \n",
 
381
                                          p->profile, modified[1], gvc_mixer_ui_device_get_description (device));
 
382
                                g_hash_table_insert (profile_descriptions,
 
383
                                                     g_strdup (p->profile),
 
384
                                                     g_strdup (modified[1]));
 
385
                        }
 
386
                }
 
387
                g_strfreev (modified);                          
 
388
        }
 
389
        
 
390
        // Determine if we want allow the user to change the profile from the device
 
391
        // i.e. is there any actual choice or just much of the same thing from the 
 
392
        // context of the direction on this device.
 
393
        gboolean identical = TRUE;
 
394
        GList *shortened_profiles;
 
395
        shortened_profiles = g_hash_table_get_values (profile_descriptions);
 
396
        
 
397
        for (t = shortened_profiles; t != NULL; t = t->next) {
 
398
                gchar* prof;
 
399
                prof = t->data;
 
400
                if (g_list_next (t) != NULL){
 
401
                        gchar* next_prof;
 
402
                        GList* n;
 
403
                        n = g_list_next (t);
 
404
                        next_prof = n->data;
 
405
                        identical = g_strcmp0 (prof, next_prof) == 0; 
 
406
                }
 
407
                if (!identical){
 
408
                        break;
 
409
                }
 
410
        }
 
411
        g_list_free (shortened_profiles);
 
412
 
 
413
        g_print ("\n device->priv->disable_profile_swapping = %i \n", 
 
414
                  identical);
 
415
 
 
416
        device->priv->disable_profile_swapping = identical;
 
417
        GList *x;
 
418
        GList *y;
 
419
 
 
420
        if (!identical) {
 
421
                for (y = in_profiles; y != NULL; y = y->next) {
 
422
                        GvcMixerCardProfile* p;
 
423
                        p = y->data;
 
424
                        gchar* short_name;
 
425
                        short_name = g_hash_table_lookup (profile_descriptions, p->profile);
 
426
 
 
427
                        g_print ("\n\n has this profile passed already- %s , %s \n\n", short_name, p->profile);
 
428
 
 
429
                        for (x = in_profiles; x != NULL; x = x->next) {
 
430
                                GvcMixerCardProfile* l;
 
431
                                l = x->data;
 
432
                                gchar* other_modified;
 
433
                                                                
 
434
                                if (g_strcmp0 (p->profile, "off") == 0){
 
435
                                        g_print ("\n\n Bluetooth off profile - ignore it");
 
436
                                        continue;
 
437
                                }
 
438
                                
 
439
                                if (g_hash_table_contains (device->priv->profiles, short_name) == TRUE){
 
440
                                        g_print ("\n\n SHORT NAME already populated move on - %s \n\n", p->profile);
 
441
                                        continue;                               
 
442
                                }
 
443
 
 
444
                                other_modified = g_hash_table_lookup (profile_descriptions, l->profile);
 
445
                                
 
446
                                if (g_strcmp0 (other_modified, short_name) == 0){
 
447
                                        if (sort_profiles (p, l) > 0){
 
448
                                                g_hash_table_insert (device->priv->profiles, short_name, p);
 
449
                                        }
 
450
                                        else{
 
451
                                                g_hash_table_insert (device->priv->profiles, short_name, l);                                            
 
452
                                        }                               
 
453
                                }
 
454
                        }
 
455
                }
 
456
        }
 
457
        else{
 
458
                // If it's identical we want to find the profile that is relevant to the context of the device
 
459
                // For the sake of the UI - avoid user confusion.
 
460
                GList* profile_descriptions_keys;
 
461
                profile_descriptions_keys = g_hash_table_get_keys (profile_descriptions);
 
462
                GList* c;
 
463
                gboolean matched = FALSE;
 
464
                for (c = profile_descriptions_keys; c != NULL; c = c->next) {
 
465
                        gchar* prof;
 
466
                        prof = c->data;
 
467
                        gchar* shortened_value;
 
468
                        shortened_value = g_hash_table_lookup (profile_descriptions, prof);
 
469
                        if (g_strcmp0 (shortened_value, prof) == 0){
 
470
                                GList *j;
 
471
                                for (j = in_profiles; j != NULL; j = j->next) {
 
472
                                        GvcMixerCardProfile* l;
 
473
                                        l = j->data;
 
474
                                        if (g_strcmp0 (l->profile, prof) == 0){
 
475
                                                g_hash_table_insert (device->priv->profiles, 
 
476
                                                                     "tmp",
 
477
                                                                     l);        
 
478
                                                matched = TRUE;
 
479
                                        }
 
480
                                }                       
 
481
                        }
 
482
                }
 
483
                // We can't find the ideal profile for the insensitive combo
 
484
                // just pick the one with the highest priority.
 
485
                if (!matched){  
 
486
                        GvcMixerCardProfile* p;
 
487
                        // Since the profile list was already sorted on card port creation
 
488
                        // we just need to take the last one as this will have the highest priority
 
489
                        p = g_list_last (in_profiles)->data;
 
490
                        g_hash_table_insert (device->priv->profiles, 
 
491
                                             "tmp",
 
492
                                             p);                        
 
493
                }
 
494
        }
 
495
 
 
496
        /* DEBUG */
 
497
        GList* final_keys;
 
498
        final_keys = g_hash_table_get_keys (device->priv->profiles);
 
499
        GList* o;
 
500
        g_print ("\n\n Profile population \n FOR DEVICE %s", gvc_mixer_ui_device_get_description (device));
 
501
        for (o = final_keys; o != NULL; o = o->next){
 
502
                gchar* key;
 
503
                key = o->data;
 
504
                GvcMixerCardProfile* l;
 
505
                l = g_hash_table_lookup (device->priv->profiles, key);
 
506
                g_print ("\n key %s against \n profile %s \n", 
 
507
                        key,
 
508
                        l->profile);
 
509
        }
 
510
        g_hash_table_destroy (profile_descriptions);
 
511
}
 
512
 
 
513
gboolean
 
514
gvc_mixer_ui_device_determine_profile_sensitivity (GvcMixerUIDevice *device)
 
515
{
 
516
        return device->priv->disable_profile_swapping;
 
517
}
 
518
 
 
519
GList*
 
520
gvc_mixer_ui_device_get_profiles (GvcMixerUIDevice *device)
 
521
{
 
522
        return g_hash_table_get_values (device->priv->profiles); 
 
523
}
 
524
 
 
525
GList*
 
526
gvc_mixer_ui_device_get_supported_profiles (GvcMixerUIDevice *device)
 
527
{
 
528
        return device->priv->supported_profiles;
 
529
}
 
530
 
 
531
guint
 
532
gvc_mixer_ui_device_get_id (GvcMixerUIDevice *op)
 
533
{
 
534
        g_return_val_if_fail (GVC_IS_MIXER_UI_DEVICE (op), 0);
 
535
        return op->priv->id;
 
536
}
 
537
 
 
538
gint
 
539
gvc_mixer_ui_device_get_stream_id (GvcMixerUIDevice *op)
 
540
{
 
541
        gint sink_id;
 
542
        g_object_get (G_OBJECT (op),
 
543
                      "stream-id", &sink_id, NULL);
 
544
        return sink_id;                 
 
545
}
 
546
 
 
547
void                                    
 
548
gvc_mixer_ui_device_invalidate_stream (GvcMixerUIDevice *self)
 
549
{
 
550
        self->priv->stream_id = GVC_MIXER_UI_DEVICE_INVALID;
 
551
}
 
552
 
 
553
 
 
554
const gchar*
 
555
gvc_mixer_ui_device_get_description (GvcMixerUIDevice *op)
 
556
{
 
557
        return op->priv->first_line_desc;
 
558
}
 
559
 
 
560
const gchar*
 
561
gvc_mixer_ui_device_get_user_preferred_profile (GvcMixerUIDevice *dev)
 
562
{
 
563
        return dev->priv->user_preferred_profile;
 
564
}
 
565
 
 
566
const gchar*
 
567
gvc_mixer_ui_device_get_top_priority_profile (GvcMixerUIDevice *dev)
 
568
{
 
569
        GList *last;
 
570
        last = g_list_last (dev->priv->supported_profiles);
 
571
        GvcMixerCardProfile *profile;
 
572
        profile = last->data;                        
 
573
        return profile->profile;
 
574
}
 
575
 
 
576
void 
 
577
gvc_mixer_ui_device_set_user_preferred_profile (GvcMixerUIDevice *device, const gchar* profile)
 
578
{
 
579
        if (device->priv->user_preferred_profile != NULL){
 
580
                g_free (device->priv->user_preferred_profile);
 
581
                device->priv->user_preferred_profile = NULL;
 
582
        }
 
583
        device->priv->user_preferred_profile = g_strdup (profile);
 
584
}
 
585
 
 
586
const gchar*
 
587
gvc_mixer_ui_device_get_port (GvcMixerUIDevice *op)
 
588
{
 
589
        return op->priv->port_name;
 
590
}
 
591
 
 
592
gboolean
 
593
gvc_mixer_ui_device_is_software (GvcMixerUIDevice *dev)
 
594
{
 
595
        return dev->priv->port_name == NULL;
 
596
}
 
597
 
 
598
gboolean
 
599
gvc_mixer_ui_device_is_output (GvcMixerUIDevice *dev)
 
600
{
 
601
        return dev->priv->type == UiDeviceOutput;       
 
602
}
 
603