Fix compatibility with MLT >= 6.6.0

parent bab0ebc5
...@@ -92,7 +92,7 @@ bool MltDeviceCapture::buildConsumer(const QString &profileName) ...@@ -92,7 +92,7 @@ bool MltDeviceCapture::buildConsumer(const QString &profileName)
} }
qputenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1"); qputenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1");
// OpenGL monitor // OpenGL monitor
m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_audio"); m_mltConsumer = new Mlt::Consumer(*m_mltProfile, KdenliveSettings::audiobackend().toUtf8().constData());
m_mltConsumer->set("preview_off", 1); m_mltConsumer->set("preview_off", 1);
m_mltConsumer->set("preview_format", mlt_image_rgb24); m_mltConsumer->set("preview_format", mlt_image_rgb24);
m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_gl_frame_show); m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_gl_frame_show);
...@@ -396,7 +396,7 @@ bool MltDeviceCapture::slotStartCapture(const QString &params, const QString &pa ...@@ -396,7 +396,7 @@ bool MltDeviceCapture::slotStartCapture(const QString &params, const QString &pa
qputenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1"); qputenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1");
// OpenGL monitor // OpenGL monitor
previewProps->set("mlt_service", "sdl_audio"); previewProps->set("mlt_service", KdenliveSettings::audiobackend().toUtf8().constData());
previewProps->set("preview_off", 1); previewProps->set("preview_off", 1);
previewProps->set("preview_format", mlt_image_rgb24); previewProps->set("preview_format", mlt_image_rgb24);
previewProps->set("terminate_on_pause", 0); previewProps->set("terminate_on_pause", 0);
......
...@@ -547,7 +547,7 @@ void KdenliveSettingsDialog::initDevices() ...@@ -547,7 +547,7 @@ void KdenliveSettingsDialog::initDevices()
KdenliveSettings::setV4l_alsadevice(ix); KdenliveSettings::setV4l_alsadevice(ix);
} }
m_configSdl.kcfg_audio_backend->addItem(i18n("SDL"), "sdl_audio"); m_configSdl.kcfg_audio_backend->addItem(i18n("SDL"), KdenliveSettings::sdlAudioBackend());
m_configSdl.kcfg_audio_backend->addItem(i18n("RtAudio"), "rtaudio"); m_configSdl.kcfg_audio_backend->addItem(i18n("RtAudio"), "rtaudio");
if (!KdenliveSettings::audiobackend().isEmpty()) { if (!KdenliveSettings::audiobackend().isEmpty()) {
...@@ -555,7 +555,7 @@ void KdenliveSettingsDialog::initDevices() ...@@ -555,7 +555,7 @@ void KdenliveSettingsDialog::initDevices()
m_configSdl.kcfg_audio_backend->setCurrentIndex(ix); m_configSdl.kcfg_audio_backend->setCurrentIndex(ix);
KdenliveSettings::setAudio_backend(ix); KdenliveSettings::setAudio_backend(ix);
} }
m_configSdl.group_sdl->setEnabled(KdenliveSettings::audiobackend() == QLatin1String("sdl_audio")); m_configSdl.group_sdl->setEnabled(KdenliveSettings::audiobackend().startsWith(QLatin1String("sdl")));
loadCurrentV4lProfileInfo(); loadCurrentV4lProfileInfo();
} }
...@@ -926,7 +926,7 @@ void KdenliveSettingsDialog::slotCheckAlsaDriver() ...@@ -926,7 +926,7 @@ void KdenliveSettingsDialog::slotCheckAlsaDriver()
void KdenliveSettingsDialog::slotCheckAudioBackend() void KdenliveSettingsDialog::slotCheckAudioBackend()
{ {
QString value = m_configSdl.kcfg_audio_backend->itemData(m_configSdl.kcfg_audio_backend->currentIndex()).toString(); QString value = m_configSdl.kcfg_audio_backend->itemData(m_configSdl.kcfg_audio_backend->currentIndex()).toString();
m_configSdl.group_sdl->setEnabled(value == QLatin1String("sdl_audio")); m_configSdl.group_sdl->setEnabled(value.startsWith(QLatin1String("sdl_audio")));
} }
void KdenliveSettingsDialog::loadTranscodeProfiles() void KdenliveSettingsDialog::loadTranscodeProfiles()
......
...@@ -391,7 +391,18 @@ void Wizard::checkMltComponents() ...@@ -391,7 +391,18 @@ void Wizard::checkMltComponents()
} }
delete consumers; delete consumers;
if (!consumersItemList.contains(QStringLiteral("sdl")) && !consumersItemList.contains(QStringLiteral("rtaudio"))) { if (consumersItemList.contains(QStringLiteral("sdl2"))) {
// MLT >= 6.6.0 and SDL2 module
KdenliveSettings::setSdlAudioBackend(QStringLiteral("sdl2_audio"));
KdenliveSettings::setAudiobackend(QStringLiteral("sdl2_audio"));
} else if (consumersItemList.contains(QStringLiteral("sdl"))) {
// MLT < 6.6.0
KdenliveSettings::setSdlAudioBackend(QStringLiteral("sdl_audio"));
KdenliveSettings::setAudiobackend(QStringLiteral("sdl_audio"));
} else if (consumersItemList.contains(QStringLiteral("rtaudio"))) {
KdenliveSettings::setSdlAudioBackend(QStringLiteral("sdl2_audio"));
KdenliveSettings::setAudiobackend(QStringLiteral("rtaudio"));
} else {
// SDL module // SDL module
m_errors.append(i18n("<li>Missing MLT module: <b>sdl</b> or <b>rtaudio</b><br/>required for audio output</li>")); m_errors.append(i18n("<li>Missing MLT module: <b>sdl</b> or <b>rtaudio</b><br/>required for audio output</li>"));
m_systemCheckIsOk = false; m_systemCheckIsOk = false;
......
...@@ -281,6 +281,11 @@ ...@@ -281,6 +281,11 @@
<default>false</default> <default>false</default>
</entry> </entry>
<entry name="sdlAudioBackend" type="String">
<label>Detected audio backend.</label>
<default></default>
</entry>
<entry name="audio_backend" type="Int"> <entry name="audio_backend" type="Int">
<label>Audio backend index used for sound output.</label> <label>Audio backend index used for sound output.</label>
<default>0</default> <default>0</default>
...@@ -288,7 +293,7 @@ ...@@ -288,7 +293,7 @@
<entry name="audiobackend" type="String"> <entry name="audiobackend" type="String">
<label>Audio backend used for sound output.</label> <label>Audio backend used for sound output.</label>
<default>sdl_audio</default> <default></default>
</entry> </entry>
<entry name="audio_driver" type="UInt"> <entry name="audio_driver" type="UInt">
......
...@@ -1638,7 +1638,7 @@ bool MainWindow::readOptions() ...@@ -1638,7 +1638,7 @@ bool MainWindow::readOptions()
} }
bool firstRun = false; bool firstRun = false;
KConfigGroup initialGroup(config, "version"); KConfigGroup initialGroup(config, "version");
if (!initialGroup.exists()) { if (!initialGroup.exists() || KdenliveSettings::sdlAudioBackend().isEmpty()) {
// First run, check if user is on a KDE Desktop // First run, check if user is on a KDE Desktop
firstRun = true; firstRun = true;
// this is our first run, show Wizard // this is our first run, show Wizard
......
...@@ -893,7 +893,7 @@ int GLWidget::reconfigureMulti(const QString &params, const QString &path, Mlt:: ...@@ -893,7 +893,7 @@ int GLWidget::reconfigureMulti(const QString &params, const QString &path, Mlt::
m_consumer->set("0.real_time", 0); m_consumer->set("0.real_time", 0);
m_consumer->set("0.volume", (double)volume / 100); m_consumer->set("0.volume", (double)volume / 100);
if (serviceName == QLatin1String("sdl_audio")) { if (serviceName.startsWith(QLatin1String("sdl"))) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
m_consumer->set("0.audio_buffer", 2048); m_consumer->set("0.audio_buffer", 2048);
#else #else
...@@ -963,18 +963,42 @@ int GLWidget::reconfigure(Mlt::Profile *profile) ...@@ -963,18 +963,42 @@ int GLWidget::reconfigure(Mlt::Profile *profile)
//QString audioBackend = m_glslManager == nullptr ? KdenliveSettings::audiobackend() : QStringLiteral("rtaudio"); //QString audioBackend = m_glslManager == nullptr ? KdenliveSettings::audiobackend() : QStringLiteral("rtaudio");
QString audioBackend = KdenliveSettings::audiobackend(); QString audioBackend = KdenliveSettings::audiobackend();
if (serviceName.isEmpty() || serviceName != audioBackend) { if (serviceName.isEmpty() || serviceName != audioBackend) {
m_consumer = new Mlt::FilteredConsumer(*m_monitorProfile, audioBackend.toUtf8().constData()); m_consumer = new Mlt::FilteredConsumer(*m_monitorProfile, audioBackend.toLatin1().constData());
if (m_consumer->is_valid()) { if (m_consumer->is_valid()) {
serviceName = audioBackend; serviceName = audioBackend;
setProperty("mlt_service", serviceName);
} else { } else {
// Fallback // Warning, audio backend unavailable on system
serviceName = QStringLiteral("sdl_audio"); delete m_consumer;
m_consumer = nullptr;
QStringList backends = {"sdl2_audio", "sdl_audio", "rtaudio"};
for (const QString &bk : backends) {
if (bk == audioBackend) {
// Already tested
continue;
}
m_consumer = new Mlt::FilteredConsumer(*m_monitorProfile, bk.toLatin1().constData());
if (m_consumer->is_valid()) {
if (audioBackend == KdenliveSettings::sdlAudioBackend()) {
// switch sdl audio backend
KdenliveSettings::setSdlAudioBackend(bk);
}
qDebug()<<"++++++++\nSwitching audio backend to: "<<bk<<"\n++++++++++";
KdenliveSettings::setAudiobackend(bk);
serviceName = bk;
setProperty("mlt_service", serviceName);
break;
} else {
delete m_consumer;
m_consumer = nullptr;
}
}
if (!m_consumer) {
qWarning() << "WARNING, NO AUDIO BACKEND FOUND";
return -1;
}
} }
delete m_consumer;
m_consumer = nullptr;
setProperty("mlt_service", serviceName);
} }
m_consumer = new Mlt::FilteredConsumer(*m_monitorProfile, serviceName.toLatin1().constData());
delete m_threadStartEvent; delete m_threadStartEvent;
m_threadStartEvent = nullptr; m_threadStartEvent = nullptr;
delete m_threadStopEvent; delete m_threadStopEvent;
...@@ -1019,7 +1043,7 @@ int GLWidget::reconfigure(Mlt::Profile *profile) ...@@ -1019,7 +1043,7 @@ int GLWidget::reconfigure(Mlt::Profile *profile)
} }
int volume = KdenliveSettings::volume(); int volume = KdenliveSettings::volume();
if (serviceName == QLatin1String("sdl_audio")) { if (serviceName.startsWith(QLatin1String("sdl"))) {
QString audioDevice = KdenliveSettings::audiodevicename(); QString audioDevice = KdenliveSettings::audiodevicename();
if (!audioDevice.isEmpty()) { if (!audioDevice.isEmpty()) {
m_consumer->set("audio_device", audioDevice.toUtf8().constData()); m_consumer->set("audio_device", audioDevice.toUtf8().constData());
......
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