This PR provides forward and backward compatibility at macos SDK 12.0. At SDK 12.0, API function names were changed essentially replacing

occurrences of the word Master/master with Main/main. This change was test built on two different systems.

1. macos 10.15.7 with Xcode 12.4 and clang 12.0.0 on x86_64
2. macos 12.5 with Xcode 13.4.1 and clang 13.1.6 on arm64 (Apple silicon M1)

It should be noted that on macos 10.15.7 with Xcode 11.2 and clang 11.0, MPD will not build.
The MPD documentation states that clang 11.0 is the minimum requirement,
but clang 11.0 produces compile errors. Apparently the macos version
of clang 11.0 is not fully compliant.
This commit is contained in:
Dave Hocker 2022-08-01 15:45:44 -05:00 committed by Max Kellermann
parent fe195257d8
commit bbc088ae4e
2 changed files with 23 additions and 13 deletions

1
NEWS
View File

@ -4,6 +4,7 @@ ver 0.23.9 (not yet released)
* output * output
- pipewire: set app icon - pipewire: set app icon
* improve iconv detection * improve iconv detection
* macOS: fix macOS 10 build problem (0.23.8 regression)
ver 0.23.8 (2022/07/09) ver 0.23.8 (2022/07/09)
* storage * storage

View File

@ -47,6 +47,15 @@
#include <memory> #include <memory>
// Backward compatibility from OSX 12.0 API change
#if (__MAC_OS_X_VERSION_MAX_ALLOWED >= 120000)
#define KAUDIO_OBJECT_PROPERTY_ELEMENT_MM kAudioObjectPropertyElementMain
#define KAUDIO_HARDWARE_SERVICE_DEVICE_PROPERTY_VV kAudioHardwareServiceDeviceProperty_VirtualMainVolume
#else
#define KAUDIO_OBJECT_PROPERTY_ELEMENT_MM kAudioObjectPropertyElementMaster
#define KAUDIO_HARDWARE_SERVICE_DEVICE_PROPERTY_VV kAudioHardwareServiceDeviceProperty_VirtualMasterVolume
#endif
static constexpr unsigned MPD_OSX_BUFFER_TIME_MS = 100; static constexpr unsigned MPD_OSX_BUFFER_TIME_MS = 100;
static StringBuffer<64> static StringBuffer<64>
@ -160,13 +169,13 @@ OSXOutput::Create(EventLoop &, const ConfigBlock &block)
static constexpr AudioObjectPropertyAddress default_system_output_device{ static constexpr AudioObjectPropertyAddress default_system_output_device{
kAudioHardwarePropertyDefaultSystemOutputDevice, kAudioHardwarePropertyDefaultSystemOutputDevice,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain, KAUDIO_OBJECT_PROPERTY_ELEMENT_MM,
}; };
static constexpr AudioObjectPropertyAddress default_output_device{ static constexpr AudioObjectPropertyAddress default_output_device{
kAudioHardwarePropertyDefaultOutputDevice, kAudioHardwarePropertyDefaultOutputDevice,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
}; };
const auto &aopa = const auto &aopa =
@ -195,9 +204,9 @@ int
OSXOutput::GetVolume() OSXOutput::GetVolume()
{ {
static constexpr AudioObjectPropertyAddress aopa = { static constexpr AudioObjectPropertyAddress aopa = {
kAudioHardwareServiceDeviceProperty_VirtualMainVolume, KAUDIO_HARDWARE_SERVICE_DEVICE_PROPERTY_VV,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain, KAUDIO_OBJECT_PROPERTY_ELEMENT_MM,
}; };
const auto vol = AudioObjectGetPropertyDataT<Float32>(dev_id, const auto vol = AudioObjectGetPropertyDataT<Float32>(dev_id,
@ -211,9 +220,9 @@ OSXOutput::SetVolume(unsigned new_volume)
{ {
Float32 vol = new_volume / 100.0; Float32 vol = new_volume / 100.0;
static constexpr AudioObjectPropertyAddress aopa = { static constexpr AudioObjectPropertyAddress aopa = {
kAudioHardwareServiceDeviceProperty_VirtualMainVolume, KAUDIO_HARDWARE_SERVICE_DEVICE_PROPERTY_VV,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
}; };
UInt32 size = sizeof(vol); UInt32 size = sizeof(vol);
OSStatus status = AudioObjectSetPropertyData(dev_id, OSStatus status = AudioObjectSetPropertyData(dev_id,
@ -366,25 +375,25 @@ osx_output_set_device_format(AudioDeviceID dev_id,
static constexpr AudioObjectPropertyAddress aopa_device_streams = { static constexpr AudioObjectPropertyAddress aopa_device_streams = {
kAudioDevicePropertyStreams, kAudioDevicePropertyStreams,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
}; };
static constexpr AudioObjectPropertyAddress aopa_stream_direction = { static constexpr AudioObjectPropertyAddress aopa_stream_direction = {
kAudioStreamPropertyDirection, kAudioStreamPropertyDirection,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
}; };
static constexpr AudioObjectPropertyAddress aopa_stream_phys_formats = { static constexpr AudioObjectPropertyAddress aopa_stream_phys_formats = {
kAudioStreamPropertyAvailablePhysicalFormats, kAudioStreamPropertyAvailablePhysicalFormats,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
}; };
static constexpr AudioObjectPropertyAddress aopa_stream_phys_format = { static constexpr AudioObjectPropertyAddress aopa_stream_phys_format = {
kAudioStreamPropertyPhysicalFormat, kAudioStreamPropertyPhysicalFormat,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
}; };
OSStatus err; OSStatus err;
@ -484,7 +493,7 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept
static constexpr AudioObjectPropertyAddress aopa = { static constexpr AudioObjectPropertyAddress aopa = {
kAudioDevicePropertyHogMode, kAudioDevicePropertyHogMode,
kAudioObjectPropertyScopeOutput, kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
}; };
pid_t hog_pid; pid_t hog_pid;
@ -538,7 +547,7 @@ IsAudioDeviceName(AudioDeviceID id, const char *expected_name) noexcept
static constexpr AudioObjectPropertyAddress aopa_name{ static constexpr AudioObjectPropertyAddress aopa_name{
kAudioObjectPropertyName, kAudioObjectPropertyName,
kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain, KAUDIO_OBJECT_PROPERTY_ELEMENT_MM,
}; };
char actual_name[256]; char actual_name[256];
@ -561,7 +570,7 @@ FindAudioDeviceByName(const char *name)
static constexpr AudioObjectPropertyAddress aopa_hw_devices{ static constexpr AudioObjectPropertyAddress aopa_hw_devices{
kAudioHardwarePropertyDevices, kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain, KAUDIO_OBJECT_PROPERTY_ELEMENT_MM,
}; };
const auto ids = const auto ids =