| 270 | }; |
| 271 | |
| 272 | static void pull_once() |
| 273 | { |
| 274 | timerSetter timer; |
| 275 | |
| 276 | if (status == status_idle) { |
| 277 | if (!pollData()) { |
| 278 | timer = 1000; |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | int ret = decoder->prepare(); |
| 283 | |
| 284 | if (ret < 0) { |
| 285 | status = status_error; |
| 286 | |
| 287 | if (errorCallBack) { |
| 288 | errorCallBack(ret); |
| 289 | } |
| 290 | } else { |
| 291 | status = status_prepared; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | if (status == status_prepared) { |
| 296 | if (!readEos && decoder->getCacheDuration() < 1000000 * 10) { |
| 297 | int count = 0; |
| 298 | |
| 299 | while (pollData()) { |
| 300 | decoder->readPacket(); |
| 301 | |
| 302 | if (count++ > 0) { |
| 303 | break; |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | // if (decoder->getCacheDuration() == 0) |
| 309 | // timer = 1000; |
| 310 | int count = 0; |
| 311 | |
| 312 | while (pollRawBuffer == nullptr || pollRawBuffer(nullptr, 0) == 0) { |
| 313 | decoder->pull_once(); |
| 314 | |
| 315 | if (count++ > 0) { |
| 316 | break; |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | #ifdef __EMSCRIPTEN__ |
| 323 |
no test coverage detected