Exemplo n.º 1
0
 def stop_vu(self):
     pa_threaded_mainloop_lock(self.pa_mgr.mainloop)
     for _, sink in self.pa_mgr.pa_sinks.items():
         sink.stop_monitor_stream()
     for _, sink_input in self.pa_mgr.pa_sink_inputs.items():
         sink_input.stop_monitor_stream()
     pa_threaded_mainloop_unlock(self.pa_mgr.mainloop)
Exemplo n.º 2
0
 def start_vu(self):
     if self.settings.get_boolean("vu-enabled"):
         pa_threaded_mainloop_lock(self.pa_mgr.mainloop)
         for _, sink in self.pa_mgr.pa_sinks.items():
             sink.monitor_stream()
         for _, sink_input in self.pa_mgr.pa_sink_inputs.items():
             sink_input.monitor_stream()
         pa_threaded_mainloop_unlock(self.pa_mgr.mainloop)
Exemplo n.º 3
0
    def create_sliders(self):
        """(Re-)create sliders from PulseAudio sinks."""
        if self._grid is not None:
            self._grid.destroy()
        if self._sink_scales is not None:
            del self._sink_scales
        if self._sink_input_scales is not None:
            del self._sink_input_scales
        self._sink_scales = {}
        self._sink_input_scales = {}

        self._grid = Gtk.Grid()
        self._grid.set_column_spacing(2)
        self._grid.set_row_spacing(self.SPACING)
        self._frame.add(self._grid)

        pos = 0

        # touching pa objects here!
        pa_threaded_mainloop_lock(self._volctl.pa_mgr.mainloop)

        # sinks
        for _, sink in self._volctl.pa_mgr.pa_sinks.items():
            scale, btn = self._add_scale(sink)
            self._sink_scales[sink.idx] = (scale, btn)
            scale.connect("value-changed", self._cb_sink_scale_change)
            self._update_scale_values((scale, btn), sink.volume, sink.mute)
            scale.set_margin_top(self.SPACING)
            btn.set_margin_bottom(self.SPACING)
            self._grid.attach(scale, pos, 0, 1, 1)
            self._grid.attach(btn, pos, 1, 1, 1)
            pos += 1

        # separator
        if self._volctl.pa_mgr.pa_sink_inputs:
            separator = Gtk.Separator().new(Gtk.Orientation.VERTICAL)
            separator.set_margin_top(self.SPACING)
            separator.set_margin_bottom(self.SPACING)
            self._grid.attach(separator, pos, 0, 1, 2)
            pos += 1

        # sink inputs
        for _, sink_input in self._volctl.pa_mgr.pa_sink_inputs.items():
            scale, btn = self._add_scale(sink_input)
            self._sink_input_scales[sink_input.idx] = (scale, btn)
            scale.connect("value-changed", self._cb_sink_input_scale_change)
            self._update_scale_values((scale, btn), sink_input.volume, sink_input.mute)
            scale.set_margin_top(self.SPACING)
            btn.set_margin_bottom(self.SPACING)
            self._grid.attach(scale, pos, 0, 1, 1)
            self._grid.attach(btn, pos, 1, 1, 1)
            pos += 1

        pa_threaded_mainloop_unlock(self._volctl.pa_mgr.mainloop)

        self.show_all()
        self.resize(1, 1)  # smallest possible
        GObject.idle_add(self._set_position)
Exemplo n.º 4
0
    def _cb_sink_input_scale_change(self, scale):
        value = int(scale.get_value())
        idx = self._find_sink_input_idx_by_scale(scale)

        if idx >= 0:
            pa_threaded_mainloop_lock(self._volctl.pa_mgr.mainloop)
            sink_input = self._volctl.pa_mgr.pa_sink_inputs[idx]
            sink_input.set_volume(value)
            pa_threaded_mainloop_unlock(self._volctl.pa_mgr.mainloop)
Exemplo n.º 5
0
    def _cb_scroll(self, widget, event):
        old_vol = self._volume
        amount = PA_VOLUME_NORM / self._volctl.mouse_wheel_step
        if event.direction == Gdk.ScrollDirection.DOWN:
            amount *= -1
        elif event.direction == Gdk.ScrollDirection.UP:
            pass
        else:
            return
        new_value = old_vol + amount
        new_value = min(PA_VOLUME_NORM, new_value)
        new_value = max(PA_VOLUME_MUTED, new_value)
        new_value = int(new_value)

        # user action prolongs auto-close timer
        if self._volctl.sliders_win is not None:
            self._volctl.sliders_win.reset_timeout()

        pa_threaded_mainloop_lock(self._volctl.pa_mgr.mainloop)
        self._volctl.pa_mgr.set_main_volume(new_value)
        pa_threaded_mainloop_unlock(self._volctl.pa_mgr.mainloop)
Exemplo n.º 6
0
 def _cb_menu_mute(self, widget):
     pa_threaded_mainloop_lock(self._volctl.pa_mgr.mainloop)
     self._volctl.pa_mgr.toggle_main_mute()
     pa_threaded_mainloop_unlock(self._volctl.pa_mgr.mainloop)
Exemplo n.º 7
0
 def _cb_mute_toggle(self, button, sink):
     mute = button.get_property("active")
     pa_threaded_mainloop_lock(self._volctl.pa_mgr.mainloop)
     sink.set_mute(mute)
     pa_threaded_mainloop_unlock(self._volctl.pa_mgr.mainloop)