move audio init/quit to separate functions
This commit is contained in:
parent
3026bf8ba9
commit
d6d6bf80ec
|
@ -29,3 +29,6 @@ bool TAAudio::setRun(bool run) {
|
||||||
bool TAAudio::init(TAAudioDesc& request, TAAudioDesc& response) {
|
bool TAAudio::init(TAAudioDesc& request, TAAudioDesc& response) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAAudio::~TAAudio() {
|
||||||
|
}
|
|
@ -76,5 +76,7 @@ class TAAudio {
|
||||||
audioProcCallback(NULL),
|
audioProcCallback(NULL),
|
||||||
sampleRateChanged(NULL),
|
sampleRateChanged(NULL),
|
||||||
bufferSizeChanged(NULL) {}
|
bufferSizeChanged(NULL) {}
|
||||||
|
|
||||||
|
virtual ~TAAudio();
|
||||||
};
|
};
|
||||||
#endif
|
#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
|
#ifdef _WIN32
|
||||||
#include "winStuff.h"
|
#include "winStuff.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -3263,39 +3309,7 @@ bool DivEngine::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init the rest of engine
|
// init the rest of engine
|
||||||
switch (audioEngine) {
|
if (!initAudioBackend()) return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
samp_bb=blip_new(32768);
|
samp_bb=blip_new(32768);
|
||||||
if (samp_bb==NULL) {
|
if (samp_bb==NULL) {
|
||||||
|
@ -3330,7 +3344,7 @@ bool DivEngine::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivEngine::quit() {
|
bool DivEngine::quit() {
|
||||||
output->quit();
|
deinitAudioBackend();
|
||||||
quitDispatch();
|
quitDispatch();
|
||||||
logI("saving config.\n");
|
logI("saving config.\n");
|
||||||
saveConf();
|
saveConf();
|
||||||
|
|
|
@ -176,6 +176,9 @@ class DivEngine {
|
||||||
bool loadDMF(unsigned char* file, size_t len);
|
bool loadDMF(unsigned char* file, size_t len);
|
||||||
bool loadFur(unsigned char* file, size_t len);
|
bool loadFur(unsigned char* file, size_t len);
|
||||||
|
|
||||||
|
bool initAudioBackend();
|
||||||
|
bool deinitAudioBackend();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DivSong song;
|
DivSong song;
|
||||||
void nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size);
|
void nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size);
|
||||||
|
@ -196,6 +199,8 @@ class DivEngine {
|
||||||
SafeWriter* saveVGM();
|
SafeWriter* saveVGM();
|
||||||
// export to an audio file
|
// export to an audio file
|
||||||
bool saveAudio(const char* path);
|
bool saveAudio(const char* path);
|
||||||
|
// wait for audio export to finish
|
||||||
|
void waitAudioFile();
|
||||||
// stop audio file export
|
// stop audio file export
|
||||||
bool haltAudioFile();
|
bool haltAudioFile();
|
||||||
|
|
||||||
|
@ -435,6 +440,7 @@ class DivEngine {
|
||||||
unsigned char* adpcmMem;
|
unsigned char* adpcmMem;
|
||||||
|
|
||||||
DivEngine():
|
DivEngine():
|
||||||
|
output(NULL),
|
||||||
chans(0),
|
chans(0),
|
||||||
active(false),
|
active(false),
|
||||||
playing(false),
|
playing(false),
|
||||||
|
|
Loading…
Reference in a new issue