Logo Search packages:      
Sourcecode: qarecord version File versions  Download package

unsigned char * RingBuffer::beginRead ( long &  curPos,
long &  size,
bool  waitIfEmpty 
)

Parameters:
waitIfEmpty if true, waits up to 1000 ms if buffer is empty.
size amount of data in buffer (can be zero)

Definition at line 138 of file ringbuffer.cpp.

{
    unsigned long fRate;

#if QT_VERSION >= 0x040400
    fRate = fillRate.fetchAndAddOrdered(0);
#else
    q_atomic_test_and_set_acquire_int(&fillRate, 0, 0); // Just for the memory barrier
    fRate = fillRate;
#endif

    if (waitIfEmpty && fRate == 0) {
        waitForDataMutex.lock();
        waitForData.wait(&waitForDataMutex, 1000);
        waitForDataMutex.unlock();

#if QT_VERSION >= 0x040400
        fRate = fillRate.fetchAndAddOrdered(0);
#else
        q_atomic_test_and_set_acquire_int(&fillRate, 0, 0); // Just for the memory barrier
        fRate = fillRate;
#endif
    }

    if (fRate+readOfs > ringBufSize) {
        fRate = ringBufSize-readOfs;
    }
    size = fRate;
    curPos = readOfs;
    return ringBuf;
}


Generated by  Doxygen 1.6.0   Back to index