Add test plugin for sound functions
authorPhilip Chimento <philip.chimento@gmail.com>
Wed, 5 Jan 2011 21:54:34 +0000 (16:54 -0500)
committerPhilip Chimento <philip.chimento@gmail.com>
Wed, 5 Jan 2011 21:54:34 +0000 (16:54 -0500)
Add a test plugin, to be loaded with plugin-loader, for various testing
of sound functions.

tests/Makefile.am
tests/soundtest.c [new file with mode: 0644]

index 0300609191e20023fe7ba45c99594dd6fcff52bf..0fdb5425d8b7daeb06ed27ad857e5357461da4a9 100644 (file)
@@ -29,7 +29,8 @@ test_close_SOURCES = test-close.c
 test_close_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS)
 test_close_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la
 
-noinst_LTLIBRARIES = first.la model.la gridtest.la splittest.la multiwin.la styletest.la
+noinst_LTLIBRARIES = first.la model.la gridtest.la splittest.la multiwin.la \
+       styletest.la soundtest.la
 
 first_la_SOURCES = first.c
 first_la_LDFLAGS = $(TEST_PLUGIN_LIBTOOL_FLAGS)
@@ -48,3 +49,6 @@ multiwin_la_LDFLAGS = $(TEST_PLUGIN_LIBTOOL_FLAGS)
 
 styletest_la_SOURCES = styletest.c
 styletest_la_LDFLAGS = $(TEST_PLUGIN_LIBTOOL_FLAGS)
+
+soundtest_la_SOURCES = soundtest.c
+soundtest_la_LDFLAGS = $(TEST_PLUGIN_LIBTOOL_FLAGS)
diff --git a/tests/soundtest.c b/tests/soundtest.c
new file mode 100644 (file)
index 0000000..18c36fa
--- /dev/null
@@ -0,0 +1,31 @@
+#include <libchimara/glk.h>
+#include <stdio.h>
+
+void
+glk_main(void)
+{
+       if(!glk_gestalt(gestalt_Sound, 0)) {
+               fprintf(stderr, "Sound not supported.\n");
+               return;
+       }
+       if(!glk_gestalt(gestalt_SoundVolume, 0)) {
+               fprintf(stderr, "Sound volume not supported.\n");
+               return;
+       }
+       
+       schanid_t sc = glk_schannel_create(0);
+       if(!sc) {
+               fprintf(stderr, "Could not create sound channel.\n");
+               return;
+       }
+       
+       glk_schannel_set_volume(sc, 0x10000);
+       glk_schannel_set_volume(sc, 0x08000);
+       glk_schannel_set_volume(sc, 0x04000);
+       glk_schannel_set_volume(sc, 0x00000);
+       glk_schannel_set_volume(sc, 0xA0000); /* max supported volume */
+       glk_schannel_set_volume(sc, 0xB0000); /* should be coerced */
+       glk_schannel_set_volume(sc, 0x10000);
+       
+       glk_schannel_destroy(sc);
+}