Commit Graph

79 Commits (master)

Author SHA1 Message Date
tytan652 1272209710 obs-scripting: Fix SWIG flags for non-macOS POSIX 2022-08-08 15:00:09 +02:00
PatTheMav 24a123119a obs-scripting: Fix issues between runtime and compile-time versions
Calling `PyEval_InitThreads` has been deprecated in Python 3.7 and the
function itself will be removed in Python 3.11. The current check
guards this function behind a version check that only happens at compile
time.

This in turn leads to crashes when run on Python 3.6, as the necessary
initialization for `PyEval_ReleaseThread` did not take place.

This commit ensures the manual initialization takes place based on the
runtime version of Python and avoids loading the associated symbols
on Python 3.9 or later.
2022-08-02 19:36:50 -04:00
gxalpha ca470b2d53 deps/obs-scripting: Ignore base_set_crash_handler 2022-07-27 12:05:16 -04:00
Kurt Kartaltepe 57c9844f15 v4l2,scripting: Add more thread names
This sets some thread names for the scripting backend's defer thread and
the v4l2 udev thread.
2022-07-24 09:21:58 +10:00
PatTheMav ab21c7e5b0 obs-scripting: Add support for multiple Python 3 versions
This changes the way obs-scripting looks for and loads an available
Python 3 library. It tries to find a best possible version (starting
with Python 3.10) down to and including Python 3.6 by existing file
naming conventions and loads the most recent variant it can find.

User specified search path is either a Python installation directory
(Windows), or a Framework directory containing `Python.framework`
(macOS). The dll or dylib names are composed automatically.
The Python home path is also composed automatically on macOS (where
it has to point inside the Framework directory).
2022-07-21 12:16:36 -04:00
PatTheMav 47b3ff5e64 obs-scripting: Switch swig to stable ABI usage 2022-07-21 12:16:36 -04:00
tytan652 ba6f9f3f46 obs-scripting: Replace OBS_UNUSED with UNUSED_PARAMETER
OBS_UNUSED is not portable to MSVC.
2022-07-20 08:22:08 +02:00
PatTheMav e27f90fa5a obs-scripting: Fix crashes introduced by Swig update to 4.1.0
Fixes issues introduced by https://github.com/swig/swig/pull/2238. As
obs-scripting is not compatible with the SWIGPYTHON_BUILTIN, obspython
needs to disable this feature.
2022-07-13 16:50:09 -04:00
jpark37 5e3c824801 obs-scripting: Suppress long volatile warning 2022-07-11 22:07:10 -07:00
PatTheMav 64efcd155d obs-scripting: Fix swig runtime header generation for macOS
Due to swig using a hardcoded swig library path in self-compiled
variants, we need to pass our custom swig library path with every
invocation of swig on macOS.

CMake's `add_custom_command` function does _not_ inherit the environment
variables used during configuration, hence why it needs to be passed
explicitly on invocation.

Usage of CMake's "-E env" command module should allow for cross-platform
compatible invocation.
2022-07-07 14:19:23 -04:00
gxalpha e1776d872a deps/obs-scripting: Log script load/unload 2022-07-02 16:35:20 -07:00
PatTheMav 29759ef8fb obs-scripting: Fix missing frontend bindings for Python
The obspython.i file requires `ENABLE_UI` to be defined for the swig
compiler to pull in the actual obs-frontend-api header. If this is not
the case, swig will not discover the required methods and ENUMs and
in turn will not make those available in the scripting environment.
2022-05-28 16:23:14 -07:00
PatTheMav 893d3ce218 obs-scripting: Fix missing frontend bindings for Lua
The obslua.i file requires `ENABLE_UI` to be defined for the swig
compiler to pull in the actual obs-frontend-api header. If this is not
the case, swig will not discover the required methods and ENUMs and
in turn will not make those available in the scripting environment.
2022-05-28 16:23:14 -07:00
PatTheMav 8d0131c519 obs-scripting: Fix macro redefinition warning
In Python 3.9+, `PyCFunction_New` and `PyCFunction_NewEx` are themselves
macros around `PyMethod_New`. To fix the warning, both macros need to
be untouched for those Python versions, instead the actual function
`PyMethod_New` needs to be imported and aliased.

This commit:

