X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dos_sbtest;a=blobdiff_plain;f=src%2Faudio.c;fp=src%2Faudio.c;h=adb8e3e4646c883db9c9885d46e29bc6502ba664;hp=d783559b581cac3de5074f345f584bd28b8ff23b;hb=07c19444f4f2a55abf97d181ab62aeaa51033c62;hpb=01a545fde6dc446fe626382f8bba50b9b7c1a35b diff --git a/src/audio.c b/src/audio.c index d783559..adb8e3e 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,71 +1,78 @@ -#include -#include "audio.h" -#include "au_sb.h" - -struct audrv { - void *(*get_buffer)(int *size); - void (*start)(int rate, int nchan); - void (*pause)(void); - void (*cont)(void); - void (*stop)(void); - void (*volume)(int vol); -}; - -static struct audrv drv; - -static audio_callback_func cbfunc; -static void *cbcls; - -void 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; - return; - } - - printf("No supported audio device detected\n"); -} - -void audio_set_callback(audio_callback_func func, void *cls) -{ - cbfunc = func; - cbcls = cls; -} - -int audio_callback(void *buf, int sz) -{ - if(!cbfunc) { - return 0; - } - return cbfunc(buf, sz, cbcls); -} - -void audio_play(int rate, int nchan) -{ - drv.start(rate, nchan); -} - -void audio_pause(void) -{ - drv.pause(); -} - -void audio_resume(void) -{ - drv.cont(); -} - -void audio_stop(void) -{ - drv.stop(); -} - -void audio_volume(int vol) -{ - drv.volume(vol); -} +#include +#include "audio.h" +#include "au_sb.h" + +struct audrv { + void *(*get_buffer)(int *size); + void (*start)(int rate, int nchan); + void (*pause)(void); + void (*cont)(void); + void (*stop)(void); + void (*volume)(int vol); + int (*isplaying)(void); +}; + +static struct audrv drv; + +static audio_callback_func cbfunc; +static void *cbcls; + +void 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; + } + + printf("No supported audio device detected\n"); +} + +void audio_set_callback(audio_callback_func func, void *cls) +{ + cbfunc = func; + cbcls = cls; +} + +int audio_callback(void *buf, int sz) +{ + if(!cbfunc) { + return 0; + } + return cbfunc(buf, sz, cbcls); +} + +void audio_play(int rate, int nchan) +{ + drv.start(rate, nchan); +} + +void audio_pause(void) +{ + drv.pause(); +} + +void audio_resume(void) +{ + drv.cont(); +} + +void audio_stop(void) +{ + drv.stop(); +} + +void audio_volume(int vol) +{ + drv.volume(vol); +} + +int audio_isplaying(void) +{ + return drv.isplaying(); +}