fix event sound generation for volume changes
This commit is contained in:
parent
5143fa8dae
commit
8a11d0f781
|
@ -39,7 +39,7 @@ AC_PROG_LN_S
|
||||||
AC_TYPE_SIGNAL
|
AC_TYPE_SIGNAL
|
||||||
AC_HEADER_STDC
|
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_CFLAGS)
|
||||||
AC_SUBST(GUILIBS_LIBS)
|
AC_SUBST(GUILIBS_LIBS)
|
||||||
|
|
||||||
|
|
|
@ -88,23 +88,6 @@ void ChannelWidget::onVolumeScaleValueChanged() {
|
||||||
|
|
||||||
pa_volume_t volume = (pa_volume_t) ((volumeScale->get_value() * PA_VOLUME_NORM) / 100);
|
pa_volume_t volume = (pa_volume_t) ((volumeScale->get_value() * PA_VOLUME_NORM) / 100);
|
||||||
minimalStreamWidget->updateChannelVolume(channel, volume);
|
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) {
|
void ChannelWidget::set_sensitive(bool enabled) {
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
|
|
||||||
#include "pavucontrol.h"
|
#include "pavucontrol.h"
|
||||||
|
|
||||||
#include <canberra-gtk.h>
|
|
||||||
|
|
||||||
class MinimalStreamWidget;
|
class MinimalStreamWidget;
|
||||||
|
|
||||||
class ChannelWidget : public Gtk::EventBox {
|
class ChannelWidget : public Gtk::EventBox {
|
||||||
|
@ -46,8 +44,6 @@ public:
|
||||||
bool can_decibel;
|
bool can_decibel;
|
||||||
bool volumeScaleEnabled;
|
bool volumeScaleEnabled;
|
||||||
|
|
||||||
Glib::ustring beepDevice;
|
|
||||||
|
|
||||||
virtual void set_sensitive(bool enabled);
|
virtual void set_sensitive(bool enabled);
|
||||||
virtual void setBaseVolume(pa_volume_t);
|
virtual void setBaseVolume(pa_volume_t);
|
||||||
virtual void setSteps(unsigned n);
|
virtual void setSteps(unsigned n);
|
||||||
|
|
|
@ -42,7 +42,7 @@ DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Gl
|
||||||
portList->set_model(treeModel);
|
portList->set_model(treeModel);
|
||||||
portList->pack_start(portModel.desc);
|
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++)
|
for (unsigned i = 0; i < PA_CHANNELS_MAX; i++)
|
||||||
channelWidgets[i] = NULL;
|
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++) {
|
for (int i = 0; i < m.channels; i++) {
|
||||||
ChannelWidget *cw = channelWidgets[i] = ChannelWidget::create();
|
ChannelWidget *cw = channelWidgets[i] = ChannelWidget::create();
|
||||||
cw->beepDevice = beepDevice;
|
|
||||||
cw->channel = i;
|
cw->channel = i;
|
||||||
cw->can_decibel = can_decibel;
|
cw->can_decibel = can_decibel;
|
||||||
cw->minimalStreamWidget = this;
|
cw->minimalStreamWidget = this;
|
||||||
|
@ -82,10 +81,9 @@ void DeviceWidget::updateChannelVolume(int channel, pa_volume_t v) {
|
||||||
g_assert(channel < volume.channels);
|
g_assert(channel < volume.channels);
|
||||||
|
|
||||||
n = volume;
|
n = volume;
|
||||||
if (lockToggleButton->get_active()) {
|
if (lockToggleButton->get_active())
|
||||||
for (int i = 0; i < n.channels; i++)
|
pa_cvolume_set(&n, n.channels, v);
|
||||||
n.values[i] = v;
|
else
|
||||||
} else
|
|
||||||
n.values[channel] = v;
|
n.values[channel] = v;
|
||||||
|
|
||||||
setVolume(n, true);
|
setVolume(n, true);
|
||||||
|
@ -131,25 +129,25 @@ void DeviceWidget::setSteps(unsigned n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceWidget::prepareMenu() {
|
void DeviceWidget::prepareMenu() {
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int active_idx = -1;
|
int active_idx = -1;
|
||||||
|
|
||||||
treeModel->clear();
|
treeModel->clear();
|
||||||
/* Fill the ComboBox's Tree Model */
|
/* Fill the ComboBox's Tree Model */
|
||||||
for (uint32_t i = 0; i < ports.size(); ++i) {
|
for (uint32_t i = 0; i < ports.size(); ++i) {
|
||||||
Gtk::TreeModel::Row row = *(treeModel->append());
|
Gtk::TreeModel::Row row = *(treeModel->append());
|
||||||
row[portModel.name] = ports[i].first;
|
row[portModel.name] = ports[i].first;
|
||||||
row[portModel.desc] = ports[i].second;
|
row[portModel.desc] = ports[i].second;
|
||||||
if (ports[i].first == activePort)
|
if (ports[i].first == activePort)
|
||||||
active_idx = idx;
|
active_idx = idx;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active_idx >= 0)
|
if (active_idx >= 0)
|
||||||
portList->set_active(active_idx);
|
portList->set_active(active_idx);
|
||||||
|
|
||||||
if (ports.size() > 0)
|
if (ports.size() > 0)
|
||||||
portSelect->show();
|
portSelect->show();
|
||||||
else
|
else
|
||||||
portSelect->hide();
|
portSelect->hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,6 @@ public:
|
||||||
bool volumeMeterEnabled;
|
bool volumeMeterEnabled;
|
||||||
void enableVolumeMeter();
|
void enableVolumeMeter();
|
||||||
void updatePeak(double v);
|
void updatePeak(double v);
|
||||||
|
|
||||||
Glib::ustring beepDevice;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,11 +22,13 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "pavucontrol.h"
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
#include <pulse/glib-mainloop.h>
|
#include <pulse/glib-mainloop.h>
|
||||||
#include <pulse/ext-stream-restore.h>
|
#include <pulse/ext-stream-restore.h>
|
||||||
|
|
||||||
|
#include <canberra-gtk.h>
|
||||||
|
|
||||||
|
#include "pavucontrol.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "minimalstreamwidget.h"
|
#include "minimalstreamwidget.h"
|
||||||
#include "channelwidget.h"
|
#include "channelwidget.h"
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <canberra-gtk.h>
|
||||||
|
|
||||||
#include "sinkwidget.h"
|
#include "sinkwidget.h"
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
@ -39,6 +41,8 @@ SinkWidget* SinkWidget::create() {
|
||||||
|
|
||||||
void SinkWidget::executeVolumeUpdate() {
|
void SinkWidget::executeVolumeUpdate() {
|
||||||
pa_operation* o;
|
pa_operation* o;
|
||||||
|
char dev[64];
|
||||||
|
int playing = 0;
|
||||||
|
|
||||||
if (!(o = pa_context_set_sink_volume_by_index(get_context(), index, &volume, NULL, NULL))) {
|
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"));
|
show_error(_("pa_context_set_sink_volume_by_index() failed"));
|
||||||
|
@ -46,6 +50,23 @@ void SinkWidget::executeVolumeUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_operation_unref(o);
|
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() {
|
void SinkWidget::onMuteToggleButton() {
|
||||||
|
@ -77,26 +98,24 @@ void SinkWidget::onDefaultToggleButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SinkWidget::onPortChange() {
|
void SinkWidget::onPortChange() {
|
||||||
Gtk::TreeModel::iterator iter;
|
Gtk::TreeModel::iterator iter;
|
||||||
|
|
||||||
if (updating)
|
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"));
|
|
||||||
return;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,6 @@ void StreamWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {
|
||||||
|
|
||||||
for (int i = 0; i < m.channels; i++) {
|
for (int i = 0; i < m.channels; i++) {
|
||||||
ChannelWidget *cw = channelWidgets[i] = ChannelWidget::create();
|
ChannelWidget *cw = channelWidgets[i] = ChannelWidget::create();
|
||||||
cw->beepDevice = beepDevice;
|
|
||||||
cw->channel = i;
|
cw->channel = i;
|
||||||
cw->can_decibel = can_decibel;
|
cw->can_decibel = can_decibel;
|
||||||
cw->minimalStreamWidget = this;
|
cw->minimalStreamWidget = this;
|
||||||
|
|
|
@ -62,7 +62,6 @@ protected:
|
||||||
|
|
||||||
Gtk::Menu contextMenu;
|
Gtk::Menu contextMenu;
|
||||||
Gtk::MenuItem terminate;
|
Gtk::MenuItem terminate;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue