git: 985f2bd893ba - main - multimedia/{,lib}openshot: fix OPTIONS and audio output device selection

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Mon, 06 May 2024 15:06:01 UTC
The branch main has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=985f2bd893ba7faacf425f999796bdc1db9bbfa5

commit 985f2bd893ba7faacf425f999796bdc1db9bbfa5
Author:     Tatsuki Makino <tatsuki_makino@hotmail.com>
AuthorDate: 2024-05-06 15:00:48 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-05-06 15:05:33 +0000

    multimedia/{,lib}openshot: fix OPTIONS and audio output device selection
    
    Documents that require doxygen have been separated into DOXYGEN option.
    It is off by default.
    This should fix an issue where no matter what we choose, we could only
    output audio to the default sink.
    In particular, it is a fix that has become necessary to make JACK work well.
    Fixed stage-qa error - link with libpython.
    
    PR:     277648
---
 multimedia/libopenshot/Makefile                    | 30 ++++++++++++----------
 .../libopenshot/files/patch-src_CMakeLists.txt     | 20 ++++++++++-----
 .../files/patch-src_Qt_AudioPlaybackThread.cpp     | 22 ++++++++++++++++
 multimedia/openshot/Makefile                       |  2 +-
 4 files changed, 53 insertions(+), 21 deletions(-)

diff --git a/multimedia/libopenshot/Makefile b/multimedia/libopenshot/Makefile
index b84716ffa877..509f2996dfaa 100644
--- a/multimedia/libopenshot/Makefile
+++ b/multimedia/libopenshot/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	libopenshot
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.3.2
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	multimedia
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
 
@@ -20,9 +20,11 @@ LIB_DEPENDS=	libavformat.so:multimedia/ffmpeg \
 		libbabl-0.1.so:x11/babl \
 		libjsoncpp.so:devel/jsoncpp \
 		libopenshot-audio.so:audio/libopenshot-audio \
+		libpython${PYTHON_VER}${PYTHON_ABIVER}.so:lang/python${PYTHON_SUFFIX} \
 		libzmq.so:net/libzmq4
 
 USES=		cmake pkgconfig python:build qt:5
+USE_CXXSTD=	c++17
 USE_GITHUB=	yes
 GH_ACCOUNT=	OpenShot
 USE_LDCONFIG=	yes
@@ -33,17 +35,19 @@ CMAKE_ON=	USE_SYSTEM_JSONCPP DISABLE_BUNDLED_JSONCPP\
 		CMAKE_DISABLE_FIND_PACKAGE_Catch2
 CMAKE_OFF=	ENABLE_PARALLEL_CTEST VERBOSE_TESTS ENABLE_COVERAGE\
 		APPIMAGE_BUILD BUILD_TESTING ENABLE_TESTS
-USE_CXXSTD=	c++17
+DEBUG_FLAGS?=	-g
+DEBUG_FLAGS+=	-D_DEBUG -DJUCE_FORCE_DEBUG=1
 
-OPTIONS_DEFINE=	DOCS IMAGEMAGICK OPENCV RESVG RUBY
+OPTIONS_DEFINE=		DOCS DOXYGEN IMAGEMAGICK OPENCV RESVG RUBY
 OPTIONS_DEFAULT=	IMAGEMAGICK OPENCV
-OPTIONS_SUB=	yes
-RESVG_DESC?=	SVG vector graphics support via resvg
-DOCS_BUILD_DEPENDS=	doxygen:devel/doxygen
-DOCS_CMAKE_BOOL=	ENABLE_LIB_DOCS
-DOCS_CMAKE_BOOL_OFF=	CMAKE_DISABLE_FIND_PACKAGE_Doxygen
-DOCS_CMAKE_ON=	-DCMAKE_INSTALL_DOCDIR:PATH=${DOCSDIR_REL:Q}
-DOCS_PORTDOCS=	*
+OPTIONS_SUB=		yes
+RESVG_DESC?=		SVG vector graphics support via resvg
+DOCS_CMAKE_ON=		-DCMAKE_INSTALL_DOCDIR:PATH=${DOCSDIR_REL:Q}
+DOCS_PORTDOCS=		*
+DOXYGEN_IMPLIES=	DOCS
+DOXYGEN_BUILD_DEPENDS=	doxygen:devel/doxygen
+DOXYGEN_CMAKE_BOOL=	ENABLE_LIB_DOCS
+DOXYGEN_CMAKE_BOOL_OFF=	CMAKE_DISABLE_FIND_PACKAGE_Doxygen
 IMAGEMAGICK_USES=	magick
 IMAGEMAGICK_CMAKE_BOOL=	ENABLE_MAGICK
 IMAGEMAGICK_CMAKE_BOOL_OFF=	CMAKE_DISABLE_FIND_PACKAGE_ImageMagick
@@ -54,10 +58,10 @@ OPENCV_CMAKE_BOOL_OFF=	CMAKE_DISABLE_FIND_PACKAGE_OpenCV\
 			CMAKE_DISABLE_FIND_PACKAGE_Protobuf
 OPENCV_CMAKE_ON=	-DOpenCV_DIR:STRING=${LOCALBASE:Q}/cmake/opencv4
 RESVG_LIB_DEPENDS=	libresvg.so:graphics/resvg-capi
