MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / readAt

Method readAt

framework/data_source/cache/sliceBufferSource.cpp:119–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117 }
118
119 int sliceBuffer::readAt(uint8_t *buffer, int size, uint64_t offset)
120 {
121 uint64_t curNum = offset / mSliceSize;
122 uint64_t startPos = offset % mSliceSize;
123
124 if (curNum >= mSliceCount) {
125 return 0;
126 }
127
128 if (mSlices[curNum] == nullptr) {
129 return -EAGAIN;
130 }
131
132 int sizeRead = 0;
133
134 for (uint64_t i = curNum; i < mSliceCount; ++i) {
135 if (mSlices[i]->getValidSize() == 0) {
136 break;
137 }
138
139 sizeRead += mSlices[i]->readAt(buffer + sizeRead, static_cast<int>(mSliceSize), startPos);
140 startPos = 0;
141
142 if (sizeRead >= size) {
143 break;
144 }
145 }
146
147 return sizeRead;
148 }
149
150 void sliceBuffer::dump()
151 {

Callers

nothing calls this directly

Calls 3

getValidSizeMethod · 0.80
onReadSourceMethod · 0.80
updateSliceUseTimeMethod · 0.80

Tested by

no test coverage detected