summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-09-16 00:03:14 +0000
committerLennart Poettering <lennart@poettering.net>2004-09-16 00:03:14 +0000
commite0fb4dbd8a6367ab20d467caf1f5b1d641ca9867 (patch)
treeeb22366a72f2dc9641597396a5b3dafe68fc9758
parentbbf0d484e5fe48d841491d396008373142089e63 (diff)
update for new API
show logarthmic levels git-svn-id: file:///home/lennart/svn/public/pavumeter/trunk@14 c62a5a7b-6fe3-0310-9d5a-afe6de46906b
-rw-r--r--configure.ac2
-rw-r--r--src/vumeter.cc41
2 files changed, 26 insertions, 17 deletions
diff --git a/configure.ac b/configure.ac
index 5ff8a2d..02e5750 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
AC_PREREQ(2.57)
-AC_INIT([pavumeter],[0.1],[mzihzrgre (at) 0pointer (dot) de])
+AC_INIT([pavumeter],[0.2],[mzihzrgre (at) 0pointer (dot) de])
AC_CONFIG_SRCDIR([src/vumeter.cc])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign -Wall])
diff --git a/src/vumeter.cc b/src/vumeter.cc
index 53c7ea8..73a813d 100644
--- a/src/vumeter.cc
+++ b/src/vumeter.cc
@@ -9,6 +9,8 @@
#include <polyp/polyplib-introspect.h>
#include <polyp/glib-mainloop.h>
+#define LOGARITHMIC 1
+
class MainWindow : public Gtk::Window {
public:
@@ -189,8 +191,16 @@ void MainWindow::showLevels(const LevelInfo &i) {
g_assert(i.levels);
for (unsigned n = 0; n < nchan; n++) {
+ double level;
ChannelInfo *c = channels[n];
- c->progress->set_fraction(i.levels[n]);
+
+ level = i.levels[n];
+
+#ifdef LOGARITHMIC
+ level = log10(level*9+1);
+#endif
+
+ c->progress->set_fraction(level > 1 ? 1 : level);
}
}
@@ -268,27 +278,29 @@ static struct pa_context *context = NULL;
static struct pa_stream *stream = NULL;
static struct pa_sample_spec sample_spec = { (enum pa_sample_format) 0, 0, 0 };
static char* source_name = NULL;
-static uint32_t sink_index = PA_INVALID_INDEX;
-static void context_get_sink_info_callback(struct pa_context *c, const struct pa_sink_info *si, int is_last, void *) {
- if (is_last < 0) {
- g_message("Failed to get latency information: %s", pa_strerror(pa_context_errno(c)));
+static void stream_get_latency_callback(struct pa_stream *, const struct pa_latency_info *l, void *) {
+ pa_usec_t t;
+
+ if (!l) {
+ g_message("Failed to get latency information: %s", pa_strerror(pa_context_errno(context)));
Gtk::Main::quit();
return;
}
- if (!si)
+ if (!mainWindow)
return;
+
+ t = l->source_usec + l->buffer_usec + l->transport_usec;
- if (mainWindow)
- mainWindow->updateLatency(si->latency);
+ mainWindow->updateLatency(l->sink_usec > t ? l->sink_usec - t : 0);
}
static gboolean latency_func(gpointer) {
if (!stream)
return false;
- pa_operation_unref(pa_context_get_sink_info_by_index(context, sink_index, context_get_sink_info_callback, NULL));
+ pa_operation_unref(pa_stream_get_latency(stream, stream_get_latency_callback, NULL));
return true;
}
@@ -307,6 +319,9 @@ static void stream_state_callback(struct pa_stream *s, void *) {
case PA_STREAM_READY:
g_assert(!mainWindow);
mainWindow = new MainWindow(sample_spec.channels, source_name);
+
+ g_timeout_add(100, latency_func, NULL);
+ pa_operation_unref(pa_stream_get_latency(stream, stream_get_latency_callback, NULL));
break;
case PA_STREAM_FAILED:
@@ -333,12 +348,6 @@ static void context_get_source_info_callback(struct pa_context *c, const struct
sample_spec.rate = si->sample_spec.rate;
sample_spec.channels = si->sample_spec.channels;
- if (si->monitor_of_sink != PA_INVALID_INDEX) {
- g_timeout_add(100, latency_func, NULL);
- sink_index = si->monitor_of_sink;
- pa_operation_unref(pa_context_get_sink_info_by_index(context, sink_index, context_get_sink_info_callback, NULL));
- }
-
pa_sample_spec_snprint(t, sizeof(t), &sample_spec);
g_message("Using sample format: %s", t);
@@ -408,7 +417,7 @@ int main(int argc, char *argv[]) {
g_assert(m);
pa_context_set_state_callback(context, context_state_callback, NULL);
- pa_context_connect(context, NULL);
+ pa_context_connect(context, NULL, 1, NULL);
Gtk::Main::run();