Browse Source

Switch from USE_QT macro to CARLA_UTILS_USE_QT

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.5.5
falkTX 1 year ago
parent
commit
f5882c3404
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 52 additions and 20 deletions
  1. +7
    -1
      source/backend/utils/CarlaUtils.cpp
  2. +33
    -7
      source/utils/CarlaBinaryUtils.hpp
  3. +12
    -12
      source/utils/CarlaLv2Utils.hpp

+ 7
- 1
source/backend/utils/CarlaUtils.cpp View File

@@ -15,7 +15,13 @@
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "CarlaBridgeUtils.cpp"
#include "CarlaUtils.hpp"

#include "CarlaProcessUtils.cpp"

#ifndef CARLA_OS_WASM
# include "CarlaBridgeUtils.cpp"
#endif

#ifdef CARLA_OS_MAC
# include "CarlaMacUtils.cpp"


+ 33
- 7
source/utils/CarlaBinaryUtils.hpp View File

@@ -1,6 +1,6 @@
/*
* Carla binary utils
* Copyright (C) 2014-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2014-2023 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -21,7 +21,12 @@
#include "CarlaBackend.h"
#include "CarlaScopeUtils.hpp"

#include "water/files/FileInputStream.h"
#if defined(BUILDING_CARLA)
# include "water/files/FileInputStream.h"
#elif defined(CARLA_UTILS_USE_QT)
# include <QtCore/QFile>
# include <QtCore/QString>
#endif

#if defined(HAVE_LIBMAGIC) && ! defined(BUILD_BRIDGE_ALTERNATIVE_ARCH)
# include <magic.h>
@@ -80,7 +85,7 @@ BinaryType getBinaryTypeFromFile(const char* const filename)
if (filename == nullptr || filename[0] == '\0')
return BINARY_NATIVE;

#if defined(HAVE_LIBMAGIC) && ! defined(BUILD_BRIDGE_ALTERNATIVE_ARCH)
#if defined(HAVE_LIBMAGIC) && ! defined(BUILD_BRIDGE_ALTERNATIVE_ARCH)
static const CarlaMagic magic;

const char* const output(magic.getFileDescription(filename));
@@ -101,7 +106,7 @@ BinaryType getBinaryTypeFromFile(const char* const filename)
? BINARY_POSIX64
: BINARY_POSIX32;

# ifdef CARLA_OS_MAC
#ifdef CARLA_OS_MAC
if (std::strcmp(output, "directory") == 0)
if (const char* const binary = findBinaryInBundle(filename))
return getBinaryTypeFromFile(binary);
@@ -121,26 +126,36 @@ BinaryType getBinaryTypeFromFile(const char* const filename)
}

carla_debug("getBinaryTypeFromFile(\"%s\") - have output:\n%s", filename, output);
# endif
#endif

return BINARY_NATIVE;
}
#endif
#endif

#if defined(BUILDING_CARLA) || defined(CARLA_UTILS_USE_QT)
#if defined(CARLA_UTILS_USE_QT)
QFile file(QString::fromUtf8(filename));
CARLA_SAFE_ASSERT_RETURN(file.open(QIODevice::ReadOnly), BINARY_NATIVE);
#else
using water::File;
using water::FileInputStream;

CarlaScopedPointer<FileInputStream> stream(File(filename).createInputStream());
CARLA_SAFE_ASSERT_RETURN(stream != nullptr && ! stream->failedToOpen(), BINARY_NATIVE);
#endif

// ----------------------------------------------------------------------------------------------------------------
// binary type code based on Ardour's dll_info function
// See https://github.com/Ardour/ardour/blob/master/libs/ardour/plugin_manager.cc#L867,L925
// Copyright (C) 2000-2006 Paul Davis

#if defined(CARLA_UTILS_USE_QT)
char buf[68];
if (file.read(buf, 68) != 68)
#else
uint8_t buf[68];

if (stream->read(buf, 68) != 68)
#endif
return BINARY_NATIVE;

if (buf[0] != 'M' && buf[1] != 'Z')
@@ -149,10 +164,18 @@ BinaryType getBinaryTypeFromFile(const char* const filename)
const int32_t* const pe_hdr_off_ptr = (int32_t*)&buf[60];
const int32_t pe_hdr_off = *pe_hdr_off_ptr;

#if defined(CARLA_UTILS_USE_QT)
if (! file.seek(pe_hdr_off))
#else
if (! stream->setPosition(pe_hdr_off))
#endif
return BINARY_NATIVE;

#if defined(CARLA_UTILS_USE_QT)
if (file.read(buf, 6) != 6)
#else
if (stream->read(buf, 6) != 6)
#endif
return BINARY_NATIVE;

if (buf[0] != 'P' && buf[1] != 'E')
@@ -170,6 +193,9 @@ BinaryType getBinaryTypeFromFile(const char* const filename)
default:
return BINARY_NATIVE;
}
#else
return BINARY_NATIVE;
#endif
}

// --------------------------------------------------------------------------------------------------------------------


+ 12
- 12
source/utils/CarlaLv2Utils.hpp View File

@@ -83,7 +83,7 @@

#include "lv2_rdf.hpp"

#ifdef USE_QT
#ifdef CARLA_UTILS_USE_QT
# include <QtCore/QStringList>
#else
# include "water/text/StringArray.h"
@@ -1822,7 +1822,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)

if (replaceNode.is_uri())
{
#ifdef USE_QT
#ifdef CARLA_UTILS_USE_QT
const QString replaceURI(replaceNode.as_uri());

if (replaceURI.startsWith("urn:"))
@@ -1835,7 +1835,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)
if (ok && uniqueId != 0)
rdfDescriptor->UniqueID = uniqueId;
}
#else
#else
const water::String replaceURI(replaceNode.as_uri());

if (replaceURI.startsWith("urn:"))
@@ -1845,7 +1845,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)
if (uniqueId > 0)
rdfDescriptor->UniqueID = static_cast<ulong>(uniqueId);
}
#endif
#endif
}
}

@@ -2752,7 +2752,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)
if (presetNodes.size() > 0)
{
// create a list of preset URIs (for sorting and unique-ness)
#ifdef USE_QT
#ifdef CARLA_UTILS_USE_QT
QStringList presetListURIs;

LILV_FOREACH(nodes, it, presetNodes)
@@ -2768,7 +2768,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)
presetListURIs.sort();

rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count());
#else
#else
water::StringArray presetListURIs;

LILV_FOREACH(nodes, it, presetNodes)
@@ -2784,7 +2784,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)
presetListURIs.sortNatural();

rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size());
#endif
#endif

// create presets with unique URIs
rdfDescriptor->Presets = new LV2_RDF_Preset[rdfDescriptor->PresetCount];
@@ -2813,11 +2813,11 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)

if (presetLabelNodes.size() > 0)
{
#ifdef USE_QT
const int index(presetListURIs.indexOf(QString(presetURI)));
#else
const int index(presetListURIs.indexOf(water::String(presetURI)));
#endif
#ifdef CARLA_UTILS_USE_QT
const int index = presetListURIs.indexOf(QString(presetURI));
#else
const int index = presetListURIs.indexOf(water::String(presetURI));
#endif
CARLA_SAFE_ASSERT_CONTINUE(index >= 0 && index < static_cast<int>(rdfDescriptor->PresetCount));

LV2_RDF_Preset* const rdfPreset(&rdfDescriptor->Presets[index]);


Loading…
Cancel
Save