mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-04-17 21:19:20 +02:00
Added a blocking method to wait for available new bits.
This commit is contained in:
@@ -1010,3 +1010,23 @@ void MediaImpl::unlockMutex()
|
||||
_mutexLocker->unlock();
|
||||
}
|
||||
|
||||
bool MediaImpl::waitForNextBits(int timeout, const uchar** bits)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
while (time.elapsed() < timeout)
|
||||
{
|
||||
// Bits available.
|
||||
if (hasBits() && bitsHaveChanged())
|
||||
{
|
||||
if (bits)
|
||||
*bits = getBits();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Timed out.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -191,6 +191,9 @@ public:
|
||||
/// Unlocks mutex (default = no effect).
|
||||
void unlockMutex();
|
||||
|
||||
/// Wait until first data samples are available (blocking).
|
||||
bool waitForNextBits(int timeout, const uchar** bits=0);
|
||||
|
||||
private:
|
||||
//locals
|
||||
|
||||
@@ -232,7 +235,6 @@ private:
|
||||
*/
|
||||
GSource *_pollSource;
|
||||
|
||||
|
||||
/// Raw image data of the last video frame.
|
||||
uchar *_data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user