diff options
| author | Lennart Poettering <lennart@poettering.net> | 2009-08-27 05:41:11 +0200 | 
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2009-08-27 05:41:11 +0200 | 
| commit | 8a11d0f781c283c26942f7cb02fa733df79ff731 (patch) | |
| tree | fada35a35044d3612d8a58c0a5c6c0593806066c | |
| parent | 5143fa8dae53448f9b777b848f1026515d1ce247 (diff) | |
fix event sound generation for volume changes
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | src/channelwidget.cc | 17 | ||||
| -rw-r--r-- | src/channelwidget.h | 4 | ||||
| -rw-r--r-- | src/devicewidget.cc | 52 | ||||
| -rw-r--r-- | src/minimalstreamwidget.h | 2 | ||||
| -rw-r--r-- | src/pavucontrol.cc | 6 | ||||
| -rw-r--r-- | src/sinkwidget.cc | 57 | ||||
| -rw-r--r-- | src/streamwidget.cc | 1 | ||||
| -rw-r--r-- | src/streamwidget.h | 1 | 
9 files changed, 68 insertions, 74 deletions
diff --git a/configure.ac b/configure.ac index baba768..02fdfba 100644 --- a/configure.ac +++ b/configure.ac @@ -39,7 +39,7 @@ AC_PROG_LN_S  AC_TYPE_SIGNAL  AC_HEADER_STDC -PKG_CHECK_MODULES(GUILIBS, [ gtkmm-2.4 libglademm-2.4 sigc++-2.0 libcanberra-gtk >= 0.11 ]) +PKG_CHECK_MODULES(GUILIBS, [ gtkmm-2.4 libglademm-2.4 sigc++-2.0 libcanberra-gtk >= 0.16 ])  AC_SUBST(GUILIBS_CFLAGS)  AC_SUBST(GUILIBS_LIBS) diff --git a/src/channelwidget.cc b/src/channelwidget.cc index 40aa298..9fd62d8 100644 --- a/src/channelwidget.cc +++ b/src/channelwidget.cc @@ -88,23 +88,6 @@ void ChannelWidget::onVolumeScaleValueChanged() {      pa_volume_t volume = (pa_volume_t) ((volumeScale->get_value() * PA_VOLUME_NORM) / 100);      minimalStreamWidget->updateChannelVolume(channel, volume); - -    if (beepDevice != "") { -        ca_context_change_device(ca_gtk_context_get(), beepDevice.c_str()); - -        ca_context_cancel(ca_gtk_context_get(), 2); - -        ca_gtk_play_for_widget(GTK_WIDGET(volumeScale->gobj()), -                               2, -                               CA_PROP_EVENT_DESCRIPTION, _("Volume Control Feedback Sound"), -                               CA_PROP_EVENT_ID, "audio-volume-change", -                               CA_PROP_CANBERRA_CACHE_CONTROL, "permanent", -                               CA_PROP_CANBERRA_VOLUME, "0", -                               CA_PROP_CANBERRA_ENABLE, "1", -                               NULL); - -        ca_context_change_device(ca_gtk_context_get(), NULL); -    }  }  void ChannelWidget::set_sensitive(bool enabled) { diff --git a/src/channelwidget.h b/src/channelwidget.h index af823dc..b15fe84 100644 --- a/src/channelwidget.h +++ b/src/channelwidget.h @@ -23,8 +23,6 @@  #include "pavucontrol.h" -#include <canberra-gtk.h> -  class MinimalStreamWidget;  class ChannelWidget : public Gtk::EventBox { @@ -46,8 +44,6 @@ public:      bool can_decibel;      bool volumeScaleEnabled; -    Glib::ustring beepDevice; -      virtual void set_sensitive(bool enabled);      virtual void setBaseVolume(pa_volume_t);      virtual void setSteps(unsigned n); diff --git a/src/devicewidget.cc b/src/devicewidget.cc index 2b30b83..e249944 100644 --- a/src/devicewidget.cc +++ b/src/devicewidget.cc @@ -42,7 +42,7 @@ DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Gl      portList->set_model(treeModel);      portList->pack_start(portModel.desc); -    portList->signal_changed().connect( sigc::mem_fun(*this, &DeviceWidget::onPortChange)); +    portList->signal_changed().connect(sigc::mem_fun(*this, &DeviceWidget::onPortChange));      for (unsigned i = 0; i < PA_CHANNELS_MAX; i++)          channelWidgets[i] = NULL; @@ -53,7 +53,6 @@ void DeviceWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {      for (int i = 0; i < m.channels; i++) {          ChannelWidget *cw = channelWidgets[i] = ChannelWidget::create(); -        cw->beepDevice = beepDevice;          cw->channel = i;          cw->can_decibel = can_decibel;          cw->minimalStreamWidget = this; @@ -82,10 +81,9 @@ void DeviceWidget::updateChannelVolume(int channel, pa_volume_t v) {      g_assert(channel < volume.channels);      n = volume; -    if (lockToggleButton->get_active()) { -        for (int i = 0; i < n.channels; i++) -            n.values[i] = v; -    } else +    if (lockToggleButton->get_active()) +        pa_cvolume_set(&n, n.channels, v); +    else          n.values[channel] = v;      setVolume(n, true); @@ -131,25 +129,25 @@ void DeviceWidget::setSteps(unsigned n) {  }  void DeviceWidget::prepareMenu() { -  int idx = 0; -  int active_idx = -1; - -  treeModel->clear(); -  /* Fill the ComboBox's Tree Model */ -  for (uint32_t i = 0; i < ports.size(); ++i) { -    Gtk::TreeModel::Row row = *(treeModel->append()); -    row[portModel.name] = ports[i].first; -    row[portModel.desc] = ports[i].second; -    if (ports[i].first == activePort) -      active_idx = idx; -    idx++; -  } - -  if (active_idx >= 0) -    portList->set_active(active_idx); - -  if (ports.size() > 0) -    portSelect->show(); -  else -    portSelect->hide(); +    int idx = 0; +    int active_idx = -1; + +    treeModel->clear(); +    /* Fill the ComboBox's Tree Model */ +    for (uint32_t i = 0; i < ports.size(); ++i) { +        Gtk::TreeModel::Row row = *(treeModel->append()); +        row[portModel.name] = ports[i].first; +        row[portModel.desc] = ports[i].second; +        if (ports[i].first == activePort) +            active_idx = idx; +        idx++; +    } + +    if (active_idx >= 0) +        portList->set_active(active_idx); + +    if (ports.size() > 0) +        portSelect->show(); +    else +        portSelect->hide();  } diff --git a/src/minimalstreamwidget.h b/src/minimalstreamwidget.h index 55cf6f3..ba7eb1d 100644 --- a/src/minimalstreamwidget.h +++ b/src/minimalstreamwidget.h @@ -41,8 +41,6 @@ public:      bool volumeMeterEnabled;      void enableVolumeMeter();      void updatePeak(double v); - -    Glib::ustring beepDevice;  };  #endif diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc index fc17437..1e85184 100644 --- a/src/pavucontrol.cc +++ b/src/pavucontrol.cc @@ -22,11 +22,13 @@  #include <config.h>  #endif -#include "pavucontrol.h" - +#include <pulse/pulseaudio.h>  #include <pulse/glib-mainloop.h>  #include <pulse/ext-stream-restore.h> +#include <canberra-gtk.h> + +#include "pavucontrol.h"  #include "i18n.h"  #include "minimalstreamwidget.h"  #include "channelwidget.h" diff --git a/src/sinkwidget.cc b/src/sinkwidget.cc index 7a7aad9..0c39cae 100644 --- a/src/sinkwidget.cc +++ b/src/sinkwidget.cc @@ -22,6 +22,8 @@  #include <config.h>  #endif +#include <canberra-gtk.h> +  #include "sinkwidget.h"  #include "i18n.h" @@ -39,6 +41,8 @@ SinkWidget* SinkWidget::create() {  void SinkWidget::executeVolumeUpdate() {      pa_operation* o; +    char dev[64]; +    int playing = 0;      if (!(o = pa_context_set_sink_volume_by_index(get_context(), index, &volume, NULL, NULL))) {          show_error(_("pa_context_set_sink_volume_by_index() failed")); @@ -46,6 +50,23 @@ void SinkWidget::executeVolumeUpdate() {      }      pa_operation_unref(o); + +    ca_context_playing(ca_gtk_context_get(), 2, &playing); +    if (playing) +        return; + +    snprintf(dev, sizeof(dev), "%lu", (unsigned long) index); +    ca_context_change_device(ca_gtk_context_get(), dev); + +    ca_gtk_play_for_widget(GTK_WIDGET(gobj()), +                           2, +                           CA_PROP_EVENT_DESCRIPTION, _("Volume Control Feedback Sound"), +                           CA_PROP_EVENT_ID, "audio-volume-change", +                           CA_PROP_CANBERRA_CACHE_CONTROL, "permanent", +                           CA_PROP_CANBERRA_ENABLE, "1", +                           NULL); + +    ca_context_change_device(ca_gtk_context_get(), NULL);  }  void SinkWidget::onMuteToggleButton() { @@ -77,26 +98,24 @@ void SinkWidget::onDefaultToggleButton() {  }  void SinkWidget::onPortChange() { -  Gtk::TreeModel::iterator iter; - -  if (updating) -    return; - -  iter = portList->get_active(); -  if (iter) -  { -    Gtk::TreeModel::Row row = *iter; -    if (row) -    { -      pa_operation* o; -      Glib::ustring port = row[portModel.name]; - -      if (!(o = pa_context_set_sink_port_by_index(get_context(), index, port.c_str(), NULL, NULL))) { -        show_error(_("pa_context_set_sink_port_by_index() failed")); +    Gtk::TreeModel::iterator iter; + +    if (updating)          return; -      } -      pa_operation_unref(o); +    iter = portList->get_active(); +    if (iter) { +        Gtk::TreeModel::Row row = *iter; +        if (row) { +            pa_operation* o; +            Glib::ustring port = row[portModel.name]; + +            if (!(o = pa_context_set_sink_port_by_index(get_context(), index, port.c_str(), NULL, NULL))) { +                show_error(_("pa_context_set_sink_port_by_index() failed")); +                return; +            } + +            pa_operation_unref(o); +        }      } -  }  } diff --git a/src/streamwidget.cc b/src/streamwidget.cc index 8817515..2ab5c12 100644 --- a/src/streamwidget.cc +++ b/src/streamwidget.cc @@ -69,7 +69,6 @@ void StreamWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {      for (int i = 0; i < m.channels; i++) {          ChannelWidget *cw = channelWidgets[i] = ChannelWidget::create(); -        cw->beepDevice = beepDevice;          cw->channel = i;          cw->can_decibel = can_decibel;          cw->minimalStreamWidget = this; diff --git a/src/streamwidget.h b/src/streamwidget.h index e322fc3..215e332 100644 --- a/src/streamwidget.h +++ b/src/streamwidget.h @@ -62,7 +62,6 @@ protected:      Gtk::Menu contextMenu;      Gtk::MenuItem terminate; -  };  #endif  | 
