~ken-vandine/ubuntu/precise/gnome-control-center/precise

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Martin Pitt, Aurélien Gâteau
  • Date: 2012-03-08 18:30:18 UTC
  • Revision ID: package-import@ubuntu.com-20120308183018-ewmdzzyuoll4twgk
Tags: 1:3.3.91-0ubuntu2
* debian/patches/96_sound_nua_panel.patch:
  - change X-GNOME-Keywords to Keywords
  - updated to r273, fixes profile selection issues with bluetooth devices
    (lp: #948236)
* debian/patches/revert_git_drop_library.patch:
  - simplified, don't copy files or create a new dir
* debian/patches/git_zoom_shell_only.patch:
  - hide zoom option when not under gnome-shell since they do nothing 
    on other environments (lp: #945813)

[ Martin Pitt ]
* debian/control.in: Only recommend gnome-session-bin, to avoid pulling in
  all of gnome-session and Unity for derivatives. (LP: #936761)

[ Aurélien Gâteau ]
* debian/patches/60_ubuntu_nav_bar.patch: Use a GtkBox instead of a GtkGrid
  so that GTK_STYLE_CLASS_LINKED works.

Show diffs side-by-side

added added

removed removed

Lines of Context:
499
499
                 control->priv->default_sink_name,
500
500
                 control->priv->default_sink_id);
501
501
 
 
502
        control->priv->profile_swapping_device_id = gvc_mixer_ui_device_get_id (device);
 
503
 
502
504
        if (gvc_mixer_card_change_profile (card, profile)) {
503
505
                gvc_mixer_ui_device_set_user_preferred_profile (device, profile);
504
 
                control->priv->profile_swapping_device_id = gvc_mixer_ui_device_get_id (device);
505
506
                return TRUE;
506
507
        }
507
508
        return FALSE;
550
551
                return;
551
552
        }
552
553
 
553
 
        // Handle a network sink => a portless/cardless device
554
 
        if (gvc_mixer_ui_device_get_port (output) == NULL){
555
 
                g_print ("Did we try to move to a network sink ? \n");
 
554
        // Handle a network sink => a portless or cardless device
 
555
        if (gvc_mixer_ui_device_is_software (output) || gvc_mixer_ui_device_is_bluetooth (output)){
 
556
                g_print ("Did we try to move to a software/bluetooth sink ? \n");
556
557
                if (gvc_mixer_control_set_default_sink (control, stream)) {
557
558
                        // sink change successfull => update the UI.
558
559
                        g_signal_emit (G_OBJECT (control),
639
640
        }
640
641
 
641
642
        // Handle a network sink => a portless/cardless device
642
 
        if (gvc_mixer_ui_device_get_port (input) == NULL){
643
 
                g_print ("Did we try to move to a network source ? \n");
 
643
        if (gvc_mixer_ui_device_is_software (input) || gvc_mixer_ui_device_is_bluetooth (input)){
 
644
                g_print ("\n Did we try to move to a software/bluetooth source ? \n");
644
645
                if (gvc_mixer_control_set_default_source (control, stream)) {
645
 
                        // source change successfull => update the UI.
646
646
                        g_signal_emit (G_OBJECT (control),
647
647
                                       signals[ACTIVE_INPUT_UPDATE],
648
648
                                       0,
649
 
                                       gvc_mixer_ui_device_get_id (input));             
 
649
                                       gvc_mixer_ui_device_get_id (input));  
650
650
                }
651
651
                else{
652
652
                        g_warning ("Failed to set default source with stream from input %s \n",
1236
1236
sync_devices (GvcMixerControl *control,
1237
1237
              GvcMixerStream* stream, int is_output)
1238
1238
{
1239
 
 
1240
1239
        // Go through ports to see what outputs can be created.
1241
1240
        const GList *stream_ports = NULL;
1242
1241
        const GList *n = NULL;
 
1242
        const GList *d;
1243
1243
        
1244
1244
        stream_ports = gvc_mixer_stream_get_ports (stream);
1245
1245
        gint stream_port_count = 0;
1246
1246
                
1247
1247
        if (g_list_length (stream_ports) == 0){                       
1248
 
                g_print (" \n \n !!! Just found a %s without ports - creating a UI device \n", is_output ? "sink" : "source");
1249
 
                GObject *object;
1250
 
 
1251
 
                object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
1252
 
                                       "stream-id", (gint)gvc_mixer_stream_get_id (stream),
1253
 
                                       "description", gvc_mixer_stream_get_description (stream),
1254
 
                                       "origin", "", /*Leave it empty for these special cases*/
1255
 
                                       "port-name", NULL,
1256
 
                                       "port-available", TRUE,
1257
 
                                       NULL);
1258
 
                GvcMixerUIDevice* out = GVC_MIXER_UI_DEVICE (object);
 
1248
                GvcMixerUIDevice* device;
1259
1249
 
1260
1250
                if (gvc_mixer_stream_get_card_index (stream) != PA_INVALID_INDEX) {
1261
 
                        // Detecting bluetooth device !
1262
 
                        g_object_set ( object,
1263
 
                                      "card-id",
1264
 
                                       gvc_mixer_stream_get_card_index (stream), NULL);
 
1251
                        g_print ("\n \n Bluetooth device \n \n");
 
1252
                        GList *devices;
 
1253
                        gint  card_id;
 
1254
 
 
1255
                        if (GVC_IS_MIXER_SOURCE (stream)){
 
1256
                               devices  = g_hash_table_get_values (control->priv->ui_inputs);                       
 
1257
                        }
 
1258
                        else{
 
1259
                               devices  = g_hash_table_get_values (control->priv->ui_outputs);
 
1260
                        }
 
1261
 
 
1262
                        gboolean in_possession  = FALSE;
 
1263
 
 
1264
                        for (d = devices; d != NULL; d = d->next) {                             
 
1265
                                device = d->data;
 
1266
                                
 
1267
                                g_object_get (G_OBJECT (device),
 
1268
                                             "card-id", &card_id,
 
1269
                                              NULL);
 
1270
                                if (card_id == gvc_mixer_stream_get_card_index (stream)){
 
1271
                                        in_possession = TRUE;
 
1272
                                        break;
 
1273
                                }
 
1274
                        }
 
1275
                        if (!in_possession){
 
1276
                                g_warning ("\n \n Couldn't match the bluetooth stream \n \n");
 
1277
                                return;
 
1278
                        }
 
1279
 
1265
1280
                        GvcMixerCard* card = NULL;
1266
1281
                        card = gvc_mixer_control_lookup_card_id (control,
1267
1282
                                                                 gvc_mixer_stream_get_card_index (stream));
1268
 
                        const GList *profiles = NULL;
1269
 
                        profiles = gvc_mixer_card_get_profiles (card);
1270
 
                        if (profiles == NULL){
1271
 
                                g_warning ("Card has no profiles");
1272
 
                        }
1273
 
                        else{
1274
 
                                g_print ("\n Is this a bluetooth device, portless yet a card with profiles \n");
1275
 
                                gvc_mixer_ui_device_set_profiles (out, profiles);                        
1276
 
                        }
1277
 
                }
1278
 
 
1279
 
                g_hash_table_insert (is_output ? control->priv->ui_outputs : control->priv->ui_inputs,
1280
 
                                     GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (out)),
1281
 
                                     g_object_ref (out));
1282
 
                                
 
1283
                        g_object_set (G_OBJECT (device),
 
1284
                                      "stream-id", (gint)gvc_mixer_stream_get_id (stream),
 
1285
                                      "description", gvc_mixer_stream_get_description (stream),
 
1286
                                      "origin", "", /*Leave it empty for these special cases*/
 
1287
                                       "port-name", NULL,
 
1288
                                       "port-available", TRUE,
 
1289
                                       NULL);
 
1290
                }
 
1291
                else{
 
1292
                        g_print ("\n \n software device \n");
 
1293
                        GObject *object;
 
1294
 
 
1295
                        object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
 
1296
                                               "stream-id", (gint)gvc_mixer_stream_get_id (stream),
 
1297
                                               "description", gvc_mixer_stream_get_description (stream),
 
1298
                                               "origin", "", /*Leave it empty for these special cases*/
 
1299
                                               "port-name", NULL,
 
1300
                                               "port-available", TRUE,
 
1301
                                               NULL);
 
1302
                        device = GVC_MIXER_UI_DEVICE (object);
 
1303
 
 
1304
                        g_hash_table_insert (is_output ? control->priv->ui_outputs : control->priv->ui_inputs,
 
1305
                                             GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (device)),
 
1306
                                             g_object_ref (device));
 
1307
                                        
 
1308
                }
1283
1309
                g_signal_emit (G_OBJECT (control),
1284
1310
                               signals[is_output ? OUTPUT_ADDED : INPUT_ADDED],
1285
1311
                               0,
1286
 
                               gvc_mixer_ui_device_get_id (out));
 
1312
                               gvc_mixer_ui_device_get_id (device));
 
1313
 
1287
1314
                return;
1288
1315
        }
1289
1316
 
1383
1410
        stream = g_hash_table_lookup (control->priv->sinks,
1384
1411
                                      GUINT_TO_POINTER (info->index));
1385
1412
 
1386
 
 
1387
1413
        if (stream == NULL) {
1388
 
 
1389
 
 
1390
1414
                GList *list = NULL;
1391
1415
                guint i;
1392
1416
 
1471
1495
                if (gvc_mixer_stream_get_ports (stream) != NULL && output != NULL){
1472
1496
                        
1473
1497
                        g_print ("\n Apparently we have a cached desired output, \n we should be on port %s \n",
1474
 
                                gvc_mixer_ui_device_get_port (output)); 
 
1498
                                  gvc_mixer_ui_device_get_port (output)); 
1475
1499
                        GvcMixerStreamPort* active_port = gvc_mixer_stream_get_port (stream);
1476
1500
                        
1477
1501
                        if (g_strcmp0(active_port->port, gvc_mixer_ui_device_get_port (output)) == 0){
2065
2089
        
2066
2090
        card_ports = gvc_mixer_card_get_ports (card);
2067
2091
        
 
2092
        guint port_count;
 
2093
        port_count = g_list_length (card_ports);
 
2094
 
 
2095
        if (port_count == 0 && is_new){
 
2096
                // TODO : move to its own method.
 
2097
                g_print ("\n Bluetooth card just registered \n");
 
2098
                // For now just create two devices and presume this device is multi directional
 
2099
                // Ensure to remove both on card removal (available to false by default)
 
2100
                const GList *profiles = NULL;
 
2101
                profiles = gvc_mixer_card_get_profiles (card);
 
2102
 
 
2103
                GObject *object;
 
2104
                object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
 
2105
                                       "type", 0,
 
2106
                                       "description", gvc_mixer_card_get_name (card),
 
2107
                                       "origin", "", /*Leave it empty for these special cases*/
 
2108
                                       "port-name", NULL,
 
2109
                                       "port-available", FALSE,
 
2110
                                       "card-id", gvc_mixer_card_get_index (card),
 
2111
                                       NULL);
 
2112
                GvcMixerUIDevice* in = GVC_MIXER_UI_DEVICE (object);
 
2113
                gvc_mixer_ui_device_set_profiles (in, profiles);                     
 
2114
 
 
2115
                g_hash_table_insert (control->priv->ui_inputs,
 
2116
                                     GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (in)),
 
2117
                                     g_object_ref (in));
 
2118
                object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
 
2119
                                       "type", 1,
 
2120
                                       "description", gvc_mixer_card_get_name (card),
 
2121
                                       "origin", "", /*Leave it empty for these special cases*/
 
2122
                                       "port-name", NULL,
 
2123
                                       "port-available", FALSE,
 
2124
                                       "card-id", gvc_mixer_card_get_index (card),
 
2125
                                       NULL);
 
2126
                GvcMixerUIDevice* out = GVC_MIXER_UI_DEVICE (object);
 
2127
                gvc_mixer_ui_device_set_profiles (out, profiles);                     
 
2128
 
 
2129
                g_hash_table_insert (control->priv->ui_outputs,
 
2130
                                     GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (out)),
 
2131
                                     g_object_ref (out));
 
2132
        }
 
