| 218 | /// ---------------------------------- VideoCache ------------------------------ |
| 219 | |
| 220 | VideoCache::VideoCache(PlaylistTreeWidget *playlistTreeWidget, |
| 221 | PlaybackController *playbackController, |
| 222 | splitViewWidget * view, |
| 223 | QWidget * parent) |
| 224 | : QObject(parent) |
| 225 | { |
| 226 | playlist = playlistTreeWidget; |
| 227 | playback = playbackController; |
| 228 | splitView = view; |
| 229 | parentWidget = parent; |
| 230 | |
| 231 | // Create the interactive threads |
| 232 | for (int i = 0; i < 2; i++) |
| 233 | { |
| 234 | interactiveThread[i] = new loadingThread(this); |
| 235 | interactiveThread[i]->start(QThread::HighPriority); |
| 236 | connect(interactiveThread[i]->worker(), |
| 237 | &loadingWorker::loadingFinished, |
| 238 | this, |
| 239 | &VideoCache::interactiveLoaderFinished); |
| 240 | |
| 241 | // Clear the slots for queued jobs |
| 242 | interactiveItemQueued[i] = nullptr; |
| 243 | interactiveItemQueued_Idx[i] = -1; |
| 244 | } |
| 245 | |
| 246 | // Update some values from the QSettings. This will also create the correct number of threads. |
| 247 | updateSettings(); |
| 248 | |
| 249 | connect(playlist.data(), |
| 250 | &PlaylistTreeWidget::playlistChanged, |
| 251 | this, |
| 252 | &VideoCache::scheduleCachingListUpdate); |
| 253 | connect(playlist.data(), |
| 254 | &PlaylistTreeWidget::itemAboutToBeDeleted, |
| 255 | this, |
| 256 | &VideoCache::itemAboutToBeDeleted); |
| 257 | connect( |
| 258 | playlist.data(), &PlaylistTreeWidget::signalItemRecache, this, &VideoCache::itemNeedsRecache); |
| 259 | connect(playback.data(), |
| 260 | &PlaybackController::waitForItemCaching, |
| 261 | this, |
| 262 | &VideoCache::watchItemForCachingFinished); |
| 263 | connect(playback.data(), |
| 264 | &PlaybackController::signalPlaybackStarting, |
| 265 | this, |
| 266 | &VideoCache::updateCacheQueue); |
| 267 | connect(&statusUpdateTimer, &QTimer::timeout, this, [=] { emit updateCacheStatus(); }); |
| 268 | connect(&testProgrssUpdateTimer, &QTimer::timeout, this, [=] { updateTestProgress(); }); |
| 269 | } |
| 270 | |
| 271 | VideoCache::~VideoCache() |
| 272 | { |