]> git.sesse.net Git - kdenlive/blobdiff - src/renderer.h
Fix some avformat producer concurrency crashes
[kdenlive] / src / renderer.h
index cb2183b1bb12a275c32e88e216bf93229591efe6..04d8452c7bf1656c9eda0d3fec76652b20305985 100644 (file)
@@ -42,6 +42,7 @@
 #include <QList>
 #include <QEvent>
 #include <QMutex>
+#include <QFuture>
 
 class QTimer;
 class QPixmap;
@@ -60,6 +61,18 @@ class Profile;
 class Service;
 };
 
+struct requestClipInfo {
+    QDomElement xml;
+    QString clipId;
+    int imageHeight;
+    bool replaceProducer;
+
+bool operator==(const requestClipInfo &a)
+{
+    return clipId == a.clipId;
+}
+};
+
 class MltErrorEvent : public QEvent
 {
 public:
@@ -270,6 +283,22 @@ Q_OBJECT public:
 
     /** @brief Returns a pointer to the main producer. */
     Mlt::Producer *getProducer();
+    /** @brief Returns the number of clips to process (When requesting clip info). */
+    int processingItems() const;
+    /** @brief Force processing of clip with selected id. */
+    void forceProcessing(const QString &id);
+
+    /** @brief Requests the file properties for the specified URL (will be put in a queue list)
+        @param xml The xml parameters for the clip
+        @param clipId The clip Id string
+        @param imageHeight The height (in pixels) of the returned thumbnail (height of a treewidgetitem in projectlist)
+        @param replaceProducer If true, the MLT producer will be recreated */
+    void getFileProperties(const QDomElement &xml, const QString &clipId, int imageHeight, bool replaceProducer = true);
+
+    /** @brief Lock the MLT service */
+    void lock();
+    /** @brief Unlock the MLT service */
+    void unlock();
 
 private:
 
@@ -302,11 +331,14 @@ private:
 
     QTimer *m_osdTimer;
     QMutex m_mutex;
+    QMutex m_infoMutex;
 
     /** @brief A human-readable description of this renderer. */
     int m_winid;
 
     QLocale m_locale;
+    QFuture <void> m_infoThread;
+    QList <requestClipInfo> m_requestList;
 
     void closeMlt();
     void mltCheckLength(Mlt::Tractor *tractor);
@@ -325,6 +357,8 @@ private:
 
     /** @brief Make sure our audio mixing transitions are applied to the lowest track */
     void fixAudioMixing(Mlt::Tractor tractor);
+    /** @brief Make sure we inform MLT if we need a lot of threads for avformat producer */
+    void checkMaxThreads();
 
 private slots:
 
@@ -332,15 +366,17 @@ private slots:
     void refresh();
     void slotOsdTimeout();
     int connectPlaylist();
-    //void initSceneList();
+    /** @brief Process the clip info requests (in a separate thread). */
+    void processFileProperties();
 
 signals:
 
     /** @brief The renderer received a reply to a getFileProperties request. */
-    void replyGetFileProperties(const QString &clipId, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool);
+    void replyGetFileProperties(const QString &clipId, Mlt::Producer*, const stringMap &, const stringMap &, bool replaceProducer, bool refreshThumbnail = false);
 
     /** @brief The renderer received a reply to a getImage request. */
-    void replyGetImage(const QString &, const QPixmap &);
+    void replyGetImage(const QString &, const QString &, int, int);
+    void replyGetImage(const QString &, const QImage &);
 
     /** @brief The renderer stopped, either playing or rendering. */
     void stopped();
@@ -386,16 +422,6 @@ public slots:
     /** @brief Checks if the file is readable by MLT. */
     bool isValid(KUrl url);
 
-    /** @brief Requests the file properties for the specified URL.
-        @param xml The xml parameters for the clip
-        @param clipId The clip Id string
-        @param imageHeight The height (in pixels) of the returned thumbnail (height of a treewidgetitem in projectlist)
-        @param replaceProducer If true, the MLT producer will be recreated
-        @param selectClip If true, clip item will be selected in project view
-     * Upon return, the result will be emitted via replyGetFileProperties().
-     * Wraps the VEML command of the same name. */
-    void getFileProperties(const QDomElement &xml, const QString &clipId, int imageHeight, bool replaceProducer = true, bool selectClip = false);
-
     void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
     void mltSavePlaylist();
     void slotSplitView(bool doit);