- Adds the import of the `PyCMethod_New` symbol
- Adds the function definition for `Import_PyCMethod_New`
- Adds the `PyCMethod_New` function alias
2022-05-14 16:10:11 -07:00
PatTheMav a0923c9b6e obs-scripting: Fix loading of scripting libraries with runtime lookup
macOS uses runtime lookup for symbols in obs-scripting. While this guard
fixes a compiler warning, it also leads to the `_PyCMethod_New` symbol
being undefined.

In turn any library linking with obs-scripting will then fail to load
because of that undefined symbol. Removing this guard fixes that issue.
2022-05-14 16:10:11 -07:00
PatTheMav 4c1687901e obs-scripting: Fix compiler warnings 2022-05-04 12:09:04 -04:00
tytan652 c98617849a obs-scripting: Fix compiler warnings
* obs-scripting: Fix unused 'varargs' warning

* obs-scripting: Fix PyEval deprecation warnings
Remove PyEval_InitThreads() and PyEval_ThreadsInitialized() call for
Python 3.7 and later as Python calls it automatically now.

This removes deprecation warnings when using Python 3.9 or later.

https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
2022-05-04 01:37:10 -07:00
PatTheMav aae3a6a466 cmake: Fix diverging prefix padding for OBS status outputs
Status output related to OBS configuration is prefixed with the string
"OBS" and added padding for enabled and disabled features. This padding
was not aligned between platforms.

By moving the padding and prefix decoration into its own function,
both elements are controlled in a single place. CMake scripts were
changed to use this new function `obs_status` instead of using CMake's
`message` function directly.
2022-03-26 09:44:23 -04:00
jp9000 5e2c757cd1 libobs/util: Remove deprecation visibility from swig 2022-03-24 22:32:19 -07:00
jp9000 601187d0f6 deps/obs-scripting: Fix code formatting
Somehow this was incorrectly formatted at some point.
2022-03-24 22:30:52 -07:00
derrod 178ec005bd obs-scripting: Add Resources to python path on macOS
Also changes indentation of this block back to tabs to be consistent
with the rest of the file

Co-authored-by: PatTheMav <patthemav+github@gmail.com>
2022-03-23 14:56:55 +01:00
PatTheMav dbdf5c7f7a
obs-scripting: Update CMakeLists.txt for scripting modules 2022-03-16 23:11:08 +01:00
jp9000 6d3b1998ef obs-scripting: Make callback "removed" variable atomic
Makes the callback variable "removed" atomic, and on script unload,
first sets all callbacks to removed before actually unloading the script
out of a safety precaution. (See note at the bottom for further details)

This minimizes the possibility of a race condition where the script
callback could be called while those callbacks were being removed.

Big note for this change, this change should eventually be replaced with
a reference counting ownership method where script callbacks can hold a
reference and share ownership of the script if it's still alive while
the script callback is being called. That way the script callbacks can
safely execute. May require a fair amount of reworking of the script
object.
2022-03-01 03:04:37 -08:00
Jim 03d9bda387 libobs: Deprecate obs object addref functions
Deprecates:
obs_source_addref()
obs_output_addref()
obs_encoder_addref()
obs_service_addref()
obs_scene_addref()

These functions should be considered unsafe and not used. Instead, use:
obs_source_get_ref()
obs_output_get_ref()
obs_encoder_get_ref()
obs_service_get_ref()
obs_scene_get_ref()

These functions return a pointer to the incremented object only if the
object is still valid, otherwise they will return null, indicating that
the object is no longer valid or is unsafe to use.

