viewer: set video and audio caches to children of the viewer

Ensures their thread gets changed along with the viewer. The project
gets loaded/created in a background thread so the GUI can remain
responsive, and is then moved to the main thread for intended event
handling. However if the caches aren't parented, the hierarchy breaks
and the caches remain in a thread whose event loop is quickly destroyed.
Now that they're parented, events can be properly queued on them once
again.
This commit is contained in:
itsmattkc
2020-07-10 18:34:16 +10:00
parent df78e88150
commit 36dd06d2dc
5 changed files with 17 additions and 7 deletions
+3 -1
View File
@@ -24,7 +24,9 @@
OLIVE_NAMESPACE_ENTER
ViewerOutput::ViewerOutput()
ViewerOutput::ViewerOutput() :
video_frame_cache_(this),
audio_playback_cache_(this)
{
texture_input_ = new NodeInput("tex_in", NodeInput::kTexture);
AddInput(texture_input_);
+2 -1
View File
@@ -28,7 +28,8 @@
OLIVE_NAMESPACE_ENTER
AudioPlaybackCache::AudioPlaybackCache()
AudioPlaybackCache::AudioPlaybackCache(QObject* parent) :
PlaybackCache(parent)
{
quint32 r = std::rand();
UpdateFilename(QString::number(r));
+1 -1
View File
@@ -31,7 +31,7 @@ class AudioPlaybackCache : public PlaybackCache
{
Q_OBJECT
public:
AudioPlaybackCache();
AudioPlaybackCache(QObject* parent = nullptr);
AudioParams GetParameters() {
QMutexLocker locker(lock());
+7 -3
View File
@@ -35,12 +35,13 @@ class FrameHashCache : public PlaybackCache
{
Q_OBJECT
public:
FrameHashCache() = default;
FrameHashCache(QObject* parent = nullptr) :
PlaybackCache(parent)
{
}
QByteArray GetHash(const rational& time);
void SetHash(const rational& time, const QByteArray& hash, const qint64 &job_time);
void SetTimebase(const rational& tb);
/**
@@ -72,6 +73,9 @@ public:
QVector<rational> GetFrameListFromTimeRange(const TimeRangeList &range);
QVector<rational> GetInvalidatedFrames();
public slots:
void SetHash(const OLIVE_NAMESPACE::rational& time, const QByteArray& hash, const qint64 &job_time);
protected:
virtual void LengthChangedEvent(const rational& old, const rational& newlen) override;
+4 -1
View File
@@ -32,7 +32,10 @@ class PlaybackCache : public QObject
{
Q_OBJECT
public:
PlaybackCache() = default;
PlaybackCache(QObject* parent = nullptr) :
QObject(parent)
{
}
void Invalidate(const TimeRange& r);