diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..8e57a111 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,122 @@ +name: build + +on: + push: + branches: + - '*' + pull_request: + branches: + - '*' + +jobs: + build: + strategy: + matrix: + os: + # wrong use of AU MIDIPacket + # - macos-12 + # - macos-13 + # - macos-14 + # webgui failure + # - ubuntu-20.04 + - ubuntu-22.04 + - ubuntu-24.04 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set up dependencies + if: ${{ runner.os == 'Linux' }} + env: + DEBIAN_FRONTEND: noninteractive + run: | + sudo apt-get update -qq + sudo apt-get install -yq libasound2-dev libcairo2-dev libdbus-1-dev libgl1-mesa-dev liblo-dev libpulse-dev libsdl2-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev xvfb + - name: Set num jobs + if: ${{ runner.os == 'Linux' }} + run: echo "JOBS=$(nproc)" >> $GITHUB_ENV + - name: Set num jobs + if: ${{ runner.os != 'Linux' }} + run: echo "JOBS=$(sysctl -n hw.logicalcpu)" >> $GITHUB_ENV + - name: Without any warnings + env: + CFLAGS: -Werror + CXXFLAGS: -Werror + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} + - name: Run tests + if: ${{ runner.os == 'Linux' }} + run: | + xvfb-run make -C tests run + - name: As C++98 mode + env: + CFLAGS: -Werror + CXXFLAGS: -Werror -std=gnu++98 + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} + - name: As C++11 mode + env: + CFLAGS: -Werror + CXXFLAGS: -Werror -std=gnu++11 + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} + - name: As C++14 mode + env: + CFLAGS: -Werror + CXXFLAGS: -Werror -std=gnu++14 + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} + - name: As C++17 mode + env: + CFLAGS: -Werror + CXXFLAGS: -Werror -std=gnu++17 + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} + - name: As C++20 mode + env: + CFLAGS: -Werror + CXXFLAGS: -Werror -std=gnu++20 + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} + - name: No namespace + env: + CFLAGS: -Werror + CXXFLAGS: -Werror -DDONT_SET_USING_DISTRHO_NAMESPACE -DDONT_SET_USING_DGL_NAMESPACE + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} + - name: Custom namespace + env: + CFLAGS: -Werror + CXXFLAGS: -Werror -DDISTRHO_NAMESPACE=WubbWubb -DDGL_NAMESPACE=DabDab + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} + - name: With OpenGL 3.x + env: + CFLAGS: -Werror + CXXFLAGS: -Werror + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} USE_OPENGL3=true + - name: Without Cairo + env: + CFLAGS: -Werror + CXXFLAGS: -Werror + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} HAVE_CAIRO=false + - name: Without OpenGL + env: + CFLAGS: -Werror + CXXFLAGS: -Werror + run: | + make clean >/dev/null + make -j ${{ env.JOBS }} HAVE_OPENGL=false diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml deleted file mode 100644 index 06763ccf..00000000 --- a/.github/workflows/makefile.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: makefile - -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' -env: - DEBIAN_FRONTEND: noninteractive - -jobs: - linux-x86_64: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Set up dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -yq libasound2-dev libcairo2-dev libdbus-1-dev libgl1-mesa-dev liblo-dev libpulse-dev libsdl2-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev xvfb - - name: Without any warnings - env: - CFLAGS: -Werror - CXXFLAGS: -Werror - run: | - make clean >/dev/null - make -j $(nproc) - - name: Run tests - env: - CFLAGS: -Werror - CXXFLAGS: -Werror - run: | - xvfb-run make -C tests run - - name: As C++98 mode - env: - CFLAGS: -Werror - CXXFLAGS: -Werror -std=gnu++98 - run: | - make clean >/dev/null - make -j $(nproc) - - name: No namespace - env: - CFLAGS: -Werror - CXXFLAGS: -Werror -DDONT_SET_USING_DISTRHO_NAMESPACE -DDONT_SET_USING_DGL_NAMESPACE - run: | - make clean >/dev/null - make -j $(nproc) - - name: Custom namespace - env: - CFLAGS: -Werror - CXXFLAGS: -Werror -DDISTRHO_NAMESPACE=WubbWubb -DDGL_NAMESPACE=DabDab - run: | - make clean >/dev/null - make -j $(nproc) - - name: With OpenGL 3.x - env: - CFLAGS: -Werror - CXXFLAGS: -Werror - run: | - make clean >/dev/null - make -j $(nproc) USE_OPENGL3=true - - name: Without Cairo - env: - CFLAGS: -Werror - CXXFLAGS: -Werror - run: | - make clean >/dev/null - make -j $(nproc) HAVE_CAIRO= - - name: Without OpenGL - env: - CFLAGS: -Werror - CXXFLAGS: -Werror - run: | - make clean >/dev/null - make -j $(nproc) HAVE_OPENGL= diff --git a/dgl/src/pugl-upstream b/dgl/src/pugl-upstream index 25012188..f7b3fe46 160000 --- a/dgl/src/pugl-upstream +++ b/dgl/src/pugl-upstream @@ -1 +1 @@ -Subproject commit 2501218801437ea413091007b535d7c097801713 +Subproject commit f7b3fe466e7c443b4ec60901899fc538b66c0cc1 diff --git a/distrho/extra/Base64.hpp b/distrho/extra/Base64.hpp index d3eed6be..6833f16f 100644 --- a/distrho/extra/Base64.hpp +++ b/distrho/extra/Base64.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2024 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -19,10 +19,9 @@ #include "../DistrhoUtils.hpp" -#include #include -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // base64 stuff, based on http://www.adp-gmbh.ch/cpp/common/base64.html /* @@ -49,13 +48,13 @@ René Nyffenegger rene.nyffenegger@adp-gmbh.ch */ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // Helpers #ifndef DOXYGEN namespace DistrhoBase64Helpers { -static const char* const kBase64Chars = +static constexpr const char* const kBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; @@ -63,7 +62,7 @@ static const char* const kBase64Chars = static inline uint8_t findBase64CharIndex(const char c) { - static const uint8_t kBase64CharsLen(static_cast(std::strlen(kBase64Chars))); + static const uint8_t kBase64CharsLen = static_cast(std::strlen(kBase64Chars)); for (uint8_t i=0; i= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '+' || c == '/'; } } // namespace DistrhoBase64Helpers #endif -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- static inline std::vector d_getChunkFromBase64String(const char* const base64string) @@ -145,6 +144,6 @@ std::vector d_getChunkFromBase64String(const char* const base64string) return ret; } -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- #endif // DISTRHO_BASE64_HPP_INCLUDED diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp index 08bd6bed..0255bcd1 100644 --- a/distrho/extra/String.hpp +++ b/distrho/extra/String.hpp @@ -591,7 +591,7 @@ public: */ String& toLower() noexcept { - static const char kCharDiff('a' - 'A'); + static constexpr const char kCharDiff = 'a' - 'A'; for (std::size_t i=0; i < fBufferLen; ++i) { @@ -607,7 +607,7 @@ public: */ String& toUpper() noexcept { - static const char kCharDiff('a' - 'A'); + static constexpr const char kCharDiff = 'a' - 'A'; for (std::size_t i=0; i < fBufferLen; ++i) { @@ -676,7 +676,7 @@ public: static String asBase64(const void* const data, const std::size_t dataSize) { - static const char* const kBase64Chars = + static constexpr const char* const kBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; @@ -749,6 +749,192 @@ public: return ret; } + /* + * Convert to a URL encoded string. + */ + String& urlEncode() noexcept + { + static constexpr const char* const kHexChars = "0123456789ABCDEF"; + + if (fBufferLen == 0) + return *this; + + char* const newbuf = static_cast(std::malloc(fBufferLen * 3 + 1)); + DISTRHO_SAFE_ASSERT_RETURN(newbuf != nullptr, *this); + + char* newbufptr = newbuf; + + for (std::size_t i=0; i < fBufferLen; ++i) + { + const char c = fBuffer[i]; + + switch (c) + { + case '!': // 33 + case '#': // 35 + case '$': // 36 + case '&': // 38 + case '\'': // 39 + case '(': // 40 + case ')': // 41 + case '*': // 42 + case '+': // 43 + case ',': // 44 + case '-': // 45 + case '.': // 46 + case '/': // 47 + case '0': // 48 + case '1': // 49 + case '2': // 50 + case '3': // 51 + case '4': // 52 + case '5': // 53 + case '6': // 54 + case '7': // 55 + case '8': // 56 + case '9': // 57 + case ':': // 58 + case ';': // 59 + case '=': // 61 + case '?': // 63 + case '@': // 64 + case 'A': // 65 + case 'B': // 66 + case 'C': // 67 + case 'D': // 68 + case 'E': // 69 + case 'F': // 70 + case 'G': // 71 + case 'H': // 72 + case 'I': // 73 + case 'J': // 74 + case 'K': // 75 + case 'L': // 76 + case 'M': // 77 + case 'N': // 78 + case 'O': // 79 + case 'P': // 80 + case 'Q': // 81 + case 'R': // 82 + case 'S': // 83 + case 'T': // 84 + case 'U': // 85 + case 'V': // 86 + case 'W': // 87 + case 'X': // 88 + case 'Y': // 89 + case 'Z': // 90 + case '[': // 91 + case ']': // 93 + case '_': // 95 + case 'a': // 97 + case 'b': // 98 + case 'c': // 99 + case 'd': // 100 + case 'e': // 101 + case 'f': // 102 + case 'g': // 103 + case 'h': // 104 + case 'i': // 105 + case 'j': // 106 + case 'k': // 107 + case 'l': // 108 + case 'm': // 109 + case 'n': // 110 + case 'o': // 111 + case 'p': // 112 + case 'q': // 113 + case 'r': // 114 + case 's': // 115 + case 't': // 116 + case 'u': // 117 + case 'v': // 118 + case 'w': // 119 + case 'x': // 120 + case 'y': // 121 + case 'z': // 122 + case '~': // 126 + *newbufptr++ = c; + break; + default: + *newbufptr++ = '%'; + *newbufptr++ = kHexChars[(c >> 4) & 0xf]; + *newbufptr++ = kHexChars[c & 0xf]; + break; + } + } + + *newbufptr = '\0'; + + std::free(fBuffer); + fBuffer = newbuf; + fBufferLen = std::strlen(newbuf); + fBufferAlloc = true; + + return *this; + } + + /* + * Convert to a URL decoded string. + */ + String& urlDecode() noexcept + { + if (fBufferLen == 0) + return *this; + + char* const newbuf = static_cast(std::malloc(fBufferLen + 1)); + DISTRHO_SAFE_ASSERT_RETURN(newbuf != nullptr, *this); + + char* newbufptr = newbuf; + + for (std::size_t i=0; i < fBufferLen; ++i) + { + const char c = fBuffer[i]; + + if (c == '%') + { + DISTRHO_SAFE_ASSERT_CONTINUE(fBufferLen > i + 2); + + char c1 = fBuffer[i + 1]; + char c2 = fBuffer[i + 2]; + i += 2; + + /**/ if (c1 >= '0' && c1 <= '9') + c1 -= '0'; + else if (c1 >= 'A' && c1 <= 'Z') + c1 -= 'A' - 10; + else if (c1 >= 'a' && c1 <= 'z') + c1 -= 'a' - 10; + else + continue; + + /**/ if (c2 >= '0' && c2 <= '9') + c2 -= '0'; + else if (c2 >= 'A' && c2 <= 'Z') + c2 -= 'A' - 10; + else if (c2 >= 'a' && c2 <= 'z') + c2 -= 'a' - 10; + else + continue; + + *newbufptr++ = c1 << 4 | c2; + } + else + { + *newbufptr++ = c; + } + } + + *newbufptr = '\0'; + + std::free(fBuffer); + fBuffer = newbuf; + fBufferLen = std::strlen(newbuf); + fBufferAlloc = true; + + return *this; + } + // ------------------------------------------------------------------- // public operators @@ -830,7 +1016,7 @@ public: } // we have some data ourselves, reallocate to add the new stuff - char* const newBuf = (char*)realloc(fBuffer, fBufferLen + strBufLen + 1); + char* const newBuf = static_cast(std::realloc(fBuffer, fBufferLen + strBufLen + 1)); DISTRHO_SAFE_ASSERT_RETURN(newBuf != nullptr, *this); std::memcpy(newBuf + fBufferLen, strBuf, strBufLen + 1); @@ -855,7 +1041,7 @@ public: const std::size_t strBufLen = std::strlen(strBuf); const std::size_t newBufSize = fBufferLen + strBufLen; - char* const newBuf = (char*)malloc(newBufSize + 1); + char* const newBuf = static_cast(std::malloc(newBufSize + 1)); DISTRHO_SAFE_ASSERT_RETURN(newBuf != nullptr, String()); std::memcpy(newBuf, fBuffer, fBufferLen); @@ -912,7 +1098,7 @@ private: std::free(fBuffer); fBufferLen = (size > 0) ? size : std::strlen(strBuf); - fBuffer = (char*)std::malloc(fBufferLen+1); + fBuffer = static_cast(std::malloc(fBufferLen + 1)); if (fBuffer == nullptr) { @@ -960,7 +1146,7 @@ String operator+(const String& strBefore, const char* const strBufAfter) noexcep const std::size_t strBeforeLen = strBefore.length(); const std::size_t strBufAfterLen = std::strlen(strBufAfter); const std::size_t newBufSize = strBeforeLen + strBufAfterLen; - char* const newBuf = (char*)malloc(newBufSize + 1); + char* const newBuf = static_cast(malloc(newBufSize + 1)); DISTRHO_SAFE_ASSERT_RETURN(newBuf != nullptr, String()); std::memcpy(newBuf, strBefore.buffer(), strBeforeLen); @@ -980,7 +1166,7 @@ String operator+(const char* const strBufBefore, const String& strAfter) noexcep const std::size_t strBufBeforeLen = std::strlen(strBufBefore); const std::size_t strAfterLen = strAfter.length(); const std::size_t newBufSize = strBufBeforeLen + strAfterLen; - char* const newBuf = (char*)malloc(newBufSize + 1); + char* const newBuf = static_cast(malloc(newBufSize + 1)); DISTRHO_SAFE_ASSERT_RETURN(newBuf != nullptr, String()); std::memcpy(newBuf, strBufBefore, strBufBeforeLen); diff --git a/distrho/extra/WebViewImpl.hpp b/distrho/extra/WebViewImpl.hpp index 1b4f8195..cd185913 100644 --- a/distrho/extra/WebViewImpl.hpp +++ b/distrho/extra/WebViewImpl.hpp @@ -86,6 +86,7 @@ struct WebViewOptions { Provided metrics must have scale factor pre-applied. + @p url: The URL to open, assumed to be in encoded form (e.g spaces converted to %20) @p windowId: The native window id to attach this view to (X11 Window, HWND or NSView*) @p scaleFactor: Scale factor in use @p options: Extra options, optional diff --git a/distrho/src/DistrhoPluginAU.cpp b/distrho/src/DistrhoPluginAU.cpp index 3276c036..4262ca2e 100644 --- a/distrho/src/DistrhoPluginAU.cpp +++ b/distrho/src/DistrhoPluginAU.cpp @@ -2038,7 +2038,7 @@ public: case 0x9: case 0xD: // unsupported - kAudioUnitErr_InvalidPropertyValue; + return kAudioUnitErr_InvalidPropertyValue; case 0x1: case 0x2: case 0x3: diff --git a/distrho/src/DistrhoPluginVST.hpp b/distrho/src/DistrhoPluginVST.hpp index 2d488ca7..461a7ec5 100644 --- a/distrho/src/DistrhoPluginVST.hpp +++ b/distrho/src/DistrhoPluginVST.hpp @@ -70,8 +70,7 @@ enum Vst3InternalParameters { kVst3InternalParameterBaseCount, #if DISTRHO_PLUGIN_WANT_MIDI_INPUT kVst3InternalParameterMidiCC_start = kVst3InternalParameterBaseCount, - kVst3InternalParameterMidiCC_end = kVst3InternalParameterMidiCC_start + 130*16, - kVst3InternalParameterCount + kVst3InternalParameterCount = kVst3InternalParameterMidiCC_start + 130 * 16 #else kVst3InternalParameterCount = kVst3InternalParameterBaseCount #endif diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp index 3e8d2f1e..cb743923 100644 --- a/distrho/src/DistrhoPluginVST3.cpp +++ b/distrho/src/DistrhoPluginVST3.cpp @@ -359,14 +359,14 @@ class PluginVst3 midiEvent.size = 3; midiEvent.data[0] = 0x90 | (eventStorage.noteOn.channel & 0xf); midiEvent.data[1] = eventStorage.noteOn.pitch; - midiEvent.data[2] = std::max(0, std::min(127, (int)(eventStorage.noteOn.velocity * 127))); + midiEvent.data[2] = std::max(0, std::min(127, d_roundToIntPositive(eventStorage.noteOn.velocity * 127))); midiEvent.data[3] = 0; break; case NoteOff: midiEvent.size = 3; midiEvent.data[0] = 0x80 | (eventStorage.noteOff.channel & 0xf); midiEvent.data[1] = eventStorage.noteOff.pitch; - midiEvent.data[2] = std::max(0, std::min(127, (int)(eventStorage.noteOff.velocity * 127))); + midiEvent.data[2] = std::max(0, std::min(127, d_roundToIntPositive(eventStorage.noteOff.velocity * 127))); midiEvent.data[3] = 0; break; /* TODO @@ -377,7 +377,7 @@ class PluginVst3 midiEvent.size = 3; midiEvent.data[0] = 0xA0 | (eventStorage.polyPressure.channel & 0xf); midiEvent.data[1] = eventStorage.polyPressure.pitch; - midiEvent.data[2] = std::max(0, std::min(127, (int)(eventStorage.polyPressure.pressure * 127))); + midiEvent.data[2] = std::max(0, std::min(127, d_roundToIntPositive(eventStorage.polyPressure.pressure * 127))); midiEvent.data[3] = 0; break; case CC_Normal: @@ -469,7 +469,7 @@ class PluginVst3 { case 128: eventStorage.type = CC_ChannelPressure; - eventStorage.midi[1] = std::max(0, std::min(127, (int)(normalized * 127))); + eventStorage.midi[1] = std::max(0, std::min(127, d_roundToIntPositive(normalized * 127))); eventStorage.midi[2] = 0; break; case 129: @@ -480,7 +480,7 @@ class PluginVst3 default: eventStorage.type = CC_Normal; eventStorage.midi[1] = cc; - eventStorage.midi[2] = std::max(0, std::min(127, (int)(normalized * 127))); + eventStorage.midi[2] = std::max(0, std::min(127, d_roundToIntPositive(normalized * 127))); break; } @@ -1573,7 +1573,7 @@ public: { #if DISTRHO_PLUGIN_WANT_MIDI_INPUT // if there are any MIDI CC events as parameter changes, handle them here - if (canAppendMoreEvents && rindex >= kVst3InternalParameterMidiCC_start && rindex <= kVst3InternalParameterMidiCC_end) + if (canAppendMoreEvents && rindex >= kVst3InternalParameterMidiCC_start && rindex < kVst3InternalParameterCount) { for (int32_t j = 0, pcount = v3_cpp_obj(queue)->get_point_count(queue); j < pcount; ++j) { @@ -2008,7 +2008,7 @@ public: #if !DPF_VST3_PURE_MIDI_INTERNAL_PARAMETERS rindex >= kVst3InternalParameterMidiCC_start && #endif - rindex <= kVst3InternalParameterMidiCC_end) + rindex < kVst3InternalParameterCount) return 0.0; #endif @@ -2045,7 +2045,7 @@ public: #if !DPF_VST3_PURE_MIDI_INTERNAL_PARAMETERS rindex >= kVst3InternalParameterMidiCC_start && #endif - rindex <= kVst3InternalParameterMidiCC_end) + rindex < kVst3InternalParameterCount) return V3_INVALID_ARG; #endif diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index ca8894dc..f0c8d259 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -200,24 +200,30 @@ PluginWindow& UI::PrivateData::createNextWindow(UI* const ui, uint width, uint h path += "/resources"; } + path.urlEncode(); + // TODO convert win32 paths to web - // TODO encode paths (e.g. %20 for space) WebViewOptions opts; opts.initialJS = "" -"editParameter = function(index, started){ postMessage('editparam '+index+' '+(started ? 1 : 0)) };" -"setParameterValue = function(index, value){ postMessage('setparam '+index+' '+value) };" +"editParameter = function(index, started){ postMessage('editparam ' + index + ' ' + (started ? '1' : '0')) };" +"setParameterValue = function(index, value){ postMessage('setparam ' + index + ' ' + value) };" #if DISTRHO_PLUGIN_WANT_STATE -"setState = function(key, value){ postMessage('setstate '+key+' '+value) };" -"requestStateFile = function(key){ postMessage('reqstatefile '+key) };" +"setState = function(key, value){ postMessage('setstate ' + key + ' ' + value) };" +"requestStateFile = function(key){ postMessage('reqstatefile ' + key) };" #endif #if DISTRHO_PLUGIN_WANT_MIDI_INPUT -"sendNote = function(channel, note, velocity){ postMessage('sendnote '+channel+' '+note+' '+velocity) };" +"sendNote = function(channel, note, velocity){ postMessage('sendnote ' + channel + ' ' + note + ' ' + velocity) };" #endif ; opts.callback = webViewMessageCallback; opts.callbackPtr = uiData; - uiData->webview = webViewCreate("file://" + path + "/index.html", uiData->winId, width, height, scaleFactor, opts); + uiData->webview = webViewCreate("file://" + path + "/index.html", + uiData->winId != 0 ? uiData->winId : uiData->window->getNativeWindowHandle(), + width, + height, + scaleFactor, + opts); #endif } // If there are no callbacks, this is most likely a temporary window, so ignore idle callbacks @@ -268,7 +274,7 @@ void UI::PrivateData::webViewMessageCallback(void* const arg, char* const msg) char* const key = msg + 9; char* const sep = std::strchr(key, ' '); DISTRHO_SAFE_ASSERT_RETURN(sep != nullptr,); - *sep = 0; + *sep = '\0'; char* const value = sep + 1; uiData->setStateCallback(key, value); diff --git a/distrho/src/jackbridge/JackBridge.cpp b/distrho/src/jackbridge/JackBridge.cpp index 18676aec..ba5ecb18 100644 --- a/distrho/src/jackbridge/JackBridge.cpp +++ b/distrho/src/jackbridge/JackBridge.cpp @@ -1,6 +1,6 @@ /* * JackBridge for DPF - * Copyright (C) 2013-2022 Filipe Coelho + * Copyright (C) 2013-2024 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -60,10 +60,15 @@ typedef void* lib_t; # undef HAVE_SDL2 #endif -#if defined(HAVE_RTAUDIO) && DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0 +#if defined(HAVE_RTAUDIO) && (DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS) > 0 // fix conflict between DGL and macOS names # define Point CorePoint # define Size CoreSize +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# pragma clang diagnostic ignored "-Wunused-but-set-variable" +# endif # include "RtAudioBridge.hpp" # ifdef RTAUDIO_API_TYPE # include "rtaudio/RtAudio.cpp" @@ -71,15 +76,18 @@ typedef void* lib_t; # ifdef RTMIDI_API_TYPE # include "rtmidi/RtMidi.cpp" # endif +# ifdef __clang__ +# pragma clang diagnostic pop +# endif # undef Point # undef Size #endif -#if defined(HAVE_SDL2) && DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0 +#if defined(HAVE_SDL2) && (DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS) > 0 # include "SDL2Bridge.hpp" #endif -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- extern "C" { @@ -229,7 +237,7 @@ typedef void (JACKSYM_API *jacksym_set_thread_creator)(jacksym_thread_creator_t) } // extern "C" -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- struct JackBridge { lib_t lib; @@ -632,7 +640,7 @@ static bool usingNativeBridge = false; static bool usingRealJACK = true; static NativeBridge* nativeBridge = nullptr; -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- static JackBridge& getBridgeInstance() noexcept { @@ -642,7 +650,7 @@ static JackBridge& getBridgeInstance() noexcept #endif // ! (defined(JACKBRIDGE_DIRECT) || defined(JACKBRIDGE_DUMMY)) -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- #if defined(__WINE__) && ! defined(JACKBRIDGE_DIRECT) @@ -861,7 +869,7 @@ struct WineBridge { #endif // __WINE__ && ! JACKBRIDGE_DIRECT -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_is_ok() noexcept { @@ -882,7 +890,7 @@ void jackbridge_init() #endif } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- void jackbridge_get_version(int* major_ptr, int* minor_ptr, int* micro_ptr, int* proto_ptr) { @@ -915,7 +923,7 @@ const char* jackbridge_get_version_string() return nullptr; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- jack_client_t* jackbridge_client_open(const char* client_name, uint32_t options, jack_status_t* status) { @@ -1006,7 +1014,7 @@ bool jackbridge_client_close(jack_client_t* client) return false; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- int jackbridge_client_name_size() { @@ -1034,7 +1042,7 @@ const char* jackbridge_get_client_name(jack_client_t* client) return nullptr; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- char* jackbridge_client_get_uuid(jack_client_t* client) { @@ -1075,7 +1083,7 @@ char* jackbridge_get_client_name_by_uuid(jack_client_t* client, const char* uuid return nullptr; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_uuid_parse(const char* buf, jack_uuid_t* uuid) { @@ -1102,7 +1110,7 @@ void jackbridge_uuid_unparse(jack_uuid_t uuid, char buf[JACK_UUID_STRING_SIZE]) #endif } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_activate(jack_client_t* client) { @@ -1145,7 +1153,7 @@ bool jackbridge_is_realtime(jack_client_t* client) return false; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_set_thread_init_callback(jack_client_t* client, JackThreadInitCallback thread_init_callback, void* arg) { @@ -1423,7 +1431,7 @@ bool jackbridge_set_latency_callback(jack_client_t* client, JackLatencyCallback return false; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_set_freewheel(jack_client_t* client, bool onoff) { @@ -1452,7 +1460,7 @@ bool jackbridge_set_buffer_size(jack_client_t* client, jack_nframes_t nframes) return false; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- jack_nframes_t jackbridge_get_sample_rate(jack_client_t* client) { @@ -1495,7 +1503,7 @@ float jackbridge_cpu_load(jack_client_t* client) return 0.0f; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- jack_port_t* jackbridge_port_register(jack_client_t* client, const char* port_name, const char* type, uint64_t flags, uint64_t buffer_size) { @@ -1540,7 +1548,7 @@ void* jackbridge_port_get_buffer(jack_port_t* port, jack_nframes_t nframes) return nullptr; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- const char* jackbridge_port_name(const jack_port_t* port) { @@ -1672,7 +1680,7 @@ const char** jackbridge_port_get_all_connections(const jack_client_t* client, co return nullptr; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_port_rename(jack_client_t* client, jack_port_t* port, const char* port_name) { @@ -1731,7 +1739,7 @@ int jackbridge_port_get_aliases(const jack_port_t* port, char* const aliases[2]) return 0; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_port_request_monitor(jack_port_t* port, bool onoff) { @@ -1785,7 +1793,7 @@ bool jackbridge_port_monitoring_input(jack_port_t* port) return false; } -// ----------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_connect(jack_client_t* client, const char* source_port, const char* destination_port) { @@ -1828,7 +1836,8 @@ bool jackbridge_port_disconnect(jack_client_t* client, jack_port_t* port) return false; } -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- int jackbridge_port_name_size() { @@ -1869,7 +1878,8 @@ uint32_t jackbridge_port_type_get_buffer_size(jack_client_t* client, const char* return 0; } -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- void jackbridge_port_get_latency_range(jack_port_t* port, uint32_t mode, jack_latency_range_t* range) { @@ -1914,7 +1924,8 @@ bool jackbridge_recompute_total_latencies(jack_client_t* client) return false; } -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- const char** jackbridge_get_ports(jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, uint64_t flags) { @@ -1956,7 +1967,8 @@ jack_port_t* jackbridge_port_by_id(jack_client_t* client, jack_port_id_t port_id return nullptr; } -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- void jackbridge_free(void* ptr) { @@ -1973,7 +1985,8 @@ void jackbridge_free(void* ptr) #endif } -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- uint32_t jackbridge_midi_get_event_count(void* port_buffer) { @@ -2043,7 +2056,8 @@ jack_midi_data_t* jackbridge_midi_event_reserve(void* port_buffer, jack_nframes_ return nullptr; } -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_release_timebase(jack_client_t* client) { @@ -2192,7 +2206,8 @@ void jackbridge_transport_stop(jack_client_t* client) #endif } -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- bool jackbridge_set_property(jack_client_t* client, jack_uuid_t subject, const char* key, const char* value, const char* type) { @@ -2360,7 +2375,8 @@ void jackbridge_cycle_signal(jack_client_t* client, int status) #endif } -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- #ifndef JACKBRIDGE_SKIP_NATIVE_UTILS @@ -2460,4 +2476,5 @@ END_NAMESPACE_DISTRHO #endif // JACKBRIDGE_SKIP_NATIVE_UTILS -// ----------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------------------------------- diff --git a/examples/CairoUI/DemoWidgetBanner.hpp b/examples/CairoUI/DemoWidgetBanner.hpp index 49143ce8..a715a630 100644 --- a/examples/CairoUI/DemoWidgetBanner.hpp +++ b/examples/CairoUI/DemoWidgetBanner.hpp @@ -1,7 +1,7 @@ /* * DISTRHO Plugin Framework (DPF) * Copyright (C) 2019-2021 Jean Pierre Cimalando - * Copyright (C) 2012-2023 Filipe Coelho + * Copyright (C) 2012-2024 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -48,10 +48,8 @@ static constexpr const char banner[] = " ***** * * " " "; -enum { - rows = 23, - columns = 72, -}; +static constexpr const int kNumRows = 23; +static constexpr const int kNumColumns = 72; class DemoWidgetBanner : public CairoSubWidget { @@ -71,19 +69,19 @@ protected: int w = sz.getWidth(); int h = sz.getHeight(); - const double diameter = (double)w / columns; + const double diameter = (double)w / kNumColumns; const double radius = 0.5 * diameter; const double xoff = 0; - const double yoff = 0.5 * (h - rows * diameter); + const double yoff = 0.5 * (h - kNumRows * diameter); - for (int r = 0; r < rows; ++r) + for (int r = 0; r < kNumRows; ++r) { - for (int c = 0; c < columns; ++c) + for (int c = 0; c < kNumColumns; ++c) { double cx = xoff + radius + c * diameter; double cy = yoff + radius + r * diameter; - char ch = banner[c + r * columns]; + char ch = banner[c + r * kNumColumns]; if (ch != ' ') cairo_set_source_rgb(cr, 0.5, 0.9, 0.2); else