~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): Sebastien Bacher, Ken VanDine
  • Date: 2012-02-21 22:23:29 UTC
  • mfrom: (1.1.57)
  • Revision ID: package-import@ubuntu.com-20120221222329-moj5n1lsl9kwvapt
Tags: 1:3.3.90-0ubuntu1
* New upstream version:
  - gnome-control-center crashed with SIGSEGV in supply_levels_draw_cb()
    (lp: #903680)
* Refreshed patches for the new version
* debian/control.in:
  - updated g-s-d requirement
* debian/patches/91_configure_cheese.patch:
  - dropped, the fix is in the new version
* debian/source_gnome-control-center.py:
  - don't update the title several times, tag as well 
     
[ Ken VanDine ] 
* debian/patches/96_sound_nua_panel.patch
  - sound-nua: fixed crashers in gtk_tree_model_get_valist() 
    (LP: #931708) and (LP: #932446)
  - sound-nua: fixed a failure in profile selection

Show diffs side-by-side

added added

removed removed

Lines of Context:
318
318
// TODO
319
319
// Optimise so as on the first pass you can 'choose' which profiles to hold on to and
320
320
// which are useles because they are essentially duplicates.
 
321
// => a Breadthfirst approach is needed ...
321
322
void
322
323
gvc_mixer_ui_device_set_profiles (GvcMixerUIDevice *device, const GList *in_profiles)
323
324
{
 
325
        g_print ("\n SET PROFILES %s", gvc_mixer_ui_device_get_description(device));
 
326
                
324
327
        gint profile_count;
325
328
        GList* t;
326
329
        GHashTable *profile_descriptions;
327
330
        if (in_profiles == NULL)
328
331
                return;
329
332
 
330
 
        // Make sure we can
331
333
        device->priv->supported_profiles = in_profiles;
332
334
                
333
335
        profile_count = g_list_length (in_profiles);
336
338
                                                      g_free,
337
339
                                                      g_free);
338
340
 
339
 
        //debug
340
 
        gboolean is_input = device->priv->type != UiDeviceOutput;
341
 
        gboolean is_output = device->priv->type == UiDeviceOutput;
342
 
 
343
341
        // Store each profile in a hash with the shortened relevant string as the key
344
342
        for (t = in_profiles; t != NULL; t = t->next) {
345
343
 
346
344
                GvcMixerCardProfile* p;
347
345
                p = t->data;
348
346
 
349
 
 
350
 
                //g_print ("\n check if this %s has already passed %i", p->profile, g_hash_table_contains (profile_descriptions, p->profile));
351
 
 
352
347
                gchar** modified;
353
348
 
354
349
                modified = g_strsplit (p->profile, "+", 0);     
355
350
                guint count;
356
351
                
357
352
                count = g_strv_length (modified);
358
 
 
 
353
                // It's a profile that only handles one direction, cache it and move on
359
354
                if (count == 1){
360
355
                        /*g_print ("\n Single profile, %i, key %s against value %s for device %s \n",
361
356
                                 is_input,
422
417
 
423
418
        if (!identical) {
424
419
                for (y = in_profiles; y != NULL; y = y->next) {
 
420
                        GList *profiles_with_identical_shortened_names = NULL;
425
421
                        GvcMixerCardProfile* p;
426
422
                        p = y->data;
427
423
                        gchar* short_name;
428
424
                        short_name = g_hash_table_lookup (profile_descriptions, p->profile);
429
425
 
430
 
                        g_print ("\n\n has this profile passed already- %s , %s \n\n", short_name, p->profile);
431
 
 
 
426
                        g_print ("\n Not identical - examine  %s -> %s \n\n", short_name, p->profile);
 
427
                        
 
428
                        // Bloody bluetooth.
 
429
                        if (g_strcmp0 (p->profile, "off") == 0){
 
430
                                g_print ("\n Bluetooth off profile - ignore it \n");
 
431
                                continue;
 
432
                        }
 
433
 
 
434
                        // If we have already populated for this short name - trust our prioritisation below and move on.
 
435
                        if (g_hash_table_contains (device->priv->profiles, short_name) == TRUE){
 
436
                                g_print ("\n already populated for %s => ignore %s \n", short_name, p->profile);
 
437
                                continue;
 
438
                        }               
 
439
 
 
440
                        profiles_with_identical_shortened_names = g_list_append (profiles_with_identical_shortened_names, p);
 
441
                                
432
442
                        for (x = in_profiles; x != NULL; x = x->next) {
433
443
                                GvcMixerCardProfile* l;
434
444
                                l = x->data;
435
445
                                gchar* other_modified;
436
 
                                                                
437
 
                                if (g_strcmp0 (p->profile, "off") == 0){
438
 
                                        g_print ("\n\n Bluetooth off profile - ignore it");
 
446
 
 
447
                                // no point in comparing it against itself now.                                                         
 
448
                                if (g_strcmp0 (p->profile, l->profile) == 0)
439
449
                                        continue;
440
 
                                }
441
 
                                
442
 
                                if (g_hash_table_contains (device->priv->profiles, short_name) == TRUE){
443
 
                                        g_print ("\n\n SHORT NAME already populated move on - %s \n\n", p->profile);
444
 
                                        continue;                               
445
 
                                }
446
450
 
447
451
                                other_modified = g_hash_table_lookup (profile_descriptions, l->profile);
448
452
                                
449
453
                                if (g_strcmp0 (other_modified, short_name) == 0){
450
 
                                        if (sort_profiles (p, l) > 0){
451
 
                                                g_hash_table_insert (device->priv->profiles, short_name, p);
452
 
                                                g_print ("\n Sensitive comb - Populate the profile combo with %s", p->profile);
453
 
                                        }
454
 
                                        else{
455
 
                                                g_hash_table_insert (device->priv->profiles, short_name, l);                                            
456
 
                                                g_print ("\n Sensitive comb - Populate the profile combo with %s", p->profile);
457
 
                                        }                               
458
 
                                }
459
 
                                else{
460
 
                                        g_print ("failed to match %s with %s", other_modified, short_name);
461
 
                                }
462
 
                        }
 
454
                                        profiles_with_identical_shortened_names = g_list_append (profiles_with_identical_shortened_names,
 
455
                                                                                                 l);    
 
456
                                }
 
457
                        }
 
458
                        
 
459
                        // EDGE case noticed with bluetooth.
 
460
                        if (g_list_length (profiles_with_identical_shortened_names) < 2){
 
461
                                g_hash_table_insert (device->priv->profiles,
 
462
                                                     g_strdup(short_name),
 
463
                                                     p);
 
464
                                g_list_free (profiles_with_identical_shortened_names);  
 
465
                                device->priv->disable_profile_swapping = TRUE;
 
466
                                break;
 
467
                        }
 
468
                                                        
 
469
                        GList* ordered = NULL;
 
470
                        ordered = g_list_sort (profiles_with_identical_shortened_names,
 
471
                                               (GCompareFunc) sort_profiles);   
 
472
 
 
473
                        GvcMixerCardProfile* priority_profile = g_list_last(ordered)->data;
 
474
 
 
475
                        g_print ("\n Sensitive combo - Populate the profile combo with profile %s against short name %s",
 
476
                                  priority_profile->profile, short_name);
 
477
 
 
478
                        g_hash_table_insert (device->priv->profiles,
 
479
                                             g_strdup(short_name),
 
480
                                             priority_profile);
 
481
                        g_list_free (profiles_with_identical_shortened_names);          
463
482
                }
464
483
        }
465
484
        else{
466
 
                // If it's identical we want to find the profile that is relevant to the context of the device
467
 
                // For the sake of the UI - avoid user confusion.
 
485
                // If it's identical (=> combo is insensitive) we want to find the profile that is
 
486
                // relevant to the context of the device for the sake of the UI - avoid user confusion.
468
487
                GList* profile_descriptions_keys;
469
488
                profile_descriptions_keys = g_hash_table_get_keys (profile_descriptions);
470
489
                GList* c;
481
500
                                        l = j->data;
482
501
                                        if (g_strcmp0 (l->profile, prof) == 0){
483
502
                                                g_hash_table_insert (device->priv->profiles, 
484
 
                                                                     "tmp",
 
503
                                                                     g_strdup(shortened_value),
485
504
                                                                     l);        
486
505
                                                matched = TRUE;
487
506
                                        }
488
 
                                }                       
 
507
                                }               
489
508
                        }
490
509
                }
491
510
                // We can't find the ideal profile for the insensitive combo
497
516
                        p = g_list_last (in_profiles)->data;
498
517
                        if (p != NULL)
499
518
                                g_hash_table_insert (device->priv->profiles, 
500
 
                                                     "tmp",
501
 
                                                      p);                       
 
519
                                                     p->human_profile,
 
520
                                                     p);                        
502
521
                }
503
522
        }
504
 
 
505
523
        /* DEBUG */
506
 
        GList* final_keys;
 
524
        /*GList* final_keys;
507
525
        final_keys = g_hash_table_get_keys (device->priv->profiles);
508
526
        GList* o;
509
527
        g_print ("\n\n Profile population \n FOR DEVICE %s", gvc_mixer_ui_device_get_description (device));
515
533
                g_print ("\n key %s against \n profile %s \n", 
516
534
                        key,
517
535
                        l->profile);
518
 
        }
 
536
        }*/
519
537
        g_hash_table_destroy (profile_descriptions);
520
538
}
521
539
 
525
543
        return device->priv->disable_profile_swapping;
526
544
}
527
545
 
528
 
GList*
 
546
GHashTable*
529
547
gvc_mixer_ui_device_get_profiles (GvcMixerUIDevice *device)
530
548
{
531
 
        return g_hash_table_get_values (device->priv->profiles); 
 
549
        return device->priv->profiles; 
532
550
}
533
551
 
534
552
GList*