[pulseaudio-commits] [SCM] PulseAudio Volume Control branch, master, updated. v0.9.10-24-gc70b048

Colin Guthrie gitmailer-noreply at 0pointer.de
Wed Mar 9 13:55:22 PST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Volume Control" repository.

The master branch has been updated
      from  9516b6f1dc3e97587221c46086b1b57c3af67ea3 (commit)

- Log -----------------------------------------------------------------
c70b048 volume: Don't bother setting the steps.
297af52 volume: Support volumes up to 11.
-----------------------------------------------------------------------

Summary of changes:
 src/channelwidget.cc  |   56 ++++++++++++++++++++++--------------------------
 src/channelwidget.h   |    2 +-
 src/devicewidget.cc   |    7 +-----
 src/devicewidget.h    |    1 -
 src/mainwindow.cc     |    2 -
 src/pavucontrol.glade |    7 +++++-
 src/pavucontrol.h     |    5 ++++
 src/streamwidget.cc   |    2 +
 8 files changed, 41 insertions(+), 41 deletions(-)

-----------------------------------------------------------------------

commit 297af52ae5581f5373bb008f60c7aac858bb365a
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Wed Mar 9 21:50:29 2011 +0000

    volume: Support volumes up to 11.
    
    This allows us to set volumes up to ~153% aka +11dB.
    
    Also show the current dB value in the UI - as pavucontrol is a bit more
    developer-friendly than other volume UIs displaying this by default makes
    sense.

diff --git a/src/channelwidget.cc b/src/channelwidget.cc
index 21f3afa..2fb06a4 100644
--- a/src/channelwidget.cc
+++ b/src/channelwidget.cc
@@ -27,20 +27,22 @@
 
 #include "i18n.h"
 
-static bool show_decibel = true;
-
 /*** ChannelWidget ***/
 
 ChannelWidget::ChannelWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x) :
     Gtk::EventBox(cobject),
