| 516 | } |
| 517 | |
| 518 | void VideoCache::updateCacheQueue() |
| 519 | { |
| 520 | if (!cachingEnabled) |
| 521 | return; // Caching disabled |
| 522 | |
| 523 | // Now calculate the new list of frames to cache and run the cacher |
| 524 | DEBUG_CACHING("VideoCache::updateCacheQueue"); |
| 525 | |
| 526 | // Firstly clear the old cache queues |
| 527 | cacheQueue.clear(); |
| 528 | cacheDeQueue.clear(); |
| 529 | |
| 530 | // Get all items from the playlist. There are two lists. For the caching status (how full is the |
| 531 | // cache) we have to consider all items in the playlist. However, we only cache top level items |
| 532 | // and no child items. |
| 533 | QList<playlistItem *> allItems = playlist->getAllPlaylistItems(); |
| 534 | QList<playlistItem *> allItemsTop = playlist->getAllPlaylistItems(true); |
| 535 | |
| 536 | if (allItemsTop.count() == 0) |
| 537 | // No cachable items in the playlist. |
| 538 | return; |
| 539 | |
| 540 | const bool play = playback->playing(); |
| 541 | DEBUG_CACHING("VideoCache::updateCacheQueue Playback is %srunning", play ? "" : "not "); |
| 542 | |
| 543 | // Our caching priority list is like this: |
| 544 | // 1: Cache all the frames in the item that is currently selected. In order to achieve this, we |
| 545 | // will aggressively |
| 546 | // delete other frames from other sequences in the cache. This has highest priority. |
| 547 | // 2: Cache all the frames from the following items (while there is space left in the cache). If |
| 548 | // case of playback |
| 549 | // we will remove all frames from items that were already played back (are before the current |
| 550 | // item in the playlist). If playback is not running, we will not remove any frames from other |
| 551 | // items from the cache to achieve this. |
| 552 | // |
| 553 | // When frames have to be removed to fit the selected sequence into the cache, the following |
| 554 | // priorities apply to frames from other sequences. (The ones with highest priority get removed |
| 555 | // last). This priority list differs depending if playback is currently running or not. |
| 556 | // |
| 557 | // Playback is not running: |
| 558 | // 1: The frames from the previous item have highest priority and are removed last. It is very |
| 559 | // likely that in 'interactive' |
| 560 | // (playback is not running) mode, the user will go back to the previous item. |
| 561 | // 2: The item after this item is next in the priority list. |
| 562 | // 3: The item after 2 is next and so on (wrap around in the playlist) until the previous item is |
| 563 | // reached. |
| 564 | // |
| 565 | // Playback is running: |
| 566 | // 1: The item after this item has the highest priority (it will be played next) |
| 567 | // 2: The item after 2 is next and so on (wrap around in the playlist) until the previous item is |
| 568 | // reached. |
| 569 | |
| 570 | // Let's start with the currently selected item (if no item is selected, the first item in the |
| 571 | // playlist is considered as being selected) |
| 572 | auto selection = playlist->getSelectedItems(); |
| 573 | if (selection[0] == nullptr) |
| 574 | selection[0] = allItems[0]; |
| 575 | // Get the position of the curretnly selected item |
nothing calls this directly
no test coverage detected