Also changes clang-format SeparateDefinitionBlocks to Leave on ObjC
files, which avoid having an empty new line after API_AVAIABLE and the
declaration.
The uninit function prematurely released the memory allocated for the
channel map setting, which exists in the scope of source life cycle
(compared to channel names which are valid during the life cycle of a
configured device).
Splitting up the clean-up for both (memory for channel names is
released when the device is uninitialized, memory for channel map
setting is released when the source is removed) ensures that the memory
is released but pointers don't become unexpectedly invalid.
OBS handles up to 8 channels of audio, which requires the CoreAudio
input callback to omit/ignore any audio data from channels above that
count and also report a maximum amount of 8 channels to match the
speaker setup given to swresample by libobs.
macOS 14.2 changed internal defaults of SCK requiring the inclusion
of the menu bar and child windows to be enabled explicitly.
This will have a slight negative impact on capture performance but is
required to restore behavior of prior macOS versions.
In some scenarios ScreenCaptureKit will not call our completion handler
when an internal ReplayKit error occurred. This seems to be more common
when a <nil> display id is provided as the content filter for
ScreenCaptureKit.
The issue was reported to Apple as FB13455947, but it is good practice
for us to check for an invalid display ID before even attempting to start
a capture stream.
8dd20dfd33 introduced an explicit check
for the available macOS SDK, meaning that we can be sure that the macOS
13.1 SDK is available. As such, we do not require ifdef guards for the
availability of functions that are older than 13.1.
The current code assumes that a display UUID can be created with the
stored ID, but that's not always the case, e.g. when the user doesn't
have the display connected. As such, we need to null check this, and
fall back to the invalid ID (0) when the ID cannot be migrated.
The current code also only migrates on source creation, which yields
weird behaviour where if the user opens properties and then cancels it
would still show the first display, but only for the session. This is
why the code was factored out of the creation function and now is always
used when an ID needs to be acquired from OBS Data settings, including
when the source is updated.
This log line was introduced in 239e9273d and looks like it was for
debugging purposes. It always prints an error message when an SCK audio
capture source was successfully created.
Improve complicated Objective-C implementations in
mac-screen-capture implementation.
- Use `for` instead of overuse of block based iteration code.
- Use `YES` and `NO` for `BOOL` type instead of wrong `TRUE`, `FALSE`,
`true`, `false`.
- Use `length` to check empty string, omit unnecessary `nil` checks.
`screen_capture_build_content_list` or similar calls uses updated
`sc->show_hidden_windows` or similar flags, but these are not set
before calling these functions.
Creation of Info.plist files through Xcode is more canonical and
future-proof, as it will automatically pick up changes/updates
introduced by Apple. Non-standard keys can still be added via a
template file, which will then be extended by Xcode with the default
keys.
ee3c2d0 introduced a local copy of the CGDisplayStream.h header as the
macOS 13.3 SDK erroneously declared functions as unavailable on older
systems. This has been fixed in the macOS 14 SDK with the functions
correctly being declared as available on 10.8, so we can use the system
header again, and in the future remove the local copy once our minimum
compile version is new enough.
Using UUIDs to store display references in obs-studio's settings file
allows us to "rediscover" devices even between restarts
(as CGDirectDisplayID changes between those) and select the same device.
Xcode 14.3 and the macOS 13.3 platform SDK introduced a few breaking
changes:
* Updated AppleClang emits warnings about unqualified std cast calls
when using C++ - as `move` is too broad a word, developers are to use
`std::move` to make this explicit. Alas this is exactly what `json11`
uses and because that library is archived, there is no possibility
of an upstream update.
* Apple guarded calls to old screen capture APIs as "available but
deprecated", but seems to have chosen the wrong lower version
boundary: The calls are flagged as being available for macOS 13 and
macOS 14 only.
To fix this, the existing macOS platform SDK header is replaced by a
local copy that uses macOS 11 as the lower boundary (the oldest macOS
version supported by obs-studio anyway)
The current method would enum though all devices looking for a matching
uid instead of directly asking for kAudioHardwarePropertyDeviceForUID.
Asking directly instead would also enable finding hidden devices that
can only be found directly via uid and not via enumerating (were we ever
to need to find such a device).