From 7d802ab338512649eec2248b484890e7074a3649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Fri, 2 Sep 2022 23:51:48 +0200 Subject: [PATCH] Fixed tickets: #3 and #4 Closes #3: allow to build with Qt6 without mixing Qt5 libs Closes #4: errors initializing ALSA, Pulse and Sonivox emit qFatal instead of qCritical. --- cmdlnsynth/CMakeLists.txt | 2 +- guisynth/CMakeLists.txt | 2 +- libsvoxeas/CMakeLists.txt | 2 +- libsvoxeas/synthrenderer.cpp | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmdlnsynth/CMakeLists.txt b/cmdlnsynth/CMakeLists.txt index 67cce14..68c5546 100644 --- a/cmdlnsynth/CMakeLists.txt +++ b/cmdlnsynth/CMakeLists.txt @@ -5,7 +5,7 @@ get_target_property( SONIVOX_HEADERS sonivox::sonivox INTERFACE_INCLUDE_DIRECTOR target_include_directories( cmdlnsynth PRIVATE ${SONIVOX_HEADERS} ) target_link_libraries( cmdlnsynth - Qt5::Core + Qt${QT_VERSION_MAJOR}::Core Drumstick::ALSA svoxeas ) diff --git a/guisynth/CMakeLists.txt b/guisynth/CMakeLists.txt index 3ffc46e..000961a 100644 --- a/guisynth/CMakeLists.txt +++ b/guisynth/CMakeLists.txt @@ -20,7 +20,7 @@ get_target_property( SONIVOX_HEADERS sonivox::sonivox INTERFACE_INCLUDE_DIRECTOR target_include_directories( guisynth PRIVATE ${SONIVOX_HEADERS} ) target_link_libraries( guisynth - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets Drumstick::ALSA svoxeas ) diff --git a/libsvoxeas/CMakeLists.txt b/libsvoxeas/CMakeLists.txt index 1272668..c303813 100644 --- a/libsvoxeas/CMakeLists.txt +++ b/libsvoxeas/CMakeLists.txt @@ -25,7 +25,7 @@ set_target_properties( svoxeas PROPERTIES target_link_libraries( svoxeas PRIVATE sonivox::sonivox - Qt5::Core + Qt${QT_VERSION_MAJOR}::Core Drumstick::ALSA PkgConfig::PULSE ) diff --git a/libsvoxeas/synthrenderer.cpp b/libsvoxeas/synthrenderer.cpp index ff64f05..a43c8ac 100644 --- a/libsvoxeas/synthrenderer.cpp +++ b/libsvoxeas/synthrenderer.cpp @@ -26,6 +26,7 @@ #include "eas_reverb.h" #include "eas_chorus.h" #include +#include #include #include "synthrenderer.h" #include "filewrapper.h" @@ -45,7 +46,7 @@ SynthRenderer::SynthRenderer(int bufTime, QObject *parent) : QObject(parent), void SynthRenderer::initALSA() { - const QString errorstr = "Fatal error from the ALSA sequencer. " + const char* errorstr = "Fatal error from the ALSA sequencer. " "This usually happens when the kernel doesn't have ALSA support, " "or the device node (/dev/snd/seq) doesn't exists, " "or the kernel module (snd_seq) is not loaded. " @@ -69,9 +70,9 @@ SynthRenderer::initALSA() m_codec = new MidiCodec(256); m_codec->enableRunningStatus(false); } catch (const SequencerError& ex) { - qCritical() << errorstr + "Returned error was:" + ex.qstrError(); + qFatal("%s Returned error was: %s\n", errorstr, ex.what()); } catch (...) { - qCritical() << errorstr; + qFatal("%s\n", errorstr); } qDebug() << Q_FUNC_INFO; } @@ -86,19 +87,19 @@ SynthRenderer::initEAS() const S_EAS_LIB_CONFIG *easConfig = EAS_Config(); if (easConfig == 0) { - qCritical() << "EAS_Config returned null"; + qFatal("EAS_Config returned null\n"); return; } eas_res = EAS_Init(&dataHandle); if (eas_res != EAS_SUCCESS) { - qCritical() << "EAS_Init error: " << eas_res; + qFatal("EAS_Init error: %ld\n", eas_res); return; } eas_res = EAS_OpenMIDIStream(dataHandle, &handle, NULL); if (eas_res != EAS_SUCCESS) { - qCritical() << "EAS_OpenMIDIStream error: " << eas_res; + qFatal("EAS_OpenMIDIStream error: %ld\n", eas_res); EAS_Shutdown(dataHandle); return; } @@ -138,10 +139,9 @@ SynthRenderer::initPulse() device, "Synthesizer output", &samplespec, NULL, /* pa_channel_map */ &bufattr, &err); - - if (!m_pulseHandle) + if (err != PA_OK || !m_pulseHandle) { - qCritical() << "Failed to create PulseAudio connection"; + qFatal("Failed to create PulseAudio connection. err:%d - %s", err, pa_strerror(err)); } qDebug() << Q_FUNC_INFO << "latency:" << pa_simple_get_latency(m_pulseHandle, &err); }