Commit 1168b7b0 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Ensure bin audio thumbnails are loaded on project open

parent a07509ba
......@@ -123,7 +123,9 @@ ProjectClip::ProjectClip(const QString &id, const QIcon &thumb, const std::share
// Generate clip thumbnail
ClipLoadTask::start({ObjectType::BinClip,m_binId.toInt()}, QDomElement(), true, -1, -1, this);
// Generate audio thumbnail
AudioLevelsTask::start({ObjectType::BinClip, m_binId.toInt()}, this, false);
if (m_clipType == ClipType::AV || m_clipType == ClipType::Audio || m_clipType == ClipType::Playlist || m_clipType == ClipType::Unknown) {
AudioLevelsTask::start({ObjectType::BinClip, m_binId.toInt()}, this, false);
}
}
}
......@@ -532,7 +534,9 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer)
getFileHash();
// set parent again (some info need to be stored in producer)
updateParent(parentItem().lock());
AudioLevelsTask::start({ObjectType::BinClip, m_binId.toInt()}, this, false);
if (m_clipType == ClipType::AV || m_clipType == ClipType::Audio || m_clipType == ClipType::Playlist || m_clipType == ClipType::Unknown) {
AudioLevelsTask::start({ObjectType::BinClip, m_binId.toInt()}, this, false);
}
pCore->bin()->reloadMonitorIfActive(clipId());
for (auto &p : m_audioProducers) {
m_effectStack->removeService(p.second);
......
......@@ -104,6 +104,7 @@ void AudioLevelsTask::run()
QMap <int, QString> streams = binClip->audioInfo()->streams();
QMap <int, int> audioChannels = binClip->audioInfo()->streamChannels();
QMapIterator<int, QString> st(streams);
bool audioCreated = false;
while (st.hasNext() && !m_isCanceled) {
st.next();
int stream = st.key();
......@@ -113,7 +114,6 @@ void AudioLevelsTask::run()
// Generate one thumb per stream
QString cachePath = binClip->getAudioThumbPath(stream);
QVector <uint8_t> mltLevels;
qDebug()<<" TESTING AUDIO CACHE : "<<cachePath;
if (!m_isForce && QFile::exists(cachePath)) {
// Audio thumb already exists
QImage image(cachePath);
......@@ -223,7 +223,6 @@ void AudioLevelsTask::run()
//qDebug()<<"=== FINISHED PRODUCING AUDIO FOR: "<<key<<", SIZE: "<<levelsCopy->size();
m_progress = 100;
QMetaObject::invokeMethod(m_object, "updateJobProgress");
QMetaObject::invokeMethod(m_object, "updateAudioThumbnail");
// Put into an image for caching.
int count = mltLevels.size();
QImage image((count + 3) / 4 / channels, channels, QImage::Format_ARGB32);
......@@ -243,8 +242,14 @@ void AudioLevelsTask::run()
image.setPixel(i / 2, i % channels, p);
}
image.save(cachePath);
audioCreated = true;
QMetaObject::invokeMethod(m_object, "updateAudioThumbnail");
}
}
if (!audioCreated) {
// Audio was cached, ensure the bin thumbnail is loaded
QMetaObject::invokeMethod(m_object, "updateAudioThumbnail");
}
pCore->taskManager.taskDone(m_owner.second, this);
QMetaObject::invokeMethod(m_object, "updateJobProgress");
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment