From 5346f6e30990ff554a7f260b45a758b810c2b6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 21 Dec 2022 22:17:53 +0100 Subject: Report versions of found library during cmake configure. This helps to find build errors earlier. --- cmake/modules/FindChromaprint.cmake | 9 ++++++--- cmake/modules/FindEbur128.cmake | 9 ++++++--- cmake/modules/FindFLAC.cmake | 9 ++++++--- cmake/modules/FindID3Tag.cmake | 9 ++++++--- cmake/modules/FindKeyFinder.cmake | 9 ++++++--- cmake/modules/FindLibUSB.cmake | 9 ++++++--- cmake/modules/FindMAD.cmake | 9 ++++++--- cmake/modules/FindMP4.cmake | 9 ++++++--- cmake/modules/FindMP4v2.cmake | 9 ++++++--- cmake/modules/FindModplug.cmake | 9 ++++++--- cmake/modules/FindOgg.cmake | 9 ++++++--- cmake/modules/FindPortMidi.cmake | 10 ++++++---- cmake/modules/FindShoutidjc.cmake | 9 ++++++--- cmake/modules/FindSndFile.cmake | 9 ++++++--- cmake/modules/FindSoundTouch.cmake | 2 +- cmake/modules/FindUpower.cmake | 9 ++++++--- cmake/modules/Findlilv.cmake | 9 ++++++--- cmake/modules/Findrubberband.cmake | 9 ++++++--- cmake/modules/Findwavpack.cmake | 9 ++++++--- 19 files changed, 109 insertions(+), 56 deletions(-) diff --git a/cmake/modules/FindChromaprint.cmake b/cmake/modules/FindChromaprint.cmake index 52a8b8b832..750b77adbf 100644 --- a/cmake/modules/FindChromaprint.cmake +++ b/cmake/modules/FindChromaprint.cmake @@ -62,12 +62,15 @@ find_library(Chromaprint_LIBRARY ) mark_as_advanced(Chromaprint_LIBRARY) +if(DEFINED PC_Chromaprint_VERSION AND NOT PC_Chromaprint_VERSION STREQUAL "") + set(Chromaprint_VERSION "${PC_Chromaprint_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Chromaprint - DEFAULT_MSG - Chromaprint_LIBRARY - Chromaprint_INCLUDE_DIR + REQUIRED_VARS Chromaprint_LIBRARY Chromaprint_INCLUDE_DIR + VERSION_VAR Chromaprint_VERSION ) if(Chromaprint_FOUND) diff --git a/cmake/modules/FindEbur128.cmake b/cmake/modules/FindEbur128.cmake index df23185d20..b12292375a 100644 --- a/cmake/modules/FindEbur128.cmake +++ b/cmake/modules/FindEbur128.cmake @@ -62,12 +62,15 @@ find_library(Ebur128_LIBRARY ) mark_as_advanced(Ebur128_LIBRARY) +if(DEFINED PC_Ebur128_VERSION AND NOT PC_Ebur128_VERSION STREQUAL "") + set(Ebur128_VERSION "${PC_Ebur128_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Ebur128 - DEFAULT_MSG - Ebur128_LIBRARY - Ebur128_INCLUDE_DIR + REQUIRED_VARS Ebur128_LIBRARY Ebur128_INCLUDE_DIR + VERSION_VAR Ebur128_VERSION ) if(Ebur128_FOUND) diff --git a/cmake/modules/FindFLAC.cmake b/cmake/modules/FindFLAC.cmake index a40bc37f80..bad236a56f 100644 --- a/cmake/modules/FindFLAC.cmake +++ b/cmake/modules/FindFLAC.cmake @@ -61,12 +61,15 @@ find_library(FLAC_LIBRARY ) mark_as_advanced(FLAC_LIBRARY) +if(DEFINED PC_FLAC_VERSION AND NOT PC_FLAC_VERSION STREQUAL "") + set(FLAC_VERSION "${PC_FLAC_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( FLAC - DEFAULT_MSG - FLAC_LIBRARY - FLAC_INCLUDE_DIR + REQUIRED_VARS FLAC_LIBRARY FLAC_INCLUDE_DIR + VERSION_VAR FLAC_VERSION ) if(FLAC_FOUND) diff --git a/cmake/modules/FindID3Tag.cmake b/cmake/modules/FindID3Tag.cmake index bbeb6d8d95..2339a9e0dd 100644 --- a/cmake/modules/FindID3Tag.cmake +++ b/cmake/modules/FindID3Tag.cmake @@ -62,12 +62,15 @@ find_library(ID3Tag_LIBRARY ) mark_as_advanced(ID3Tag_LIBRARY) +if(DEFINED PC_ID3Tag_VERSION AND NOT PC_ID3Tag_VERSION STREQUAL "") + set(ID3Tag_VERSION "${PC_ID3Tag_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( ID3Tag - DEFAULT_MSG - ID3Tag_LIBRARY - ID3Tag_INCLUDE_DIR + REQUIRED_VARS ID3Tag_LIBRARY ID3Tag_INCLUDE_DIR + VERSION_VAR ID3Tag_VERSION ) if(ID3Tag_FOUND) diff --git a/cmake/modules/FindKeyFinder.cmake b/cmake/modules/FindKeyFinder.cmake index 10cf590eee..189ffdf42e 100644 --- a/cmake/modules/FindKeyFinder.cmake +++ b/cmake/modules/FindKeyFinder.cmake @@ -61,12 +61,15 @@ find_library(KeyFinder_LIBRARY ) mark_as_advanced(KeyFinder_LIBRARY) +if(DEFINED PC_KeyFinder_VERSION AND NOT PC_KeyFinder_VERSION STREQUAL "") + set(KeyFinder_VERSION "${PC_KeyFinder_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( KeyFinder - DEFAULT_MSG - KeyFinder_LIBRARY - KeyFinder_INCLUDE_DIR + REQUIRED_VARS KeyFinder_LIBRARY KeyFinder_INCLUDE_DIR + VERSION_VAR KeyFinder_VERSION ) if(KeyFinder_FOUND) diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index 015c4245e2..f7a0a8d403 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -63,12 +63,15 @@ find_library(LibUSB_LIBRARY ) mark_as_advanced(LibUSB_LIBRARY) +if(DEFINED PC_LibUSB_VERSION AND NOT PC_LibUSB_VERSION STREQUAL "") + set(LibUSB_VERSION "${PC_LibUSB_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( LibUSB - DEFAULT_MSG - LibUSB_LIBRARY - LibUSB_INCLUDE_DIR + REQUIRED_VARS LibUSB_LIBRARY LibUSB_INCLUDE_DIR + VERSION_VAR LibUSB_VERSION ) if(LibUSB_FOUND) diff --git a/cmake/modules/FindMAD.cmake b/cmake/modules/FindMAD.cmake index 0e68fbbf57..1ed268f5ae 100644 --- a/cmake/modules/FindMAD.cmake +++ b/cmake/modules/FindMAD.cmake @@ -62,12 +62,15 @@ find_library(MAD_LIBRARY ) mark_as_advanced(MAD_LIBRARY) +if(DEFINED PC_MAD_VERSION AND NOT PC_MAD_VERSION STREQUAL "") + set(MAD_VERSION "${PC_MAD_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( MAD - DEFAULT_MSG - MAD_LIBRARY - MAD_INCLUDE_DIR + REQUIRED_VARS MAD_LIBRARY MAD_INCLUDE_DIR + VERSION_VAR MAD_VERSION ) if(MAD_FOUND) diff --git a/cmake/modules/FindMP4.cmake b/cmake/modules/FindMP4.cmake index 95d757f99d..ed2cdf25bc 100644 --- a/cmake/modules/FindMP4.cmake +++ b/cmake/modules/FindMP4.cmake @@ -61,12 +61,15 @@ find_library(MP4_LIBRARY ) mark_as_advanced(MP4_LIBRARY) +if(DEFINED PC_MP4_VERSION AND NOT PC_MP4_VERSION STREQUAL "") + set(MP4_VERSION "${PC_MP4_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( MP4 - DEFAULT_MSG - MP4_LIBRARY - MP4_INCLUDE_DIR + REQUIRED_VARS MP4_LIBRARY MP4_INCLUDE_DIR + VERSION_VAR MP4_VERSION ) if(MP4_FOUND) diff --git a/cmake/modules/FindMP4v2.cmake b/cmake/modules/FindMP4v2.cmake index fc942dcc18..c9ef881090 100644 --- a/cmake/modules/FindMP4v2.cmake +++ b/cmake/modules/FindMP4v2.cmake @@ -61,12 +61,15 @@ find_library(MP4v2_LIBRARY ) mark_as_advanced(MP4v2_LIBRARY) +if(DEFINED PC_MP4v2_VERSION AND NOT PC_MP4v2_VERSION STREQUAL "") + set(MP4v2_VERSION "${PC_MP4v2_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( MP4v2 - DEFAULT_MSG - MP4v2_LIBRARY - MP4v2_INCLUDE_DIR + REQUIRED_VARS MP4v2_LIBRARY MP4v2_INCLUDE_DIR + VERSION_VAR MP4v2_VERSION ) if(MP4v2_FOUND) diff --git a/cmake/modules/FindModplug.cmake b/cmake/modules/FindModplug.cmake index 6a74f62a94..48b4d3f84d 100644 --- a/cmake/modules/FindModplug.cmake +++ b/cmake/modules/FindModplug.cmake @@ -61,12 +61,15 @@ find_library(Modplug_LIBRARY ) mark_as_advanced(Modplug_LIBRARY) +if(DEFINED PC_Modplug_VERSION AND NOT PC_Modplug_VERSION STREQUAL "") + set(Modplug_VERSION "${PC_Modplug_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Modplug - DEFAULT_MSG - Modplug_LIBRARY - Modplug_INCLUDE_DIR + REQUIRED_VARS Modplug_LIBRARY Modplug_INCLUDE_DIR + VERSION_VAR Modplug_VERSION ) if(Modplug_FOUND) diff --git a/cmake/modules/FindOgg.cmake b/cmake/modules/FindOgg.cmake index 4761c13ac9..8f620fd729 100644 --- a/cmake/modules/FindOgg.cmake +++ b/cmake/modules/FindOgg.cmake @@ -53,12 +53,15 @@ find_library(Ogg_LIBRARY ) mark_as_advanced(Ogg_LIBRARY) +if(DEFINED PC_Ogg_VERSION AND NOT PC_Ogg_VERSION STREQUAL "") + set(Ogg_VERSION "${PC_Ogg_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Ogg - REQUIRED_VARS - Ogg_INCLUDE_DIR - Ogg_LIBRARY + REQUIRED_VARS Ogg_LIBRARY Ogg_INCLUDE_DIR + VERSION_VAR Ogg_VERSION ) if(Ogg_FOUND) diff --git a/cmake/modules/FindPortMidi.cmake b/cmake/modules/FindPortMidi.cmake index fa4964148a..73ff808c62 100644 --- a/cmake/modules/FindPortMidi.cmake +++ b/cmake/modules/FindPortMidi.cmake @@ -61,13 +61,15 @@ find_library(PortTime_LIBRARY ) mark_as_advanced(PortTime_LIBRARY) +if(DEFINED PC_PortMidi_VERSION AND NOT PC_PortMidi_VERSION STREQUAL "") + set(PortMidi_VERSION "${PC_PortMidi_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( PortMidi - DEFAULT_MSG - PortMidi_LIBRARY - PortMidi_INCLUDE_DIR - PortTime_INCLUDE_DIR + REQUIRED_VARS PortMidi_LIBRARY PortMidi_INCLUDE_DIR PortTime_INCLUDE_DIR + VERSION_VAR PortMidi_VERSION ) if(PortMidi_FOUND) diff --git a/cmake/modules/FindShoutidjc.cmake b/cmake/modules/FindShoutidjc.cmake index ce6bb839f5..0cfba62e0b 100644 --- a/cmake/modules/FindShoutidjc.cmake +++ b/cmake/modules/FindShoutidjc.cmake @@ -63,12 +63,15 @@ find_library(Shoutidjc_LIBRARY ) mark_as_advanced(Shoutidjc_LIBRARY) +if(DEFINED PC_Shoutidjc_VERSION AND NOT PC_Shoutidjc_VERSION STREQUAL "") + set(Shoutidjc_VERSION "${PC_Shoutidjc_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Shoutidjc - DEFAULT_MSG - Shoutidjc_LIBRARY - Shoutidjc_INCLUDE_DIR + REQUIRED_VARS Shoutidjc_LIBRARY Shoutidjc_INCLUDE_DIR + VERSION_VAR Shoutidjc_VERSION ) if(Shoutidjc_FOUND) diff --git a/cmake/modules/FindSndFile.cmake b/cmake/modules/FindSndFile.cmake index 38d8555029..8f81919737 100644 --- a/cmake/modules/FindSndFile.cmake +++ b/cmake/modules/FindSndFile.cmake @@ -62,12 +62,15 @@ find_library(SndFile_LIBRARY ) mark_as_advanced(SndFile_LIBRARY) +if(DEFINED PC_SndFile_VERSION AND NOT PC_SndFile_VERSION STREQUAL "") + set(SndFile_VERSION "${PC_SndFile_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( SndFile - DEFAULT_MSG - SndFile_LIBRARY - SndFile_INCLUDE_DIR + REQUIRED_VARS SndFile_LIBRARY SndFile_INCLUDE_DIR + VERSION_VAR SndFile_VERSION ) file(STRINGS "${SndFile_INCLUDE_DIR}/sndfile.h" SndFile_SUPPORTS_SET_COMPRESSION_LEVEL REGEX ".*SFC_SET_COMPRESSION_LEVEL.*") diff --git a/cmake/modules/FindSoundTouch.cmake b/cmake/modules/FindSoundTouch.cmake index 8b2ccd54ee..690ca24c62 100644 --- a/cmake/modules/FindSoundTouch.cmake +++ b/cmake/modules/FindSoundTouch.cmake @@ -62,7 +62,7 @@ find_library(SoundTouch_LIBRARY mark_as_advanced(SoundTouch_LIBRARY) # Version detection -if(DEFINED PC_SoundTouch_VERSION) +if(DEFINED PC_SoundTouch_VERSION AND NOT PC_SoundTouch_VERSION STREQUAL "") set(SoundTouch_VERSION "${PC_SoundTouch_VERSION}") else() if(EXISTS "${SoundTouch_INCLUDE_DIR}/soundtouch/SoundTouch.h") diff --git a/cmake/modules/FindUpower.cmake b/cmake/modules/FindUpower.cmake index 1513489a6d..8b36d3b0e6 100644 --- a/cmake/modules/FindUpower.cmake +++ b/cmake/modules/FindUpower.cmake @@ -62,12 +62,15 @@ find_library(Upower_LIBRARY ) mark_as_advanced(Upower_LIBRARY) +if(DEFINED PC_Upower_VERSION AND NOT PC_Upower_VERSION STREQUAL "") + set(Upower_VERSION "${PC_Upower_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Upower - DEFAULT_MSG - Upower_LIBRARY - Upower_INCLUDE_DIR + REQUIRED_VARS Upower_LIBRARY Upower_INCLUDE_DIR + VERSION_VAR Upower_VERSION ) if(Upower_FOUND) diff --git a/cmake/modules/Findlilv.cmake b/cmake/modules/Findlilv.cmake index f23b0bcf1b..be51595f8f 100644 --- a/cmake/modules/Findlilv.cmake +++ b/cmake/modules/Findlilv.cmake @@ -63,12 +63,15 @@ find_library(lilv_LIBRARY ) mark_as_advanced(lilv_LIBRARY) +if(DEFINED PC_lilv_VERSION AND NOT PC_lilv_VERSION STREQUAL "") + set(lilv_VERSION "${PC_lilv_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( lilv - DEFAULT_MSG - lilv_LIBRARY - lilv_INCLUDE_DIR + REQUIRED_VARS lilv_LIBRARY lilv_INCLUDE_DIR + VERSION_VAR lilv_VERSION ) if(lilv_FOUND) diff --git a/cmake/modules/Findrubberband.cmake b/cmake/modules/Findrubberband.cmake index 95269c3f70..3ce168c441 100644 --- a/cmake/modules/Findrubberband.cmake +++ b/cmake/modules/Findrubberband.cmake @@ -61,12 +61,15 @@ find_library(rubberband_LIBRARY ) mark_as_advanced(rubberband_LIBRARY) +if(DEFINED PC_rubberband_VERSION AND NOT PC_rubberband_VERSION STREQUAL "") + set(rubberband_VERSION "${PC_rubberband_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( rubberband - DEFAULT_MSG - rubberband_LIBRARY - rubberband_INCLUDE_DIR + REQUIRED_VARS rubberband_LIBRARY rubberband_INCLUDE_DIR + VERSION_VAR rubberband_VERSION ) if(rubberband_FOUND) diff --git a/cmake/modules/Findwavpack.cmake b/cmake/modules/Findwavpack.cmake index 30943deb92..5d1b3c5090 100644 --- a/cmake/modules/Findwavpack.cmake +++ b/cmake/modules/Findwavpack.cmake @@ -61,12 +61,15 @@ find_library(wavpack_LIBRARY NAMES wavpack wv wavpackdll ) mark_as_advanced(wavpack_LIBRARY) +if(DEFINED PC_wavpack_VERSION AND NOT PC_wavpack_VERSION STREQUAL "") + set(wavpack_VERSION "${PC_wavpack_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( wavpack - DEFAULT_MSG - wavpack_LIBRARY - wavpack_INCLUDE_DIR + REQUIRED_VARS wavpack_LIBRARY wavpack_INCLUDE_DIR + VERSION_VAR wavpack_VERSION ) if(wavpack_FOUND) -- cgit v1.2.3 From 22d8a2a1abab378eb71a3b42a048d1b7792fb90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 21 Dec 2022 22:29:01 +0100 Subject: Report versions of found library during cmake configure. This changes the main only files. --- cmake/modules/FindOpus.cmake | 9 ++++++--- cmake/modules/FindOpusFile.cmake | 9 ++++++--- cmake/modules/FindPortAudio.cmake | 9 ++++++--- cmake/modules/FindTagLib.cmake | 13 ++++++++++++- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/cmake/modules/FindOpus.cmake b/cmake/modules/FindOpus.cmake index 255a43b0a2..a3f1b5b888 100644 --- a/cmake/modules/FindOpus.cmake +++ b/cmake/modules/FindOpus.cmake @@ -53,12 +53,15 @@ find_library(Opus_LIBRARY ) mark_as_advanced(Opus_LIBRARY) +if(DEFINED PC_Opus_VERSION AND NOT PC_Opus_VERSION STREQUAL "") + set(Opus_VERSION "${PC_Opus_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Opus - DEFAULT_MSG - Opus_LIBRARY - Opus_INCLUDE_DIR + REQUIRED_VARS Opus_LIBRARY Opus_INCLUDE_DIR + VERSION_VAR Opus_VERSION ) if(Opus_FOUND) diff --git a/cmake/modules/FindOpusFile.cmake b/cmake/modules/FindOpusFile.cmake index aac46427e3..8f122e5d4d 100644 --- a/cmake/modules/FindOpusFile.cmake +++ b/cmake/modules/FindOpusFile.cmake @@ -60,12 +60,15 @@ find_library(OpusFile_LIBRARY ) mark_as_advanced(OpusFile_LIBRARY) +if(DEFINED PC_OpusFile_VERSION AND NOT PC_OpusFile_VERSION STREQUAL "") + set(OpusFile_VERSION "${PC_OpusFile_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( OpusFile - DEFAULT_MSG - OpusFile_LIBRARY - OpusFile_INCLUDE_DIR + REQUIRED_VARS OpusFile_LIBRARY OpusFile_INCLUDE_DIR + VERSION_VAR OpusFile_VERSION ) if(OpusFile_FOUND) diff --git a/cmake/modules/FindPortAudio.cmake b/cmake/modules/FindPortAudio.cmake index 90094685c7..e555cbe297 100644 --- a/cmake/modules/FindPortAudio.cmake +++ b/cmake/modules/FindPortAudio.cmake @@ -67,12 +67,15 @@ find_library(PortAudio_LIBRARY ) mark_as_advanced(PortAudio_LIBRARY) +if(DEFINED PC_PortAudio_VERSION AND NOT PC_PortAudio_VERSION STREQUAL "") + set(PortAudio_VERSION "${PC_PortAudio_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( PortAudio - DEFAULT_MSG - PortAudio_LIBRARY - PortAudio_INCLUDE_DIR + REQUIRED_VARS PortAudio_LIBRARY PortAudio_INCLUDE_DIR + VERSION_VAR PortAudio_VERSION ) if(PortAudio_FOUND) diff --git a/cmake/modules/FindTagLib.cmake b/cmake/modules/FindTagLib.cmake index ed2505219c..7966cc5402 100644 --- a/cmake/modules/FindTagLib.cmake +++ b/cmake/modules/FindTagLib.cmake @@ -64,8 +64,19 @@ find_library(TagLib_LIBRARY ) mark_as_advanced(TagLib_LIBRARY) +if(DEFINED PC_Chromaprint_VERSION AND NOT PC_Chromaprint_VERSION STREQUAL "") + set(Chromaprint_VERSION "${PC_Chromaprint_VERSION}") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + Chromaprint + REQUIRED_VARS Chromaprint_LIBRARY Chromaprint_INCLUDE_DIR + VERSION_VAR Chromaprint_VERSION +) + # Version detection -if(PC_TagLib_VERSION) +if(DEFINED PC_TagLib_VERSION AND NOT PC_TagLib_VERSION STREQUAL "") set(TagLib_VERSION "${PC_TagLib_VERSION}") else() if (EXISTS "${TagLib_INCLUDE_DIR}/taglib.h") -- cgit v1.2.3 From ae79dadb5ca189ea959dff9c7febf473f30c5ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 22 Dec 2022 09:44:24 +0100 Subject: Update FindJACK.cmake to match other Find* files --- cmake/modules/FindJACK.cmake | 50 ++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/cmake/modules/FindJACK.cmake b/cmake/modules/FindJACK.cmake index dfd2b0dad3..62f743aa49 100644 --- a/cmake/modules/FindJACK.cmake +++ b/cmake/modules/FindJACK.cmake @@ -24,17 +24,21 @@ This module provides the following imported targets, if found: find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(JACK jack) -else() - find_library(JACK_LINK_LIBRARIES - NAMES jack - DOC "JACK library" - ) - find_path(JACK_INCLUDEDIR - NAMES jack/jack.h - DOC "JACK header" - ) endif() +find_path(JACK_INCLUDE_DIR + NAMES jack/jack.h + PATHS ${PC_JACK_INCLUDE_DIRS} + DOC "JACK include directory") +mark_as_advanced(JACK_INCLUDE_DIR) + +find_library(JACK_LIBRARY + NAMES jack + PATHS ${PC_JACK_LIBRARY_DIRS} + DOC "JACK library" +) +mark_as_advanced(JACK_LIBRARY) + if(WIN32) # vcpkg provides CMake targets for pthreads4w # This won't work if pthreads4w was built without vcpkg. @@ -42,16 +46,30 @@ if(WIN32) list(APPEND JACK_LINK_LIBRARIES PThreads4W::PThreads4W) endif() +if(DEFINED PC_JACK_VERSION AND NOT PC_JACK_VERSION STREQUAL "") + set(JACK_VERSION "${PC_JACK_VERSION}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( JACK - DEFAULT_MSG - JACK_LINK_LIBRARIES - JACK_INCLUDEDIR + REQUIRED_VARS JACK_LIBRARY JACK_INCLUDE_DIR + VERSION_VAR JACK_VERSION + ) -if(JACK_FOUND AND NOT TARGET JACK::jack) - add_library(JACK::jack INTERFACE IMPORTED) - target_link_libraries(JACK::jack INTERFACE "${JACK_LINK_LIBRARIES}") - target_include_directories(JACK::jack INTERFACE "${JACK_INCLUDEDIR}") +if(JACK_FOUND) + set(JACK_LIBRARIES "${JACK_LIBRARY}") + set(JACK_INCLUDE_DIRS "${JACK_INCLUDE_DIR}") + set(JACK_DEFINITIONS ${PC_JACK_CFLAGS_OTHER}) + + if(NOT TARGET JACK::jack) + add_library(JACK::jack UNKNOWN IMPORTED) + set_target_properties(JACK::jack + PROPERTIES + IMPORTED_LOCATION "${JACK_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_JACK_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${JACK_INCLUDE_DIR}" + ) + endif() endif() -- cgit v1.2.3 From cdaff802ea65796aa316be38ab62e05017642ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 22 Dec 2022 23:39:08 +0100 Subject: Forward CMAKE_PREFIX_PATH using | as separator to workaround a shell issue --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b15da69298..4e979c2e3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1860,6 +1860,11 @@ endif() target_include_directories(mixxx-lib SYSTEM PUBLIC lib/fidlib) target_link_libraries(mixxx-lib PRIVATE fidlib) +# Create a list from CMAKE_PREFIX_PATH with an alternate separator +# This is required to forward CMAKE_PREFIX_PATH in ExternalProject_Add() +# using the LIST_SEPARATOR option +string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}") + # KeyFinder option(KEYFINDER "KeyFinder support" ON) if(KEYFINDER) @@ -1886,12 +1891,14 @@ if(KEYFINDER) -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_PREFIX_PATH:PATH="${CMAKE_PREFIX_PATH}" + -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH_ALT_SEP} + -DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -DBUILD_TESTING=OFF BUILD_COMMAND ${CMAKE_COMMAND} --build . BUILD_BYPRODUCTS /${KeyFinder_LIBRARY} EXCLUDE_FROM_ALL TRUE + LIST_SEPARATOR | ) # This is a bit of a hack to make sure that the include directory actually @@ -1999,12 +2006,14 @@ else() -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_PREFIX_PATH=${PIPE_DELIMITED_CMAKE_PREFIX_PATH} + -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH_ALT_SEP} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -DBUILD_TESTING=OFF BUILD_COMMAND ${CMAKE_COMMAND} --build . BUILD_BYPRODUCTS /${PortAudio_LIBRARIES} EXCLUDE_FROM_ALL TRUE + LIST_SEPARATOR | ) add_dependencies(mixxx-lib portaudio) target_link_libraries(mixxx-lib PRIVATE -- cgit v1.2.3 From ae797b2c84e5ec13492a1bd75da6f79fca18f018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 23 Dec 2022 00:55:31 +0100 Subject: lower MIN_LIBKEYFINDER_VERSION, to allow using the vcpkg version --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e979c2e3a..a2af8d0af2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1868,8 +1868,9 @@ string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}") # KeyFinder option(KEYFINDER "KeyFinder support" ON) if(KEYFINDER) - set(LIBKEYFINDER_VERSION 2.2.6) - find_package(KeyFinder ${LIBKEYFINDER_VERSION}) + set(MIN_LIBKEYFINDER_VERSION 2.2.4) + set(FETCH_LIBKEYFINDER_VERSION 2.2.6) + find_package(KeyFinder ${MIN_LIBKEYFINDER_VERSION}) if (KeyFinder_FOUND) target_link_libraries(mixxx-lib PRIVATE KeyFinder::KeyFinder) else() @@ -1881,7 +1882,7 @@ if(KEYFINDER) # copy it into DOWNLOAD_DIR under DOWNLOAD_NAME prior to starting # the configuration. ExternalProject_Add(libkeyfinder - URL "https://github.com/mixxxdj/libkeyfinder/archive/refs/tags/v${LIBKEYFINDER_VERSION}.zip" + URL "https://github.com/mixxxdj/libkeyfinder/archive/refs/tags/v${FETCH_LIBKEYFINDER_VERSION}.zip" URL_HASH SHA256=f15deb56c2dcaa6b10dc3717a7d2f42a8407c04ad550f694de42118be998d256 DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/downloads" DOWNLOAD_NAME "libkeyfinder-${LIBKEYFINDER_VERSION}.zip" -- cgit v1.2.3 From b43cec6542f7ea173f6fbd33d2e8469aad454404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 23 Dec 2022 09:47:57 +0100 Subject: Improve error conditions in ReadAheadManager::getNextSamples() --- src/engine/readaheadmanager.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/engine/readaheadmanager.cpp b/src/engine/readaheadmanager.cpp index 5c3d15e2ba..9630954ffd 100644 --- a/src/engine/readaheadmanager.cpp +++ b/src/engine/readaheadmanager.cpp @@ -75,7 +75,7 @@ SINT ReadAheadManager::getNextSamples(double dRate, CSAMPLE* pOutput, } // Sanity checks. - if (samples_from_reader < 0) { + VERIFY_OR_DEBUG_ASSERT(samples_from_reader >= 0) { qDebug() << "Need negative samples in ReadAheadManager::getNextSamples. Ignoring read"; return 0; } @@ -152,12 +152,10 @@ SINT ReadAheadManager::getNextSamples(double dRate, CSAMPLE* pOutput, } // do crossfade from the current buffer into the new loop beginning - if (samples_from_reader != 0) { // avoid division by zero - SampleUtil::linearCrossfadeBuffersOut( - pOutput, - m_pCrossFadeBuffer, - samples_from_reader); - } + SampleUtil::linearCrossfadeBuffersOut( + pOutput, + m_pCrossFadeBuffer, + samples_from_reader); } //qDebug() << "read" << m_currentPosition << samples_read; -- cgit v1.2.3 From cd16288d9376a20a24236feb6bfbdc184f334a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 23 Dec 2022 09:55:41 +0100 Subject: Replace possible locking m_pSoundTouch->flush() call. The code should be unreachable anyway. Assert for this and remove the wrong early exit by break. --- src/engine/bufferscalers/enginebufferscalest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/bufferscalers/enginebufferscalest.cpp b/src/engine/bufferscalers/enginebufferscalest.cpp index cff3c4a9c2..b780fedb5e 100644 --- a/src/engine/bufferscalers/enginebufferscalest.cpp +++ b/src/engine/bufferscalers/enginebufferscalest.cpp @@ -154,8 +154,12 @@ double EngineBufferScaleST::scaleBuffer( m_pSoundTouch->putSamples(buffer_back.data(), iAvailFrames); } else { if (last_read_failed) { - m_pSoundTouch->flush(); - break; // exit loop after failure + DEBUG_ASSERT(!"getNextSamples must never fail"); + // Add silence that allows to Flush the last samples out of Soundtouch + // m_pSoundTouch->flush(); must not be used, because it allocates a + // temporary buffer in the heap which maybe locking + SampleUtil::clear(m_bufferBack.data(), m_bufferBack.size()); + m_pSoundTouch->putSamples(m_bufferBack.data(), m_bufferBack.size()); } last_read_failed = true; } -- cgit v1.2.3 From 94f50888651e3ecc4d1cbf8ee01cceac046473e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 23 Dec 2022 10:24:14 +0100 Subject: Remove unnecessary flushing and build up logic with Rrubbrband. Assert that assumption. --- .../bufferscalers/enginebufferscalerubberband.cpp | 30 ++++++++++------------ .../bufferscalers/enginebufferscalerubberband.h | 2 +- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/engine/bufferscalers/enginebufferscalerubberband.cpp b/src/engine/bufferscalers/enginebufferscalerubberband.cpp index 6f2e60d74f..8ecd96b163 100644 --- a/src/engine/bufferscalers/enginebufferscalerubberband.cpp +++ b/src/engine/bufferscalers/enginebufferscalerubberband.cpp @@ -144,13 +144,15 @@ SINT EngineBufferScaleRubberBand::retrieveAndDeinterleave( } void EngineBufferScaleRubberBand::deinterleaveAndProcess( - const CSAMPLE* pBuffer, SINT frames, bool flush) { - + const CSAMPLE* pBuffer, + SINT frames) { SampleUtil::deinterleaveBuffer( - m_retrieve_buffer[0], m_retrieve_buffer[1], pBuffer, frames); + m_retrieve_buffer[0], + m_retrieve_buffer[1], + pBuffer, + frames); - m_pRubberBand->process((const float* const*)m_retrieve_buffer, - frames, flush); + m_pRubberBand->process((const float* const*)m_retrieve_buffer, frames, false); } double EngineBufferScaleRubberBand::scaleBuffer( @@ -168,7 +170,6 @@ double EngineBufferScaleRubberBand::scaleBuffer( SINT remaining_frames = getOutputSignal().samples2frames(iOutputBufferSize); CSAMPLE* read = pOutputBuffer; bool last_read_failed = false; - bool break_out_after_retrieve_and_reset_rubberband = false; while (remaining_frames > 0) { // ReadAheadManager will eventually read the requested frames with // enough calls to retrieveAndDeinterleave because CachingReader returns @@ -180,14 +181,6 @@ double EngineBufferScaleRubberBand::scaleBuffer( total_received_frames += received_frames; read += getOutputSignal().frames2samples(received_frames); - if (break_out_after_retrieve_and_reset_rubberband) { - //qDebug() << "break_out_after_retrieve_and_reset_rubberband"; - // If we break out early then we have flushed RubberBand and need to - // reset it. - m_pRubberBand->reset(); - break; - } - size_t iLenFramesRequired = m_pRubberBand->getSamplesRequired(); if (iLenFramesRequired == 0) { // rubberband 1.3 (packaged up through Ubuntu Quantal) has a bug @@ -213,14 +206,17 @@ double EngineBufferScaleRubberBand::scaleBuffer( if (iAvailFrames > 0) { last_read_failed = false; - deinterleaveAndProcess(m_buffer_back, iAvailFrames, false); + deinterleaveAndProcess(m_buffer_back, iAvailFrames); } else { if (last_read_failed) { + DEBUG_ASSERT(!"getNextSamples must never fail"); // Flush and break out after the next retrieval. If we are // at EOF this serves to get the last samples out of // RubberBand. - deinterleaveAndProcess(m_buffer_back, 0, true); - break_out_after_retrieve_and_reset_rubberband = true; + SampleUtil::clear( + m_buffer_back, + getOutputSignal().frames2samples(iLenFramesRequired)); + deinterleaveAndProcess(m_buffer_back, iLenFramesRequired); } last_read_failed = true; } diff --git a/src/engine/bufferscalers/enginebufferscalerubberband.h b/src/engine/bufferscalers/enginebufferscalerubberband.h index dbbd3064e9..01c1be2902 100644 --- a/src/engine/bufferscalers/enginebufferscalerubberband.h +++ b/src/engine/bufferscalers/enginebufferscalerubberband.h @@ -32,7 +32,7 @@ class EngineBufferScaleRubberBand : public EngineBufferScale { // Reset RubberBand library with new audio signal void onSampleRateChanged() override; - void deinterleaveAndProcess(const CSAMPLE* pBuffer, SINT frames, bool flush); + void deinterleaveAndProcess(const CSAMPLE* pBuffer, SINT frames); SINT retrieveAndDeinterleave(CSAMPLE* pBuffer, SINT frames); // The read-ahead manager that we use to fetch samples -- cgit v1.2.3 From 840a9a18fe3de0f2a2efe1ba40e9a2cc862e2896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 23 Dec 2022 10:26:10 +0100 Subject: Don't break loop if the caching reader fails, which never happens. Assert for that. --- src/engine/bufferscalers/enginebufferscalelinear.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/bufferscalers/enginebufferscalelinear.cpp b/src/engine/bufferscalers/enginebufferscalelinear.cpp index 78aca3ecb4..c10f4c5d2b 100644 --- a/src/engine/bufferscalers/enginebufferscalelinear.cpp +++ b/src/engine/bufferscalers/enginebufferscalelinear.cpp @@ -291,7 +291,9 @@ SINT EngineBufferScaleLinear::do_scale(CSAMPLE* buf, SINT buf_size) { if (m_bufferIntSize == 0) { if (++read_failed_count > 1) { - break; + DEBUG_ASSERT(!"getNextSamples must never fail"); + SampleUtil::clear(m_bufferInt, samples_to_read); + m_bufferIntSize = getOutputSignal().samples2frames(samples_to_read); } else { continue; } -- cgit v1.2.3 From d46a8c9ac81b499a2df220599a7ca7e9b36fd0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 17 Mar 2023 17:53:14 +0100 Subject: Dispose not working read_failed_count --- src/engine/bufferscalers/enginebufferscalelinear.cpp | 19 +++++-------------- src/engine/bufferscalers/enginebufferscalest.cpp | 4 ++-- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/engine/bufferscalers/enginebufferscalelinear.cpp b/src/engine/bufferscalers/enginebufferscalelinear.cpp index c10f4c5d2b..f5f3aafef8 100644 --- a/src/engine/bufferscalers/enginebufferscalelinear.cpp +++ b/src/engine/bufferscalers/enginebufferscalelinear.cpp @@ -219,7 +219,6 @@ SINT EngineBufferScaleLinear::do_scale(CSAMPLE* buf, SINT buf_size) { SINT unscaled_frames_needed = static_cast(frames + m_dNextFrame - floor(m_dNextFrame)); - int read_failed_count = 0; CSAMPLE floor_sample[2]; CSAMPLE ceil_sample[2]; @@ -289,14 +288,11 @@ SINT EngineBufferScaleLinear::do_scale(CSAMPLE* buf, SINT buf_size) { rate_new == 0 ? rate_old : rate_new, m_bufferInt, samples_to_read); - if (m_bufferIntSize == 0) { - if (++read_failed_count > 1) { - DEBUG_ASSERT(!"getNextSamples must never fail"); - SampleUtil::clear(m_bufferInt, samples_to_read); - m_bufferIntSize = getOutputSignal().samples2frames(samples_to_read); - } else { - continue; - } + VERIFY_OR_DEBUG_ASSERT(m_bufferIntSize != 0) { + // getNextSamples() must never fail, + // using silence as a last resort + SampleUtil::clear(m_bufferInt, samples_to_read); + m_bufferIntSize = getOutputSignal().samples2frames(samples_to_read); } frames_read += getOutputSignal().samples2frames(m_bufferIntSize); @@ -307,11 +303,6 @@ SINT EngineBufferScaleLinear::do_scale(CSAMPLE* buf, SINT buf_size) { currentFrameFloor = static_cast(floor(m_dCurrentFrame)); } while (getOutputSignal().frames2samples(currentFrameFloor) + 3 >= m_bufferIntSize); - // I guess? - if (read_failed_count > 1) { - break; - } - // Now that the buffer is up to date, we can get the value of the sample // at the floor of our position. if (currentFrameFloor >= 0) { diff --git a/src/engine/bufferscalers/enginebufferscalest.cpp b/src/engine/bufferscalers/enginebufferscalest.cpp index b780fedb5e..9ead8b7781 100644 --- a/src/engine/bufferscalers/enginebufferscalest.cpp +++ b/src/engine/bufferscalers/enginebufferscalest.cpp @@ -158,8 +158,8 @@ double EngineBufferScaleST::scaleBuffer( // Add silence that allows to Flush the last samples out of Soundtouch // m_pSoundTouch->flush(); must not be used, because it allocates a // temporary buffer in the heap which maybe locking - SampleUtil::clear(m_bufferBack.data(), m_bufferBack.size()); - m_pSoundTouch->putSamples(m_bufferBack.data(), m_bufferBack.size()); + SampleUtil::clear(buffer_back.data(), buffer_back.size()); + m_pSoundTouch->putSamples(buffer_back.data(), buffer_back.size()); } last_read_failed = true; } -- cgit v1.2.3 From bd17f7ce4be4c01296169e4a7ee421f883d4cfb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 15 May 2023 16:32:07 +0200 Subject: Don't allow to set loop in/out at the silence padding after the track. This fixes https://github.com/mixxxdj/mixxx/issues/11557 --- src/engine/controls/loopingcontrol.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index e055c0257c..052d0dc339 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -513,11 +513,16 @@ void LoopingControl::setLoopInToCurrentPosition() { const mixxx::BeatsPointer pBeats = m_pBeats; LoopSamples loopSamples = m_loopSamples.getValue(); double quantizedBeat = -1; - double pos = m_currentSample.getValue(); + + SampleOfTrack sampleOfTrack = getSampleOfTrack(); + // Note: currentPos can be past the end of the track, in the padded + // silence of the last buffer. This position might be not reachable in + // a future runs, depending on the buffering. + double pos = math_min(sampleOfTrack.current, sampleOfTrack.total); if (m_pQuantizeEnabled->toBool() && pBeats) { if (m_bAdjustingLoopIn) { double closestBeat = m_pClosestBeat->get(); - if (closestBeat == m_currentSample.getValue()) { + if (closestBeat == pos) { quantizedBeat = closestBeat; } else { quantizedBeat = m_pPreviousBeat->get(); @@ -615,11 +620,16 @@ void LoopingControl::setLoopOutToCurrentPosition() { mixxx::BeatsPointer pBeats = m_pBeats; LoopSamples loopSamples = m_loopSamples.getValue(); double quantizedBeat = -1; - double pos = m_currentSample.getValue(); + + SampleOfTrack sampleOfTrack = getSampleOfTrack(); + // Note: currentPos can be past the end of the track, in the padded + // silence of the last buffer. This position might be not reachable in + // a future runs, depending on the buffering. + double pos = math_min(sampleOfTrack.current, sampleOfTrack.total); if (m_pQuantizeEnabled->toBool() && pBeats) { if (m_bAdjustingLoopOut) { double closestBeat = m_pClosestBeat->get(); - if (closestBeat == m_currentSample.getValue()) { + if (closestBeat == pos) { quantizedBeat = closestBeat; } else { quantizedBeat = m_pNextBeat->get(); @@ -1039,7 +1049,12 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable // give start and end defaults so we can detect problems LoopSamples newloopSamples = {kNoTrigger, kNoTrigger, false}; LoopSamples loopSamples = m_loopSamples.getValue(); - double currentSample = m_currentSample.getValue(); + + SampleOfTrack sampleOfTrack = getSampleOfTrack(); + // Note: currentPos can be past the end of the track, in the padded + // silence of the last buffer. This position might be not reachable in + // a future runs, depending on the buffering. + double currentSample = math_min(sampleOfTrack.current, sampleOfTrack.total); // Start from the current position/closest beat and // create the loop around X beats from there. -- cgit v1.2.3 From 4f6df515c554deb8c3725b4eb3eb01c4c0a39b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 15 May 2023 16:32:07 +0200 Subject: Read track total samples only one time in LoopingControl::slotBeatLoop() --- src/engine/controls/loopingcontrol.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index 052d0dc339..03854f086f 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -1037,9 +1037,9 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable beats = minBeatSize; } - int samples = static_cast(m_pTrackSamples->get()); + SampleOfTrack sampleOfTrack = getSampleOfTrack(); const mixxx::BeatsPointer pBeats = m_pBeats; - if (samples == 0 || !pBeats) { + if (sampleOfTrack.total <= 0 || !pBeats) { clearActiveBeatLoop(); m_pCOBeatLoopSize->setAndConfirm(beats); return; @@ -1050,32 +1050,26 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable LoopSamples newloopSamples = {kNoTrigger, kNoTrigger, false}; LoopSamples loopSamples = m_loopSamples.getValue(); - SampleOfTrack sampleOfTrack = getSampleOfTrack(); - // Note: currentPos can be past the end of the track, in the padded - // silence of the last buffer. This position might be not reachable in - // a future runs, depending on the buffering. - double currentSample = math_min(sampleOfTrack.current, sampleOfTrack.total); - // Start from the current position/closest beat and // create the loop around X beats from there. if (keepStartPoint) { if (loopSamples.start != kNoTrigger) { newloopSamples.start = loopSamples.start; } else { - newloopSamples.start = currentSample; + newloopSamples.start = math_min(sampleOfTrack.current, sampleOfTrack.total); } } else { // loop_in is set to the closest beat if quantize is on and the loop size is >= 1 beat. // The closest beat might be ahead of play position and will cause a catching loop. double prevBeat; double nextBeat; - pBeats->findPrevNextBeats(currentSample, &prevBeat, &nextBeat); + pBeats->findPrevNextBeats(sampleOfTrack.current, &prevBeat, &nextBeat); if (m_pQuantizeEnabled->toBool() && prevBeat != -1) { double beatLength = nextBeat - prevBeat; double loopLength = beatLength * beats; - double closestBeat = pBeats->findClosestBeat(currentSample); + double closestBeat = pBeats->findClosestBeat(sampleOfTrack.current); if (beats >= 1.0) { newloopSamples.start = closestBeat; } else { @@ -1086,12 +1080,12 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable // // If we press 1/2 beatloop we want loop from 50% to 100%, // If I press 1/4 beatloop, we want loop from 50% to 75% etc - double samplesSinceLastBeat = currentSample - prevBeat; + double samplesSinceLastBeat = sampleOfTrack.current - prevBeat; // find the previous beat fraction and check if the current position is closer to this or the next one // place the new loop start to the closer one double previousFractionBeat = prevBeat + floor(samplesSinceLastBeat / loopLength) * loopLength; - double samplesSinceLastFractionBeat = currentSample - previousFractionBeat; + double samplesSinceLastFractionBeat = sampleOfTrack.current - previousFractionBeat; if (samplesSinceLastFractionBeat <= (loopLength / 2.0)) { newloopSamples.start = previousFractionBeat; @@ -1110,13 +1104,16 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable newloopSamples.start -= loopLength; } } else { - newloopSamples.start = currentSample; + newloopSamples.start = sampleOfTrack.current; } } newloopSamples.end = pBeats->findNBeatsFromSample(newloopSamples.start, beats); - if (newloopSamples.start >= newloopSamples.end // happens when the call above fails - || newloopSamples.end > samples) { // Do not allow beat loops to go beyond the end of the track + if (newloopSamples.start >= + newloopSamples.end // happens when the call above fails + || newloopSamples.end > + sampleOfTrack.total) { // Do not allow beat loops to go + // beyond the end of the track // If a track is loaded with beatloop_size larger than // the distance between the loop in point and // the end of the track, let beatloop_size be set to -- cgit v1.2.3 From 09d28e29c01512eaf5e14e41863602a9c189a351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 15 May 2023 23:08:51 +0200 Subject: Add a now required ProcessBuffer() call to LoopingControlTest --- src/test/looping_control_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/looping_control_test.cpp b/src/test/looping_control_test.cpp index 7f0dcb1fde..e91284db87 100644 --- a/src/test/looping_control_test.cpp +++ b/src/test/looping_control_test.cpp @@ -63,6 +63,8 @@ class LoopingControlTest : public MockedEngineBackendTest { m_pButtonBeatLoopRoll1Activate = std::make_unique(m_sGroup1, "beatlooproll_1_activate"); m_pButtonBeatLoopRoll2Activate = std::make_unique(m_sGroup1, "beatlooproll_2_activate"); m_pButtonBeatLoopRoll4Activate = std::make_unique(m_sGroup1, "beatlooproll_4_activate"); + + ProcessBuffer(); } bool isLoopEnabled() { @@ -427,8 +429,10 @@ TEST_F(LoopingControlTest, LoopDoubleButton_IgnoresPastTrackEnd) { TEST_F(LoopingControlTest, LoopDoubleButton_DoublesBeatloopSize) { m_pTrack1->trySetBpm(120.0); m_pBeatLoopSize->set(16.0); + EXPECT_EQ(16.0, m_pBeatLoopSize->get()); m_pButtonBeatLoopActivate->set(1.0); m_pButtonBeatLoopActivate->set(0.0); + EXPECT_EQ(16.0, m_pBeatLoopSize->get()); m_pButtonLoopDouble->set(1.0); m_pButtonLoopDouble->set(0.0); EXPECT_EQ(32.0, m_pBeatLoopSize->get()); -- cgit v1.2.3 From 83ffe0fc1db0527fcd5afcd6e7ef07bc2052f474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 16 May 2023 23:39:38 +0200 Subject: Make sure that loop in and loop out are not placed one an extended beat behind the track. --- src/engine/controls/loopingcontrol.cpp | 56 ++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index 03854f086f..aee9081079 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -520,18 +520,24 @@ void LoopingControl::setLoopInToCurrentPosition() { // a future runs, depending on the buffering. double pos = math_min(sampleOfTrack.current, sampleOfTrack.total); if (m_pQuantizeEnabled->toBool() && pBeats) { - if (m_bAdjustingLoopIn) { - double closestBeat = m_pClosestBeat->get(); - if (closestBeat == pos) { - quantizedBeat = closestBeat; + double prevBeat; + double nextBeat; + if (pBeats->findPrevNextBeats(pos, &prevBeat, &nextBeat)) { + double closestBeat = + (nextBeat - pos > pos - prevBeat) ? prevBeat : nextBeat; + if (m_bAdjustingLoopIn) { + if (closestBeat == pos) { + pos = closestBeat; + } else { + pos = prevBeat; + } } else { - quantizedBeat = m_pPreviousBeat->get(); + if (closestBeat > sampleOfTrack.total) { + pos = prevBeat; + } else { + pos = closestBeat; + } } - } else { - quantizedBeat = m_pClosestBeat->get(); - } - if (quantizedBeat != -1) { - pos = quantizedBeat; } } @@ -627,18 +633,28 @@ void LoopingControl::setLoopOutToCurrentPosition() { // a future runs, depending on the buffering. double pos = math_min(sampleOfTrack.current, sampleOfTrack.total); if (m_pQuantizeEnabled->toBool() && pBeats) { - if (m_bAdjustingLoopOut) { - double closestBeat = m_pClosestBeat->get(); - if (closestBeat == pos) { - quantizedBeat = closestBeat; + double prevBeat; + double nextBeat; + if (pBeats->findPrevNextBeats(pos, &prevBeat, &nextBeat)) { + double closestBeat = + (nextBeat - pos > pos - prevBeat) ? prevBeat : nextBeat; + if (m_bAdjustingLoopOut) { + if (closestBeat == pos) { + pos = closestBeat; + } else { + if (nextBeat > sampleOfTrack.total) { + pos = prevBeat; + } else { + pos = nextBeat; + } + } } else { - quantizedBeat = m_pNextBeat->get(); + if (closestBeat > sampleOfTrack.total) { + pos = prevBeat; + } else { + pos = closestBeat; + } } - } else { - quantizedBeat = m_pClosestBeat->get(); - } - if (quantizedBeat != -1) { - pos = quantizedBeat; } } -- cgit v1.2.3 From 4d9fa71d528f87eb865ff9be843f837ba9e4d5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 21 May 2023 08:34:49 +0200 Subject: Remove now unused special beat COs from LoopingControl --- src/engine/controls/loopingcontrol.cpp | 3 --- src/engine/controls/loopingcontrol.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index aee9081079..4d71ead435 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -110,9 +110,6 @@ LoopingControl::LoopingControl(const QString& group, Qt::DirectConnection); m_pQuantizeEnabled = ControlObject::getControl(ConfigKey(group, "quantize")); - m_pNextBeat = ControlObject::getControl(ConfigKey(group, "beat_next")); - m_pPreviousBeat = ControlObject::getControl(ConfigKey(group, "beat_prev")); - m_pClosestBeat = ControlObject::getControl(ConfigKey(group, "beat_closest")); m_pTrackSamples = ControlObject::getControl(ConfigKey(group, "track_samples")); m_pSlipEnabled = ControlObject::getControl(ConfigKey(group, "slip_enabled")); diff --git a/src/engine/controls/loopingcontrol.h b/src/engine/controls/loopingcontrol.h index b9f1028299..0502bc1871 100644 --- a/src/engine/controls/loopingcontrol.h +++ b/src/engine/controls/loopingcontrol.h @@ -141,9 +141,6 @@ class LoopingControl : public EngineControl { LoopSamples m_oldLoopSamples; ControlValueAtomic m_currentSample; ControlObject* m_pQuantizeEnabled; - ControlObject* m_pNextBeat; - ControlObject* m_pPreviousBeat; - ControlObject* m_pClosestBeat; ControlObject* m_pTrackSamples; QAtomicPointer m_pActiveBeatLoop; -- cgit v1.2.3 From 736da453f5f82627678822ae1bc403cee599a2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 21 May 2023 08:41:34 +0200 Subject: Use the combined getSampleOfTrack() in LoopingControl::slotLoopMove() --- src/engine/controls/loopingcontrol.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index 4d71ead435..0f35757662 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -1260,8 +1260,14 @@ void LoopingControl::slotLoopMove(double beats) { return; } - if (BpmControl::getBeatContext(pBeats, m_currentSample.getValue(), - nullptr, nullptr, nullptr, nullptr)) { + SampleOfTrack sampleOfTrack = getSampleOfTrack(); + + if (BpmControl::getBeatContext(pBeats, + sampleOfTrack.current, + nullptr, + nullptr, + nullptr, + nullptr)) { double new_loop_in = pBeats->findNBeatsFromSample(loopSamples.start, beats); double new_loop_out = currentLoopMatchesBeatloopSize() ? pBeats->findNBeatsFromSample(new_loop_in, m_pCOBeatLoopSize->get()) : @@ -1270,7 +1276,7 @@ void LoopingControl::slotLoopMove(double beats) { // The track would stop as soon as the playhead crosses track end, // so we don't allow moving a loop beyond end. // https://bugs.launchpad.net/mixxx/+bug/1799574 - if (new_loop_out > m_pTrackSamples->get()) { + if (new_loop_out > sampleOfTrack.total) { return; } // If we are looping make sure that the play head does not leave the -- cgit v1.2.3 From 13bee112b9f16abeadf93849123739fcdbad1528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 21 May 2023 08:46:05 +0200 Subject: Remove use of "track_samples" CO from LoopingControl --- src/engine/controls/loopingcontrol.cpp | 11 +++++------ src/engine/controls/loopingcontrol.h | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index 0f35757662..109b830abc 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -110,7 +110,6 @@ LoopingControl::LoopingControl(const QString& group, Qt::DirectConnection); m_pQuantizeEnabled = ControlObject::getControl(ConfigKey(group, "quantize")); - m_pTrackSamples = ControlObject::getControl(ConfigKey(group, "track_samples")); m_pSlipEnabled = ControlObject::getControl(ConfigKey(group, "slip_enabled")); // DEPRECATED: Use beatloop_size and beatloop_set instead. @@ -244,11 +243,11 @@ void LoopingControl::slotLoopScale(double scaleFactor) { return; } const double loopLength = (loopSamples.end - loopSamples.start) * scaleFactor; - const int trackSamples = static_cast(m_pTrackSamples->get()); + SampleOfTrack sampleOfTrack = getSampleOfTrack(); // Abandon loops that are too short of extend beyond the end of the file. if (loopLength < MINIMUM_AUDIBLE_LOOP_SIZE || - loopSamples.start + loopLength > trackSamples) { + loopSamples.start + loopLength > sampleOfTrack.total) { return; } @@ -261,15 +260,15 @@ void LoopingControl::slotLoopScale(double scaleFactor) { // Don't allow 0 samples loop, so one can still manipulate it if (loopSamples.end == loopSamples.start) { - if ((loopSamples.end + 2) >= trackSamples) { + if ((loopSamples.end + 2) >= sampleOfTrack.total) { loopSamples.start -= 2; } else { loopSamples.end += 2; } } // Do not allow loops to go past the end of the song - else if (loopSamples.end > trackSamples) { - loopSamples.end = trackSamples; + else if (loopSamples.end > sampleOfTrack.total) { + loopSamples.end = sampleOfTrack.total; } // Reseek if the loop shrank out from under the playposition. diff --git a/src/engine/controls/loopingcontrol.h b/src/engine/controls/loopingcontrol.h index 0502bc1871..500d5a6dad 100644 --- a/src/engine/controls/loopingcontrol.h +++ b/src/engine/controls/loopingcontrol.h @@ -141,7 +141,6 @@ class LoopingControl : public EngineControl { LoopSamples m_oldLoopSamples; ControlValueAtomic m_currentSample; ControlObject* m_pQuantizeEnabled; - ControlObject* m_pTrackSamples; QAtomicPointer m_pActiveBeatLoop; // Base BeatLoop Control Object. -- cgit v1.2.3 From 3fcfd4912de62919a577446816db43df6fce46b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 21 May 2023 20:54:54 +0200 Subject: Loop when reaching the track end with loop-out pressed. This avoids to stop the track in an active loop --- src/engine/controls/loopingcontrol.cpp | 79 ++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index 109b830abc..b10516b754 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -375,48 +375,61 @@ double LoopingControl::nextTrigger(bool reverse, } if (m_bLoopingEnabled && - !m_bAdjustingLoopIn && !m_bAdjustingLoopOut && loopSamples.start != kNoTrigger && loopSamples.end != kNoTrigger) { - - if (loopSamples.start != m_oldLoopSamples.start || - loopSamples.end != m_oldLoopSamples.end) { - // bool seek is only valid after the loop has changed - if (loopSamples.seek) { - // here the loop has changed and the play position - // should be moved with it - *pTarget = seekInsideAdjustedLoop(currentSample, - m_oldLoopSamples.start, loopSamples.start, loopSamples.end); - } else { - bool movedOut = false; - // Check if we have moved out of the loop, before we could enable it - if (reverse) { - if (loopSamples.start > currentSample) { - movedOut = true; - } + if (!m_bAdjustingLoopIn && !m_bAdjustingLoopOut) { + if (loopSamples.start != m_oldLoopSamples.start || + loopSamples.end != m_oldLoopSamples.end) { + // bool seek is only valid after the loop has changed + if (loopSamples.seek) { + // here the loop has changed and the play position + // should be moved with it + *pTarget = seekInsideAdjustedLoop(currentSample, + m_oldLoopSamples.start, + loopSamples.start, + loopSamples.end); } else { - if (loopSamples.end < currentSample) { - movedOut = true; + bool movedOut = false; + // Check if we have moved out of the loop, before we could enable it + if (reverse) { + if (loopSamples.start > currentSample) { + movedOut = true; + } + } else { + if (loopSamples.end < currentSample) { + movedOut = true; + } + } + if (movedOut) { + *pTarget = seekInsideAdjustedLoop(currentSample, + loopSamples.start, + loopSamples.start, + loopSamples.end); } } - if (movedOut) { - *pTarget = seekInsideAdjustedLoop(currentSample, - loopSamples.start, loopSamples.start, loopSamples.end); + m_oldLoopSamples = loopSamples; + if (*pTarget != kNoTrigger) { + // jump immediately + return currentSample; } } - m_oldLoopSamples = loopSamples; - if (*pTarget != kNoTrigger) { - // jump immediately - return currentSample; - } - } - if (reverse) { - *pTarget = loopSamples.end; - return loopSamples.start; + if (reverse) { + *pTarget = loopSamples.end; + return loopSamples.start; + } else { + *pTarget = loopSamples.start; + return loopSamples.end; + } } else { - *pTarget = loopSamples.start; - return loopSamples.end; + // LOOP in or out button is pressed for adjusting. + // Jump back to loop start, when reaching the track end this + // prevents that the track stops outside the adjusted loop. + if (!reverse) { + SampleOfTrack sampleOfTrack = getSampleOfTrack(); + *pTarget = loopSamples.start; + return sampleOfTrack.total; + } } } return kNoTrigger; -- cgit v1.2.3 From 7feb919c9918e8ec4dbcc1f09b872345b25c5e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 21 May 2023 21:19:50 +0200 Subject: Disable loop if loop out is placed behind loop in --- src/engine/controls/loopingcontrol.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index b10516b754..89fb9a7552 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -556,6 +556,9 @@ void LoopingControl::setLoopInToCurrentPosition() { loopSamples.end < pos) { loopSamples.end = kNoTrigger; m_pCOLoopEndPosition->set(kNoTrigger); + if (m_bLoopingEnabled) { + setLoopingEnabled(false); + } } // If we're looping and the loop-in and out points are now so close -- cgit v1.2.3 From 7da673baaab063791299559fb8c1cbe11a587075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 21 May 2023 21:31:39 +0200 Subject: Don't disable loop when adjusting loop-in and reaching loop out. Jump to th old loop-in istead for another try --- src/engine/controls/loopingcontrol.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index 89fb9a7552..b9d5a147d4 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -426,9 +426,20 @@ double LoopingControl::nextTrigger(bool reverse, // Jump back to loop start, when reaching the track end this // prevents that the track stops outside the adjusted loop. if (!reverse) { + if (m_bAdjustingLoopIn) { + // Just in case the user does not release loop-in in time. + *pTarget = m_oldLoopSamples.start; + return loopSamples.end; + } SampleOfTrack sampleOfTrack = getSampleOfTrack(); *pTarget = loopSamples.start; return sampleOfTrack.total; + } else { + if (m_bAdjustingLoopOut) { + // Just in case the user does not release loop-out in time. + *pTarget = m_oldLoopSamples.end; + return loopSamples.start; + } } } } -- cgit v1.2.3 From 9c106189c5f283132a3e01a9a2824db0e90ff996 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 25 May 2023 10:55:06 +0200 Subject: buffer scalers: consider getNextSamples() returning 0 after loop move --- src/engine/bufferscalers/enginebufferscalelinear.cpp | 10 +++------- src/engine/bufferscalers/enginebufferscalerubberband.cpp | 12 ++++++++---- src/engine/bufferscalers/enginebufferscalest.cpp | 13 +++++++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/engine/bufferscalers/enginebufferscalelinear.cpp b/src/engine/bufferscalers/enginebufferscalelinear.cpp index f5f3aafef8..079466ecfd 100644 --- a/src/engine/bufferscalers/enginebufferscalelinear.cpp +++ b/src/engine/bufferscalers/enginebufferscalelinear.cpp @@ -287,13 +287,9 @@ SINT EngineBufferScaleLinear::do_scale(CSAMPLE* buf, SINT buf_size) { m_bufferIntSize = m_pReadAheadManager->getNextSamples( rate_new == 0 ? rate_old : rate_new, m_bufferInt, samples_to_read); - - VERIFY_OR_DEBUG_ASSERT(m_bufferIntSize != 0) { - // getNextSamples() must never fail, - // using silence as a last resort - SampleUtil::clear(m_bufferInt, samples_to_read); - m_bufferIntSize = getOutputSignal().samples2frames(samples_to_read); - } + // Note we may get 0 samples once if we just hit a loop trigger, + // e.g. when reloop_toggle jumps back to loop_in, or when + // moving a loop causes the play position to be moved along. frames_read += getOutputSignal().samples2frames(m_bufferIntSize); unscaled_frames_needed -= getOutputSignal().samples2frames(m_bufferIntSize); diff --git a/src/engine/bufferscalers/enginebuffers