1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 16:33:02 +00:00

ao_coreaudio: fix CoreAudio deprecations

This commit is contained in:
der richter 2024-10-30 22:13:28 +01:00
parent 6f009a91a6
commit 84adbd9d35
5 changed files with 38 additions and 10 deletions

View File

@ -27,6 +27,7 @@
#include "ao_coreaudio_chmap.h"
#include "ao_coreaudio_properties.h"
#include "ao_coreaudio_utils.h"
#include "osdep/mac/compat.h"
// The timeout for stopping the audio unit after being reset. This allows the
// device to sleep after playback paused. The duration is chosen to match the
@ -490,7 +491,7 @@ static bool register_hotplug_cb(struct ao *ao)
AudioObjectPropertyAddress addr = {
hotplug_properties[i],
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};
err = AudioObjectAddPropertyListener(
kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao);
@ -520,7 +521,7 @@ static void unregister_hotplug_cb(struct ao *ao)
AudioObjectPropertyAddress addr = {
hotplug_properties[i],
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};
err = AudioObjectRemovePropertyListener(
kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao);

View File

@ -50,6 +50,7 @@
#include "audio/out/ao_coreaudio_chmap.h"
#include "audio/out/ao_coreaudio_properties.h"
#include "audio/out/ao_coreaudio_utils.h"
#include "osdep/mac/compat.h"
struct priv {
// This must be put in the front
@ -123,7 +124,7 @@ static OSStatus enable_property_listener(struct ao *ao, bool enabled)
for (int n = 0; n < MP_ARRAY_SIZE(devs); n++) {
AudioObjectPropertyAddress addr = {
.mScope = kAudioObjectPropertyScopeGlobal,
.mElement = kAudioObjectPropertyElementMaster,
.mElement = kAudioObjectPropertyElementMain,
.mSelector = selectors[n],
};
AudioDeviceID device = devs[n];

View File

@ -22,6 +22,7 @@
#include "audio/out/ao_coreaudio_properties.h"
#include "audio/out/ao_coreaudio_utils.h"
#include "mpv_talloc.h"
#include "osdep/mac/compat.h"
OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
uint32_t size, void *data)
@ -29,7 +30,7 @@ OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
.mSelector = selector,
.mScope = scope,
.mElement = kAudioObjectPropertyElementMaster,
.mElement = kAudioObjectPropertyElementMain,
};
return AudioObjectGetPropertyData(id, &p_addr, 0, NULL, &size, data);
@ -41,7 +42,7 @@ OSStatus ca_set(AudioObjectID id, ca_scope scope, ca_sel selector,
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
.mSelector = selector,
.mScope = scope,
.mElement = kAudioObjectPropertyElementMaster,
.mElement = kAudioObjectPropertyElementMain,
};
return AudioObjectSetPropertyData(id, &p_addr, 0, NULL, size, data);
@ -56,7 +57,7 @@ OSStatus ca_get_ary(AudioObjectID id, ca_scope scope, ca_sel selector,
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
.mSelector = selector,
.mScope = scope,
.mElement = kAudioObjectPropertyElementMaster,
.mElement = kAudioObjectPropertyElementMain,
};
err = AudioObjectGetPropertyDataSize(id, &p_addr, 0, NULL, &p_size);
@ -95,7 +96,7 @@ Boolean ca_settable(AudioObjectID id, ca_scope scope, ca_sel selector,
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
.mSelector = selector,
.mScope = kAudioObjectPropertyScopeGlobal,
.mElement = kAudioObjectPropertyElementMaster,
.mElement = kAudioObjectPropertyElementMain,
};
return AudioObjectIsPropertySettable(id, &p_addr, data);

View File

@ -26,6 +26,7 @@
#include "osdep/timer.h"
#include "osdep/endian.h"
#include "audio/format.h"
#include "osdep/mac/compat.h"
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
#include "audio/out/ao_coreaudio_properties.h"
@ -97,7 +98,7 @@ OSStatus ca_select_device(struct ao *ao, char* name, AudioDeviceID *device)
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
.mSelector = kAudioHardwarePropertyDeviceForUID,
.mScope = kAudioObjectPropertyScopeGlobal,
.mElement = kAudioObjectPropertyElementMaster,
.mElement = kAudioObjectPropertyElementMain,
};
err = AudioObjectGetPropertyData(
kAudioObjectSystemObject, &p_addr, 0, 0, &size, &v);
@ -377,7 +378,7 @@ static OSStatus ca_change_mixing(struct ao *ao, AudioDeviceID device,
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
.mSelector = kAudioDevicePropertySupportsMixing,
.mScope = kAudioObjectPropertyScopeGlobal,
.mElement = kAudioObjectPropertyElementMaster,
.mElement = kAudioObjectPropertyElementMain,
};
if (AudioObjectHasProperty(device, &p_addr)) {
@ -486,7 +487,7 @@ bool ca_change_physical_format_sync(struct ao *ao, AudioStreamID stream,
AudioObjectPropertyAddress p_addr = {
.mSelector = kAudioStreamPropertyPhysicalFormat,
.mScope = kAudioObjectPropertyScopeGlobal,
.mElement = kAudioObjectPropertyElementMaster,
.mElement = kAudioObjectPropertyElementMain,
};
err = AudioObjectAddPropertyListener(stream, &p_addr,

24
osdep/mac/compat.h Normal file
View File

@ -0,0 +1,24 @@
/*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "config.h"
#if !HAVE_MACOS_12_FEATURES
#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
#endif