diff --git a/CHANGELOG.md b/CHANGELOG.md index d2dcbb8e3..d17fb6145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # Unreleased -- ALSA(process_output): pass `silent=true` to `PCM.try_recover`, so it doesn't write to stderr -- WASAPI: Expose IMMDevice from WASAPI host Device. +- ALSA(process_output): pass `silent=true` to `PCM.try_recover`, so it doesn't write to stderr. - CoreAudio: `Device::supported_configs` now returns a single element containing the available sample rate range when all elements have the same `mMinimum` and `mMaximum` values (which is the most common case). +- iOS: Fix example by properly activating audio session. +- WASAPI: Expose IMMDevice from WASAPI host Device. # Version 0.16.0 (2025-06-07) diff --git a/examples/ios-feedback/ios-src/AppDelegate.m b/examples/ios-feedback/ios-src/AppDelegate.m index 18bf183e3..608c4e1d1 100644 --- a/examples/ios-feedback/ios-src/AppDelegate.m +++ b/examples/ios-feedback/ios-src/AppDelegate.m @@ -22,9 +22,6 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. - NSError *error; - BOOL success; - // It is necessary to access the sharedInstance so that calls to AudioSessionGetProperty // will work. AVAudioSession *session = AVAudioSession.sharedInstance; @@ -32,15 +29,22 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // Since this demo records and plays, lets use AVAudioSessionCategoryPlayAndRecord. // Also default to speaker as defaulting to the phone earpiece would be unusual. // Allowing bluetooth should direct audio to your bluetooth headset. - success = [session setCategory:AVAudioSessionCategoryPlayAndRecord - withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetooth - error:&error]; - - if (success) { - NSLog(@"Calling rust_ios_main()"); - rust_ios_main(); + NSError *categoryError = nil; + BOOL isSetCategorySuccess = [session setCategory:AVAudioSessionCategoryPlayAndRecord + withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetooth + error:&categoryError]; + if (isSetCategorySuccess) { + NSError *activateError = nil; + BOOL isActivateSuccess = [session setActive:YES error:&activateError]; + + if (isActivateSuccess) { + NSLog(@"Calling rust_ios_main()"); + rust_ios_main(); + } else { + NSLog(@"Failed to activate audio session: %@", activateError); + } } else { - NSLog(@"Failed to configure audio session category"); + NSLog(@"Failed to set category: %@", categoryError); } return YES;