diff --git a/src/rogue/interfaces/stream/Frame.cpp b/src/rogue/interfaces/stream/Frame.cpp index 51a5abda5..8d525b9d6 100755 --- a/src/rogue/interfaces/stream/Frame.cpp +++ b/src/rogue/interfaces/stream/Frame.cpp @@ -58,7 +58,7 @@ ris::Frame::BufferIterator ris::Frame::appendBuffer(ris::BufferPtr buff) { buff->setFrame(shared_from_this()); buffers_.push_back(buff); - updateSizes(); + sizeDirty_ = true; return(buffers_.begin()+oSize); } @@ -70,9 +70,8 @@ ris::Frame::BufferIterator ris::Frame::appendFrame(ris::FramePtr frame) { (*it)->setFrame(shared_from_this()); buffers_.push_back(*it); } - frame->buffers_.clear(); - frame->updateSizes(); - updateSizes(); + frame->clear(); + sizeDirty_ = true; return(buffers_.begin()+oSize); } @@ -102,8 +101,8 @@ bool ris::Frame::isEmpty() { void ris::Frame::updateSizes() { ris::Frame::BufferIterator it; - size_ = 0; - payload_ = 0; + size_ = 0; + payload_ = 0; for (it = buffers_.begin(); it != buffers_.end(); ++it) { payload_ += (*it)->getPayload(); @@ -199,7 +198,7 @@ void ris::Frame::minPayload(uint32_t size) { if ( size > getPayload() ) setPayload(size); } -//! Adjust payload size, TODO: Reduce iterations +//! Adjust payload size void ris::Frame::adjustPayload(int32_t value) { uint32_t size = getPayload(); @@ -213,22 +212,32 @@ void ris::Frame::adjustPayload(int32_t value) { void ris::Frame::setPayloadFull() { ris::Frame::BufferIterator it; - for (it = buffers_.begin(); it != buffers_.end(); ++it) + size_ = 0; + payload_ = 0; + + for (it = buffers_.begin(); it != buffers_.end(); ++it) { (*it)->setPayloadFull(); - // Refresh - updateSizes(); + payload_ += (*it)->getPayload(); + size_ += (*it)->getSize(); + } + sizeDirty_ = false; } //! Set the buffer as empty (minus header reservation) void ris::Frame::setPayloadEmpty() { ris::Frame::BufferIterator it; - for (it = buffers_.begin(); it != buffers_.end(); ++it) + size_ = 0; + payload_ = 0; + + for (it = buffers_.begin(); it != buffers_.end(); ++it) { (*it)->setPayloadEmpty(); - // Refresh - updateSizes(); + payload_ += (*it)->getPayload(); + size_ += (*it)->getSize(); + } + sizeDirty_ = false; } //! Get flags