Commit 2c87162c authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix thumbnails for audio clips in bin

parent fd237161
Pipeline #62120 passed with stage
in 8 minutes and 18 seconds
......@@ -216,7 +216,7 @@ void ProjectClip::updateAudioThumbnail()
emit audioThumbReady();
if (m_clipType == ClipType::Audio) {
QImage thumb = ThumbnailCache::get()->getThumbnail(m_binId, 0);
if (thumb.isNull()) {
if (thumb.isNull() && !pCore->taskManager.hasPendingJob({ObjectType::BinClip, m_binId.toInt()}, AbstractTask::AUDIOTHUMBJOB)) {
int iconHeight = int(QFontInfo(qApp->font()).pixelSize() * 3.5);
QImage img(QSize(int(iconHeight * pCore->getCurrentDar()), iconHeight), QImage::Format_ARGB32);
img.fill(Qt::darkGray);
......@@ -257,7 +257,9 @@ void ProjectClip::updateAudioThumbnail()
// Cache thumbnail
ThumbnailCache::get()->storeThumbnail(m_binId, 0, thumb, true);
}
setThumbnail(thumb, -1, -1);
if (!thumb.isNull()) {
setThumbnail(thumb, -1, -1);
}
}
if (!KdenliveSettings::audiothumbnails()) {
return;
......
......@@ -205,11 +205,11 @@ void AudioLevelsTask::run()
for (double &v : mltLevels) {
m_audioLevels << uchar(255 * v / maxLevel);
}*/
m_progress = 100;
if (m_isCanceled) {
mltLevels.clear();
m_progress = 100;
QMetaObject::invokeMethod(m_object, "updateJobProgress");
}
QMetaObject::invokeMethod(m_object, "updateJobProgress");
if (mltLevels.size() > 0) {
QVector <uint8_t>* levelsCopy = new QVector <uint8_t>(mltLevels);
producer->lock();
......@@ -217,6 +217,8 @@ void AudioLevelsTask::run()
producer->set(key.toUtf8().constData(), levelsCopy, 0, (mlt_destructor) deleteQVariantList);
producer->unlock();
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();
......
......@@ -235,9 +235,9 @@ void ClipLoadTask::processSlideShow(std::shared_ptr<Mlt::Producer> producer)
void ClipLoadTask::generateThumbnail(std::shared_ptr<ProjectClip>binClip, std::shared_ptr<Mlt::Producer> producer)
{
// Fetch thumbnail
qDebug()<<"===== \nREADY FOR THUMB\n\n=========";
qDebug()<<"===== \nREADY FOR THUMB"<<binClip->clipType()<<"\n\n=========";
int frameNumber = m_in > -1 ? m_in : qMax(0, binClip->getProducerIntProperty(QStringLiteral("kdenlive:thumbnailFrame")));
if (binClip->clipType() != ClipType::Audio) {
if (binClip->clipType() != ClipType::Audio && producer->get_int("video_index") > -1) {
if (ThumbnailCache::get()->hasThumbnail(QString::number(m_owner.second), frameNumber, false)) {
// Thumbnail found in cache
QImage result = ThumbnailCache::get()->getThumbnail(QString::number(m_owner.second), frameNumber);
......
......@@ -82,7 +82,7 @@ bool TaskManager::hasPendingJob(const ObjectId &owner, AbstractTask::JOBTYPE typ
}
std::vector<AbstractTask*> taskList = m_taskList.at(owner.second);
for (AbstractTask* t : taskList) {
if (type == t->m_type) {
if (type == t->m_type && t->m_progress < 100) {
return true;
}
}
......
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