Added a blocking method to wait for available new bits.

This commit is contained in:
Tats
2016-02-17 15:54:58 -05:00
parent d62343ee95
commit 51f5d7f9fb
2 changed files with 23 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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;