2133
 
2068
2134
        for (m = card_ports; m != NULL; m = m->next) {
2069
2135
                GvcMixerCardPort *card_port;
2070
2136
                card_port = m->data;
2569
2635
                                         gvc_mixer_ui_device_get_description (device)); 
2570
2636
                                g_hash_table_remove (control->priv->ui_outputs,
2571
2637
                                                     GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (device)));
 
2638
 
2572
2639
                        }
2573
2640
                        else{
2574
2641
                                g_signal_emit (G_OBJECT (control),
2579
2646
                                         gvc_mixer_ui_device_get_description (device)); 
2580
2647
                                g_hash_table_remove (control->priv->ui_inputs,
2581
2648
                                                     GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (device)));                                
 
2649
 
2582
2650
                        }                        
2583
2651
                }
2584
2652
        }
2616
2684
 
2617
2685
                gvc_mixer_ui_device_invalidate_stream (device);
2618
2686
                // If its a software device - get rid of it
2619
 
                if (gvc_mixer_ui_device_is_software (device)) {
 
2687
                if (gvc_mixer_ui_device_is_software (device) || gvc_mixer_ui_device_is_bluetooth (device)) {
2620
2688
                        g_signal_emit (G_OBJECT (control),
2621
2689
                                       signals[OUTPUT_REMOVED],
2622
2690
                                       0,
2623
 
                                       gvc_mixer_ui_device_get_id (device));                      
 
2691
                                       gvc_mixer_ui_device_get_id (device));  
2624
2692
                }
