AVAudioSession errors in iOS 12

I am having following after upgrading to iOS 12 & XCode 10:


2018-09-20 11:58:09.622656+0400 MyApp-Swift[1027:137400] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)


This keeps firing on every route change notification. Wonder if it's a known bug in iOS 12 or I am doing something wrong.

Replies

I'm also seeing this after upgrading to iOS 12 & XCode 10 (using an iPad Air 2). Similar messages appear when swapping between headphones, speaker or AirPlay. I'm using AVAudioSessionCategoryPlayAndRecord. I haven't tried any other session category types.


I get up to 4 messages. The first refers to the previous input type and the other 3 refer to the new input type.


- The first is logged sometime before my route change notification handler is called


- The second is logged when my handler executes the line:

AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;


- The other two are called sometime after the handler exits


The problem appears to be benign as I see no adverse effects (the same code has worked for the last year or so).


One possible complication is that since the route change notification isn't called from the main thread, my route change handler does something like this:


dispatch_async(dispatch_get_main_queue(), ^{
self->mpAudioManager->OnRouteChange(notification);
});


... and I then do the remaining work inside my OnRouteChange() function on the main thread. Therefore, the handler's work isn't actually performed instantly, but instead some short time later on the main thread (such as the code line I mentioned on the second logged message).

I am having the same issue on iOS 12 with swift 4.2. Does anyone has a explanation or solution for this?

I Converted the Syntax to Swift 4.2, and it worked.


AVAudioSession has some changes.


Here is how I am initializing it now:


         // Prepare Audio Session
        let audioSession = AVAudioSession.sharedInstance()
        try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: .spokenAudio, options: .defaultToSpeaker)
        try audioSession.setActive(true, options: .notifyOthersOnDeactivation)

You can also convert the Syntax by going to Edit, Convert, To Current Swift Syntax.


Good luck

I too have the same issue. Xcode 10, iOS 12. I get four of the same warning.

I tried updating the syntax to Swift 4.2 and it did nothing to fix the issue for me.

Anyone have any other ideas?

@Farini - Are you able to show the code you had before the syntax change? I'm working in Obj-C and get these problems, so is there any chance it coud have made some sort of functional/parameter change too?


Or, given that this didn't fix it for @geoffheatley, is there any chance that other changes were made at the same time which could explain the improvement in behaviour?

I am also experiencing this error even after implementing the fix for Swift 4.2, here is my code sample:



let audioSession = AVAudioSession.sharedInstance()
   
    do {
      try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: .spokenAudio, options: .defaultToSpeaker)
      try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
    } catch {
      print("audioSession properties weren't set because of an error.")
    }


I get the same error as stated above, I am using Xcode 10 and Swift 4.2. I have found a number of solutions on stackoverflow all pointing towards the same AVAudioSession.setcategory syntax change in Swift 4.2. I wonder if this is a genuine bug with Swift 4.2 since I am not the only one experiencing it.

I'm working in Obj-C and see the same problem, so I don't think it can solely be attributed to a bug in the Swift implementation.


The only common factor so far seems to be that it's iOS 12 related. Either iOS 12 expects the API to be used in a different way, or it's being too enthusiastic about logging what appears to be a benign issue (or at least an issue which only occurs once and then allows the system to carry on as usual).


The fact it prints a source code line number suggests it's an message which isn't meant for public consumption - typically this would be done with error return codes. I'm pretty sure I check all return codes from the API but none of those have reported a problem.

I'm having the same issue.


[avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Philips SHB7150 (type: BluetoothA2DPOutput)


and when I turn off the headset:


[avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Luidspreker (type: Speaker)


What I've tried:
updating my pods
converting to recent swift syntax (4.2)
Restarting mac and xcode
I have ios 12 on my phone.

I am having the same issue...also in Obj-C....but what are you're symptoms? I am dealing with an app where we set up a live call (Think Facetime, or the Ring Doorbell) and on iOS12 the audio won't play in the live call...I am wondering if it's related to this error.

I have the same issue Obj-C with Live Call App and audio won't play too

We see the same trace on iOS 12 in objective C project too (same code run without this trace before iOS 12). It seems an iOS 12 issue, has anyone found a solution for this?

I still have these warnings in the console. I am using iOS12.1, XCode Version 10.1 (10B61).


Did anyone find a solution to this problem, or is this a normal warning which Apple forgot to hide?

I am experiencing the same issue but only when I run it on my iPhone X from Xcode. None of the code changes made a difference for me.


2018-11-24 21:45:31.227497-0500 Pitch Perfect[343:20265] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)
2018-11-24 21:45:31.285499-0500 Pitch Perfect[343:20265] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)
2018-11-24 21:45:31.285741-0500 Pitch Perfect[343:20265] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)


Original syntax:

Initial setting

try recordingSession.setCategory(.playAndRecord, mode: .default, options: [])


Changed mode

try recordingSession.setCategory(.playAndRecord, mode: .spokenAudio, options: [])


try recordingSession.setActive(true, options: [])


Attempted fix syntax:


try recordingSession.setCategory(.playAndRecord, mode: .spokenAudio, options: .defaultToSpeaker)


try recordingSession.setActive(true, options: .notifyOthersOnDeactivation)


Also tried:


try recordingSession.setCategory(.playAndRecord, mode: .default)


try recordingSession.setActive(true)


I'm running Xcode Version 10.1 (10B61) on macOS Mojave Version 10.14.1 (18B75) with a deployment target of 12.1 using Swift 4.2 settings


iPhone X is running iOS Version 12.1 (16B92)


Another issue I am seeing besides the console messages is my playback is erratic on my iPhone but not in the simulator. Tapping different sound filter buttons on my iPhone doesn't always play the related audio file. Usually takes multiple taps before it responds but it does not do this on the simulator.


On the simulator I get this message, but it does not display when I run on my iPhone:

2018-11-24 22:37:10.669600-0500 Pitch Perfect[13586:24145857] 317:  ca_debug_string: inPropertyData == NULL

Same issue here in obj-c i`m using streaming cameras with 2wey audio.. I only have audio from the camera but I can not speak


any solution???

- (void)viewDidAppear:(BOOL)animated{
    sda=_playerContainer.bounds;
    [AVAudioSession.sharedInstance setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
    [AVAudioSession.sharedInstance setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation e
- (IBAction)micButtonPressed:(id)sender {
    NSLog(@"DEBUG --- STREAM AUDIO STARTED");
    AVAudioSession *audioSesion = AVAudioSession.sharedInstance;

    AVAudioSessionRecordPermission micAuthorizationStatus = audioSesion.recordPermission;
//
    switch (micAuthorizationStatus) {
        case AVAudioSessionRecordPermissionGranted:
            
            [self.cameraManagerPlayer startAudio];
            [self bitingButtonAnimation];
            break;


LOG

2018-12-13 09:08:34.977485-0300 Smart Stg-D[5147:1700905] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receptor (type: Receiver)
2018-12-13 09:08:34.982108-0300 Smart Stg-D[5147:1700905] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Bocina (type: Speaker)