X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dos_auplay;a=blobdiff_plain;f=src%2Faudio.c;h=0e16101f821784f634ef192109de45297b1485c8;hp=88b84005d3a66f81368386a61f1e7f360e10fc97;hb=6e29178202fe1876a0fb0231e71fa0e75a7b6460;hpb=87ef5613bb9baae3903237321c15133066139f7c diff --git a/src/audio.c b/src/audio.c index 88b8400..0e16101 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,36 +1,24 @@ #include #include "audio.h" -#include "au_sb.h" - -struct audrv { - void *(*get_buffer)(int *size); - void (*start)(int rate, int bits, int nchan); - void (*pause)(void); - void (*cont)(void); - void (*stop)(void); - void (*volume)(int vol); - int (*isplaying)(void); -}; +#include "audrv.h" static struct audrv drv; static audio_callback_func cbfunc; static void *cbcls; -void audio_init(void) +/* driver detect/init functions are defined in their respective source files */ +int sb_detect(struct audrv *drv); + + +int audio_init(void) { - if(sb_detect()) { - drv.get_buffer = sb_buffer; - drv.start = sb_start; - drv.pause = sb_pause; - drv.cont = sb_continue; - drv.stop = sb_stop; - drv.volume = sb_volume; - drv.isplaying = sb_isplaying; - return; + if(sb_detect(&drv)) { + return 0; } - printf("No supported audio device detected\n"); + fprintf(stderr, "No supported audio device detected\n"); + return -1; } void audio_set_callback(audio_callback_func func, void *cls) @@ -49,6 +37,7 @@ int audio_callback(void *buf, int sz) void audio_play(int rate, int bits, int nchan) { + printf("play %d samples/s, %d bits, %s\n", rate, bits, nchan == 1 ? "mono" : "stereo"); drv.start(rate, bits, nchan); } @@ -67,9 +56,14 @@ void audio_stop(void) drv.stop(); } -void audio_volume(int vol) +void audio_setvolume(int ctl, int vol) +{ + drv.setvolume(ctl, vol); +} + +int audio_getvolume(int ctl) { - drv.volume(vol); + return drv.getvolume(ctl); } int audio_isplaying(void)