-    volumeScaleEnabled(true) {
+    can_decibel(false),
+    volumeScaleEnabled(true),
+    last(false) {
 
     x->get_widget("channelLabel", channelLabel);
     x->get_widget("volumeLabel", volumeLabel);
     x->get_widget("volumeScale", volumeScale);
 
-    volumeScale->set_value(100.0);
-    volumeScale->set_increments(1.0, 5.0);
+    volumeScale->set_range((double)PA_VOLUME_MUTED, (double)PA_VOLUME_UI_MAX);
+    volumeScale->set_value((double)PA_VOLUME_NORM);
+    volumeScale->set_increments(((double)PA_VOLUME_NORM)/100.0, ((double)PA_VOLUME_NORM)/20.0);
+    setBaseVolume(PA_VOLUME_NORM);
 
     volumeScale->signal_value_changed().connect(sigc::mem_fun(*this, &ChannelWidget::onVolumeScaleValueChanged));
 }
@@ -59,24 +61,19 @@ void ChannelWidget::setVolume(pa_volume_t volume) {
     char txt[64];
 
     v = ((gdouble) volume * 100) / PA_VOLUME_NORM;
-
-    if (can_decibel && show_decibel) {
+    if (can_decibel) {
         double dB = pa_sw_volume_to_dB(volume);
-
-        if (dB > PA_DECIBEL_MININFTY) {
-            snprintf(txt, sizeof(txt), "%0.2f dB", dB);
-            volumeLabel->set_tooltip_text(txt);
-        } else
-            volumeLabel->set_tooltip_markup("-&#8734;dB");
-        volumeLabel->set_has_tooltip(TRUE);
-    } else
-        volumeLabel->set_has_tooltip(FALSE);
-
-    snprintf(txt, sizeof(txt), "%0.0f%%", v);
-    volumeLabel->set_text(txt);
+        if (dB > PA_DECIBEL_MININFTY)
+            snprintf(txt, sizeof(txt), "<small>%0.0f%% (%0.2fdB)</small>", v, dB);
+        else
+            snprintf(txt, sizeof(txt), "<small>%0.0f%% (-&#8734;dB)</small>", v);
+    }
+    else
+        snprintf(txt, sizeof(txt), "%0.0f%%", v);
+    volumeLabel->set_markup(txt);
 
     volumeScaleEnabled = false;
-    volumeScale->set_value(v > 100 ? 100 : v);
+    volumeScale->set_value(volume > PA_VOLUME_UI_MAX ? PA_VOLUME_UI_MAX : volume);
     volumeScaleEnabled = true;
 }
 
@@ -88,7 +85,7 @@ void ChannelWidget::onVolumeScaleValueChanged() {
     if (minimalStreamWidget->updating)
         return;
 
-    pa_volume_t volume = (pa_volume_t) ((volumeScale->get_value() * PA_VOLUME_NORM) / 100);
+    pa_volume_t volume = (pa_volume_t) volumeScale->get_value();
     minimalStreamWidget->updateChannelVolume(channel, volume);
 }
 
@@ -102,17 +99,20 @@ void ChannelWidget::set_sensitive(bool enabled) {
 
 void ChannelWidget::setBaseVolume(pa_volume_t v) {
 
-    gtk_scale_add_mark(GTK_SCALE(volumeScale->gobj()), 0.0, (GtkPositionType) GTK_POS_BOTTOM,
-                       can_decibel ? _("<small>Silence</small>") : _("<small>Min</small>"));
-    gtk_scale_add_mark(GTK_SCALE(volumeScale->gobj()), 100.0, (GtkPositionType) GTK_POS_BOTTOM, _("<small>Max</small>"));
+    gtk_scale_clear_marks(GTK_SCALE(volumeScale->gobj()));
+
+    gtk_scale_add_mark(GTK_SCALE(volumeScale->gobj()), (double)PA_VOLUME_MUTED, (GtkPositionType) GTK_POS_BOTTOM,
+                       last ? (can_decibel ? _("<small>Silence</small>") : _("<small>Min</small>")) : NULL);
+    gtk_scale_add_mark(GTK_SCALE(volumeScale->gobj()), (double)PA_VOLUME_NORM, (GtkPositionType) GTK_POS_BOTTOM,
+                       last ? _("<small>100% (0dB)</small>") : NULL);
 
     if (v > PA_VOLUME_MUTED && v < PA_VOLUME_NORM) {
-        double p = ((double) v * 100) / PA_VOLUME_NORM;
-        gtk_scale_add_mark(GTK_SCALE(volumeScale->gobj()), p, (GtkPositionType) GTK_POS_BOTTOM, _("<small><i>Base</i></small>"));
+        gtk_scale_add_mark(GTK_SCALE(volumeScale->gobj()), (double)v, (GtkPositionType) GTK_POS_BOTTOM,
+                           last ? _("<small><i>Base</i></small>") : NULL);
     }
 
 }
 
 void ChannelWidget::setSteps(unsigned n) {
-    volumeScale->set_increments(100.0/(n-1), 100.0/(n-1));
+    /*volumeScale->set_increments(100.0/(n-1), 100.0/(n-1));*/
 }
diff --git a/src/channelwidget.h b/src/channelwidget.h
index 26a880c..a1debda 100644
--- a/src/channelwidget.h
+++ b/src/channelwidget.h
@@ -43,6 +43,7 @@ public:
 
     bool can_decibel;
     bool volumeScaleEnabled;
+    bool last;
 
     virtual void set_sensitive(bool enabled);
     virtual void setBaseVolume(pa_volume_t);
diff --git a/src/devicewidget.cc b/src/devicewidget.cc
index 9a75970..b513ee8 100644
--- a/src/devicewidget.cc
+++ b/src/devicewidget.cc
@@ -77,6 +77,7 @@ void DeviceWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {
         cw->channelLabel->set_markup(text);
         channelsVBox->pack_start(*cw, false, false, 0);
     }
+    channelWidgets[m.channels-1]->last = true;
 
     lockToggleButton->set_sensitive(m.channels > 1);
 }
diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade
index db21b8a..3077a88 100644
--- a/src/pavucontrol.glade
+++ b/src/pavucontrol.glade
@@ -150,6 +150,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="xalign">0</property>
+            <property name="yalign">0</property>
             <property name="label" translatable="yes">&lt;b&gt;left-front&lt;/b&gt;</property>
             <property name="use_markup">True</property>
             <property name="width_chars">15</property>
@@ -179,7 +180,11 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="xalign">1</property>
-            <property name="label" translatable="yes">50%</property>
+            <property name="yalign">0</property>
+            <property name="xpad">8</property>
+            <property name="label" translatable="yes">&lt;small&gt;50%&lt;/small&gt;</property>
+            <property name="use_markup">True</property>
+            <property name="justify">right</property>
             <property name="width_chars">9</property>
           </object>
           <packing>
diff --git a/src/pavucontrol.h b/src/pavucontrol.h
index 4e3d32e..1ef2519 100644
--- a/src/pavucontrol.h
+++ b/src/pavucontrol.h
@@ -34,6 +34,11 @@
 #define GLADE_FILE "pavucontrol.glade"
 #endif
 
+/* Can be removed when PulseAudio 0.9.23 or newer is required */
+#ifndef PA_VOLUME_UI_MAX
+# define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0))
+#endif
+
 enum SinkInputType {
     SINK_INPUT_ALL,
     SINK_INPUT_CLIENT,
diff --git a/src/streamwidget.cc b/src/streamwidget.cc
index 431e460..94363ec 100644
--- a/src/streamwidget.cc
+++ b/src/streamwidget.cc
@@ -78,6 +78,8 @@ void StreamWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {
         cw->channelLabel->set_markup(text);
         channelsVBox->pack_start(*cw, false, false, 0);
     }
+    channelWidgets[m.channels-1]->last = true;
+    channelWidgets[m.channels-1]->setBaseVolume(PA_VOLUME_NORM);
 
     lockToggleButton->set_sensitive(m.channels > 1);
 }

commit c70b048c98db9cc7869484ff9d6b1ed84b9dea91
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Wed Mar 9 21:54:05 2011 +0000

    volume: Don't bother setting the steps.
    
    The number of volume steps doesn't really affect our scale, so there
    is little value in setting it.

diff --git a/src/channelwidget.cc b/src/channelwidget.cc
index 2fb06a4..6f59de2 100644
--- a/src/channelwidget.cc
+++ b/src/channelwidget.cc
@@ -112,7 +112,3 @@ void ChannelWidget::setBaseVolume(pa_volume_t v) {
     }
 
 }
