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

Method Seek

plugin/BiDataSource.cpp:146–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146int64_t BiDataSource::Seek(int64_t offset, int whence)
147{
148 int64_t ret;
149
150 if (mCurrent == nullptr)
151 return -EINVAL;
152
153 if (whence == SEEK_SIZE) {
154 if (fileSize == 0) {
155 fileSize = getFileSize();
156 }
157 return fileSize;
158 } else if ((whence == SEEK_CUR && offset == 0) ||
159 (whence == SEEK_SET && offset == fileSize)) {
160 if (fileSize == 0) {
161 fileSize = getFileSize();
162 }
163 return fileSize;
164 } else if ((fileSize <= 0 && whence == SEEK_END)) {
165 return FRAMEWORK_ERR(ENOSYS);
166 }
167
168 if (whence == SEEK_CUR) {
169 offset += filePos;
170 } else if (whence == SEEK_END) {
171 if (fileSize == 0) {
172 fileSize = getFileSize();
173 }
174 if (fileSize < 0)
175 return -EINVAL;
176 offset += fileSize;
177 } else if (whence != SEEK_SET) {
178 return FRAMEWORK_ERR(EINVAL);
179 }
180
181 if (offset < 0) {
182 return -(EINVAL);
183 }
184
185 if (offset == filePos) {
186 return offset;
187 }
188
189 if (mSources.size() > 1) {
190 mCurrent = nullptr;
191 }
192
193 if (mCurrent == nullptr) { // first try local
194 source *local = mSources[0]->mDataSource->getSpeedLevel() == speedLevel_local ? mSources[0].get() : mSources[1].get();
195 if (local->mRange.end > offset) {
196 mCurrent = local;
197 }
198 }
199 if (mCurrent == nullptr) { //change current to remote
200 mCurrent = mSources[0]->mDataSource->getSpeedLevel() == speedLevel_remote ? mSources[0].get() : mSources[1].get();
201 }
202
203 if (!mCurrent->mIsOpened) {

Callers 10

OpenMethod · 0.45
getFileSizeMethod · 0.45
ReadMethod · 0.45
ProcessPrepareMsgMethod · 0.45
ProcessSeekToMsgMethod · 0.45
switchAudioMethod · 0.45
switchSubTitleMethod · 0.45
GetOptionMethod · 0.45
SwitchVideoMethod · 0.45
seekMethod · 0.45

Calls 4

getSpeedLevelMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
OpenMethod · 0.45

Tested by

no test coverage detected