~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-control.c

  • Committer: Package Import Robot
  • Author(s): Ken VanDine, Sebastien Bacher
  • Date: 2012-02-10 14:57:36 UTC
  • Revision ID: package-import@ubuntu.com-20120210145736-jncyehqpozbmph9c
Tags: 1:3.2.2-2ubuntu8
[ Sebastien Bacher ]
* debian/patches/git_extra_keywords.patch:
  - list "preferences" as a keyword for system settings (lp: #921039)

* debian/patches/96_sound_nua_panel.patch
  - Updated with latest changes from ronoc:
    * protect against null in_profiles in the device
    * ensure when swapping profiles on a sink that is not the pulse server 
      default that is reset as the default sink when the appropriate new 
      stream is created after the profile swap - head melt

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        guint            cached_desired_output_id;
87
87
        guint            cached_desired_input_id;
88
88
        GvcMixerStream   *new_default_stream; /* new default stream, used in gvc_mixer_control_set_default_sink () */
89
 
 
 
89
        guint            profile_swapping_device_id;
90
90
        GvcMixerControlState state;
91
91
};
92
92
 
206
206
        ports = gvc_mixer_stream_get_ports (stream);
207
207
 
208
208
        is_network_stream = ports == NULL;
209
 
        g_print ("\n is_network_stream = %i \n", is_network_stream);
 
209
        //g_print ("\n is_network or bluetooth stream = %i \n", is_network_stream);
210
210
 
211
211
        for (d = devices; d != NULL; d = d->next) {             
212
212
                device = d->data;
232
232
                        if (stream_id == gvc_mixer_stream_get_id (stream) &&
233
233
                            g_strcmp0 (gvc_mixer_ui_device_get_port(device),
234
234
                                       port->port) == 0) {
235
 
                                g_print ("\n \n lookup device from stream found device  \n device port = %s \n device stream id %i \n from \n stream port = %s stream id %u \n",
 
235
                                g_print ("\n \n lookup-device-from-stream found device  \n device description %s \n device port = %s \n device stream id %i \n AND \n stream port = %s stream id %u and stream description %s \n",
 
236
                                         gvc_mixer_ui_device_get_description (device),
236
237
                                         gvc_mixer_ui_device_get_port(device),                                 
237
238
                                         stream_id,
238
239
                                         port->port,
239
 
                                         gvc_mixer_stream_get_id (stream));
 
240
                                         gvc_mixer_stream_get_id (stream),
 
241
                                         gvc_mixer_stream_get_description (stream));
240
242
                                return device;
241
243
                        }
242
244
                }
254
256
        g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), FALSE);
255
257
        g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
256
258
 
 
259
        g_print ("\n about to set default sink on server \n");
257
260
        o = pa_context_set_default_sink (control->priv->pa_context,
258
261
                                         gvc_mixer_stream_get_name (stream),
259
262
                                         NULL,
485
488
                g_warning ("gvc_mixer_control_change_profile - no card => different profile but cant find a valid card id ?");
486
489
                return;
487
490
        }
488
 
        g_print ("\n Trying to move to profile %s \n", profile);
489
491
        GvcMixerCard *card;
490
 
        card = gvc_mixer_control_lookup_card_id (control, card_id);        
 
492
        card = gvc_mixer_control_lookup_card_id (control, card_id);     
 
493
        g_print ("\n Trying to move to profile %s on card %s on stream id %i \n",
 
494
                profile,
 
495
                gvc_mixer_card_get_name (card),
 
496
                gvc_mixer_ui_device_get_stream_id (device));
 
497
 
 
498
        
 
499
        g_print ("\n default sink name = %s \n and default sink id %u",
 
500
                 control->priv->default_sink_name,
 
501
                 control->priv->default_sink_id);
 
502
 
491
503
        if (gvc_mixer_card_change_profile (card, profile)) {
492
504
                gvc_mixer_ui_device_set_user_preferred_profile (device, profile);
 
505
                control->priv->profile_swapping_device_id = gvc_mixer_ui_device_get_id (device);
493
506
                return TRUE;
494
507
        }
495
508
        return FALSE;
1105
1118
                update_default_source_from_name (control, info->default_source_name);
1106
1119
        }
1107
1120
        if (info->default_sink_name != NULL) {
 
1121
                g_print ("\n update server");
1108
1122
                update_default_sink_from_name (control, info->default_sink_name);
1109
1123
        }
1110
1124
}
1197
1211
 
1198
1212
                if ( stream_card_id == card_id &&
1199
1213
                     g_strcmp0 (device_port_name, stream_port->port) == 0) {                                         
1200
 
                        g_print ("\n Match device with stream \n We have a match with description : %s  \n origin : %s \n cached already with device id %u, \n fill in the blanks \n\n ",
 
1214
                        g_print ("\n Match device with stream \n We have a match with description : %s  \n origin : %s \n cached already with device id %u, \n => set stream id to %i \n\n ",
1201
1215
                                 description,
1202
1216
                                 origin,
1203
 
                                 gvc_mixer_ui_device_get_id (device));
 
1217
                                 gvc_mixer_ui_device_get_id (device),
 
1218
                                 stream_id);
1204
1219
                        
1205
1220
                        g_object_set (G_OBJECT (device),
1206
1221
                                      "stream-id", (gint)stream_id,
1476
1491
                        }                         
1477
1492
                }
1478
1493
                control->priv->cached_desired_output_id = GVC_MIXER_UI_DEVICE_INVALID;
1479
 
        }                
1480
 
 
1481
 
        if (control->priv->default_sink_name != NULL
 
1494
        }        
 
1495
        
 
1496
        /*
 
1497
        When we change profile on a device that is not the server default sink,
 
1498
        it will jump back to the default sink set by the server to prevent the audio setup from being 'outputless'.
 
1499
        All well and good but then when we get the new stream created for the new profile how do we know 
 
1500
        that this is the intended default or selected device the user wishes to use.
 
1501
        This is messy but it's the only reliable way that it can be done without ripping the whole thing apart.
 
1502
        */
 
1503
        gboolean default_set = FALSE;
 
1504
 
 
1505
        if (control->priv->profile_swapping_device_id != GVC_MIXER_UI_DEVICE_INVALID){
 
1506
                GvcMixerUIDevice *dev = NULL;
 
1507
                dev = gvc_mixer_control_lookup_output_id (control, control->priv->profile_swapping_device_id);
 
1508
                if (dev != NULL){
 
1509
                        // now check to make sure this new stream is the same stream just matched and set on the device object
 
1510
                        if (gvc_mixer_ui_device_get_stream_id (dev) == gvc_mixer_stream_get_id (stream)){
 
1511
                                g_print ("Looks like we profile swapped on a non server default sink");
 
1512
                                gvc_mixer_control_set_default_sink (control, stream);
 
1513
                                default_set = TRUE;                   
 
1514
                        }  
 
1515
                }
 
1516
                control->priv->profile_swapping_device_id = GVC_MIXER_UI_DEVICE_INVALID;                
 
1517
        }
 
1518
 
 
1519
        if (!default_set && control->priv->default_sink_name != NULL
1482
1520
            && info->name != NULL
1483
1521
            && strcmp (control->priv->default_sink_name, info->name) == 0) {
1484
1522
                _set_default_sink (control, stream);
2221
2259
                g_warning ("Server info callback failure");
2222
2260
                return;
2223
2261
        }
2224
 
 
 
2262
        g_print ("\n get server info \n");
2225
2263
        update_server (control, i);
2226
2264
        dec_outstanding (control);
2227
2265
}
2575
2613
        device = gvc_mixer_control_lookup_device_from_stream (control, stream);
2576
2614
 
2577
2615
        if (device != NULL){
2578
 
                g_print ("\n invalidate stream on device - %s \n", gvc_mixer_ui_device_get_description (device));        
 
2616
                g_print ("\n invalidate stream on device - remove-sinks - %s \n", gvc_mixer_ui_device_get_description (device));        
2579
2617
 
2580
2618
                gvc_mixer_ui_device_invalidate_stream (device);
2581
2619
                // If its a software device - get rid of it
2583
2621
                        g_signal_emit (G_OBJECT (control),
2584
2622
                                       signals[OUTPUT_REMOVED],
2585
2623
                                       0,
2586
 
                                       gvc_mixer_ui_device_get_id (device));                            
 
2624
                                       gvc_mixer_ui_device_get_id (device));                      
2587
2625
                }
2588
2626
                // otherwise check to make sure to invalidate other devices which may have that stream
2589
2627
                else{
3101
3139
        gvc_mixer_new_pa_context (self);
3102
3140
        self->priv->cached_desired_output_id = GVC_MIXER_UI_DEVICE_INVALID;
3103
3141
        self->priv->cached_desired_input_id = GVC_MIXER_UI_DEVICE_INVALID;
 
3142
        self->priv->profile_swapping_device_id = GVC_MIXER_UI_DEVICE_INVALID;
3104
3143
 
3105
3144
        return object;
3106
3145
}