mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-02-03 13:24:46 +01:00
Fixed luckup bug
This commit is contained in:
parent
a33fe5a4cc
commit
bb7965b3c4
@ -38,10 +38,7 @@ namespace dsp {
|
|||||||
swapCV.wait(lck, [this]{ return (canSwap || writerStop); });
|
swapCV.wait(lck, [this]{ return (canSwap || writerStop); });
|
||||||
|
|
||||||
// If writer was stopped, abandon operation
|
// If writer was stopped, abandon operation
|
||||||
if (writerStop) {
|
if (writerStop) { return false; }
|
||||||
writerStop = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Swap buffers
|
// Swap buffers
|
||||||
dataSize = size;
|
dataSize = size;
|
||||||
@ -66,23 +63,22 @@ namespace dsp {
|
|||||||
std::unique_lock<std::mutex> lck(rdyMtx);
|
std::unique_lock<std::mutex> lck(rdyMtx);
|
||||||
rdyCV.wait(lck, [this]{ return (dataReady || readerStop); });
|
rdyCV.wait(lck, [this]{ return (dataReady || readerStop); });
|
||||||
|
|
||||||
// If stopped, abort
|
return (readerStop ? -1 : dataSize);
|
||||||
if (readerStop) {
|
|
||||||
readerStop = false;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataReady = false;
|
|
||||||
|
|
||||||
return dataSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush() {
|
void flush() {
|
||||||
|
// Clear data ready
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lck(rdyMtx);
|
||||||
|
dataReady = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Notify writer that buffers can be swapped
|
// Notify writer that buffers can be swapped
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lck(swapMtx);
|
std::lock_guard<std::mutex> lck(swapMtx);
|
||||||
canSwap = true;
|
canSwap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
swapCV.notify_all();
|
swapCV.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user