m_endPix = QPixmap();
m_audioThumbCachePic.clear();
}
+ kDebug()<<"........... RESET THMBS";
slotFetchThumbs();
}
void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readPropertiesFromProducer)
{
if (producer == NULL || !producer->is_valid()) return;
- if (reset) m_producerMutex.lock();
+ if (reset) QMutexLocker locker(&m_producerMutex);
if (m_placeHolder) {
char *tmp = qstrdup(i18n("Missing clip").toUtf8().constData());
producer->set("markup", tmp);
m_audioTrackProducers[pos] = producer;
updated = true;
}
- if (reset) m_producerMutex.unlock();
return;
} else if (id.endsWith("video")) {
if (m_videoOnlyProducer == NULL) {
m_videoOnlyProducer = producer;
updated = true;
}
- if (reset) m_producerMutex.unlock();
return;
}
int pos = id.toInt();
}
if (updated && readPropertiesFromProducer && (m_clipType != COLOR && m_clipType != IMAGE && m_clipType != TEXT))
setDuration(GenTime(producer->get_length(), KdenliveSettings::project_fps()));
- if (reset) m_producerMutex.unlock();
}
static double getPixelAspect(QMap<QString, QString>& props) {
Mlt::Producer *DocClipBase::audioProducer(int track)
{
- m_producerMutex.lock();
+ QMutexLocker locker(&m_producerMutex);
if (m_audioTrackProducers.count() <= track) {
while (m_audioTrackProducers.count() - 1 < track) {
m_audioTrackProducers.append(NULL);
Mlt::Producer *base;
if (i >= m_audioTrackProducers.count()) {
// Could not find a valid producer for that clip
- m_producerMutex.unlock();
+ locker.unlock();
base = producer();
if (base == NULL) {
return NULL;
}
- m_producerMutex.lock();
+ locker.relock();
}
else base = m_audioTrackProducers.at(i);
m_audioTrackProducers[track] = cloneProducer(base);
adjustProducerProperties(m_audioTrackProducers.at(track), QString(getId() + '_' + QString::number(track) + "_audio"), false, true);
}
- m_producerMutex.unlock();
return m_audioTrackProducers.at(track);
}
Mlt::Producer *DocClipBase::videoProducer()
{
- m_producerMutex.lock();
+ QMutexLocker locker(&m_producerMutex);
if (m_videoOnlyProducer == NULL) {
int i;
for (i = 0; i < m_baseTrackProducers.count(); i++)
m_videoOnlyProducer = cloneProducer(m_baseTrackProducers.at(i));
adjustProducerProperties(m_videoOnlyProducer, QString(getId() + "_video"), true, false);
}
- m_producerMutex.unlock();
return m_videoOnlyProducer;
}
Mlt::Producer *DocClipBase::producer(int track)
{
- m_producerMutex.lock();
+ QMutexLocker locker(&m_producerMutex);
if (track == -1 || (m_clipType != AUDIO && m_clipType != AV && m_clipType != PLAYLIST)) {
if (m_baseTrackProducers.count() == 0) {
- m_producerMutex.unlock();
return NULL;
}
for (int i = 0; i < m_baseTrackProducers.count(); i++) {
if (m_baseTrackProducers.at(i) != NULL) {
- m_producerMutex.unlock();
return m_baseTrackProducers.at(i);
}
}
- m_producerMutex.unlock();
return NULL;
}
if (track >= m_baseTrackProducers.count()) {
if (i >= m_baseTrackProducers.count()) {
// Could not find a valid producer for that clip, check in
- m_producerMutex.unlock();
return NULL;
}
m_baseTrackProducers[track] = cloneProducer(m_baseTrackProducers.at(i));
adjustProducerProperties(m_baseTrackProducers.at(track), QString(getId() + '_' + QString::number(track)), false, false);
}
- m_producerMutex.unlock();
return m_baseTrackProducers.at(track);
}
m_thumbProd->extractImage(frame, frame2);
}
-void DocClipBase::slotBlock()
-{
- m_producerMutex.lock();
-}
-
-void DocClipBase::slotRelease()
-{
- m_producerMutex.unlock();
-}
-
QPixmap DocClipBase::extractImage(int frame, int width, int height)
{
if (m_thumbProd == NULL) return QPixmap(width, height);
- m_producerMutex.lock();
+ QMutexLocker locker(&m_producerMutex);
QPixmap p = m_thumbProd->extractImage(frame, width, height);
- m_producerMutex.unlock();
return p;
}
QMap <QString, QString> properties() const;
QMap <QString, QString> metadata() const;
void slotExtractImage(int frame, int frame2);
- /** @brief Lock mutex to prevent changing producers while operation. */
- void slotBlock();
- /** @brief Release mutex preventing a change in producers. */
- void slotRelease();
signals:
void gotAudioData();
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="kdenlive" version="63">
+<gui name="kdenlive" version="64">
<ToolBar name="extraToolBar" >
<text>Extra Toolbar</text>
<Action name="project_render" />
<Action name="stopmotion" />
<Separator />
<Action name="reload_clip" />
+ <Action name="proxy_clip" />
<Menu name="clip_in_timeline"><text>Clip in Timeline</text>
</Menu>
<Action name="clip_properties" />
void KThumb::updateClipUrl(KUrl url, const QString &hash)
{
m_url = url;
- if (m_producer)
- m_producer->set("resource", url.path().toUtf8().constData());
+ //if (m_producer)
+ //m_producer->set("resource", url.path().toUtf8().constData());
m_thumbFile = m_clipManager->projectFolder() + "/thumbs/" + hash + ".thumb";
}
connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
reloadClip->setEnabled(false);
+ QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
+ collection.addAction("proxy_clip", proxyClip);
+ proxyClip->setData("proxy_clip");
+ proxyClip->setCheckable(true);
+ proxyClip->setChecked(false);
+ connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
+
QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
collection.addAction("stopmotion", stopMotion);
connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
addClips->addAction(addFolderButton);
addClips->addAction(reloadClip);
+ addClips->addAction(proxyClip);
addClips->addAction(clipProperties);
addClips->addAction(openClip);
addClips->addAction(deleteClip);
setLayout(layout);
searchView->setTreeWidget(m_listView);
- m_proxyAction = new QAction(i18n("Proxy clip"), this);
- m_proxyAction->setCheckable(true);
- m_proxyAction->setChecked(false);
- connect(m_proxyAction, SIGNAL(toggled(bool)), this, SLOT(slotProxyCurrentItem(bool)));
connect(this, SIGNAL(processNextThumbnail()), this, SLOT(slotProcessNextThumbnail()));
connect(m_listView, SIGNAL(projectModified()), this, SIGNAL(projectModified()));
connect(m_listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
m_reloadAction = actions.at(i);
actions.removeAt(i);
i--;
+ } else if (actions.at(i)->data().toString() == "proxy_clip") {
+ m_proxyAction = actions.at(i);
+ actions.removeAt(i);
+ i--;
}
}
QMap<QString, QDomElement>::const_iterator j = m_infoQueue.constBegin();
if (j != m_infoQueue.constEnd()) {
- QDomElement dom = j.value();
+ QDomElement dom = j.value().cloneNode().toElement();
const QString id = j.key();
m_infoQueue.remove(id);
m_processingClips.append(id);
}
m_processingClips.removeAll(clipId);
if (m_infoQueue.isEmpty() && m_processingClips.isEmpty()) m_listView->setEnabled(true);
-
if (item && producer) {
//m_listView->blockSignals(true);
monitorItemEditing(false);
if (clip->getProperty("frame_size").section('x', 0, 0).toInt() > m_doc->getDocumentProperty("proxyminsize").toInt()) {
if (clip->getProperty("proxy").isEmpty()) {
// We need to insert empty proxy in old properties so that undo will work
- QMap <QString, QString> oldProps = clip->properties();
+ QMap <QString, QString> oldProps;// = clip->properties();
oldProps.insert("proxy", QString());
QMap <QString, QString> newProps;
newProps.insert("proxy", proxydir + item->referencedClip()->getClipHash() + "." + m_doc->getDocumentProperty("proxyextension"));
proxyProducer = false;
}
- KUrl url = KUrl(path);
+ KUrl url(path);
Mlt::Producer *producer = NULL;
CLIPTYPE type = (CLIPTYPE)xml.attribute("type").toInt();
//kDebug() << "PROFILE WIDT: "<< xml.attribute("mlt_service") << ": "<< m_mltProfile->width() << "\n...................\n\n";
play.appendChild(doc.importNode(xml, true));
producer = new Mlt::Producer(*m_mltProfile, "xml-string", doc.toString().toUtf8().constData());
} else {
- producer = new Mlt::Producer(*m_mltProfile, url.path().toUtf8().constData());
+ producer = new Mlt::Producer(*m_mltProfile, path.toUtf8().constData());
}
if (producer == NULL || producer->is_blank() || !producer->is_valid()) {
- kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: ";
+ kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: "<<path;
if (proxyProducer) {
// Proxy file is corrupted
emit removeInvalidProxy(clipId, false);
if ((!replaceProducer && xml.hasAttribute("file_hash")) || xml.hasAttribute("proxy")) {
// Clip already has all properties
if (replaceProducer) emit blockClipMonitor(clipId);
+ // Querying a frame is required by MLT, otherwise the producer is not correctly initialised
+ Mlt::Frame *frame = producer->get_frame();
+ delete frame;
emit replyGetFileProperties(clipId, producer, QMap < QString, QString >(), QMap < QString, QString >(), replaceProducer, selectClip);
return;
}
int Render::setProducer(Mlt::Producer *producer, int position)
{
+ QMutexLocker locker(&m_mutex);
if (m_winid == -1) return -1;
-
if (m_mltConsumer) {
if (!m_mltConsumer->is_stopped()) {
m_mltConsumer->stop();
}
m_mltConsumer->set("refresh", 0);
}
- else return -1;
+ else {
+ return -1;
+ }
m_isBlocked = true;
if (m_mltProducer) {
emit stopped();
}
blockSignals(true);
- if (producer) {
+ if (producer && producer->is_valid()) {
m_mltProducer = new Mlt::Producer(producer->get_producer());
} else m_mltProducer = m_blackClip->cut(0, 50);
#include <qmap.h>
#include <QList>
#include <QEvent>
-
+#include <QMutex>
class QTimer;
class QPixmap;
QString m_activeProfile;
QTimer *m_osdTimer;
+ QMutex m_mutex;
/** @brief A human-readable description of this renderer. */
int m_winid;
void removeInvalidProxy(const QString &id, bool durationError);
void refreshDocumentProducers(bool displayRatioChanged, bool fpsChanged);
- /** @brief If we will delete the producer, make sure to oause the monitor */
+ /** @brief If we will delete the producer, make sure to pause the monitor */
void blockClipMonitor(const QString);
/** @brief A frame's image has to be shown.