mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-09 02:07:52 -04:00
VisualProcessor : protect against null input queue
This commit is contained in:
parent
f4107c1541
commit
6019207bd4
@ -30,9 +30,13 @@ public:
|
|||||||
bool isInputEmpty() {
|
bool isInputEmpty() {
|
||||||
std::lock_guard < std::mutex > busy_lock(busy_update);
|
std::lock_guard < std::mutex > busy_lock(busy_update);
|
||||||
|
|
||||||
|
if (input) {
|
||||||
return input->empty();
|
return input->empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool isOutputEmpty() {
|
bool isOutputEmpty() {
|
||||||
std::lock_guard < std::mutex > busy_lock(busy_update);
|
std::lock_guard < std::mutex > busy_lock(busy_update);
|
||||||
|
|
||||||
@ -84,7 +88,12 @@ public:
|
|||||||
//this is purposefully (almost) non-blocking call.
|
//this is purposefully (almost) non-blocking call.
|
||||||
void flushQueues() {
|
void flushQueues() {
|
||||||
|
|
||||||
input->flush();
|
//capture a local copy atomically, so we don't need to protect input.
|
||||||
|
VisualInputQueueTypePtr localInput = input;
|
||||||
|
|
||||||
|
if (localInput) {
|
||||||
|
localInput->flush();
|
||||||
|
}
|
||||||
|
|
||||||
//scoped-lock: create a local copy of outputs, and work with it.
|
//scoped-lock: create a local copy of outputs, and work with it.
|
||||||
std::vector<VisualOutputQueueTypePtr> local_outputs;
|
std::vector<VisualOutputQueueTypePtr> local_outputs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user