Skip to content

AVFAudio iOS xcode16.2 b2

Rolf Bjarne Kvinge edited this page Nov 22, 2024 · 2 revisions

#AVFAudio.framework https://github.com/xamarin/xamarin-macios/pull/21687

diff -ruN /Applications/Xcode_16.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioApplication.h /Applications/Xcode_16.2.0-beta2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioApplication.h
--- /Applications/Xcode_16.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioApplication.h	2024-09-29 03:14:11
+++ /Applications/Xcode_16.2.0-beta2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioApplication.h	2024-10-21 11:59:07
@@ -28,7 +28,27 @@
 	AVAudioApplicationRecordPermissionGranted = 'grnt'
 } NS_SWIFT_NAME(AVAudioApplication.recordPermission);
 
+/*!
+    @enum AVAudioApplicationMicrophoneInjectionPermission
+    @brief    These are the values returned by microphoneInjectionPermission.
+    @var    AVAudioApplicationMicrophoneInjectionPermissionServiceDisabled
+    The user has disabled this service for all apps.
+    @var    AVAudioApplicationMicrophoneInjectionUndetermined
+    The user has not yet been asked for permission.
+    @var    AVAudioApplicationMicrophoneInjectionPermissionDenied
+    The user has been asked and has denied permission.
+    @var    AVAudioApplicationMicrophoneInjectionPermissionGranted
+    The user has been asked and has granted permission.
 
+    Introduced: ios(18.2) visionos(2.2)
+*/
+typedef NS_ENUM(NSInteger, AVAudioApplicationMicrophoneInjectionPermission) {
+    AVAudioApplicationMicrophoneInjectionPermissionServiceDisabled = 'srds',
+    AVAudioApplicationMicrophoneInjectionPermissionUndetermined    = 'undt',
+    AVAudioApplicationMicrophoneInjectionPermissionDenied          = 'deny',
+    AVAudioApplicationMicrophoneInjectionPermissionGranted         = 'grnt'
+} NS_SWIFT_NAME(AVAudioApplication.MicrophoneInjectionPermission);
+
 /*!
 	@brief	Notification sent to registered listeners when the application's input is muted
 			or unmuted.
@@ -97,6 +117,21 @@
 	granted. Note that the block may be called in a different thread context.
 */
 + (void)requestRecordPermissionWithCompletionHandler:(void (^)(BOOL granted))response API_AVAILABLE(ios(17.0), watchos(10.0), tvos(17.0), macos(14.0));
+
+/// Returns an enum indicating whether the user has granted or denied permission to inject audio into input,
+/// or has not been asked
+@property(readonly) AVAudioApplicationMicrophoneInjectionPermission microphoneInjectionPermission API_AVAILABLE(ios(18.2), visionos(2.2)) API_UNAVAILABLE(tvos, watchos, macos);
+
+/*!
+    @brief Checks to see if calling process has permission to inject audio to input stream.
+
+    The 'response' block will be called immediately if permission has already been granted or
+    denied or if the service is disabled by the user.  Otherwise, it presents a dialog to notify the
+    user and allow them to choose, and calls the block once the UI has been dismissed.
+    'granted' indicates whether permission has been granted. Note that the block may be
+    called in a different thread context.
+*/
++ (void)requestMicrophoneInjectionPermissionWithCompletionHandler:(void (^)(AVAudioApplicationMicrophoneInjectionPermission permission))response API_AVAILABLE(ios(18.2), visionos(2.2)) API_UNAVAILABLE(tvos, watchos, macos);
 
 @end
 
diff -ruN /Applications/Xcode_16.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSession.h /Applications/Xcode_16.2.0-beta2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSession.h
--- /Applications/Xcode_16.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSession.h	2024-09-29 01:37:37
+++ /Applications/Xcode_16.2.0-beta2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSession.h	2024-10-21 14:53:23
@@ -163,9 +163,9 @@
     ringtones and alerts. By setting this property to YES, clients will not be interrupted
     by incoming call notifications and other alerts. Starting in iOS 14.0, users can set a global
     preference for incoming call display style to "Banner" or "Full Screen". With "Banner" display style,
-    if below property is set to YES then clients will not be interrupted on incoming call notification
-    and user will have opportunity to accept or decline the call. If call is declined, the session
-    will not be interrupted, but if user accepts the incoming call, the session will be interrupted.
+    if below property is set to YES then system audio will be silenced. Thus, clients will not be interrupted
+    on incoming call notification and user will have opportunity to accept or decline the call. If call is declined,
+    the session will not be interrupted, but if user accepts the incoming call, the session will be interrupted.
     With  display style set as "Full Screen", below property will have no effect and clients will be
     interrupted by incoming calls. Apps that record audio and/or video and apps that are used for
     music performance are candidates for using this feature.
@@ -447,6 +447,19 @@
 
 @end // interface for AVAudioSession (RoutingConfiguration)
 
