MCPcopy Create free account
hub / github.com/IENT/YUView / updateStatus

Method updateStatus

YUViewLib/src/ui/widgets/VideoCacheInfoWidget.cpp:93–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void VideoCacheStatusWidget::updateStatus(PlaylistTreeWidget *playlist, unsigned int cacheRate)
94{
95 // Get all items from the playlist
96 QList<playlistItem *> allItems = playlist->getAllPlaylistItems();
97
98 // Get if caching is enabled and how much memory we can use for the cache
99 QSettings settings;
100 settings.beginGroup("VideoCache");
101 cacheLevelMaxMB = settings.value("ThresholdValueMB", 49).toUInt();
102 const int64_t cacheLevelMax = cacheLevelMaxMB * 1000 * 1000;
103 settings.endGroup();
104
105 // Clear the old percent values
106 relativeValsEnd.clear();
107
108 // Let's find out how much space in the cache is used.
109 // In combination with cacheLevelMax we also know how much space is free.
110 int64_t cacheLevel = 0;
111 for (int i = 0; i < allItems.count(); i++)
112 {
113 playlistItem *item = allItems.at(i);
114 int nrFrames = item->getNumberCachedFrames();
115 unsigned int frameSize = item->getCachingFrameSize();
116 int64_t itemCacheSize = nrFrames * frameSize;
117 DEBUG_CACHINGINFO("VideoCacheStatusWidget::updateStatus Item %d frames %d * size %d = %d",
118 i,
119 nrFrames,
120 frameSize,
121 (int)itemCacheSize);
122
123 float endVal = (float)(cacheLevel + itemCacheSize) / cacheLevelMax;
124 relativeValsEnd.append(endVal);
125 cacheLevel += itemCacheSize;
126 }
127
128 // Save the values that will be shown as text
129 cacheLevelMB = cacheLevel / 1000000;
130 cacheRateInBytesPerMs = cacheRate;
131
132 // Also redraw if the values were updated
133 update();
134}
135
136/// ------------------------- VideoCacheInfoWidget -----------------------
137

Callers 1

onUpdateCacheStatusMethod · 0.80

Calls 6

getAllPlaylistItemsMethod · 0.80
appendMethod · 0.80
clearMethod · 0.45
atMethod · 0.45
getNumberCachedFramesMethod · 0.45
getCachingFrameSizeMethod · 0.45

Tested by

no test coverage detected