Bugfix in RtAudio. Almost working properly
This commit is contained in:
parent
3d188281ab
commit
f301e3d5f9
@ -30,17 +30,17 @@ typedef vector<us> usvec;
|
||||
typedef std::lock_guard<std::mutex> mutexlock;
|
||||
|
||||
class DataType {
|
||||
public:
|
||||
string name;
|
||||
unsigned sw;
|
||||
bool is_floating;
|
||||
public:
|
||||
string name;
|
||||
unsigned sw;
|
||||
bool is_floating;
|
||||
|
||||
DataType(const char *name, unsigned sw, bool is_floating)
|
||||
DataType(const char *name, unsigned sw, bool is_floating)
|
||||
: name(name), sw(sw), is_floating(is_floating) {}
|
||||
DataType() : name("invalid data type"), sw(0), is_floating(false) {}
|
||||
bool operator==(const DataType &o) {
|
||||
return (name == o.name && sw == o.sw && is_floating == o.is_floating);
|
||||
}
|
||||
DataType() : name("invalid data type"), sw(0), is_floating(false) {}
|
||||
bool operator==(const DataType &o) {
|
||||
return (name == o.name && sw == o.sw && is_floating == o.is_floating);
|
||||
}
|
||||
};
|
||||
|
||||
const DataType dtype_invalid;
|
||||
@ -51,25 +51,25 @@ const DataType dtype_int16("16-bits integers", 2, false);
|
||||
const DataType dtype_int32("32-bits integers", 4, false);
|
||||
|
||||
const std::vector<DataType> dataTypes = {
|
||||
dtype_int8, dtype_int16, dtype_int32, dtype_fl32, dtype_fl64,
|
||||
dtype_int8, dtype_int16, dtype_int32, dtype_fl32, dtype_fl64,
|
||||
};
|
||||
|
||||
class DaqApi {
|
||||
public:
|
||||
string apiname = "Invalid API";
|
||||
int apicode = -1;
|
||||
unsigned api_specific_subcode = 0;
|
||||
public:
|
||||
string apiname = "Invalid API";
|
||||
int apicode = -1;
|
||||
unsigned api_specific_subcode = 0;
|
||||
|
||||
DaqApi(string apiname, unsigned apicode, unsigned api_specific_subcode = 0)
|
||||
DaqApi(string apiname, unsigned apicode, unsigned api_specific_subcode = 0)
|
||||
: apiname(apiname), apicode(apicode),
|
||||
api_specific_subcode(api_specific_subcode) {}
|
||||
DaqApi() {}
|
||||
bool operator==(const DaqApi &other) const {
|
||||
return (apiname == other.apiname && apicode == other.apicode &&
|
||||
api_specific_subcode == other.api_specific_subcode);
|
||||
}
|
||||
api_specific_subcode(api_specific_subcode) {}
|
||||
DaqApi() {}
|
||||
bool operator==(const DaqApi &other) const {
|
||||
return (apiname == other.apiname && apicode == other.apicode &&
|
||||
api_specific_subcode == other.api_specific_subcode);
|
||||
}
|
||||
|
||||
static vector<DaqApi> getAvailableApis();
|
||||
static vector<DaqApi> getAvailableApis();
|
||||
};
|
||||
|
||||
#ifdef HAS_ULDAQ_API
|
||||
|
@ -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()) {
|
||||
|
@ -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 *);
|
||||
|
@ -285,23 +285,22 @@ 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
|
||||
|
||||
sd.thread.join()
|
||||
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
|
||||
fprintf(stderr, "End cleanup stream queues...\n")
|
||||
del sd.outQueue
|
||||
sd.outQueue = NULL
|
||||
fprintf(stderr, "End cleanup stream queues...\n")
|
||||
|
||||
if sd.pyCallback:
|
||||
Py_DECREF(<object> sd.pyCallback)
|
||||
|
Loading…
Reference in New Issue
Block a user