+@interface  AVAudioSession (MicrophoneInjection)
+
+/// Set the preferred form of audio injection into another app's input stream
+/// See AVAudioSessionMicrophoneInjectionMode for available modes
+- (BOOL)setPreferredMicrophoneInjectionMode:(AVAudioSessionMicrophoneInjectionMode)inValue error:(NSError**)outError API_AVAILABLE(ios(18.2), visionos(2.2)) API_UNAVAILABLE(tvos, watchos, macos);
+@property(readonly) AVAudioSessionMicrophoneInjectionMode  preferredMicrophoneInjectionMode API_AVAILABLE(ios(18.2), visionos(2.2)) API_UNAVAILABLE(tvos, watchos, macos);
+
+/// Indicates if microphone injection is available.
+/// Observe AVAudioSessionMicrophoneInjectionCapabilitiesChangeNotification for changes to this property
+@property(readonly) BOOL isMicrophoneInjectionAvailable API_AVAILABLE(ios(18.2), visionos(2.2)) API_UNAVAILABLE(tvos, watchos, macos);
+
+@end
+
 #if TARGET_OS_VISION
 /*!
  The perceived "size" or "immersivity" of the sound. Use Small for least
@@ -623,6 +636,14 @@
  */
 OS_EXPORT NSNotificationName const AVAudioSessionRenderingCapabilitiesChangeNotification API_AVAILABLE(ios(17.2), tvos(17.2)) API_UNAVAILABLE(watchos, macos, visionos) NS_SWIFT_NAME(AVAudioSession.renderingCapabilitiesChangeNotification);
 
+/*!
+     @brief Notification sent to registered listeners when the system's capability to inject audio into input stream is changed
+ 
+ Check the notification's userInfo dictionary for AVAudioSessionMicrophoneInjectionIsAvailableKey to check if microphone
+ injection is available. Use AVAudioSession's isMicrophoneInjectionAvailable property to check if microphone injection is available
+ */
+OS_EXPORT NSNotificationName const AVAudioSessionMicrophoneInjectionCapabilitiesChangeNotification API_AVAILABLE(ios(18.2), visionos(2.2)) API_UNAVAILABLE(tvos, watchos, macos) NS_SWIFT_NAME(AVAudioSession.microphoneInjectionCapabilitiesChangeNotification);
+
 #pragma mark-- Keys for NSNotification userInfo dictionaries --
 
 /// keys for AVAudioSessionSpatialPlaybackCapabilitiesChangedNotification
@@ -667,6 +688,13 @@
 /// keys for AVAudioSessionRenderingModeChangeNotification
 /// Contains a payload of NSInteger representing the new resolved rendering mode
 OS_EXPORT NSString *const AVAudioSessionRenderingModeNewRenderingModeKey API_AVAILABLE(ios(17.2), tvos(17.2)) API_UNAVAILABLE(watchos, macos, visionos);
+
+/*!
+    Keys for AVAudioSessionMicrophoneInjectionCapabilitiesChangeNotification
+*/
+/// Indicates if microphone injection is available.
+/// Value is an NSNumber whose boolean value indicates if microphone injection is available.
+OS_EXPORT NSString *const AVAudioSessionMicrophoneInjectionIsAvailableKey API_AVAILABLE(ios(18.2), visionos(2.2)) API_UNAVAILABLE(tvos, watchos, macos);
 
 NS_ASSUME_NONNULL_END
 
diff -ruN /Applications/Xcode_16.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSessionTypes.h /Applications/Xcode_16.2.0-beta2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSessionTypes.h
--- /Applications/Xcode_16.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSessionTypes.h	2024-09-29 03:14:11
+++ /Applications/Xcode_16.2.0-beta2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSessionTypes.h	2024-10-21 18:46:34
@@ -650,6 +650,27 @@
 	AVAudioSessionRenderingModeDolbyAtmos              = 5,
 } NS_SWIFT_NAME(AVAudioSession.RenderingMode);
 
+/*!
+    @enum AVAudioSessionMicrophoneInjectionMode
+    @brief Various modes to inject audio coming from a session to another app’s input stream
+ 
+    Applications can state their intent to mix locally generated audio, which should consist primarily of
+    synthesized speech, to another app's input stream. This feature is intended to be used by accessibility apps
+    implementing augmentative and alternative communication systems that enable users with disabilities to
+    communicate with synthesized speech. When input is muted, microphone injection will also be muted.
+ 
+    @var  AVAudioSessionMicrophoneInjectionModeNone
+    @var  AVAudioSessionMicrophoneInjectionModeSpokenAudio
+ 
+*/
+typedef NS_ENUM(NSInteger, AVAudioSessionMicrophoneInjectionMode) {
+    /// Default state, microphone injection is not preferred
+    AVAudioSessionMicrophoneInjectionModeNone = 0,
+    
+    /// Inject Spoken Audio, like synthesized speech, with microphone audio
+    AVAudioSessionMicrophoneInjectionModeSpokenAudio = 1,
+} NS_SWIFT_NAME(AVAudioSession.MicrophoneInjectionMode);
+
 #endif // AudioSession_AVAudioSessionTypes_h
 #else
 #include <AudioSession/AVAudioSessionTypes.h>
Clone this wiki locally