X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dos_sbtest;a=blobdiff_plain;f=src%2Faudio.c;h=88b84005d3a66f81368386a61f1e7f360e10fc97;hp=49b8a8deab18a3e90dceb66138fa952432a4acee;hb=b4ee0075a2a231ef06e333b77510187aeb22f8fa;hpb=6d4de53a835a8258ba05c83a2af38f27a0e92d21 diff --git a/src/audio.c b/src/audio.c index 49b8a8d..88b8400 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,88 +1,78 @@ -/* -pcboot - bootable PC demo/game kernel -Copyright (C) 2018 John Tsiombikas - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY, without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#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 bits, 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 bits, int nchan) +{ + drv.start(rate, bits, 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(); +}