renderer: remove frames from hash map as well when the diskmanager deletes
them
This commit is contained in:
@@ -343,7 +343,7 @@ void VideoRenderBackend::TruncateFrameCacheLength(const rational &length)
|
||||
|
||||
void VideoRenderBackend::FrameRemovedFromDiskCache(const QByteArray &hash)
|
||||
{
|
||||
QList<rational> deleted_frames = frame_cache()->FramesWithHash(hash);
|
||||
QList<rational> deleted_frames = frame_cache()->TakeFramesWithHash(hash);
|
||||
|
||||
foreach (const rational& frame, deleted_frames) {
|
||||
TimeRange invalidated(frame, frame+params_.time_base());
|
||||
|
||||
@@ -83,7 +83,7 @@ void VideoRenderFrameCache::RemoveHashFromCurrentlyCaching(const QByteArray &has
|
||||
currently_caching_list_.removeOne(hash);
|
||||
}
|
||||
|
||||
QList<rational> VideoRenderFrameCache::FramesWithHash(const QByteArray &hash)
|
||||
QList<rational> VideoRenderFrameCache::FramesWithHash(const QByteArray &hash) const
|
||||
{
|
||||
QList<rational> times;
|
||||
|
||||
@@ -98,6 +98,25 @@ QList<rational> VideoRenderFrameCache::FramesWithHash(const QByteArray &hash)
|
||||
return times;
|
||||
}
|
||||
|
||||
QList<rational> VideoRenderFrameCache::TakeFramesWithHash(const QByteArray &hash)
|
||||
{
|
||||
QList<rational> times;
|
||||
|
||||
QMap<rational, QByteArray>::iterator iterator = time_hash_map_.begin();
|
||||
|
||||
while (iterator != time_hash_map_.end()) {
|
||||
if (iterator.value() == hash) {
|
||||
times.append(iterator.key());
|
||||
|
||||
iterator = time_hash_map_.erase(iterator);
|
||||
} else {
|
||||
iterator++;
|
||||
}
|
||||
}
|
||||
|
||||
return times;
|
||||
}
|
||||
|
||||
const QMap<rational, QByteArray> &VideoRenderFrameCache::time_hash_map() const
|
||||
{
|
||||
return time_hash_map_;
|
||||
|
||||
@@ -43,7 +43,15 @@ public:
|
||||
|
||||
void RemoveHashFromCurrentlyCaching(const QByteArray& hash);
|
||||
|
||||
QList<rational> FramesWithHash(const QByteArray& hash);
|
||||
/**
|
||||
* @brief Returns a list of frames that use a particular hash
|
||||
*/
|
||||
QList<rational> FramesWithHash(const QByteArray& hash) const;
|
||||
|
||||
/**
|
||||
* @brief Same as FramesWithHash() but also removes these frames from the map
|
||||
*/
|
||||
QList<rational> TakeFramesWithHash(const QByteArray& hash);
|
||||
|
||||
const QMap<rational, QByteArray>& time_hash_map() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user