fix audio problems in SDL audio backend
this was a Furnace bug issue #2503
This commit is contained in:
parent
3ce445e96e
commit
4fc278eb46
|
@ -27,16 +27,36 @@ void taSDLProcess(void* inst, unsigned char* buf, int nframes) {
|
|||
}
|
||||
|
||||
void TAAudioSDL::onProcess(unsigned char* buf, int nframes) {
|
||||
unsigned int unframes=nframes/(sizeof(float)*desc.outChans);
|
||||
if (nframes<0) {
|
||||
logE("nframes is negative! (%d)",nframes);
|
||||
return;
|
||||
}
|
||||
for (int i=0; i<desc.inChans; i++) {
|
||||
if (unframes>desc.bufsize) {
|
||||
delete[] inBufs[i];
|
||||
inBufs[i]=new float[unframes];
|
||||
}
|
||||
}
|
||||
for (int i=0; i<desc.outChans; i++) {
|
||||
if (unframes>desc.bufsize) {
|
||||
delete[] outBufs[i];
|
||||
outBufs[i]=new float[unframes];
|
||||
}
|
||||
}
|
||||
if (audioProcCallback!=NULL) {
|
||||
if (midiIn!=NULL) midiIn->gather();
|
||||
audioProcCallback(audioProcCallbackUser,inBufs,outBufs,desc.inChans,desc.outChans,desc.bufsize);
|
||||
audioProcCallback(audioProcCallbackUser,inBufs,outBufs,desc.inChans,desc.outChans,unframes);
|
||||
}
|
||||
float* fbuf=(float*)buf;
|
||||
for (size_t j=0; j<desc.bufsize; j++) {
|
||||
for (size_t j=0; j<unframes; j++) {
|
||||
for (size_t i=0; i<desc.outChans; i++) {
|
||||
fbuf[j*desc.outChans+i]=outBufs[i][j];
|
||||
}
|
||||
}
|
||||
if (unframes!=desc.bufsize) {
|
||||
desc.bufsize=unframes;
|
||||
}
|
||||
}
|
||||
|
||||
void* TAAudioSDL::getContext() {
|
||||
|
|
Loading…
Reference in a new issue