mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-24 05:25:12 +00:00
move audio init/quit to separate functions
This commit is contained in:
parent
3026bf8ba9
commit
d6d6bf80ec
4 changed files with 59 additions and 34 deletions
|
@ -28,4 +28,7 @@ bool TAAudio::setRun(bool run) {
|
|||
|
||||
bool TAAudio::init(TAAudioDesc& request, TAAudioDesc& response) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TAAudio::~TAAudio() {
|
||||
}
|
|
@ -76,5 +76,7 @@ class TAAudio {
|
|||
audioProcCallback(NULL),
|
||||
sampleRateChanged(NULL),
|
||||
bufferSizeChanged(NULL) {}
|
||||
|
||||
virtual ~TAAudio();
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -3225,6 +3225,52 @@ void DivEngine::quitDispatch() {
|
|||
} \
|
||||
}
|
||||
|
||||
bool DivEngine::initAudioBackend() {
|
||||
switch (audioEngine) {
|
||||
case DIV_AUDIO_JACK:
|
||||
#ifndef HAVE_JACK
|
||||
logE("Furnace was not compiled with JACK support!\n");
|
||||
setConf("audioEngine","SDL");
|
||||
saveConf();
|
||||
output=new TAAudioSDL;
|
||||
#else
|
||||
output=new TAAudioJACK;
|
||||
#endif
|
||||
break;
|
||||
case DIV_AUDIO_SDL:
|
||||
output=new TAAudioSDL;
|
||||
break;
|
||||
default:
|
||||
logE("invalid audio engine!\n");
|
||||
return false;
|
||||
}
|
||||
want.bufsize=getConfInt("audioBufSize",1024);
|
||||
want.rate=getConfInt("audioRate",44100);
|
||||
want.fragments=2;
|
||||
want.inChans=0;
|
||||
want.outChans=2;
|
||||
want.outFormat=TA_AUDIO_FORMAT_F32;
|
||||
want.name="Furnace";
|
||||
|
||||
output->setCallback(process,this);
|
||||
|
||||
logI("initializing audio.\n");
|
||||
if (!output->init(want,got)) {
|
||||
logE("error while initializing audio!\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DivEngine::deinitAudioBackend() {
|
||||
if (output!=NULL) {
|
||||
output->quit();
|
||||
delete output;
|
||||
output=NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winStuff.h"
|
||||
#endif
|
||||
|
@ -3263,39 +3309,7 @@ bool DivEngine::init() {
|
|||
}
|
||||
|
||||
// init the rest of engine
|
||||
switch (audioEngine) {
|
||||
case DIV_AUDIO_JACK:
|
||||
#ifndef HAVE_JACK
|
||||
logE("Furnace was not compiled with JACK support!\n");
|
||||
setConf("audioEngine","SDL");
|
||||
saveConf();
|
||||
return false;
|
||||
#else
|
||||
output=new TAAudioJACK;
|
||||
#endif
|
||||
break;
|
||||
case DIV_AUDIO_SDL:
|
||||
output=new TAAudioSDL;
|
||||
break;
|
||||
default:
|
||||
logE("invalid audio engine!\n");
|
||||
return false;
|
||||
}
|
||||
want.bufsize=getConfInt("audioBufSize",1024);
|
||||
want.rate=getConfInt("audioRate",44100);
|
||||
want.fragments=2;
|
||||
want.inChans=0;
|
||||
want.outChans=2;
|
||||
want.outFormat=TA_AUDIO_FORMAT_F32;
|
||||
want.name="Furnace";
|
||||
|
||||
output->setCallback(process,this);
|
||||
|
||||
logI("initializing audio.\n");
|
||||
if (!output->init(want,got)) {
|
||||
logE("error while initializing audio!\n");
|
||||
return false;
|
||||
}
|
||||
if (!initAudioBackend()) return false;
|
||||
|
||||
samp_bb=blip_new(32768);
|
||||
if (samp_bb==NULL) {
|
||||
|
@ -3330,7 +3344,7 @@ bool DivEngine::init() {
|
|||
}
|
||||
|
||||
bool DivEngine::quit() {
|
||||
output->quit();
|
||||
deinitAudioBackend();
|
||||
quitDispatch();
|
||||
logI("saving config.\n");
|
||||
saveConf();
|
||||
|
|
|
@ -176,6 +176,9 @@ class DivEngine {
|
|||
bool loadDMF(unsigned char* file, size_t len);
|
||||
bool loadFur(unsigned char* file, size_t len);
|
||||
|
||||
bool initAudioBackend();
|
||||
bool deinitAudioBackend();
|
||||
|
||||
public:
|
||||
DivSong song;
|
||||
void nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size);
|
||||
|
@ -196,6 +199,8 @@ class DivEngine {
|
|||
SafeWriter* saveVGM();
|
||||
// export to an audio file
|
||||
bool saveAudio(const char* path);
|
||||
// wait for audio export to finish
|
||||
void waitAudioFile();
|
||||
// stop audio file export
|
||||
bool haltAudioFile();
|
||||
|
||||
|
@ -435,6 +440,7 @@ class DivEngine {
|
|||
unsigned char* adpcmMem;
|
||||
|
||||
DivEngine():
|
||||
output(NULL),
|
||||
chans(0),
|
||||
active(false),
|
||||
playing(false),
|
||||
|
|
Loading…
Reference in a new issue