Add test plugin for sound functions
[projects/chimara/chimara.git] / tests / soundtest.c
1 #include <libchimara/glk.h>
2 #include <stdio.h>
3
4 void
5 glk_main(void)
6 {
7         if(!glk_gestalt(gestalt_Sound, 0)) {
8                 fprintf(stderr, "Sound not supported.\n");
9                 return;
10         }
11         if(!glk_gestalt(gestalt_SoundVolume, 0)) {
12                 fprintf(stderr, "Sound volume not supported.\n");
13                 return;
14         }
15         
16         schanid_t sc = glk_schannel_create(0);
17         if(!sc) {
18                 fprintf(stderr, "Could not create sound channel.\n");
19                 return;
20         }
21         
22         glk_schannel_set_volume(sc, 0x10000);
23         glk_schannel_set_volume(sc, 0x08000);
24         glk_schannel_set_volume(sc, 0x04000);
25         glk_schannel_set_volume(sc, 0x00000);
26         glk_schannel_set_volume(sc, 0xA0000); /* max supported volume */
27         glk_schannel_set_volume(sc, 0xB0000); /* should be coerced */
28         glk_schannel_set_volume(sc, 0x10000);
29         
30         glk_schannel_destroy(sc);
31 }