mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-22 19:05:37 +00:00
conditionally alias now-deprecated method
This commit is contained in:
parent
47e1756fa7
commit
cb55894da5
|
@ -9,6 +9,11 @@
|
||||||
#include "soundio_private.h"
|
#include "soundio_private.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
|
|
||||||
|
#if !defined(MAC_OS_VERSION_12_0) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0)
|
||||||
|
#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
|
||||||
|
#endif
|
||||||
|
|
||||||
static const int OUTPUT_ELEMENT = 0;
|
static const int OUTPUT_ELEMENT = 0;
|
||||||
static const int INPUT_ELEMENT = 1;
|
static const int INPUT_ELEMENT = 1;
|
||||||
|
@ -17,77 +22,77 @@ static AudioObjectPropertyAddress device_listen_props[] = {
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyDeviceHasChanged,
|
kAudioDevicePropertyDeviceHasChanged,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioObjectPropertyName,
|
kAudioObjectPropertyName,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyDeviceUID,
|
kAudioDevicePropertyDeviceUID,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyStreamConfiguration,
|
kAudioDevicePropertyStreamConfiguration,
|
||||||
kAudioObjectPropertyScopeInput,
|
kAudioObjectPropertyScopeInput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyStreamConfiguration,
|
kAudioDevicePropertyStreamConfiguration,
|
||||||
kAudioObjectPropertyScopeOutput,
|
kAudioObjectPropertyScopeOutput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyPreferredChannelLayout,
|
kAudioDevicePropertyPreferredChannelLayout,
|
||||||
kAudioObjectPropertyScopeInput,
|
kAudioObjectPropertyScopeInput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyPreferredChannelLayout,
|
kAudioDevicePropertyPreferredChannelLayout,
|
||||||
kAudioObjectPropertyScopeOutput,
|
kAudioObjectPropertyScopeOutput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyNominalSampleRate,
|
kAudioDevicePropertyNominalSampleRate,
|
||||||
kAudioObjectPropertyScopeInput,
|
kAudioObjectPropertyScopeInput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyNominalSampleRate,
|
kAudioDevicePropertyNominalSampleRate,
|
||||||
kAudioObjectPropertyScopeOutput,
|
kAudioObjectPropertyScopeOutput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyAvailableNominalSampleRates,
|
kAudioDevicePropertyAvailableNominalSampleRates,
|
||||||
kAudioObjectPropertyScopeInput,
|
kAudioObjectPropertyScopeInput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyAvailableNominalSampleRates,
|
kAudioDevicePropertyAvailableNominalSampleRates,
|
||||||
kAudioObjectPropertyScopeOutput,
|
kAudioObjectPropertyScopeOutput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyBufferFrameSize,
|
kAudioDevicePropertyBufferFrameSize,
|
||||||
kAudioObjectPropertyScopeInput,
|
kAudioObjectPropertyScopeInput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyBufferFrameSize,
|
kAudioDevicePropertyBufferFrameSize,
|
||||||
kAudioObjectPropertyScopeOutput,
|
kAudioObjectPropertyScopeOutput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyBufferFrameSizeRange,
|
kAudioDevicePropertyBufferFrameSizeRange,
|
||||||
kAudioObjectPropertyScopeInput,
|
kAudioObjectPropertyScopeInput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kAudioDevicePropertyBufferFrameSizeRange,
|
kAudioDevicePropertyBufferFrameSizeRange,
|
||||||
kAudioObjectPropertyScopeOutput,
|
kAudioObjectPropertyScopeOutput,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -141,7 +146,7 @@ static void destroy_ca(struct SoundIoPrivate *si) {
|
||||||
AudioObjectPropertyAddress prop_address = {
|
AudioObjectPropertyAddress prop_address = {
|
||||||
kAudioHardwarePropertyDevices,
|
kAudioHardwarePropertyDevices,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
};
|
};
|
||||||
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &prop_address, on_devices_changed, si);
|
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &prop_address, on_devices_changed, si);
|
||||||
|
|
||||||
|
@ -440,7 +445,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
AudioObjectPropertyAddress prop_address = {
|
AudioObjectPropertyAddress prop_address = {
|
||||||
kAudioHardwarePropertyDevices,
|
kAudioHardwarePropertyDevices,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((os_err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
|
if ((os_err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
|
||||||
|
@ -509,7 +514,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
|
|
||||||
prop_address.mSelector = kAudioObjectPropertyName;
|
prop_address.mSelector = kAudioObjectPropertyName;
|
||||||
prop_address.mScope = kAudioObjectPropertyScopeGlobal;
|
prop_address.mScope = kAudioObjectPropertyScopeGlobal;
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
io_size = sizeof(CFStringRef);
|
io_size = sizeof(CFStringRef);
|
||||||
if (rd.string_ref) {
|
if (rd.string_ref) {
|
||||||
CFRelease(rd.string_ref);
|
CFRelease(rd.string_ref);
|
||||||
|
@ -531,7 +536,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
|
|
||||||
prop_address.mSelector = kAudioDevicePropertyDeviceUID;
|
prop_address.mSelector = kAudioDevicePropertyDeviceUID;
|
||||||
prop_address.mScope = kAudioObjectPropertyScopeGlobal;
|
prop_address.mScope = kAudioObjectPropertyScopeGlobal;
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
io_size = sizeof(CFStringRef);
|
io_size = sizeof(CFStringRef);
|
||||||
if (rd.string_ref) {
|
if (rd.string_ref) {
|
||||||
CFRelease(rd.string_ref);
|
CFRelease(rd.string_ref);
|
||||||
|
@ -558,7 +563,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
io_size = 0;
|
io_size = 0;
|
||||||
prop_address.mSelector = kAudioDevicePropertyStreamConfiguration;
|
prop_address.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||||
prop_address.mScope = aim_to_scope(aim);
|
prop_address.mScope = aim_to_scope(aim);
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
if ((os_err = AudioObjectGetPropertyDataSize(device_id, &prop_address, 0, NULL, &io_size))) {
|
if ((os_err = AudioObjectGetPropertyDataSize(device_id, &prop_address, 0, NULL, &io_size))) {
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
return SoundIoErrorOpeningDevice;
|
return SoundIoErrorOpeningDevice;
|
||||||
|
@ -609,7 +614,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
|
|
||||||
prop_address.mSelector = kAudioDevicePropertyPreferredChannelLayout;
|
prop_address.mSelector = kAudioDevicePropertyPreferredChannelLayout;
|
||||||
prop_address.mScope = aim_to_scope(aim);
|
prop_address.mScope = aim_to_scope(aim);
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
if (!(os_err = AudioObjectGetPropertyDataSize(device_id, &prop_address,
|
if (!(os_err = AudioObjectGetPropertyDataSize(device_id, &prop_address,
|
||||||
0, NULL, &io_size)))
|
0, NULL, &io_size)))
|
||||||
{
|
{
|
||||||
|
@ -649,7 +654,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
|
|
||||||
prop_address.mSelector = kAudioDevicePropertyNominalSampleRate;
|
prop_address.mSelector = kAudioDevicePropertyNominalSampleRate;
|
||||||
prop_address.mScope = aim_to_scope(aim);
|
prop_address.mScope = aim_to_scope(aim);
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
io_size = sizeof(double);
|
io_size = sizeof(double);
|
||||||
double value;
|
double value;
|
||||||
if ((os_err = AudioObjectGetPropertyData(device_id, &prop_address, 0, NULL,
|
if ((os_err = AudioObjectGetPropertyData(device_id, &prop_address, 0, NULL,
|
||||||
|
@ -675,7 +680,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
} else {
|
} else {
|
||||||
prop_address.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
|
prop_address.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
|
||||||
prop_address.mScope = aim_to_scope(aim);
|
prop_address.mScope = aim_to_scope(aim);
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
if ((os_err = AudioObjectGetPropertyDataSize(device_id, &prop_address, 0, NULL,
|
if ((os_err = AudioObjectGetPropertyDataSize(device_id, &prop_address, 0, NULL,
|
||||||
&io_size)))
|
&io_size)))
|
||||||
{
|
{
|
||||||
|
@ -721,7 +726,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
|
|
||||||
prop_address.mSelector = kAudioDevicePropertyBufferFrameSize;
|
prop_address.mSelector = kAudioDevicePropertyBufferFrameSize;
|
||||||
prop_address.mScope = aim_to_scope(aim);
|
prop_address.mScope = aim_to_scope(aim);
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
io_size = sizeof(UInt32);
|
io_size = sizeof(UInt32);
|
||||||
UInt32 buffer_frame_size;
|
UInt32 buffer_frame_size;
|
||||||
if ((os_err = AudioObjectGetPropertyData(device_id, &prop_address, 0, NULL,
|
if ((os_err = AudioObjectGetPropertyData(device_id, &prop_address, 0, NULL,
|
||||||
|
@ -735,7 +740,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
|
|
||||||
prop_address.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
|
prop_address.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
|
||||||
prop_address.mScope = aim_to_scope(aim);
|
prop_address.mScope = aim_to_scope(aim);
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
io_size = sizeof(AudioValueRange);
|
io_size = sizeof(AudioValueRange);
|
||||||
AudioValueRange avr;
|
AudioValueRange avr;
|
||||||
if ((os_err = AudioObjectGetPropertyData(device_id, &prop_address, 0, NULL,
|
if ((os_err = AudioObjectGetPropertyData(device_id, &prop_address, 0, NULL,
|
||||||
|
@ -749,7 +754,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
|
|
||||||
prop_address.mSelector = kAudioDevicePropertyLatency;
|
prop_address.mSelector = kAudioDevicePropertyLatency;
|
||||||
prop_address.mScope = aim_to_scope(aim);
|
prop_address.mScope = aim_to_scope(aim);
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
io_size = sizeof(UInt32);
|
io_size = sizeof(UInt32);
|
||||||
if ((os_err = AudioObjectGetPropertyData(device_id, &prop_address, 0, NULL,
|
if ((os_err = AudioObjectGetPropertyData(device_id, &prop_address, 0, NULL,
|
||||||
&io_size, &dca->latency_frames)))
|
&io_size, &dca->latency_frames)))
|
||||||
|
@ -900,7 +905,7 @@ static void outstream_destroy_ca(struct SoundIoPrivate *si, struct SoundIoOutStr
|
||||||
AudioObjectPropertyAddress prop_address = {
|
AudioObjectPropertyAddress prop_address = {
|
||||||
kAudioDeviceProcessorOverload,
|
kAudioDeviceProcessorOverload,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
};
|
};
|
||||||
AudioObjectRemovePropertyListener(dca->device_id, &prop_address, on_outstream_device_overload, os);
|
AudioObjectRemovePropertyListener(dca->device_id, &prop_address, on_outstream_device_overload, os);
|
||||||
|
|
||||||
|
@ -1157,7 +1162,7 @@ static void instream_destroy_ca(struct SoundIoPrivate *si, struct SoundIoInStrea
|
||||||
AudioObjectPropertyAddress prop_address = {
|
AudioObjectPropertyAddress prop_address = {
|
||||||
kAudioDeviceProcessorOverload,
|
kAudioDeviceProcessorOverload,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
};
|
};
|
||||||
AudioObjectRemovePropertyListener(dca->device_id, &prop_address, on_instream_device_overload, is);
|
AudioObjectRemovePropertyListener(dca->device_id, &prop_address, on_instream_device_overload, is);
|
||||||
|
|
||||||
|
@ -1236,7 +1241,7 @@ static int instream_open_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPri
|
||||||
AudioObjectPropertyAddress prop_address;
|
AudioObjectPropertyAddress prop_address;
|
||||||
prop_address.mSelector = kAudioDevicePropertyStreamConfiguration;
|
prop_address.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||||
prop_address.mScope = kAudioObjectPropertyScopeInput;
|
prop_address.mScope = kAudioObjectPropertyScopeInput;
|
||||||
prop_address.mElement = kAudioObjectPropertyElementMaster;
|
prop_address.mElement = kAudioObjectPropertyElementMain;
|
||||||
io_size = 0;
|
io_size = 0;
|
||||||
if ((os_err = AudioObjectGetPropertyDataSize(dca->device_id, &prop_address,
|
if ((os_err = AudioObjectGetPropertyDataSize(dca->device_id, &prop_address,
|
||||||
0, NULL, &io_size)))
|
0, NULL, &io_size)))
|
||||||
|
@ -1443,7 +1448,7 @@ int soundio_coreaudio_init(struct SoundIoPrivate *si) {
|
||||||
AudioObjectPropertyAddress prop_address = {
|
AudioObjectPropertyAddress prop_address = {
|
||||||
kAudioHardwarePropertyDevices,
|
kAudioHardwarePropertyDevices,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMain
|
||||||
};
|
};
|
||||||
if ((err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &prop_address,
|
if ((err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &prop_address,
|
||||||
on_devices_changed, si)))
|
on_devices_changed, si)))
|
||||||
|
|
Loading…
Reference in a new issue