-RESVG_USE_OFF=	QT=svg
+RESVG_USE_OFF=		QT=svg
 RESVG_CMAKE_BOOL_OFF=	CMAKE_DISABLE_FIND_PACKAGE_Resvg
-RESVG_CMAKE_ON=	-DRESVGDIR:STRING=${LOCALBASE:Q}
-RUBY_USES=	ruby:build
+RESVG_CMAKE_ON=		-DRESVGDIR:STRING=${LOCALBASE:Q}
+RUBY_USES=		ruby:build
 RUBY_CMAKE_BOOL=	ENABLE_RUBY
 RUBY_CMAKE_BOOL_OFF=	CMAKE_DISABLE_FIND_PACKAGE_Ruby
 
diff --git a/multimedia/libopenshot/files/patch-src_CMakeLists.txt b/multimedia/libopenshot/files/patch-src_CMakeLists.txt
index c94d5a8ab374..4ad80fbc34a8 100644
--- a/multimedia/libopenshot/files/patch-src_CMakeLists.txt
+++ b/multimedia/libopenshot/files/patch-src_CMakeLists.txt
@@ -1,20 +1,26 @@
 --- src/CMakeLists.txt.orig	2023-03-27 18:48:43 UTC
 +++ src/CMakeLists.txt
-@@ -516,6 +516,18 @@ See https://github.com/opencv/opencv/issues/19260]])
+@@ -516,6 +516,24 @@ See https://github.com/opencv/opencv/issues/19260]])
  endif()  # ENABLE_OPENCV
  add_feature_info("OpenCV algorithms" ENABLE_OPENCV "Use OpenCV algorithms")
  
 +# EXECINFO
 +include(CheckFunctionExists)
-+check_function_exists("backtrace" FUNCTION_BACKTRACE_FOUND)
++include(CheckLibraryExists)
++check_function_exists(backtrace FUNCTION_BACKTRACE_FOUND)
 +if(NOT FUNCTION_BACKTRACE_FOUND)
 +	find_library(EXECINFO_LIBRARY NAMES execinfo)
-+	if(NOT EXECINFO_LIBRARY)
-+		message(FATAL_ERROR "${EXECINFO_LIBRARY}")
-+	endif(NOT EXECINFO_LIBRARY)
-+	target_link_libraries(openshot PRIVATE ${EXECINFO_LIBRARY})
++	if(EXECINFO_LIBRARY)
++		unset(FUNCTION_BACKTRACE_FOUND CACHE)
++		check_library_exists(${EXECINFO_LIBRARY} backtrace "" FUNCTION_BACKTRACE_FOUND)
++	endif(EXECINFO_LIBRARY)
++endif(NOT FUNCTION_BACKTRACE_FOUND)
++if(NOT FUNCTION_BACKTRACE_FOUND)
++	message(FATAL_ERROR "backtrace - ${FUNCTION_BACKTRACE_FOUND}")
 +endif(NOT FUNCTION_BACKTRACE_FOUND)
-+unset(FUNCTION_BACKTRACE_FOUND)
++if(EXECINFO_LIBRARY)
++	target_link_libraries(openshot PRIVATE ${EXECINFO_LIBRARY})
++endif(EXECINFO_LIBRARY)
 +
  ###############  LINK LIBRARY  #################
  # Link remaining dependency libraries
diff --git a/multimedia/libopenshot/files/patch-src_Qt_AudioPlaybackThread.cpp b/multimedia/libopenshot/files/patch-src_Qt_AudioPlaybackThread.cpp
new file mode 100644
index 000000000000..11530ddc36d1
--- /dev/null
+++ b/multimedia/libopenshot/files/patch-src_Qt_AudioPlaybackThread.cpp
@@ -0,0 +1,22 @@
+--- src/Qt/AudioPlaybackThread.cpp.orig	2023-04-19 22:01:02 UTC
++++ src/Qt/AudioPlaybackThread.cpp
+@@ -102,8 +102,17 @@ namespace openshot
+ 
+ 				// Settings for audio device playback
+ 				AudioDeviceManager::AudioDeviceSetup deviceSetup = AudioDeviceManager::AudioDeviceSetup();
+-				deviceSetup.inputChannels = 0;
+-				deviceSetup.outputChannels = channels;
++				deviceSetup.outputDeviceName = attempt_device.name;
++				deviceSetup.inputDeviceName = "";
++				//deviceSetup.inputChannels = 0;
++				deviceSetup.inputChannels.clear();
++				deviceSetup.useDefaultInputChannels = false;
++				//deviceSetup.outputChannels = channels;
++				deviceSetup.outputChannels.clear();
++				for (int i = 0; i < channels; ++i) {
++					deviceSetup.outputChannels.setBit(i);
++				}
++				deviceSetup.useDefaultOutputChannels = false;
+ 
+ 				// Loop through common sample rates, starting with the user's requested rate
+ 				// Not all sample rates are supported by audio devices, for example, many VMs
diff --git a/multimedia/openshot/Makefile b/multimedia/openshot/Makefile
index 1bacbe08bc16..92a47356fdbc 100644
--- a/multimedia/openshot/Makefile
+++ b/multimedia/openshot/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	openshot
 DISTVERSIONPREFIX=	v
 DISTVERSION=	3.1.1
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	multimedia
 
 MAINTAINER=	tatsuki_makino@hotmail.com