Moved frame number counter to inside mutex

This commit is contained in:
Matt Hill
2014-07-03 10:48:38 -04:00
parent ec6a9555eb
commit 584aabf635

View File

@@ -25,11 +25,11 @@ class VideoDispatcher
int getLatestFrame(cv::Mat* frame)
{
tthread::lock_guard<tthread::mutex> guard(mMutex);
if (latestFrameNumber == lastFrameRead)
return -1;
tthread::lock_guard<tthread::mutex> guard(mMutex);
frame->create(latestFrame->size(), latestFrame->type());
latestFrame->copyTo(*frame);
@@ -40,6 +40,7 @@ class VideoDispatcher
void setLatestFrame(cv::Mat* frame)
{
tthread::lock_guard<tthread::mutex> guard(mMutex);
this->latestFrame = frame;
this->latestFrameNumber++;