Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Work in progress] [macOS] Syphon output #63

Closed
wants to merge 6 commits into from

Conversation

s6joui
Copy link

@s6joui s6joui commented Aug 28, 2023

Added Syphon framework integration to share video output with other macOS applications such as Resolume that support Syphon.

Syphon output can be enabled via the textureSharingEnabled command line option. Example:

projectMSDL --textureSharingEnabled 1

This is a work in progress. Currently facing the following issues:

  • How to bundle the Syphon objecive-c framework with the app.(current implementations loads it from /Library/Frameworks/ directory)
  • Resizing the window is not well supported in this implementation.

@kblaschke
Copy link
Member

If there is a way to not check in all the dependencies into the current repo, but find and link them via CMake' find_package(), that'd be a great improvement. IMO, 3rd party libs should stay at their original repos, otherwise the codebase will at some point become a maintenance hell (plus, it's very hard for Linux maintainers to use the distro packages in such a case).


Poco::Logger& _logger{Poco::Logger::get("TextureSharing")}; //!< The class logger.

GLuint _shareFamebuffer, _shareTexture;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GLuint _shareFamebuffer, _shareTexture;
GLuint _shareFramebuffer, _shareTexture;

@s6joui
Copy link
Author

s6joui commented Sep 10, 2023

If there is a way to not check in all the dependencies into the current repo, but find and link them via CMake' find_package(), that'd be a great improvement. IMO, 3rd party libs should stay at their original repos, otherwise the codebase will at some point become a maintenance hell (plus, it's very hard for Linux maintainers to use the distro packages in such a case).

Agreed! I'll try to figure out how to do it.

Copy link
Member

@kblaschke kblaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments, there are still some things to fix before we can merge this, as the current state of the code will break the build for all platforms except macOS, as Syphon support will be a mandatory feature while it should be optional.

My suggestion here would be this:

  • If building on macOS (and only then), provide the user with an option to (forcibly) enable Syphon support.
  • If building on macOS and the above option is not on (default), still check for the required libraries and headers (Syphon, GLAD and KHRPlatform). If those are available, set the option to ON if it's not been set to OFF by user already.
  • If the option is ON, require the Syphon libraries and fail if they aren't available, so the dev can make sure the Syphon code is definitely compiled in.
  • In the build system, code and config files, only add the Spyhon-specific parts (linked libraries/code files in CMake, additional includes and code in C++ and the default options in the config file) if Syphon support is being built. In any other case, leave this out, so it won't break builds on unsupported platforms and also if macOS devs don't want it.

If you need advice on how to best do this in CMake and C++, you can just ask here or in Discord, I'll be glad to help!

@@ -17,6 +17,8 @@ add_executable(projectMSDL WIN32
RenderLoop.h
SDLRenderingWindow.h
SDLRenderingWindow.cpp
TextureSharing.h
TextureSharing.mm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check that this still compiles on Windows and Linux, as those OSes don't have Obj-C++ support?

Because on my Linux machine, I get an error configuring the project:

Cannot get compiler information:
	Compiler exited with error code 1: /usr/bin/c++ -xobjective-c++ -DAUDIO_IMPL_HEADER=\"AudioCaptureImpl_SDL.h\" -DPOCO_ENABLE_CPP11 -DPOCO_ENABLE_CPP14 -DPOCO_HAVE_FD_EPOLL -DPOCO_OS_FAMILY_UNIX -DPOCO_STATIC -DPROJECTMSDL_VERSION=\"2.0.0\" -DPROJECTM_STATIC_DEFINE -DXML_DTD -D_DEBUG -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_REENTRANT -D_THREAD_SAFE -D_XOPEN_SOURCE=500 -isystem/home/kai/Dev/install/projectM-latest-shared/include -isystem/home/kai/Dev/install/Poco/static/include -isystem/home/kai/Dev/install/libSDL/64/include -isystem/home/kai/Dev/install/libSDL/64/include/SDL2 -g -std=gnu++14 -fPIE -fopenmp -fpch-preprocess -v -dD -E
	Using built-in specs.
	COLLECT_GCC=/usr/bin/c++
	Target: x86_64-pc-linux-gnu
	Configured with: /var/tmp/portage/sys-devel/gcc-12.3.0/work/gcc-12.3.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/12 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/12/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/12/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 12.3.0 p2' --with-gcc-major-version-only --disable-esp --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-cet --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --without-zstd --without-isl --enable-default-pie --enable-default-ssp
	Thread model: posix
	Supported LTO compression algorithms: zlib
	gcc version 12.3.0 (Gentoo 12.3.0 p2) 
	c++: error: language objective-c++ not recognized
	c++: error: language objective-c++ not recognized

target_link_libraries(projectMSDL
PRIVATE
libprojectM::playlist
Poco::Util
SDL2::SDL2$<$<STREQUAL:${SDL2_LINKAGE},static>:-static>
SDL2::SDL2main
glad
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is glad required for all platforms, even macOS, when not building Syphon support? I'd suggest making All the Syphon-specific code, libraries etc. dependent on a specific ENABLE_SYPHON option or similar, then check for all required dependencies and requirements and give the user proper feedback of something's wrong or missing.

Also, use cmake_dependent_option() to only show the option to devs if the build is executed on macOS, as it doesn't make sense or works on any other platform.

@@ -160,6 +160,10 @@ void ProjectMSDLApplication::defineOptions(Poco::Util::OptionSet& options)
false, "<number>", true)
.binding("projectM.beatSensitivity", _commandLineOverrides));

options.addOption(Option("textureSharingEnabled", "", "Syphon texture sharing enabled.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - only provide the command-line option in builds which actually have Syphon support built-in. for any other build, it would confuse users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't check in 3rd party headers, rather require them on the build system and use CMake's find_package()/find_include() commands to check their availability and get the proper include path. Ideally, add a CMake Find script in the "cmake" dir on the project top-level dir.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with GLAD: Better use a Find script instead of making a copy in the repo which we need to maintain in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also make this addition in the config file dependent on actual Syphon support, so we don't add any options here which aren't supported at all.

@kblaschke
Copy link
Member

@s6joui still working on this? If not, I'd close the PR.
If you've got anything that works and doesn't affect other platforms where Syphon isn't available, you can just open a new PR.

@kblaschke
Copy link
Member

kblaschke commented Jan 17, 2024

No activity or replies for several months now. I'll close the PR due to inactivity.

If you continue working on it and have something you want to merge, please feel free to open a new PR. In the 4.2 release of libprojectM, there will be new API calls to enable render-to-texture instead of always drawing to the default framebuffer, which would immensely help with this.

I'll also create two feature tickets in the bug tracker, both for Syphon and Spout, to keep this in our minds and track any progress plus allowing for discussions.

@kblaschke kblaschke closed this Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants