~cjcurran/+junk/soundnua-gtk-warnings

« back to all changes in this revision

Viewing changes to soundnua/gvc-mixer-control.c

  • Committer: Conor Curran
  • Date: 2012-04-26 07:28:31 UTC
  • Revision ID: conor.curran@canonical.com-20120426072831-27idltfw5zcarjqn
make sure to disconnect old streams from callbacks - fixes gtk warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1886
1886
{
1887
1887
        UiDeviceDirection direction;
1888
1888
        
1889
 
        direction = (is_card_port_an_output(port) == TRUE) ? UiDeviceOutput : UiDeviceInput;
1890
1889
        GObject *object;
1891
1890
        gboolean available = port->available == 0 || port->available == 2;
1892
1891
 
1902
1901
        GvcMixerUIDevice* uidevice = GVC_MIXER_UI_DEVICE (object);
1903
1902
        gvc_mixer_ui_device_set_profiles (uidevice, port->profiles);
1904
1903
 
1905
 
 
1906
 
        if (is_card_port_an_output (port)) {
1907
 
                g_hash_table_insert (control->priv->ui_outputs,
1908
 
                                     GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (uidevice)),
1909
 
                                     g_object_ref (uidevice));
1910
 
 
1911
 
                if (available) {
1912
 
                        g_signal_emit (G_OBJECT (control),
1913
 
                                       signals[OUTPUT_ADDED],
1914
 
                                       0,
1915
 
                                       gvc_mixer_ui_device_get_id (uidevice));
1916
 
                }       
1917
 
                                     
1918
 
        }
1919
 
        else{
1920
 
                g_hash_table_insert (control->priv->ui_inputs,
1921
 
                                     GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (uidevice)),
1922
 
                                     g_object_ref (uidevice));
1923
 
 
1924
 
                if (available) {
1925
 
                        g_signal_emit (G_OBJECT (control),
1926
 
                                       signals[INPUT_ADDED],
1927
 
                                       0,
1928
 
                                       gvc_mixer_ui_device_get_id (uidevice));
1929
 
                }                                            
1930
 
        }
1931
 
 
1932
 
        g_debug ("\n create_ui_device_from_port, direction %u \n description %s \n origin %s \n port available %i \n \n", 
1933
 
                 direction,
1934
 
                 port->human_port,
1935
 
                 gvc_mixer_card_get_name (card),
1936
 
                 available);
 
1904
        g_hash_table_insert ( is_card_port_an_output (port) ? control->priv->ui_outputs : control->priv->ui_inputs,
 
1905
                             GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (uidevice)),
 
1906
                             g_object_ref (uidevice));
 
1907
 
 
1908
        if (available) {
 
1909
                g_signal_emit (G_OBJECT (control),
 
1910
                               is_card_port_an_output (port) ? signals[OUTPUT_ADDED] : signals[INPUT_ADDED],
 
1911
                               0,
 
1912
                               gvc_mixer_ui_device_get_id (uidevice));
 
1913
        }       
1937
1914
}
1938
 
 
 
1915
/*
 
1916
TODO:
 
1917
This method could be optimised. Alot of duplication, line length could be significantly reduced. 
 
1918
*/
1939
1919
static void
1940
1920
match_card_port_with_existing_device (GvcMixerControl *control,
1941
1921
                                      GvcMixerCardPort* card_port,
1948
1928
        gboolean in_possession  = FALSE;
1949
1929
        gboolean is_output      = is_card_port_an_output (card_port);
1950
1930
 
1951
 
        if (is_output){
1952
 
               devices  = g_hash_table_get_values (control->priv->ui_outputs);
1953
 
        }
1954
 
        else{
1955
 
               devices  = g_hash_table_get_values (control->priv->ui_inputs);       
1956
 
        }
 
1931
        devices  = g_hash_table_get_values (is_output ? control->priv->ui_outputs : control->priv->ui_inputs);
1957
1932
 
1958
1933
        for (d = devices; d != NULL; d = d->next) {                                     
1959
1934
                device = d->data;
1974
1949
                        g_object_set ( G_OBJECT (device),
1975
1950
                                       "port-available", available, NULL);
1976
1951
                        if (is_output) {
1977
 
                                if (available) {
1978
 
                                        g_signal_emit (G_OBJECT (control),
1979
 
                                                       signals[OUTPUT_ADDED],
1980
 
                                                       0,
1981
 
                                                       gvc_mixer_ui_device_get_id (device));    
1982
 
                                }
1983
 
                                else{
1984
 
                                        g_signal_emit (G_OBJECT (control),
1985
 
                                                       signals[OUTPUT_REMOVED],
1986
 
                                                       0,
1987
 
                                                       gvc_mixer_ui_device_get_id (device));    
1988
 
                                }
 
1952
                                g_signal_emit (G_OBJECT (control),
 
1953
                                               available ? signals[OUTPUT_ADDED] : signals[OUTPUT_REMOVED],
 
1954
                                               0,
 
1955
                                               gvc_mixer_ui_device_get_id (device));    
1989
1956
                        }
1990
1957
                        else{
1991
 
                                if (available) {
1992
 
                                        g_signal_emit (G_OBJECT (control),
1993
 
                                                       signals[INPUT_ADDED],
1994
 
                                                       0,
1995
 
                                                       gvc_mixer_ui_device_get_id (device)); 
1996
 
                                }
1997
 
                                else{
1998
 
                                        g_signal_emit (G_OBJECT (control),
1999
 
                                                       signals[INPUT_REMOVED],
2000
 
                                                       0,
2001
 
                                                       gvc_mixer_ui_device_get_id (device)); 
2002
 
                                }                                
 
1958
                                g_signal_emit (G_OBJECT (control),
 
1959
                                               available ? signals[INPUT_ADDED] : signals[INPUT_REMOVED],
 
1960
                                               0,
 
1961
                                               gvc_mixer_ui_device_get_id (device)); 
2003
1962
                        }
2004
1963
               }
2005
1964
               g_free (device_port_name);