Files
oak-editor/app/widget/viewer/viewerqueue.h
T
Mike-Solar e85c6cf60a fix: OFX param instance lifecycle and thread-safety fixes
- Fix SIGSEGV in PluginMisc.Keyer by linking Param::SetInstance to instances.
    Olive's custom param instances (IntegerInstance, DoubleInstance, etc.) were
    not passing the SetInstance pointer to the OpenFX HostSupport base class,
    leaving _paramSetInstance as nullptr. When Keyer called paramSetValue during
    createInstanceAction, the suite function dereferenced the null pointer in
    paramChangedByPlugin(). Now newParam() passes 'this' to every constructor.

  - Fix render-thread crash when OFX plugins set params during rendering.
    MinOFX calls paramSetValue inside createInstanceAction from the render
    thread. SubmitUndoCommand() used to push undo commands directly to
    UndoStack, which modifies QAction state (GUI-only). Added IsGuiThread()
    check: non-GUI threads execute redo_now() and discard the command without
    touching the undo stack.

  - Enable PluginMisc.MergeOver and PluginMisc.Keyer integration tests.
    MergeOver now supplies both Source and Bg textures; Keyer uses U16 format.
    Both pass in the full test suite.

  - Make ViewerQueue thread-safe with QMutex around AppendTimewise/PurgeBefore.
    Adds copy ctor and assignment to support mutex-per-instance semantics.
2026-05-14 22:32:34 +08:00

86 lines
2.1 KiB
C++

/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef VIEWERQUEUE_H
#define VIEWERQUEUE_H
#include <QVariant>
#include <QMutex>
#include <QMutexLocker>
#include "codec/frame.h"
namespace olive
{
struct ViewerPlaybackFrame {
rational timestamp;
QVariant frame;
};
class ViewerQueue : public std::list<ViewerPlaybackFrame> {
public:
ViewerQueue() : mutex_(new QMutex()) {}
ViewerQueue(const ViewerQueue &other)
: std::list<ViewerPlaybackFrame>(other), mutex_(new QMutex()) {}
~ViewerQueue() { delete mutex_; }
ViewerQueue &operator=(const ViewerQueue &other)
{
std::list<ViewerPlaybackFrame>::operator=(other);
return *this;
}
void AppendTimewise(const ViewerPlaybackFrame &f, int playback_speed)
{
QMutexLocker locker(mutex_);
if (this->empty() ||
(this->back().timestamp < f.timestamp) == (playback_speed > 0)) {
this->push_back(f);
} else {
for (auto i = this->begin(); i != this->end(); i++) {
if ((i->timestamp > f.timestamp) == (playback_speed > 0)) {
this->insert(i, f);
break;
}
}
}
}
void PurgeBefore(const rational &time, int playback_speed)
{
QMutexLocker locker(mutex_);
while (!this->empty() &&
((playback_speed > 0 && this->front().timestamp < time) ||
(playback_speed < 0 && this->front().timestamp > time))) {
this->pop_front();
}
}
private:
QMutex *mutex_;
};
}
Q_DECLARE_METATYPE(olive::ViewerPlaybackFrame)
#endif // VIEWERQUEUE_H