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



#include <QObject>
#include <QVector>
#include <QMutex>
#include <QWaitCondition>

#if QT_VERSION >= 0x040400
#include <QAtomicInt>
#define QAtomicInt int

 * Thread-safe ring buffer - one thread produces and another consumes.
 * A third thread reads maximum
00019 class RingBuffer : public QObject
    unsigned char *ringBuf;
    unsigned long ringBufSize;
    unsigned long fillRateMax;
    unsigned long writeOfs;
    unsigned long readOfs;
    QAtomicInt fillRate;

    int frameCounter;
    QMutex waitForDataMutex;
    QWaitCondition waitForData;

    int channels, sampleSize;
    QVector<QAtomicInt> max;
    void updateMax(long startpos, long endpos);
    RingBuffer(long size, int channelCount, bool enable32bit);
    void reset();
    long readMax(int channelIndex);
    unsigned long getFillRate() { return fillRate; }
    unsigned long getFillRateMax() { return fillRateMax; }

    unsigned char* beginWrite(long& curPos, long& size);
    void endWrite(long curPos);
    unsigned char* beginRead(long& curPos, long& size, bool waitIfEmpty);
    void endRead(long curPos);
    void discardBuffer();



Generated by  Doxygen 1.6.0   Back to index