@@ -73,7 +73,9 @@ struct _MsdMediaKeysManagerPrivate
73
73
/* Volume bits */
74
74
MateMixerContext * context ;
75
75
MateMixerStream * stream ;
76
+ MateMixerStream * source_stream ;
76
77
MateMixerStreamControl * control ;
78
+ MateMixerStreamControl * source_control ;
77
79
#endif
78
80
GtkWidget * dialog ;
79
81
GSettings * settings ;
@@ -635,15 +637,21 @@ update_dialog (MsdMediaKeysManager *manager,
635
637
guint volume ,
636
638
gboolean muted ,
637
639
gboolean sound_changed ,
638
- gboolean quiet )
640
+ gboolean quiet ,
641
+ gboolean is_mic )
639
642
{
640
643
if (muted )
641
644
volume = 0.0 ;
642
645
643
646
dialog_init (manager );
644
647
645
- msd_media_keys_window_set_volume_muted (MSD_MEDIA_KEYS_WINDOW (manager -> priv -> dialog ),
646
- muted );
648
+ if (is_mic )
649
+ msd_media_keys_window_set_mic_muted (MSD_MEDIA_KEYS_WINDOW (manager -> priv -> dialog ),
650
+ muted );
651
+ else
652
+ msd_media_keys_window_set_volume_muted (MSD_MEDIA_KEYS_WINDOW (manager -> priv -> dialog ),
653
+ muted );
654
+
647
655
msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (manager -> priv -> dialog ),
648
656
volume );
649
657
@@ -652,7 +660,7 @@ update_dialog (MsdMediaKeysManager *manager,
652
660
dialog_show (manager );
653
661
654
662
#ifdef HAVE_LIBCANBERRA
655
- if (quiet == FALSE && sound_changed != FALSE && muted == FALSE)
663
+ if (quiet == FALSE && sound_changed != FALSE && muted == FALSE && is_mic == FALSE )
656
664
ca_gtk_play_for_widget (manager -> priv -> dialog , 0 ,
657
665
CA_PROP_EVENT_ID , "audio-volume-change" ,
658
666
CA_PROP_EVENT_DESCRIPTION , "Volume changed through key press" ,
@@ -675,14 +683,21 @@ do_sound_action (MsdMediaKeysManager *manager,
675
683
guint volume_min , volume_max ;
676
684
guint volume_step ;
677
685
guint volume_last ;
686
+ MateMixerStreamControl * control ;
678
687
679
- if (manager -> priv -> control == NULL )
688
+ gboolean is_input_control =
689
+ type == MIC_MUTE_KEY ? TRUE : FALSE;
690
+ if (is_input_control )
691
+ control = manager -> priv -> source_control ;
692
+ else
693
+ control = manager -> priv -> control ;
694
+ if (control == NULL )
680
695
return ;
681
696
682
697
/* Theoretically the volume limits might be different for different
683
698
* streams, also the minimum might not always start at 0 */
684
- volume_min = mate_mixer_stream_control_get_min_volume (manager -> priv -> control );
685
- volume_max = mate_mixer_stream_control_get_normal_volume (manager -> priv -> control );
699
+ volume_min = mate_mixer_stream_control_get_min_volume (control );
700
+ volume_max = mate_mixer_stream_control_get_normal_volume (control );
686
701
687
702
volume_step = g_settings_get_int (manager -> priv -> settings , "volume-step" );
688
703
if (volume_step <= 0 ||
@@ -693,12 +708,13 @@ do_sound_action (MsdMediaKeysManager *manager,
693
708
volume_step = (volume_max - volume_min ) * volume_step / 100 ;
694
709
695
710
volume = volume_last =
696
- mate_mixer_stream_control_get_volume (manager -> priv -> control );
711
+ mate_mixer_stream_control_get_volume (control );
697
712
muted = muted_last =
698
- mate_mixer_stream_control_get_mute (manager -> priv -> control );
713
+ mate_mixer_stream_control_get_mute (control );
699
714
700
715
switch (type ) {
701
716
case MUTE_KEY :
717
+ case MIC_MUTE_KEY :
702
718
muted = !muted ;
703
719
break ;
704
720
case VOLUME_DOWN_KEY :
@@ -723,13 +739,14 @@ do_sound_action (MsdMediaKeysManager *manager,
723
739
}
724
740
725
741
if (muted != muted_last ) {
726
- if (mate_mixer_stream_control_set_mute (manager -> priv -> control , muted ))
742
+ if (mate_mixer_stream_control_set_mute (control , muted ))
727
743
sound_changed = TRUE;
728
744
else
729
745
muted = muted_last ;
730
746
}
731
- if (volume != mate_mixer_stream_control_get_volume (manager -> priv -> control )) {
732
- if (mate_mixer_stream_control_set_volume (manager -> priv -> control , volume ))
747
+
748
+ if (volume != mate_mixer_stream_control_get_volume (control )) {
749
+ if (mate_mixer_stream_control_set_volume (control , volume ))
733
750
sound_changed = TRUE;
734
751
else
735
752
volume = volume_last ;
@@ -739,7 +756,8 @@ do_sound_action (MsdMediaKeysManager *manager,
739
756
CLAMP (100 * volume / (volume_max - volume_min ), 0 , 100 ),
740
757
muted ,
741
758
sound_changed ,
742
- quiet );
759
+ quiet ,
760
+ is_input_control );
743
761
}
744
762
745
763
static void
@@ -775,12 +793,45 @@ update_default_output (MsdMediaKeysManager *manager)
775
793
g_debug ("Default output stream unset" );
776
794
}
777
795
796
+ static void
797
+ update_default_input (MsdMediaKeysManager * manager )
798
+ {
799
+ MateMixerStream * stream ;
800
+ MateMixerStreamControl * control = NULL ;
801
+
802
+ stream = mate_mixer_context_get_default_input_stream (manager -> priv -> context );
803
+ if (stream != NULL )
804
+ control = mate_mixer_stream_get_default_control (stream );
805
+
806
+ if (stream == manager -> priv -> source_stream )
807
+ return ;
808
+
809
+ g_clear_object (& manager -> priv -> source_stream );
810
+ g_clear_object (& manager -> priv -> source_control );
811
+
812
+ if (control != NULL ) {
813
+ MateMixerStreamControlFlags flags = mate_mixer_stream_control_get_flags (control );
814
+
815
+ /* Do not use the stream if it is not possible to mute it or
816
+ * change the volume */
817
+ if (!(flags & MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE ))
818
+ return ;
819
+
820
+ manager -> priv -> source_stream = g_object_ref (stream );
821
+ manager -> priv -> source_control = g_object_ref (control );
822
+ g_debug ("Default input stream updated to %s" ,
823
+ mate_mixer_stream_get_name (stream ));
824
+ } else
825
+ g_debug ("Default input stream unset" );
826
+ }
827
+
778
828
static void
779
829
on_context_state_notify (MateMixerContext * context ,
780
830
GParamSpec * pspec ,
781
831
MsdMediaKeysManager * manager )
782
832
{
783
833
update_default_output (manager );
834
+ update_default_input (manager );
784
835
}
785
836
786
837
static void
@@ -791,6 +842,14 @@ on_context_default_output_notify (MateMixerContext *context,
791
842
update_default_output (manager );
792
843
}
793
844
845
+ static void
846
+ on_context_default_input_notify (MateMixerContext * context ,
847
+ GParamSpec * pspec ,
848
+ MsdMediaKeysManager * manager )
849
+ {
850
+ update_default_input (manager );
851
+ }
852
+
794
853
static void
795
854
on_context_stream_removed (MateMixerContext * context ,
796
855
const gchar * name ,
@@ -805,6 +864,15 @@ on_context_stream_removed (MateMixerContext *context,
805
864
g_clear_object (& manager -> priv -> control );
806
865
}
807
866
}
867
+ if (manager -> priv -> source_stream != NULL ) {
868
+ MateMixerStream * stream =
869
+ mate_mixer_context_get_stream (manager -> priv -> context , name );
870
+
871
+ if (stream == manager -> priv -> source_stream ) {
872
+ g_clear_object (& manager -> priv -> source_stream );
873
+ g_clear_object (& manager -> priv -> source_control );
874
+ }
875
+ }
808
876
}
809
877
#endif /* HAVE_LIBMATEMIXER */
810
878
@@ -1102,6 +1170,7 @@ do_action (MsdMediaKeysManager *manager,
1102
1170
case MUTE_KEY :
1103
1171
case VOLUME_DOWN_KEY :
1104
1172
case VOLUME_UP_KEY :
1173
+ case MIC_MUTE_KEY :
1105
1174
#ifdef HAVE_LIBMATEMIXER
1106
1175
do_sound_action (manager , type , FALSE);
1107
1176
#endif
@@ -1398,6 +1467,10 @@ msd_media_keys_manager_start (MsdMediaKeysManager *manager, GError **error)
1398
1467
"notify::default-output-stream" ,
1399
1468
G_CALLBACK (on_context_default_output_notify ),
1400
1469
manager );
1470
+ g_signal_connect (manager -> priv -> context ,
1471
+ "notify::default-input-stream" ,
1472
+ G_CALLBACK (on_context_default_input_notify ),
1473
+ manager );
1401
1474
g_signal_connect (manager -> priv -> context ,
1402
1475
"stream-removed" ,
1403
1476
G_CALLBACK (on_context_stream_removed ),
@@ -1483,7 +1556,9 @@ msd_media_keys_manager_stop (MsdMediaKeysManager *manager)
1483
1556
1484
1557
#ifdef HAVE_LIBMATEMIXER
1485
1558
g_clear_object (& priv -> stream );
1559
+ g_clear_object (& priv -> source_stream );
1486
1560
g_clear_object (& priv -> control );
1561
+ g_clear_object (& priv -> source_control );
1487
1562
g_clear_object (& priv -> context );
1488
1563
#endif
1489
1564
0 commit comments