summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/proplist-test.c19
-rw-r--r--src/tests/volume-ui.py76
2 files changed, 71 insertions, 24 deletions
diff --git a/src/tests/proplist-test.c b/src/tests/proplist-test.c
index f69fa686..5526bb7e 100644
--- a/src/tests/proplist-test.c
+++ b/src/tests/proplist-test.c
@@ -29,8 +29,9 @@
#include <pulsecore/core-util.h>
int main(int argc, char*argv[]) {
- pa_proplist *a, *b, *c;
- char *s, *t, *u;
+ pa_proplist *a, *b, *c, *d;
+ char *s, *t, *u, *v;
+ const char *text;
a = pa_proplist_new();
pa_assert_se(pa_proplist_sets(a, PA_PROP_MEDIA_TITLE, "Brandenburgische Konzerte") == 0);
@@ -63,5 +64,19 @@ int main(int argc, char*argv[]) {
pa_proplist_free(b);
pa_proplist_free(c);
+ text = " eins = zwei drei = \"\\\"vier\\\"\" fuenf=sechs sieben ='\\a\\c\\h\\t\\'\\\"' neun= hex:0123456789abCDef ";
+
+ printf("%s\n", text);
+ d = pa_proplist_from_string(text);
+ v = pa_proplist_to_string(d);
+ pa_proplist_free(d);
+ printf("%s\n", v);
+ d = pa_proplist_from_string(v);
+ pa_xfree(v);
+ v = pa_proplist_to_string(d);
+ pa_proplist_free(d);
+ printf("%s\n", v);
+ pa_xfree(v);
+
return 0;
}
diff --git a/src/tests/volume-ui.py b/src/tests/volume-ui.py
index a2b756e6..6dc1c47d 100644
--- a/src/tests/volume-ui.py
+++ b/src/tests/volume-ui.py
@@ -1,9 +1,15 @@
#!/usr/bin/python
-import pygtk, gtk
+import pygtk, gtk, sys
from ctypes import *
-libpulse = cdll.LoadLibrary("../.libs/libpulse.so")
+try:
+ libpulse = cdll.LoadLibrary("../.libs/libpulse.so")
+except OSError:
+ try:
+ libpulse = cdll.LoadLibrary(".libs/libpulse.so")
+ except OSError:
+ libpulse = cdll.LoadLibrary("libpulse.so")
class ChannelMap(Structure):
_fields_ = [("channels", c_ubyte),
@@ -29,6 +35,18 @@ class ChannelMap(Structure):
_position_to_pretty_string.restype = c_char_p
_position_to_pretty_string.argtypes = [c_uint]
+ _can_balance = libpulse.pa_channel_map_can_balance
+ _can_balance.restype = c_int
+ _can_balance.argtypes = [c_void_p]
+
+ _can_fade = libpulse.pa_channel_map_can_fade
+ _can_fade.restype = c_int
+ _can_fade.argtypes = [c_void_p]
+
+ _parse = libpulse.pa_channel_map_parse
+ _parse.restype = c_void_p
+ _parse.argtypes = [c_void_p, c_char_p]
+
def to_name(this):
return this._to_name(byref(this))
@@ -42,7 +60,7 @@ class ChannelMap(Structure):
if r is None:
return None
else:
- return s.raw
+ return s.value
def position_to_string(this, pos):
return this._position_to_string(pos)
@@ -50,11 +68,21 @@ class ChannelMap(Structure):
def position_to_pretty_string(this, pos):
return this._position_to_pretty_string(pos)
+ def can_balance(this):
+ return bool(this._can_balance(byref(this)))
+
+ def can_fade(this):
+ return bool(this._can_fade(byref(this)))
+
+ def parse(this, s):
+ if this._parse(byref(this), s) is None:
+ raise Exception("Parse failure")
+
+
class CVolume(Structure):
_fields_ = [("channels", c_ubyte),
("values", c_uint32 * 32)]
-
_snprint = libpulse.pa_cvolume_snprint
_snprint.restype = c_char_p
_snprint.argtypes = [c_char_p, c_ulong, c_void_p]
@@ -110,19 +138,12 @@ class CVolume(Structure):
def set_fade(this, cm, f):
return this._set_fade(byref(this), byref(cm), f)
-
-
cm = ChannelMap()
-cm.channels = 6
-cm.map[0] = 1
-cm.map[1] = 2
-cm.map[2] = 3
-cm.map[3] = 5
-cm.map[4] = 6
-cm.map[5] = 7
-print "Channel map name: %s" % cm.to_name()
-print "Channel map mapping: %s" % cm.snprint()
+if len(sys.argv) > 1:
+ cm.parse(sys.argv[1])
+else:
+ cm.parse("surround-51")
v = CVolume()
v.channels = cm.channels
@@ -130,13 +151,12 @@ v.channels = cm.channels
for i in range(cm.channels):
v.values[i] = 65536/2
-print v.max()
-print v.snprint()
-print v.get_balance(cm)
-print v.get_fade(cm)
+title = cm.to_pretty_name()
+if title is None:
+ title = cm.snprint()
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
-window.set_title(cm.to_pretty_name())
+window.set_title(unicode(title))
window.set_border_width(12)
vbox = gtk.VBox(spacing=6)
@@ -213,7 +233,7 @@ fade_scale.set_digits(2)
vbox.pack_start(fade_scale, expand=False, fill=True)
window.add(vbox)
-window.set_default_size(600, 400)
+window.set_default_size(600, 50)
update_volume()
@@ -223,5 +243,17 @@ fade_scale.connect("value_changed", fade_value_changed)
balance_scale.connect("value_changed", balance_value_changed)
value_scale.connect("value_changed", value_value_changed)
-window.show_all()
+vbox.show_all()
+
+if not cm.can_balance():
+ balance_label.hide()
+ balance_scale.hide()
+
+if not cm.can_fade():
+ fade_label.hide()
+ fade_scale.hide()
+
+
+window.show()
+
gtk.main()