cache: cancel tasks on disable
This commit is contained in:
@@ -127,12 +127,6 @@ void ClipBlock::set_media_in(const rational &media_in)
|
||||
void ClipBlock::SetAutocache(bool e)
|
||||
{
|
||||
SetStandardValue(kAutoCacheInput, e);
|
||||
|
||||
if (e) {
|
||||
RequestInvalidatedFromConnected();
|
||||
} else {
|
||||
qDebug() << "FIXME: signal that frames for this clip should be unqueued";
|
||||
}
|
||||
}
|
||||
|
||||
rational ClipBlock::SequenceToMediaTime(const rational &sequence_time, bool ignore_reverse, bool ignore_speed) const
|
||||
@@ -189,7 +183,7 @@ rational ClipBlock::MediaToSequenceTime(const rational &media_time) const
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
void ClipBlock::RequestInvalidatedFromConnected()
|
||||
void ClipBlock::RequestInvalidatedFromConnected(const TimeRange &range)
|
||||
{
|
||||
Track::Type type = GetTrackType();
|
||||
|
||||
@@ -198,39 +192,39 @@ void ClipBlock::RequestInvalidatedFromConnected()
|
||||
TimeRange max_range = InputTimeAdjustment(kBufferIn, -1, TimeRange(0, length()));
|
||||
if (type == Track::kVideo) {
|
||||
// Handle thumbnails
|
||||
{
|
||||
TimeRangeList invalid = connected->thumbnail_cache()->GetInvalidatedRanges(max_range);
|
||||
for (const TimeRange &r : invalid) {
|
||||
emit connected->thumbnail_cache()->Request(r, PlaybackCache::kPreviewsOnly);
|
||||
}
|
||||
}
|
||||
RequestInvalidatedForCache(connected->thumbnail_cache(), max_range, range);
|
||||
|
||||
// Handle video cache
|
||||
if (IsAutocaching()) {
|
||||
TimeRangeList invalid = connected->video_frame_cache()->GetInvalidatedRanges(max_range);
|
||||
for (const TimeRange &r : invalid) {
|
||||
emit connected->video_frame_cache()->Request(r, PlaybackCache::kPreviewsOnly);
|
||||
}
|
||||
RequestInvalidatedForCache(connected->video_frame_cache(), max_range, range);
|
||||
}
|
||||
} else if (type == Track::kAudio) {
|
||||
{
|
||||
TimeRangeList invalid = connected->waveform_cache()->GetInvalidatedRanges(max_range);
|
||||
for (const TimeRange &r : invalid) {
|
||||
emit connected->waveform_cache()->Request(r, PlaybackCache::kPreviewsOnly);
|
||||
}
|
||||
}
|
||||
// Handle waveforms
|
||||
RequestInvalidatedForCache(connected->waveform_cache(), max_range, range);
|
||||
|
||||
// Handle audio cache
|
||||
if (IsAutocaching()) {
|
||||
TimeRangeList invalid = connected->audio_playback_cache()->GetInvalidatedRanges(max_range);
|
||||
for (const TimeRange &r : invalid) {
|
||||
emit connected->audio_playback_cache()->Request(r, PlaybackCache::kPreviewsOnly);
|
||||
}
|
||||
RequestInvalidatedForCache(connected->audio_playback_cache(), max_range, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::RequestInvalidatedForCache(PlaybackCache *cache, const TimeRange &max_range, const TimeRange &range)
|
||||
{
|
||||
if ((range.in() == RATIONAL_MIN && range.out() == RATIONAL_MAX) || !range.length().isNull()) {
|
||||
// Request only this range
|
||||
emit cache->Request(range.Intersected(max_range));
|
||||
} else {
|
||||
// Request all ranges currently marked as invalid
|
||||
TimeRangeList invalid = cache->GetInvalidatedRanges(max_range);
|
||||
for (const TimeRange &r : invalid) {
|
||||
emit cache->Request(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
@@ -238,7 +232,7 @@ void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int
|
||||
// If signal is from texture input, transform all times from media time to sequence time
|
||||
if (from == kBufferIn) {
|
||||
// Render caches where necessary
|
||||
RequestInvalidatedFromConnected();
|
||||
RequestInvalidatedFromConnected(range);
|
||||
|
||||
// Adjust range from media time to sequence time
|
||||
TimeRange adj;
|
||||
@@ -311,6 +305,27 @@ void ClipBlock::InputDisconnectedEvent(const QString &input, int element, Node *
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
super::InputValueChangedEvent(input, element);
|
||||
|
||||
if (input == kAutoCacheInput) {
|
||||
if (IsAutocaching()) {
|
||||
RequestInvalidatedFromConnected();
|
||||
} else {
|
||||
Track::Type type = GetTrackType();
|
||||
|
||||
if (Node *connected = GetConnectedOutput(kBufferIn)) {
|
||||
if (type == Track::kVideo) {
|
||||
emit connected->video_frame_cache()->CancelAll();
|
||||
} else if (type == Track::kAudio) {
|
||||
emit connected->audio_playback_cache()->CancelAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange ClipBlock::InputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
@@ -178,12 +178,16 @@ protected:
|
||||
|
||||
virtual void InputDisconnectedEvent(const QString& input, int element, Node *output) override;
|
||||
|
||||
virtual void InputValueChangedEvent(const QString& input, int element) override;
|
||||
|
||||
private:
|
||||
rational SequenceToMediaTime(const rational& sequence_time, bool ignore_reverse = false, bool ignore_speed = false) const;
|
||||
|
||||
rational MediaToSequenceTime(const rational& media_time) const;
|
||||
|
||||
void RequestInvalidatedFromConnected();
|
||||
void RequestInvalidatedFromConnected(const TimeRange &range = TimeRange());
|
||||
|
||||
void RequestInvalidatedForCache(PlaybackCache *cache, const TimeRange &max_range, const TimeRange &range);
|
||||
|
||||
QVector<Block*> block_links_;
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ Node::Node() :
|
||||
AddInput(kEnabledInput, NodeValue::kBoolean, true);
|
||||
|
||||
video_cache_ = new FrameHashCache(this);
|
||||
thumbnail_cache_ = new FrameHashCache(this);
|
||||
thumbnail_cache_ = new ThumbnailCache(this);
|
||||
audio_cache_ = new AudioPlaybackCache(this);
|
||||
waveform_cache_ = new AudioWaveformCache(this);
|
||||
}
|
||||
|
||||
+2
-2
@@ -227,7 +227,7 @@ public:
|
||||
return video_cache_;
|
||||
}
|
||||
|
||||
FrameHashCache* thumbnail_cache() const
|
||||
ThumbnailCache* thumbnail_cache() const
|
||||
{
|
||||
return thumbnail_cache_;
|
||||
}
|
||||
@@ -1416,7 +1416,7 @@ private:
|
||||
QString effect_input_;
|
||||
|
||||
FrameHashCache *video_cache_;
|
||||
FrameHashCache *thumbnail_cache_;
|
||||
ThumbnailCache *thumbnail_cache_;
|
||||
|
||||
AudioPlaybackCache *audio_cache_;
|
||||
AudioWaveformCache *waveform_cache_;
|
||||
|
||||
@@ -226,13 +226,13 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from,
|
||||
//emit connected->thumbnail_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
if (autocache_input_video_) {
|
||||
TimeRange max_range = InputTimeAdjustment(from, element, TimeRange(0, GetVideoLength()));
|
||||
emit connected->video_frame_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
emit connected->video_frame_cache()->Request(range.Intersected(max_range));
|
||||
}
|
||||
} else if (from == kSamplesInput) {
|
||||
TimeRange max_range = InputTimeAdjustment(from, element, TimeRange(0, GetAudioLength()));
|
||||
emit connected->waveform_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
emit connected->waveform_cache()->Request(range.Intersected(max_range));
|
||||
if (autocache_input_audio_) {
|
||||
emit connected->audio_playback_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
emit connected->audio_playback_cache()->Request(range.Intersected(max_range));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,7 +392,7 @@ void ViewerOutput::ConnectedToPreviewEvent()
|
||||
TimeRange max_range = InputTimeAdjustment(kSamplesInput, -1, TimeRange(0, GetAudioLength()));
|
||||
TimeRangeList invalid = connected->waveform_cache()->GetInvalidatedRanges(max_range);
|
||||
for (const TimeRange &r : invalid) {
|
||||
emit connected->waveform_cache()->Request(r, PlaybackCache::kPreviewsOnly);
|
||||
emit connected->waveform_cache()->Request(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,9 @@ public:
|
||||
|
||||
virtual void ConnectedToPreviewEvent() override;
|
||||
|
||||
bool IsVideoAutoCacheEnabled() const { qDebug() << "sequence ac is a stub"; return false; }
|
||||
void SetVideoAutoCacheEnabled(bool e) { qDebug() << "sequence ac is a stub"; }
|
||||
|
||||
static const QString kVideoParamsInput;
|
||||
static const QString kAudioParamsInput;
|
||||
static const QString kSubtitleParamsInput;
|
||||
|
||||
Reference in New Issue
Block a user