mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-29 11:01:27 +00:00
JACK: fix crash when changing buffer size
This commit is contained in:
parent
1c92d23d27
commit
2af4992e9b
1 changed files with 19 additions and 6 deletions
|
@ -52,17 +52,30 @@ void TAAudioJACK::onBufferSize(jack_nframes_t bufsize) {
|
|||
}
|
||||
|
||||
void TAAudioJACK::onProcess(jack_nframes_t nframes) {
|
||||
if (audioProcCallback!=NULL) {
|
||||
if (midiIn!=NULL) midiIn->gather();
|
||||
audioProcCallback(audioProcCallbackUser,inBufs,outBufs,desc.inChans,desc.outChans,desc.bufsize);
|
||||
}
|
||||
for (int i=0; i<desc.inChans; i++) {
|
||||
iInBufs[i]=(float*)jack_port_get_buffer(ai[i],nframes);
|
||||
memcpy(iInBufs[i],inBufs[i],desc.bufsize*sizeof(float));
|
||||
if (nframes>desc.bufsize) {
|
||||
delete[] inBufs[i];
|
||||
inBufs[i]=new float[nframes];
|
||||
}
|
||||
memcpy(iInBufs[i],inBufs[i],nframes*sizeof(float));
|
||||
}
|
||||
for (int i=0; i<desc.outChans; i++) {
|
||||
if (nframes>desc.bufsize) {
|
||||
delete[] outBufs[i];
|
||||
outBufs[i]=new float[nframes];
|
||||
}
|
||||
}
|
||||
if (audioProcCallback!=NULL) {
|
||||
if (midiIn!=NULL) midiIn->gather();
|
||||
audioProcCallback(audioProcCallbackUser,inBufs,outBufs,desc.inChans,desc.outChans,nframes);
|
||||
}
|
||||
for (int i=0; i<desc.outChans; i++) {
|
||||
iOutBufs[i]=(float*)jack_port_get_buffer(ao[i],nframes);
|
||||
memcpy(iOutBufs[i],outBufs[i],desc.bufsize*sizeof(float));
|
||||
memcpy(iOutBufs[i],outBufs[i],nframes*sizeof(float));
|
||||
}
|
||||
if (nframes!=desc.bufsize) {
|
||||
desc.bufsize=nframes;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue