X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=bootcensus;a=blobdiff_plain;f=src%2Faudio.c;h=49b8a8deab18a3e90dceb66138fa952432a4acee;hp=c7142f1f2b5d5367a3b12f94f25d4ad97d9df013;hb=1e2ddab65ead32350d8ff87a6de74168e429666b;hpb=bd35c984636a2d5dfdff7a80f8eaa4e388c6899c diff --git a/src/audio.c b/src/audio.c index c7142f1..49b8a8d 100644 --- a/src/audio.c +++ b/src/audio.c @@ -19,12 +19,70 @@ along with this program. If not, see . #include "audio.h" #include "au_sb.h" -void init_audio(void) +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()) { - /* TODO use the sound blaster */ + 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); +}