// `getProduceChunk` is a non-blocking function which returns a pointer // (`result.data`) inside RingBuffer's buffer, `result.size` is the // size of the continious chunk (can be smaller than availableToProduce()).
ContiniousChunk getProduceChunk() const;
// Tries to move the `produce` cursor by `size`, returns the actual size // moved.
size_t produce(size_t size);
// Tried to write `size` bytes into the internal buffer from `data`, // returns the actual size written.
size_t produce(constvoid *data, size_t size);
// `getConsumeChunk` is a non-blocking function which a pointer // (`result.data`) inside RingBuffer's buffer, `result.size` is the // size of the continious chunk (can be smaller than availableToConsume()). // IMPORTANT: do not call long running functions while have an instance of // ContiniousLockedChunk, it might block the producer because // it need to drop the stale audio data to replace it with // more recent one. // NOTE: ContiniousLockedChunk holds a lock inside, it might deadlock // if you calling other RingBuffer's functions that assume it is // unlocked, in this case you want to introduce a function like // `consume` below.
ContiniousLockedChunk getConsumeChunk() const;
// Tries to move the `consume` cursor by `size`, returns the actual size // moved.
size_t consume(const ContiniousLockedChunk&, size_t size);
private:
std::unique_ptr<uint8_t[]> mBuffer; mutable std::condition_variable mProduceAvailable; mutable std::condition_variable mConsumeAvailable; mutable std::mutex mMutex; constint mCapacity; int mAvailableToConsume = 0; int mProducePos = 0; int mConsumePos = 0;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.