Hi Sven,

It depends on the architecture of your engine. Something is probably evading 
the propagation of the stream format there.

In my experience on a similar issue and after several exchange with Apple DTS 
(input from Apple engineers on this would be very welcome): Problems might 
arise if you use AVAudioEngine’s mainMixer singleton. In my experience I 
noticed that sometimes (and not all the time), the stream format is not 
coherently propagated if I use the mainMixer. I ended up setting up my own 
AVAudioMixerNode, and reconstructing it at the notification if there are 
changes. In my case, this was happening from time to time when the device 
sample rate was changing due to a port change.

I saw afterwards that there are similar workarounds by folks at AudioKit (v5).

If you’re using your custom AU effect, also make sure you are acknowledging 
stream format changes (obvious but sometimes easily missed).

Hope this helps. Let us know!

Arshia Cont
metronautapp.com



> On 11 May 2021, at 17:35, Sven Thoennissen via Coreaudio-api 
> <[email protected]> wrote:
> 
> Hello,
> 
> In my iOS app I am observing the AVAudioEngineConfigurationChange 
> notification. It uses AVAudioEngine, its audio input node, some samplers, 
> some effects, some mixers, and the output node.
> 
> So when I plug in an external audio interface into the iPad while the app is 
> running my observer is called. AVAudioSession.inputNumberOfChannels tells me 
> there are now 6 input channels instead of 1 (the audio interface indeed has 6 
> inputs). My AVAudioEngine's inputNode inputFormat shows the new hardware 
> format (6 channels) but the outputFormat still shows 1 channel.
> How can I update the input node's outputFormat?
> 
> Should I allocate a new engine and therefore a new inputNode? The docs forbid 
> that:
> "The engine must not be deallocated from within the client's notification 
> handler"
> https://developer.apple.com/documentation/foundation/nsnotification/name/1389078-avaudioengineconfigurationchange
>  
> <https://developer.apple.com/documentation/foundation/nsnotification/name/1389078-avaudioengineconfigurationchange>
> (okay, it does not forbid to allocate a new engine, but allocating a new one 
> also means dropping the reference to the old engine)
> 
> Or should I refrain from using AVAudioEngine.inputNode and allocate my own 
> AVAudioInputNode instance?
> Or should I call engine.inputNode.reset() ?
> 
> I have also tried to reconnect the inputNode with the new hardware format to 
> the next node in the graph, like the documentation suggests. As a result the 
> next node render call fails to pullInput() with code 
> kAudioUnitErr_CannotDoInCurrentContext (it's my own custom AU effect so I can 
> tell).
> 
> Any experience on this would be welcome.
> 
> Sven
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/coreaudio-api/arshiacont%40antescofo.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to