2625
2693
                // otherwise check to make sure to invalidate other devices which may have that stream
2626
2694
                else{
2627
 
 
2628
 
                        GList                   *d;
2629
 
                        GList                   *devices;
 
2695
                        GList   *d;
 
2696
                        GList   *devices;
2630
2697
 
2631
2698
                        devices = g_hash_table_get_values (control->priv->ui_outputs);          
2632
2699
 
2673
2740
 
2674
2741
                gvc_mixer_ui_device_invalidate_stream (device);
2675
2742
                // If its a software device - get rid of it
2676
 
                if (gvc_mixer_ui_device_is_software (device)) {
 
2743
                if (gvc_mixer_ui_device_is_software (device) || gvc_mixer_ui_device_is_bluetooth (device)) {
2677
2744
                        g_signal_emit (G_OBJECT (control),
2678
2745
                                       signals[INPUT_REMOVED],
2679
2746
                                       0,
2682
2749
                // otherwise check to make sure to invalidate other devices which may have that stream
2683
2750
                else{
2684
2751
 
2685
 
                        GList                   *d;
2686
 
                        GList                   *devices;
 
2752
                        GList           *d;
 
2753
                        GList           *devices;
2687
2754
 
2688
2755
                        devices = g_hash_table_get_values (control->priv->ui_inputs);          
2689
2756