summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-06-20 22:17:24 +0000
committerLennart Poettering <lennart@poettering.net>2006-06-20 22:17:24 +0000
commitd062d7d87f5be3fff0e8b263da86c0b51b26fef3 (patch)
treef1a7390e650b0ad79ae92be76c1865acf7cd6aea
parent6a6dc2c2454a8cad1899c1e4e81c7d0ab63751b6 (diff)
s/polyp/pulse/g
git-svn-id: file:///home/lennart/svn/public/pavumeter/trunk@40 c62a5a7b-6fe3-0310-9d5a-afe6de46906b
-rw-r--r--Makefile.am8
-rwxr-xr-xbootstrap.sh8
-rw-r--r--configure.ac24
-rw-r--r--doc/Makefile.am8
-rw-r--r--doc/style.css8
-rw-r--r--src/Makefile.am12
-rw-r--r--src/pavumeter.desktop2
-rw-r--r--src/vumeter.cc150
8 files changed, 135 insertions, 85 deletions
diff --git a/Makefile.am b/Makefile.am
index 6ade00d..99bdaa3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,19 +1,19 @@
# $Id$
#
-# This file is part of Polypaudio Volume Meter.
+# This file is part of PulseAudio Volume Meter.
#
-# Polypaudio Volume Meter is free software; you can redistribute it and/or modify
+# PulseAudio Volume Meter is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
-# Polypaudio Volume Meter is distributed in the hope that it will be useful, but
+# PulseAudio Volume Meter is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with Polypaudio Volume Meter; if not, write to the Free Software
+# along with PulseAudio Volume Meter; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
diff --git a/bootstrap.sh b/bootstrap.sh
index 87305af..027a8bc 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,20 +1,20 @@
#!/bin/bash
# $Id$
-# This file is part of Polypaudio Volume Meter.
+# This file is part of PulseAudio Volume Meter.
#
-# Polypaudio Volume Meter is free software; you can redistribute it and/or modify it
+# PulseAudio Volume Meter is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
-# Polypaudio Volume Meter is distributed in the hope that it will be useful, but
+# PulseAudio Volume Meter is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with Polypaudio Volume Meter; if not, write to the Free Software Foundation,
+# along with PulseAudio Volume Meter; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
VERSION=1.9
diff --git a/configure.ac b/configure.ac
index 7b0ea11..da4cae0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,24 +3,24 @@
# $Id$
-# This file is part of Polypaudio Volume Meter.
+# This file is part of PulseAudio Volume Meter.
#
-# Polypaudio Volume Meter is free software; you can redistribute it and/or modify it
+# PulseAudio Volume Meter is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
-# Polypaudio Volume Meter is distributed in the hope that it will be useful, but
+# PulseAudio Volume Meter is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with Polypaudio Volume Meter; if not, write to the Free Software Foundation,
+# along with PulseAudio Volume Meter; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
AC_PREREQ(2.57)
-AC_INIT([pavumeter],[0.9.0],[mzihzrgre (at) 0pointer (dot) de])
+AC_INIT([pavumeter],[0.9.2],[mzihzrgre (at) 0pointer (dot) de])
AC_CONFIG_SRCDIR([src/vumeter.cc])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign 1.9 -Wall])
@@ -43,16 +43,16 @@ PKG_CHECK_MODULES(GUILIBS, [ gtkmm-2.4 ])
AC_SUBST(GUILIBS_CFLAGS)
AC_SUBST(GUILIBS_LIBS)
-if test -d ../polypaudio ; then
- POLYP_CFLAGS='-I$(top_srcdir)/../polypaudio/src'
- POLYP_LIBS='-L$(top_srcdir)/../polypaudio/src/.libs -lpolyp -lpolyp-mainloop-glib'
- echo "*** Found polypaudio in ../polypaudio, using that version ***"
+if test -d ../pulseaudio ; then
+ PULSE_CFLAGS='-I$(top_srcdir)/../pulseaudio/src'
+ PULSE_LIBS='-L$(top_srcdir)/../pulseaudio/src/.libs -lpulse -lpulse-mainloop-glib'
+ echo "*** Found pulseaudio in ../pulseaudio, using that version ***"
else
- PKG_CHECK_MODULES(POLYP, [ polyplib >= 0.9.0 polyplib-glib-mainloop >= 0.9.0 ])
+ PKG_CHECK_MODULES(PULSE, [ libpulse >= 0.9.0 libpulse-mainloop-glib >= 0.9.0 ])
fi
-AC_SUBST(POLYP_LIBS)
-AC_SUBST(POLYP_CFLAGS)
+AC_SUBST(PULSE_LIBS)
+AC_SUBST(PULSE_CFLAGS)
# If using GCC specifiy some additional parameters
if test "x$GCC" = "xyes" ; then
diff --git a/doc/Makefile.am b/doc/Makefile.am
index a7c5410..1b43f66 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,19 +1,19 @@
# $Id$
-# This file is part of Polypaudio Volume Meter.
+# This file is part of PulseAudio Volume Meter.
#
-# Polypaudio Volume Meter is free software; you can redistribute it and/or modify it
+# PulseAudio Volume Meter is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
-# Polypaudio Volume Meter is distributed in the hope that it will be useful, but
+# PulseAudio Volume Meter is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with Polypaudio Volume Meter; if not, write to the Free Software Foundation,
+# along with PulseAudio Volume Meter; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
noinst_DATA = README.html README
diff --git a/doc/style.css b/doc/style.css
index faedd8d..3728bc7 100644
--- a/doc/style.css
+++ b/doc/style.css
@@ -1,20 +1,20 @@
/* $Id$ */
/***
- * This file is part of Polypaudio Volume Meter.
+ * This file is part of PulseAudio Volume Meter.
*
- * Polypaudio Volume Meter is free software; you can redistribute it and/or modify it
+ * PulseAudio Volume Meter is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * Polypaudio Volume Meter is distributed in the hope that it will be useful, but
+ * PulseAudio Volume Meter is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Polypaudio Volume Meter; if not, write to the Free Software Foundation,
+ * along with PulseAudio Volume Meter; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
***/
diff --git a/src/Makefile.am b/src/Makefile.am
index 6afa449..d314c62 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,19 +1,19 @@
# $Id$
#
-# This file is part of Polypaudio Volume Meter.
+# This file is part of PulseAudio Volume Meter.
#
-# Polypaudio Volume Meter is free software; you can redistribute it and/or modify
+# PulseAudio Volume Meter is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
-# Polypaudio Volume Meter is distributed in the hope that it will be useful, but
+# PulseAudio Volume Meter is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with Polypaudio Volume Meter; if not, write to the Free Software
+# along with PulseAudio Volume Meter; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
@@ -23,7 +23,7 @@ bin_PROGRAMS=pavumeter
pavumeter_SOURCES=vumeter.cc
-pavumeter_LDADD=$(AM_LDADD) $(GUILIBS_LIBS) $(POLYP_LIBS)
-pavumeter_CXXFLAGS=$(AM_CXXFLAGS) $(GUILIBS_CFLAGS) $(POLYP_CFLAGS)
+pavumeter_LDADD=$(AM_LDADD) $(GUILIBS_LIBS) $(PULSE_LIBS)
+pavumeter_CXXFLAGS=$(AM_CXXFLAGS) $(GUILIBS_CFLAGS) $(PULSE_CFLAGS)
dist_desktop_DATA=pavumeter.desktop
diff --git a/src/pavumeter.desktop b/src/pavumeter.desktop
index 76b19eb..bc98488 100644
--- a/src/pavumeter.desktop
+++ b/src/pavumeter.desktop
@@ -1,6 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
-Name=Polypaudio Volume Meter
+Name=PulseAudio Volume Meter
GenericName=Volume Meter
Comment=Monitor the output or input volume
Exec=pavumeter
diff --git a/src/vumeter.cc b/src/vumeter.cc
index deb40eb..ee2b4cc 100644
--- a/src/vumeter.cc
+++ b/src/vumeter.cc
@@ -24,8 +24,8 @@
#include <gtkmm.h>
#include <gtk/gtk.h>
-#include <polyp/polypaudio.h>
-#include <polyp/glib-mainloop.h>
+#include <pulse/pulseaudio.h>
+#include <pulse/glib-mainloop.h>
#define LOGARITHMIC 1
@@ -92,7 +92,7 @@ MainWindow::MainWindow(const pa_channel_map &map, const char *source_name) :
char t[256];
int n;
- set_title("Polypaudio Volume Meter");
+ set_title("PulseAudio Volume Meter");
gtk_window_set_icon_name(GTK_WINDOW(gobj()), "audio-input-microphone");
@@ -115,7 +115,7 @@ MainWindow::MainWindow(const pa_channel_map &map, const char *source_name) :
titleVBox.add(subtitleLabel);
titleVBox.set_spacing(6);
- titleLabel.set_markup("<span size=\"18000\" color=\"black\"><b>Polypaudio Volume Meter</b></span>");
+ titleLabel.set_markup("<span size=\"18000\" color=\"black\"><b>PulseAudio Volume Meter</b></span>");
titleLabel.set_alignment(0, 1);
snprintf(t, sizeof(t), "Showing signal levels of source <b>%s</b>.", source_name);
subtitleLabel.set_markup(t);
@@ -319,11 +319,14 @@ bool MainWindow::LevelInfo::elapsed() {
}
static MainWindow *mainWindow = NULL;
-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 struct pa_channel_map channel_map;
-static char* source_name = NULL;
+static pa_context *context = NULL;
+static pa_stream *stream = NULL;
+static char* device_name = NULL;
+static enum {
+ PLAYBACK,
+ RECORD
+} mode = PLAYBACK;
+
void show_error(const char *txt, bool show_pa_error = true) {
char buf[256];
@@ -337,7 +340,7 @@ void show_error(const char *txt, bool show_pa_error = true) {
Gtk::Main::quit();
}
-static void stream_update_timing_info_callback(struct pa_stream *s, int success, void *) {
+static void stream_update_timing_info_callback(pa_stream *s, int success, void *) {
pa_usec_t t;
int negative = 0;
@@ -366,7 +369,7 @@ static gboolean latency_func(gpointer) {
return true;
}
-static void stream_read_callback(struct pa_stream *s, size_t l, void *) {
+static void stream_read_callback(pa_stream *s, size_t l, void *) {
const void *p;
g_assert(mainWindow);
@@ -380,7 +383,7 @@ static void stream_read_callback(struct pa_stream *s, size_t l, void *) {
pa_stream_drop(s);
}
-static void stream_state_callback(struct pa_stream *s, void *) {
+static void stream_state_callback(pa_stream *s, void *) {
switch (pa_stream_get_state(s)) {
case PA_STREAM_UNCONNECTED:
case PA_STREAM_CREATING:
@@ -388,7 +391,7 @@ static void stream_state_callback(struct pa_stream *s, void *) {
case PA_STREAM_READY:
g_assert(!mainWindow);
- mainWindow = new MainWindow(channel_map, source_name);
+ mainWindow = new MainWindow(*pa_stream_get_channel_map(s), device_name);
g_timeout_add(100, latency_func, NULL);
pa_operation_unref(pa_stream_update_timing_info(stream, stream_update_timing_info_callback, NULL));
@@ -403,9 +406,27 @@ static void stream_state_callback(struct pa_stream *s, void *) {
}
}
-static void context_get_source_info_callback(struct pa_context *c, const struct pa_source_info *si, int is_last, void *) {
+static void create_stream(const char *name, const pa_sample_spec &ss, const pa_channel_map &cmap) {
char t[256];
+ pa_sample_spec nss;
+ g_free(device_name);
+ device_name = g_strdup(name);
+
+ nss.format = PA_SAMPLE_FLOAT32;
+ nss.rate = ss.rate;
+ nss.channels = ss.channels;
+
+ g_message("Using sample format: %s", pa_sample_spec_snprint(t, sizeof(t), &nss));
+ g_message("Using channel map: %s", pa_channel_map_snprint(t, sizeof(t), &cmap));
+
+ stream = pa_stream_new(context, "PulseAudio Volume Meter", &nss, &cmap);
+ pa_stream_set_state_callback(stream, stream_state_callback, NULL);
+ pa_stream_set_read_callback(stream, stream_read_callback, NULL);
+ pa_stream_connect_record(stream, name, NULL, (enum pa_stream_flags) 0);
+}
+
+static void context_get_source_info_callback(pa_context *, const pa_source_info *si, int is_last, void *) {
if (is_last < 0) {
show_error("Failed to get source information");
return;
@@ -414,37 +435,48 @@ static void context_get_source_info_callback(struct pa_context *c, const struct
if (!si)
return;
- sample_spec.format = PA_SAMPLE_FLOAT32;
- sample_spec.rate = si->sample_spec.rate;
- sample_spec.channels = si->sample_spec.channels;
+ create_stream(si->name, si->sample_spec, si->channel_map);
+}
+
+static void context_get_sink_info_callback(pa_context *, const pa_sink_info *si, int is_last, void *) {
+ if (is_last < 0) {
+ show_error("Failed to get sink information");
+ return;
+ }
- channel_map = si->channel_map;
-
- g_message("Using sample format: %s", pa_sample_spec_snprint(t, sizeof(t), &sample_spec));
- g_message("Using channel map: %s", pa_channel_map_snprint(t, sizeof(t), &channel_map));
+ if (!si)
+ return;
- stream = pa_stream_new(c, "vumeter", &sample_spec, &channel_map);
- pa_stream_set_state_callback(stream, stream_state_callback, NULL);
- pa_stream_set_read_callback(stream, stream_read_callback, NULL);
- pa_stream_connect_record(stream, source_name, NULL, (enum pa_stream_flags) 0);
+ create_stream(si->monitor_source_name, si->sample_spec, si->channel_map);
}
-static void context_get_server_info_callback(struct pa_context *c, const struct pa_server_info*si, void *) {
+static void context_get_server_info_callback(pa_context *c, const pa_server_info*si, void *) {
if (!si) {
show_error("Failed to get server information");
return;
}
- if (!*si->default_source_name) {
- show_error("No default source set.", false);
- return;
- }
-
- source_name = g_strdup(si->default_source_name);
- pa_operation_unref(pa_context_get_source_info_by_name(c, source_name, context_get_source_info_callback, NULL));
+ if (mode == PLAYBACK) {
+
+ if (!si->default_sink_name) {
+ show_error("No default sink set.", false);
+ return;
+ }
+
+ pa_operation_unref(pa_context_get_sink_info_by_name(c, si->default_sink_name, context_get_sink_info_callback, NULL));
+
+ } else if (mode == RECORD) {
+
+ if (!si->default_source_name) {
+ show_error("No default source set.", false);
+ return;
+ }
+
+ pa_operation_unref(pa_context_get_source_info_by_name(c, si->default_source_name, context_get_source_info_callback, NULL));
+ }
}
-static void context_state_callback(struct pa_context *c, void *) {
+static void context_state_callback(pa_context *c, void *) {
switch (pa_context_get_state(c)) {
case PA_CONTEXT_UNCONNECTED:
case PA_CONTEXT_CONNECTING:
@@ -455,8 +487,10 @@ static void context_state_callback(struct pa_context *c, void *) {
case PA_CONTEXT_READY:
g_assert(!stream);
- if (source_name)
- pa_operation_unref(pa_context_get_source_info_by_name(c, source_name, context_get_source_info_callback, NULL));
+ if (device_name && mode == RECORD)
+ pa_operation_unref(pa_context_get_source_info_by_name(c, device_name, context_get_source_info_callback, NULL));
+ else if (device_name && mode == PLAYBACK)
+ pa_operation_unref(pa_context_get_sink_info_by_name(c, device_name, context_get_sink_info_callback, NULL));
else
pa_operation_unref(pa_context_get_server_info(c, context_get_server_info_callback, NULL));
@@ -472,28 +506,44 @@ static void context_state_callback(struct pa_context *c, void *) {
}
int main(int argc, char *argv[]) {
- struct pa_glib_mainloop *m;
-
+ pa_glib_mainloop *m;
+ bool record;
+
signal(SIGPIPE, SIG_IGN);
- Gtk::Main kit(argc, argv);
+ Glib::OptionGroup og("PulseAudio Volume Meter", "Control the volume of your PulseAudio Sound Server");
+
+ Glib::OptionEntry oe;
+ oe.set_long_name("record");
+ oe.set_description("Show Record Levels");
+ og.add_entry(oe, record);
- if (argc > 1)
- source_name = g_strdup(argv[1]);
+ Glib::OptionContext oc;
+ oc.set_main_group(og);
+
+ Gtk::Main kit(argc, argv, oc);
+
+ mode = record ? RECORD : PLAYBACK;
+
+ g_message("Starting in %s mode.", mode == RECORD ? "record" : "playback");
+
+ /* Rather ugly and incomplete */
+ if (argc > 1)
+ device_name = g_strdup(argv[1]) ;
else {
- char *e = getenv("POLYP_SOURCE");
- if (e)
- source_name = g_strdup(e);
+ char *e;
+ if ((e = getenv(mode == RECORD ? "PULSE_SOURCE" : "PULSE_SINK")))
+ device_name = g_strdup(e);
}
- if (source_name)
- g_message("Using source '%s'", source_name);
+ if (device_name)
+ g_message("Using device '%s'", device_name);
m = pa_glib_mainloop_new(g_main_context_default());
g_assert(m);
- context = pa_context_new(pa_glib_mainloop_get_api(m), "vumeter");
- g_assert(m);
+ context = pa_context_new(pa_glib_mainloop_get_api(m), "PulseAudio Volume Meter");
+ g_assert(context);
pa_context_set_state_callback(context, context_state_callback, NULL);
pa_context_connect(context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL);
@@ -508,8 +558,8 @@ int main(int argc, char *argv[]) {
if (mainWindow)
delete mainWindow;
- if(source_name)
- g_free(source_name);
+ if(device_name)
+ g_free(device_name);
pa_glib_mainloop_free(m);