From ca7d2c46ded9c992b652a490532c6334b7eed207 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 5 Jan 2011 16:54:34 -0500 Subject: [PATCH] Add test plugin for sound functions Add a test plugin, to be loaded with plugin-loader, for various testing of sound functions. --- tests/Makefile.am | 6 +++++- tests/soundtest.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/soundtest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 0300609..0fdb542 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 0000000..18c36fa --- /dev/null +++ b/tests/soundtest.c @@ -0,0 +1,31 @@ +#include +#include + +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); +} -- 2.30.2