|
@@ -185,21 +185,32 @@ int
|
|
read_YUV_frame(NvBuffer & buffer)
|
|
read_YUV_frame(NvBuffer & buffer)
|
|
{
|
|
{
|
|
std::cout<<"read frame."<<std::endl;
|
|
std::cout<<"read frame."<<std::endl;
|
|
- char * strdata = gstrbuffer;
|
|
|
|
- while(gbNewData == false)
|
|
|
|
|
|
+// char * strdata = gstrbuffer;
|
|
|
|
+// while(gbNewData == false)
|
|
|
|
+// {
|
|
|
|
+// gWaitMutex.lock();
|
|
|
|
+// gwc.wait(&gWaitMutex,10);
|
|
|
|
+// gWaitMutex.unlock();
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// gMutexLock.lock();
|
|
|
|
+// memcpy(strdata,gstrbuffer,gndatasize);
|
|
|
|
+// gbNewData = false;
|
|
|
|
+// gMutexLock.unlock();
|
|
|
|
+
|
|
|
|
+ char * strdata;
|
|
|
|
+ static qint64 nlastuptime = 0;
|
|
|
|
+ while(nlastuptime == gbuffer->GetUpTime())
|
|
{
|
|
{
|
|
- gWaitMutex.lock();
|
|
|
|
- gwc.wait(&gWaitMutex,10);
|
|
|
|
- gWaitMutex.unlock();
|
|
|
|
|
|
+ gbuffer->WaitRead(100);
|
|
}
|
|
}
|
|
|
|
|
|
- gMutexLock.lock();
|
|
|
|
- memcpy(strdata,gstrbuffer,gndatasize);
|
|
|
|
- gbNewData = false;
|
|
|
|
- gMutexLock.unlock();
|
|
|
|
-
|
|
|
|
-// char * strdata;
|
|
|
|
-// static qint64 nlastuptime = 0;
|
|
|
|
|
|
+ nlastuptime = gbuffer->GetUpTime();
|
|
|
|
+ int nreq = gbuffer->RequireBuffer(&strdata,1000);
|
|
|
|
+ while(nreq<0)
|
|
|
|
+ {
|
|
|
|
+ nreq = gbuffer->RequireBuffer(&strdata,1000);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -225,6 +236,7 @@ read_YUV_frame(NvBuffer & buffer)
|
|
}
|
|
}
|
|
plane.bytesused = plane.fmt.stride * plane.fmt.height;
|
|
plane.bytesused = plane.fmt.stride * plane.fmt.height;
|
|
}
|
|
}
|
|
|
|
+ gbuffer->ReleaseBuffer();
|
|
std::cout<<"complete read a frame."<<std::endl;
|
|
std::cout<<"complete read a frame."<<std::endl;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|