summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-08-27 05:41:11 +0200
committerLennart Poettering <lennart@poettering.net>2009-08-27 05:41:11 +0200
commit8a11d0f781c283c26942f7cb02fa733df79ff731 (patch)
treefada35a35044d3612d8a58c0a5c6c0593806066c /src
parent5143fa8dae53448f9b777b848f1026515d1ce247 (diff)
fix event sound generation for volume changes
Diffstat (limited to 'src')
-rw-r--r--src/channelwidget.cc17
-rw-r--r--src/channelwidget.h4
-rw-r--r--src/devicewidget.cc52
-rw-r--r--src/minimalstreamwidget.h2
-rw-r--r--src/pavucontrol.cc6
-rw-r--r--src/sinkwidget.cc57
-rw-r--r--src/streamwidget.cc1
-rw-r--r--src/streamwidget.h1
8 files changed, 67 insertions, 73 deletions
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