Fix audio mix clicks when using recent MLT

BUG: 371849
parent 59616383
......@@ -22,7 +22,6 @@
#include "gentime.h"
#include "effectslist/effectslist.h"
#include "kdenlive_debug.h"
#include <QTreeWidgetItem>
......
......@@ -21,6 +21,7 @@
#include "definitions.h"
#include "effectslist/initeffects.h"
#include "timeline/transitionhandler.h"
#include "mainwindow.h"
#include "core.h"
#include "mltcontroller/bincontroller.h"
......@@ -1177,6 +1178,18 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
}
}
}
if (TransitionHandler::sumAudioMixAvailable()) {
QDomNodeList transitions = m_doc.elementsByTagName(QStringLiteral("transition"));
max = transitions.count();
for (int i = 0; i < max; ++i) {
QDomElement trans = transitions.at(i).toElement();
if (trans.isNull()) continue;
const QString service = EffectsList::property(trans, QStringLiteral("mlt_service"));
if (service == QLatin1String("mix")) {
EffectsList::renameProperty(trans, QStringLiteral("combine"), QStringLiteral("sum"));
}
}
}
}
m_modified = true;
......
......@@ -80,7 +80,7 @@ void DocUndoStack::push(QUndoCommand *cmd)
QUndoStack::push(cmd);
}
const double DOCUMENTVERSION = 0.95;
const double DOCUMENTVERSION = 0.96;
KdenliveDoc::KdenliveDoc(const QUrl &url, const QString &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QMap<QString, QString> &properties, const QMap<QString, QString> &metadata, const QPoint &tracks, Render *render, NotesPlugin *notes, bool *openBackup, MainWindow *parent) :
QObject(parent),
......@@ -498,7 +498,11 @@ QDomDocument KdenliveDoc::createEmptyDocument(const QList<TrackInfo> &tracks)
transition.appendChild(cur_property);
cur_property = doc.createElement(QStringLiteral("property"));
cur_property.setAttribute(QStringLiteral("name"), QStringLiteral("combine"));
if (TransitionHandler::sumAudioMixAvailable()) {
cur_property.setAttribute(QStringLiteral("name"), QStringLiteral("sum"));
} else {
cur_property.setAttribute(QStringLiteral("name"), QStringLiteral("combine"));
}
value = doc.createTextNode(QStringLiteral("1"));
cur_property.appendChild(value);
transition.appendChild(cur_property);
......
......@@ -1520,7 +1520,11 @@ QList<TransitionInfo> Render::mltInsertTrack(int ix, const QString &name, bool v
mix.set("b_track", ix);
mix.set("always_active", 1);
mix.set("internal_added", 237);
mix.set("combine", 1);
if (TransitionHandler::sumAudioMixAvailable()) {
mix.set("sum", 1);
} else {
mix.set("combine", 1);
}
field->plant_transition(mix, 0, ix);
service.unlock();
blockSignals(false);
......
......@@ -641,7 +641,11 @@ void TransitionHandler::rebuildTransitions(int mode, const QList<int> &videoTrac
for (int i = 1; i < maxTrack; i++) {
Mlt::Transition transition(*m_tractor->profile(), "mix");
transition.set("always_active", 1);
transition.set("combine", 1);
if (sumAudioMixAvailable()) {
transition.set("sum", 1);
} else {
transition.set("combine", 1);
}
transition.set("a_track", 0);
transition.set("b_track", i);
transition.set("internal_added", 237);
......@@ -680,3 +684,10 @@ void TransitionHandler::rebuildTransitions(int mode, const QList<int> &videoTrac
field->unlock();
delete field;
}
// static
bool TransitionHandler::sumAudioMixAvailable() {
// TODO: remove whenever we require MLT > 6.4.x
return (LIBMLT_VERSION_MAJOR > 6 || (LIBMLT_VERSION_MAJOR == 6 && LIBMLT_VERSION_MINOR > 4));
}
......@@ -60,6 +60,7 @@ public:
static const QString compositeTransition();
/** @brief Initialize transition settings. */
void initTransition(const QDomElement &xml);
static bool sumAudioMixAvailable();
private:
Mlt::Tractor *m_tractor;
......
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