-
-void ChannelWidget::setSteps(unsigned n) {
-    /*volumeScale->set_increments(100.0/(n-1), 100.0/(n-1));*/
-}
diff --git a/src/channelwidget.h b/src/channelwidget.h
index a1debda..bcfa48d 100644
--- a/src/channelwidget.h
+++ b/src/channelwidget.h
@@ -47,7 +47,6 @@ public:
 
     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 b513ee8..bf09f12 100644
--- a/src/devicewidget.cc
+++ b/src/devicewidget.cc
@@ -139,12 +139,6 @@ void DeviceWidget::setBaseVolume(pa_volume_t v) {
         channelWidgets[channelMap.channels-1]->setBaseVolume(v);
 }
 
-void DeviceWidget::setSteps(unsigned n) {
-
-    for (int i = 0; i < channelMap.channels; i++)
-        channelWidgets[channelMap.channels-1]->setSteps(n);
-}
-
 void DeviceWidget::prepareMenu() {
     int idx = 0;
     int active_idx = -1;
diff --git a/src/devicewidget.h b/src/devicewidget.h
index 358c708..2ad5d1e 100644
--- a/src/devicewidget.h
+++ b/src/devicewidget.h
@@ -58,7 +58,6 @@ public:
 
     virtual void executeVolumeUpdate();
     virtual void setBaseVolume(pa_volume_t v);
-    virtual void setSteps(unsigned n);
 
     std::vector< std::pair<Glib::ustring,Glib::ustring> > ports;
     Glib::ustring activePort;
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 119e30e..ddd0579 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -278,7 +278,6 @@ void MainWindow::updateSink(const pa_sink_info &info) {
         is_new = true;
 
         w->setBaseVolume(info.base_volume);
-        w->setSteps(info.n_volume_steps);
     }
 
     w->updating = true;
@@ -415,7 +414,6 @@ void MainWindow::updateSource(const pa_source_info &info) {
         is_new = true;
 
         w->setBaseVolume(info.base_volume);
-        w->setSteps(info.n_volume_steps);
 
         if (pa_context_get_server_protocol_version(get_context()) >= 13)
             createMonitorStreamForSource(info.index);

-- 
hooks/post-receive
PulseAudio Volume Control



More information about the pulseaudio-commits mailing list