m_audioThumbCreated(false),
m_id(id),
m_placeHolder(xml.hasAttribute("placeholder")),
- m_properties()
+ m_properties(),
+ m_abortProxy(false)
{
int type = xml.attribute("type").toInt();
m_clipType = (CLIPTYPE) type;
void DocClipBase::slotGenerateProxy(QStringList parameters)
{
- int result = QProcess::execute("ffmpeg", parameters);
+ QProcess myProcess;
+ myProcess.start("ffmpeg", parameters);
+ myProcess.waitForStarted();
+ int result = -1;
+ while (myProcess.state() != QProcess::NotRunning) {
+ // building proxy file
+ if (m_abortProxy) {
+ QString path = getProperty("proxy");
+ myProcess.close();
+ myProcess.waitForFinished();
+ QFile::remove(path);
+ m_abortProxy = false;
+ result = 1;
+ }
+ myProcess.waitForFinished(500);
+ }
+ myProcess.waitForFinished();
+ if (result == -1) result = myProcess.exitStatus();
if (result == 0) emit proxyReady(m_id, true);
else {
- resetProducerProperty("proxy");
+ clearProperty("proxy");
+ emit proxyReady(m_id, false);
+ }
+}
+
+void DocClipBase::abortProxy()
+{
+ if (m_proxyThread.isRunning()) {
+ // Proxy is being created, abort
+ m_abortProxy = true;
+ }
+ else {
+ clearProperty("proxy");
emit proxyReady(m_id, false);
}
}
void setPlaceHolder(bool place);
/** @brief Generate a proxy clip (lower resolution copy) named like the clip's hash. */
void generateProxy(KUrl proxyFolder);
+ /** @brief Abort creation of the proxy clip (lower resolution copy). */
+ void abortProxy();
private: // Private attributes
bool m_placeHolder;
QList <CutZoneInfo> m_cutZones;
-
- QFuture<void> m_proxyThread;
void setAudioThumbCreated(bool isDone);
/** Holds clip infos like fps, size,... */
QMap <QString, QString> m_properties;
/** Holds clip metadata like author, copyright,... */
QMap <QString, QString> m_metadata;
+
+ QFuture<void> m_proxyThread;
+ /** Used to kill the proxy thread */
+ bool m_abortProxy;
/** Create connections for audio thumbnails */
void slotCreateAudioTimer();
void slotRefreshProducer();
void ProjectItem::setProxyStatus(int status)
{
+ if (status == data(0, ProxyRole).toInt()) return;
setData(0, ProxyRole, status);
+ if (m_clip && status == 0) m_clip->abortProxy();
}
bool ProjectItem::hasProxy() const
{
- return data(0, ProxyRole).toInt() == 2;
+ if (m_clip == NULL) return false;
+ return !m_clip->getProperty("proxy").isEmpty();
}
+
+bool ProjectItem::isProxyRunning() const
+{
+ return (data(0, ProxyRole).toInt() == 1);
+}
+
void slotSetToolTip();
/** \brief Set the status of proxy clip creation. 0 = no proxy, 1 = creating proxy, 2 = proxy created. */
void setProxyStatus(int status);
- /** \brief Returns the proxy status for this clip (true means there is a proxy clip. */
+ /** \brief Returns the proxy status for this clip (true means there is a proxy clip). */
bool hasProxy() const;
+ /** \brief Returns true if we are currently creating the proxy for this clip. */
+ bool isProxyRunning() const;
virtual bool operator<(const QTreeWidgetItem &other)const {
int column = treeWidget()->sortColumn();
}
else if (!item->referencedClip()->getProperty("proxy").isEmpty()) {
// remove proxy
- item->referencedClip()->clearProperty("proxy");
- QDomElement e = item->toXml().cloneNode().toElement();
- e.removeAttribute("file_hash");
- e.setAttribute("replace", 1);
- m_infoQueue.insert(item->clipId(), e);
+ if (!item->isProxyRunning()) {
+ setProxyStatus(item, 0);
+ QDomElement e = item->toXml().cloneNode().toElement();
+ e.removeAttribute("file_hash");
+ e.setAttribute("replace", 1);
+ m_infoQueue.insert(item->clipId(), e);
+ }
+ else setProxyStatus(item, 0);
}
}
}