The reason why this is being done is because certain third party plugins
seem to be using addref, and are somehow managing to call addref on
sources that have already been fully released. For the sake of safety,
almost all usage of these functions within OBS have also been replaced
as well.
2022-01-25 05:20:03 -08:00
Scratch a78558b46a obs-scripting: add transition duration functions 2021-10-15 16:50:59 -07:00
jpark37 bc7ecd4527 deps/obs-scripting: Fix pthread mutex leaks 2021-08-23 22:30:55 -07:00
PatTheMav ecdc81ba0f obs-scripting: Add Py 3.8+ C-API changes
Closes obsproject/obs-studio#3689
2021-01-27 11:33:34 -08:00
Ryan Foster 81c2dac75e deps: Update cmake_minimum_required to 2.8.12 2021-01-18 01:37:45 -08:00
Scratch 842ad1781b obs-scripting: Fix removing signal handlers in lua 2020-12-07 15:44:00 +11:00
Colin Edwards 7b0d7c6357 Remove BUILD_CAPTIONS build flag 2020-11-02 22:46:55 -06:00
Per Heed 318779be7a obs-scripting: Fix script_path() python mem corruption
Returning PyObject with borrowed reference will result in double free
and/or use after free issue.  Issue seen as crash when running Python
script calling script_path().
2020-09-13 16:20:56 -07:00
Scratch e4b81c2b1b obs-scripting: Fix removing signal handlers in python
Closes #3218
2020-08-16 00:26:32 +10:00
jp9000 7993179466 cmake: Add cmake folders 2020-05-13 06:52:37 -07:00
Clayton Groeneveld a149b1df88 obs-scripting: Expose platform functions to scripts 2020-04-27 09:33:43 -05:00
Colin Edwards 55e2985026
Merge pull request #1944 from WizardCM/windows-rc-definition
CMake: Build Windows modules with file descriptors
2020-04-18 18:27:22 -05:00
comex 849d5462ad obs-scripting: Add missing Python imports
Add PyDict_New and PyTuple_New to obs-scripting-python-import.[ch];
these functions are used by SWIG's generated code when I build OBS on
macOS with SWIG 4.0.1.
2020-03-08 18:35:35 -07:00
jp9000 345e933d9f deps/obs-scripting: Fix incorrect parameter type 2020-01-21 02:43:21 -08:00
Scratch 41fcb9ae08 obs-scripting: Add Python functions for frontend events 2020-01-03 12:07:17 +11:00
Rat 83fdf41e3f deps/obs-scripting: Expose matrix3 & 4 to scripting
Various functions available in the scripting API aren't usable
currently since you can't create the matrix3 and matrix4 needed
for their arguments.
2019-12-25 00:37:31 +01:00
Jim 654508de7c
Merge pull request #2183 from ratwithacompiler/macos-python-fix-2
obs-scripting: Fix Python in new MacOS .app bundles
2019-11-18 19:46:09 -08:00
jp9000 6ab6fdffd1 deps/obs-scripting: Fix formatting 2019-11-17 18:06:56 -08:00
Rat a19fef2248 obs-scripting: Fix Python in new MacOS .app bundles
The current scripting directory path given to Python on OSX is
`../data/obs-scripting`. This works when bin/ and data/ are in the same
folder like rundir after a compile and in the old .app bundles but the
new normal .app bundle structure is different.

For bundles move obspython.py and _obspython.so to the binary folder,
just like the Lua one, and pass that bin path to the Python interpreter
so it can find it.

The current working dir isn't guaranteed to be set with .app bundles
so look up binary path at runtime.
2019-11-17 22:11:44 +01:00
Jim 9bdb21205d
Merge pull request #2085 from ratwithacompiler/macos-python-fix
obs-scripting: Fix Python on MacOS
2019-11-14 20:38:53 -08:00
Jim def6fcb0ee
Merge pull request #2125 from DDRBoxman/appbundle
Fixes to make OBS work on Catalina
2019-11-13 12:21:13 -08:00
Colin Edwards 32690926b9 CI: Use custom macdylibbundler for OSX deps 2019-11-03 00:00:38 -05:00
jpark37 7336226774 obs-scripting: Quiet CMake SWIG warnings 2019-10-15 21:08:30 -07:00
Matt Gajownik 51be039cf8 CMake: Build Windows modules with file descriptors 2019-10-15 21:34:12 +11:00
luz.paz d124e6402c docs/sphinx: Fix various typos
(This modifies UI, libobs, deps/obs-scripting, various cmake files)

Found using:
`codespell -q 3 -S *.ini,./UI/data/locale,./deps/w32-pthreads -L aci,dur,iff,mut,numer,uint`
2019-10-14 17:19:38 -07:00
Rat a44ff34ef0 obs-scripting: Link _obspython as dynamic_lookup on MacOS
_obspython.so currently links directly against python as @rpath/Python
and has 3 common python install paths set as rpaths so it would only
work if a user had python installed at one of those hardcoded paths.

Don't link _obspython against python at all but instead link it with
"-undefined dynamic_lookup" so when it is imported by python all it's
undefined python symbols get resolved at runtime against the user
supplied python instance loaded into the process earlier.

The rpaths aren't needed anymore this way.
2019-09-26 23:42:33 +02:00
Rat e7801e10ba obs-scripting: Fix python lib path on MacOS
The libpython .dylib files on MacOS are in the python_path/lib
subdir. The user supplied python_path still needs to be to the actual
python root and not lib/ as the root path get's used as python home dir
so just add lib/ when loading the dylib.
2019-09-26 23:37:00 +02:00