summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2011-05-06 10:55:17 +0100
committerColin Guthrie <colin@mageia.org>2011-07-22 09:35:38 +0100
commit9784b9d76d76751ab00aa47d0c167a024b28d0ac (patch)
treebf8bb17153ff3ce256a48a7e94bd9bf604212626
parent50efee1180a785f297ce6dc38b349ee7e28c8129 (diff)
stream-volumes: Support source-output volume controls now available in PA.
-rw-r--r--src/mainwindow.cc6
-rw-r--r--src/pavucontrol.h2
-rw-r--r--src/sinkinputwidget.h2
-rw-r--r--src/sinkwidget.cc6
-rw-r--r--src/sourceoutputwidget.cc32
-rw-r--r--src/sourceoutputwidget.h4
6 files changed, 47 insertions, 5 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index ac41831..1ae0fb0 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -606,6 +606,7 @@ void MainWindow::updateSourceOutput(const pa_source_output_info &info) {
w = sourceOutputWidgets[info.index];
else {
sourceOutputWidgets[info.index] = w = SourceOutputWidget::create(this);
+ w->setChannelMap(info.channel_map, true);
recsVBox->pack_start(*w, false, false, 0);
w->index = info.index;
w->clientIndex = info.client;
@@ -631,6 +632,11 @@ void MainWindow::updateSourceOutput(const pa_source_output_info &info) {
setIconFromProplist(w->iconImage, info.proplist, "audio-input-microphone");
+#if HAVE_SOURCE_OUTPUT_VOLUMES
+ w->setVolume(info.volume);
+ w->muteToggleButton->set_active(info.mute);
+#endif
+
w->updating = false;
if (is_new)
diff --git a/src/pavucontrol.h b/src/pavucontrol.h
index 1ef2519..922f567 100644
--- a/src/pavucontrol.h
+++ b/src/pavucontrol.h
@@ -39,6 +39,8 @@
# define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0))
#endif
+#define HAVE_SOURCE_OUTPUT_VOLUMES PA_CHECK_VERSION(1,0,0)
+
enum SinkInputType {
SINK_INPUT_ALL,
SINK_INPUT_CLIENT,
diff --git a/src/sinkinputwidget.h b/src/sinkinputwidget.h
index de3ecb8..368dde0 100644
--- a/src/sinkinputwidget.h
+++ b/src/sinkinputwidget.h
@@ -39,8 +39,8 @@ public:
void setSinkIndex(uint32_t idx);
uint32_t sinkIndex();
virtual void executeVolumeUpdate();
- virtual void onDeviceChangePopup();
virtual void onMuteToggleButton();
+ virtual void onDeviceChangePopup();
virtual void onKill();
private:
diff --git a/src/sinkwidget.cc b/src/sinkwidget.cc
index c797e68..02643ac 100644
--- a/src/sinkwidget.cc
+++ b/src/sinkwidget.cc
@@ -52,9 +52,9 @@ void SinkWidget::executeVolumeUpdate() {
pa_operation_unref(o);
- ca_context_playing(ca_gtk_context_get(), 2, &playing);
- if (playing)
- return;
+ //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);
diff --git a/src/sourceoutputwidget.cc b/src/sourceoutputwidget.cc
index ce1cbb6..827c5a8 100644
--- a/src/sourceoutputwidget.cc
+++ b/src/sourceoutputwidget.cc
@@ -37,9 +37,11 @@ SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefP
terminate.set_label(_("Terminate Recording"));
- /* Source Outputs do not have volume controls */
+#if !HAVE_SOURCE_OUTPUT_VOLUMES
+ /* Source Outputs do not have volume controls in versions of PA < 1.0 */
muteToggleButton->hide();
lockToggleButton->hide();
+#endif
}
SourceOutputWidget* SourceOutputWidget::create(MainWindow* mainWindow) {
@@ -69,6 +71,34 @@ uint32_t SourceOutputWidget::sourceIndex() {
return mSourceIndex;
}
+#if HAVE_SOURCE_OUTPUT_VOLUMES
+void SourceOutputWidget::executeVolumeUpdate() {
+ pa_operation* o;
+
+ if (!(o = pa_context_set_source_output_volume(get_context(), index, &volume, NULL, NULL))) {
+ show_error(_("pa_context_set_source_output_volume() failed"));
+ return;
+ }
+
+ pa_operation_unref(o);
+}
+
+void SourceOutputWidget::onMuteToggleButton() {
+ StreamWidget::onMuteToggleButton();
+
+ if (updating)
+ return;
+
+ pa_operation* o;
+ if (!(o = pa_context_set_source_output_mute(get_context(), index, muteToggleButton->get_active(), NULL, NULL))) {
+ show_error(_("pa_context_set_source_output_mute() failed"));
+ return;
+ }
+
+ pa_operation_unref(o);
+}
+#endif
+
void SourceOutputWidget::onKill() {
pa_operation* o;
if (!(o = pa_context_kill_source_output(get_context(), index, NULL, NULL))) {
diff --git a/src/sourceoutputwidget.h b/src/sourceoutputwidget.h
index e9b0dce..1b9ab0f 100644
--- a/src/sourceoutputwidget.h
+++ b/src/sourceoutputwidget.h
@@ -38,6 +38,10 @@ public:
uint32_t index, clientIndex;
void setSourceIndex(uint32_t idx);
uint32_t sourceIndex();
+#if HAVE_SOURCE_OUTPUT_VOLUMES
+ virtual void executeVolumeUpdate();
+ virtual void onMuteToggleButton();
+#endif
virtual void onDeviceChangePopup();
virtual void onKill();