123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- {!
- @file AudioHardwareService.h
- @framework AudioToolbox.framework
- @copyright (c) 2006-2015 by Apple, Inc., all rights reserved.
- @abstract API's for general high level audio services.
-
- @discussion
-
- The Audio Hardware Service (AHS) provides a way for applications to query and manipulate the
- aspects of an audio hardware device without incurring the overhead of loading the full audio
- HAL. AHS provides access to all the AudioObjects and their properties on the system. However,
- access is limited to only those properties that do not directly impact IO. For example, you can
- query the device's format but you can't query its IO buffer size. As such, the AHS API directly
- incorporates the various structures and constants in HAL's API, with the caveat that the
- AudioObjectIDs used in AHS cannot be used with the HAL.
- }
- { Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
- {
- Modified for use with Free Pascal
- Version 308
- Please report any bugs to <[email protected]>
- }
- {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
- {$mode macpas}
- {$modeswitch cblocks}
- {$packenum 1}
- {$macro on}
- {$inline on}
- {$calling mwpascal}
- unit AudioHardwareService;
- interface
- {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
- {$setc GAP_INTERFACES_VERSION := $0308}
- {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
- {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
- {$endc}
- {$ifc defined CPUPOWERPC and defined CPUI386}
- {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
- {$endc}
- {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
- {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
- {$endc}
- {$ifc not defined __ppc__ and defined CPUPOWERPC32}
- {$setc __ppc__ := 1}
- {$elsec}
- {$setc __ppc__ := 0}
- {$endc}
- {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
- {$setc __ppc64__ := 1}
- {$elsec}
- {$setc __ppc64__ := 0}
- {$endc}
- {$ifc not defined __i386__ and defined CPUI386}
- {$setc __i386__ := 1}
- {$elsec}
- {$setc __i386__ := 0}
- {$endc}
- {$ifc not defined __x86_64__ and defined CPUX86_64}
- {$setc __x86_64__ := 1}
- {$elsec}
- {$setc __x86_64__ := 0}
- {$endc}
- {$ifc not defined __arm__ and defined CPUARM}
- {$setc __arm__ := 1}
- {$elsec}
- {$setc __arm__ := 0}
- {$endc}
- {$ifc not defined __arm64__ and defined CPUAARCH64}
- {$setc __arm64__ := 1}
- {$elsec}
- {$setc __arm64__ := 0}
- {$endc}
- {$ifc defined cpu64}
- {$setc __LP64__ := 1}
- {$elsec}
- {$setc __LP64__ := 0}
- {$endc}
- {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
- {$error Conflicting definitions for __ppc__ and __i386__}
- {$endc}
- {$ifc defined __ppc__ and __ppc__}
- {$setc TARGET_CPU_PPC := TRUE}
- {$setc TARGET_CPU_PPC64 := FALSE}
- {$setc TARGET_CPU_X86 := FALSE}
- {$setc TARGET_CPU_X86_64 := FALSE}
- {$setc TARGET_CPU_ARM := FALSE}
- {$setc TARGET_CPU_ARM64 := FALSE}
- {$setc TARGET_OS_MAC := TRUE}
- {$setc TARGET_OS_IPHONE := FALSE}
- {$setc TARGET_IPHONE_SIMULATOR := FALSE}
- {$setc TARGET_OS_EMBEDDED := FALSE}
- {$elifc defined __ppc64__ and __ppc64__}
- {$setc TARGET_CPU_PPC := FALSE}
- {$setc TARGET_CPU_PPC64 := TRUE}
- {$setc TARGET_CPU_X86 := FALSE}
- {$setc TARGET_CPU_X86_64 := FALSE}
- {$setc TARGET_CPU_ARM := FALSE}
- {$setc TARGET_CPU_ARM64 := FALSE}
- {$setc TARGET_OS_MAC := TRUE}
- {$setc TARGET_OS_IPHONE := FALSE}
- {$setc TARGET_IPHONE_SIMULATOR := FALSE}
- {$setc TARGET_OS_EMBEDDED := FALSE}
- {$elifc defined __i386__ and __i386__}
- {$setc TARGET_CPU_PPC := FALSE}
- {$setc TARGET_CPU_PPC64 := FALSE}
- {$setc TARGET_CPU_X86 := TRUE}
- {$setc TARGET_CPU_X86_64 := FALSE}
- {$setc TARGET_CPU_ARM := FALSE}
- {$setc TARGET_CPU_ARM64 := FALSE}
- {$ifc defined(iphonesim)}
- {$setc TARGET_OS_MAC := FALSE}
- {$setc TARGET_OS_IPHONE := TRUE}
- {$setc TARGET_IPHONE_SIMULATOR := TRUE}
- {$elsec}
- {$setc TARGET_OS_MAC := TRUE}
- {$setc TARGET_OS_IPHONE := FALSE}
- {$setc TARGET_IPHONE_SIMULATOR := FALSE}
- {$endc}
- {$setc TARGET_OS_EMBEDDED := FALSE}
- {$elifc defined __x86_64__ and __x86_64__}
- {$setc TARGET_CPU_PPC := FALSE}
- {$setc TARGET_CPU_PPC64 := FALSE}
- {$setc TARGET_CPU_X86 := FALSE}
- {$setc TARGET_CPU_X86_64 := TRUE}
- {$setc TARGET_CPU_ARM := FALSE}
- {$setc TARGET_CPU_ARM64 := FALSE}
- {$ifc defined(iphonesim)}
- {$setc TARGET_OS_MAC := FALSE}
- {$setc TARGET_OS_IPHONE := TRUE}
- {$setc TARGET_IPHONE_SIMULATOR := TRUE}
- {$elsec}
- {$setc TARGET_OS_MAC := TRUE}
- {$setc TARGET_OS_IPHONE := FALSE}
- {$setc TARGET_IPHONE_SIMULATOR := FALSE}
- {$endc}
- {$setc TARGET_OS_EMBEDDED := FALSE}
- {$elifc defined __arm__ and __arm__}
- {$setc TARGET_CPU_PPC := FALSE}
- {$setc TARGET_CPU_PPC64 := FALSE}
- {$setc TARGET_CPU_X86 := FALSE}
- {$setc TARGET_CPU_X86_64 := FALSE}
- {$setc TARGET_CPU_ARM := TRUE}
- {$setc TARGET_CPU_ARM64 := FALSE}
- { will require compiler define when/if other Apple devices with ARM cpus ship }
- {$setc TARGET_OS_MAC := FALSE}
- {$setc TARGET_OS_IPHONE := TRUE}
- {$setc TARGET_IPHONE_SIMULATOR := FALSE}
- {$setc TARGET_OS_EMBEDDED := TRUE}
- {$elifc defined __arm64__ and __arm64__}
- {$setc TARGET_CPU_PPC := FALSE}
- {$setc TARGET_CPU_PPC64 := FALSE}
- {$setc TARGET_CPU_X86 := FALSE}
- {$setc TARGET_CPU_X86_64 := FALSE}
- {$setc TARGET_CPU_ARM := FALSE}
- {$setc TARGET_CPU_ARM64 := TRUE}
- { will require compiler define when/if other Apple devices with ARM cpus ship }
- {$setc TARGET_OS_MAC := FALSE}
- {$setc TARGET_OS_IPHONE := TRUE}
- {$setc TARGET_IPHONE_SIMULATOR := FALSE}
- {$setc TARGET_OS_EMBEDDED := TRUE}
- {$elsec}
- {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
- {$endc}
- {$ifc defined __LP64__ and __LP64__ }
- {$setc TARGET_CPU_64 := TRUE}
- {$elsec}
- {$setc TARGET_CPU_64 := FALSE}
- {$endc}
- {$ifc defined FPC_BIG_ENDIAN}
- {$setc TARGET_RT_BIG_ENDIAN := TRUE}
- {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
- {$elifc defined FPC_LITTLE_ENDIAN}
- {$setc TARGET_RT_BIG_ENDIAN := FALSE}
- {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
- {$elsec}
- {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
- {$endc}
- {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
- {$setc CALL_NOT_IN_CARBON := FALSE}
- {$setc OLDROUTINENAMES := FALSE}
- {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
- {$setc OPAQUE_UPP_TYPES := TRUE}
- {$setc OTCARBONAPPLICATION := TRUE}
- {$setc OTKERNEL := FALSE}
- {$setc PM_USE_SESSION_APIS := TRUE}
- {$setc TARGET_API_MAC_CARBON := TRUE}
- {$setc TARGET_API_MAC_OS8 := FALSE}
- {$setc TARGET_API_MAC_OSX := TRUE}
- {$setc TARGET_CARBON := TRUE}
- {$setc TARGET_CPU_68K := FALSE}
- {$setc TARGET_CPU_MIPS := FALSE}
- {$setc TARGET_CPU_SPARC := FALSE}
- {$setc TARGET_OS_UNIX := FALSE}
- {$setc TARGET_OS_WIN32 := FALSE}
- {$setc TARGET_RT_MAC_68881 := FALSE}
- {$setc TARGET_RT_MAC_CFM := FALSE}
- {$setc TARGET_RT_MAC_MACHO := TRUE}
- {$setc TYPED_FUNCTION_POINTERS := TRUE}
- {$setc TYPE_BOOL := FALSE}
- {$setc TYPE_EXTENDED := FALSE}
- {$setc TYPE_LONGLONG := TRUE}
- uses MacTypes,AudioHardwareBase,AudioHardware;
- {$endc} {not MACOSALLINCLUDE}
- {$ALIGN POWER}
-
- //==================================================================================================
- //#pragma mark Audio Hardware Service Properties
- {!
- @enum Audio Hardware Service Properties
- @abstract AudioObjectPropertySelector values that apply to various kinds of AudioObjects
- only when accessed via the Audio Hardware Service API.
- @constant kAudioHardwareServiceProperty_ServiceRestarted
- A Float32 whose value has no meaning. Rather, this property exists so that
- clients can be informed when the service has been reset for some reason.
- When a reset happens, any state the client has with AHS, such as cached data
- or added listeners, must be re-established by the client.
- @constant kAudioHardwareServiceDeviceProperty_VirtualMasterVolume
- A Float32 that represents the value of the volume control. The range is
- between 0.0 and 1.0 (inclusive). This actual volume controls this property
- manipulates depends on what the device provides. If the device has a true
- master volume control, this property directly controls that. If the device
- has individual channel volume controls, this property will apply to those
- identified by the device's preferred multi-channel layout (or preferred
- stereo pair if the device is stereo only). Note that this control maintains
- the relative balance between all the channels it affects.
- @constant kAudioHardwareServiceDeviceProperty_VirtualMasterBalance
- A Float32 that represents the value of the stereo balance control. The range
- is from 0.0 (all power to the left) to 1.0 (all power to the right) with
- the value of 0.5 signifying that the channels have equal power. This control
- is only present for devices that have individual channel volume controls. It
- manipulates the relative balance between the volume controls on the channels
- identified as the device's default stereo pair.
- }
- const
- kAudioHardwareServiceProperty_ServiceRestarted = FourCharCode('srst');
- kAudioHardwareServiceDeviceProperty_VirtualMasterVolume = FourCharCode('vmvc');
- kAudioHardwareServiceDeviceProperty_VirtualMasterBalance = FourCharCode('vmbc');
- //==================================================================================================
- //#pragma mark Audio Hardware Service Functions
- {$ifc TARGET_OS_MAC}
- {!
- @functiongroup Audio Hardware Service
- }
- {!
- @function AudioHardwareServiceHasProperty
- @abstract Queries an AudioObject about whether or not it has the given property.
- @param inObjectID
- The AudioObject to query.
- @param inAddress
- An AudioObjectPropertyAddress indicating which property is being queried.
- @result A Boolean indicating whether or not the AudioObject has the given property.
- }
- function AudioHardwareServiceHasProperty( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress ): Boolean; external name '_AudioHardwareServiceHasProperty';
- (* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
- {!
- @function AudioHardwareServiceIsPropertySettable
- @abstract Queries an AudioObject about whether or not the given property can be set using
- AudioHardwareServiceSetPropertyData.
- @param inObjectID
- The AudioObject to query.
- @param inAddress
- An AudioObjectPropertyAddress indicating which property is being queried.
- @param outIsSettable
- A Boolean indicating whether or not the property can be set.
- @result An OSStatus indicating success or failure.
- }
- function AudioHardwareServiceIsPropertySettable( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; var outIsSettable: Boolean ): OSStatus; external name '_AudioHardwareServiceIsPropertySettable';
- (* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
- {!
- @function AudioHardwareServiceGetPropertyDataSize
- @abstract Queries an AudioObject to find the size of the data for the given property.
- @param inObjectID
- The AudioObject to query.
- @param inAddress
- An AudioObjectPropertyAddress indicating which property is being queried.
- @param inQualifierDataSize
- A UInt32 indicating the size of the buffer pointed to by inQualifierData.
- Note that not all properties require qualification, in which case this
- value will be 0.
- @param inQualifierData
- A buffer of data to be used in determining the data of the property being
- queried. Note that not all properties require qualification, in which case
- this value will be NULL.
- @param outDataSize
- A UInt32 indicating how many bytes the data for the given property occupies.
- @result An OSStatus indicating success or failure.
- }
- function AudioHardwareServiceGetPropertyDataSize( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inQualifierDataSize: UInt32; inQualifierData: {const} UnivPtr; var outDataSize: UInt32 ): OSStatus; external name '_AudioHardwareServiceGetPropertyDataSize';
- (* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
- {!
- @function AudioHardwareServiceGetPropertyData
- @abstract Queries an AudioObject to get the data of the given property and places it in
- the provided buffer.
- @param inObjectID
- The AudioObject to query.
- @param inAddress
- An AudioObjectPropertyAddress indicating which property is being queried.
- @param inQualifierDataSize
- A UInt32 indicating the size of the buffer pointed to by inQualifierData.
- Note that not all properties require qualification, in which case this
- value will be 0.
- @param inQualifierData
- A buffer of data to be used in determining the data of the property being
- queried. Note that not all properties require qualification, in which case
- this value will be NULL.
- @param ioDataSize
- A UInt32 which on entry indicates the size of the buffer pointed to by
- outData and on exit indicates how much of the buffer was used.
- @param outData
- The buffer into which the AudioObject will put the data for the given
- property.
- @result An OSStatus indicating success or failure.
- }
- function AudioHardwareServiceGetPropertyData( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inQualifierDataSize: UInt32; inQualifierData: {const} UnivPtr; var ioDataSize: UInt32; outData: UnivPtr ): OSStatus; external name '_AudioHardwareServiceGetPropertyData';
- (* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
- {!
- @function AudioHardwareServiceSetPropertyData
- @abstract Tells an AudioObject to change the value of the given property using the
- provided data.
- @discussion Note that the value of the property should not be considered changed until the
- HAL has called the listeners as many properties values are changed
- asynchronously.
- @param inObjectID
- The AudioObject to change.
- @param inAddress
- An AudioObjectPropertyAddress indicating which property is being changed.
- @param inQualifierDataSize
- A UInt32 indicating the size of the buffer pointed to by inQualifierData.
- Note that not all properties require qualification, in which case this
- value will be 0.
- @param inQualifierData
- A buffer of data to be used in determining the data of the property being
- queried. Note that not all properties require qualification, in which case
- this value will be NULL.
- @param inDataSize
- A UInt32 indicating the size of the buffer pointed to by inData.
- @param inData
- The buffer containing the data to be used to change the property's value.
- @result An OSStatus indicating success or failure.
- }
- function AudioHardwareServiceSetPropertyData( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inQualifierDataSize: UInt32; inQualifierData: {const} UnivPtr; inDataSize: UInt32; inData: {const} UnivPtr ): OSStatus; external name '_AudioHardwareServiceSetPropertyData';
- (* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
- {!
- @function AudioHardwareServiceAddPropertyListener
- @abstract Registers the given AudioObjectPropertyListenerProc to receive notifications
- when the given properties change.
- @param inObjectID
- The AudioObject to register the listener with.
- @param inAddress
- The AudioObjectPropertyAddresses indicating which property the listener
- should be notified about.
- @param inListener
- The AudioObjectPropertyListenerProc to call.
- @param inClientData
- A pointer to client data that is passed to the listener when it is called.
- @result An OSStatus indicating success or failure.
- }
- function AudioHardwareServiceAddPropertyListener( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inListener: AudioObjectPropertyListenerProc; inClientData: UnivPtr ): OSStatus; external name '_AudioHardwareServiceAddPropertyListener';
- (* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
- {!
- @function AudioHardwareServiceRemovePropertyListener
- @abstract Unregisters the given AudioObjectPropertyListenerProc from receiving
- notifications when the given properties change.
- @param inObjectID
- The AudioObject to unregister the listener from.
- @param inAddress
- The AudioObjectPropertyAddresses indicating which property the listener
- will stop being notified about.
- @param inListener
- The AudioObjectPropertyListenerProc being removed.
- @param inClientData
- A pointer to client data that is passed to the listener when it is called.
- @result An OSStatus indicating success or failure.
- }
- function AudioHardwareServiceRemovePropertyListener( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inListener: AudioObjectPropertyListenerProc; inClientData: UnivPtr ): OSStatus; external name '_AudioHardwareServiceRemovePropertyListener';
- (* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
- {$endc}
- {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
- end.
- {$endc} {not MACOSALLINCLUDE}
|