Bugfix in RtAudio. Almost working properly

This commit is contained in:
Anne de Jong 2020-11-07 21:36:05 +01:00
parent 3d188281ab
commit f301e3d5f9
4 changed files with 54 additions and 45 deletions

View File

@ -160,7 +160,7 @@ class AudioDaq: public Daq {
}
try {
rtaudio = new RtAudio((RtAudio::Api) devinfo.api_specific_devindex);
rtaudio = new RtAudio((RtAudio::Api) devinfo.api.api_specific_subcode);
if(!rtaudio) {
throw runtime_error("RtAudio allocation failed");
}
@ -177,6 +177,8 @@ class AudioDaq: public Daq {
);
} catch(...) {
if(rtaudio) delete rtaudio;
if(instreamparams) delete instreamparams;
if(outstreamparams) delete outstreamparams;
throw;
}
if(monitorOutput) {
@ -224,16 +226,22 @@ class AudioDaq: public Daq {
assert(rtaudio);
rtaudio->stopStream();
}
if(inqueue) delete inqueue;
if(outqueue) delete outqueue;
if(outDelayqueue) delete outDelayqueue;
if(inqueue) {
inqueue = nullptr;
}
if(outqueue) {
outqueue = nullptr;
}
if(outDelayqueue) {
delete outDelayqueue;
outDelayqueue = nullptr;
}
}
bool isRunning() const {return (rtaudio && rtaudio->isStreamRunning());}
~AudioDaq() {
assert(rtaudio);
if(rtaudio->isStreamRunning()) {
if(isRunning()) {
stop();
}
if(rtaudio->isStreamOpen()) {

View File

@ -192,12 +192,14 @@ public:
outqueue = NULL;
inqueue = NULL;
if (inbuffer)
if (inbuffer) {
delete inbuffer;
if (outbuffer)
inbuffer = nullptr;
}
if (outbuffer) {
delete outbuffer;
outbuffer = NULL;
inbuffer = NULL;
outbuffer = nullptr;
}
}
friend void threadfcn(DT9837A *);

View File

@ -285,22 +285,21 @@ cdef class Daq:
if sd.inQueue:
# If waiting in the input queue, hereby we let it run.
sd.inQueue.enqueue(NULL)
# printf('Joining thread...\n')
# HERE WE SHOULD RELEASE THE GIL, as exiting the thread function
# will require the GIL, which is locked by this thread!
sd.thread.join()
# printf('Thread joined!\n')
del sd.thread
sd.thread = NULL
if sd.inQueue:
while not sd.inQueue.empty():
free(sd.inQueue.dequeue())
del sd.inQueue
if sd.outQueue:
while not sd.outQueue.empty():
free(sd.outQueue.dequeue())
del sd.outQueue
if sd.inQueue:
while not sd.inQueue.empty():
free(sd.inQueue.dequeue())
del sd.inQueue
sd.outQueue = NULL
fprintf(stderr, "End cleanup stream queues...\n")
if sd.pyCallback: