_playingThroughDeviceSpeaker doesn't get change notification within audioRouteChangeNotification...

TAAE 1.5.2

...if the sampleRate has changed.

I've been spending time making our app better respond to sampleRate changes in response to the iPhone 6S and it's love of 48kHz.

I noticed an oddity along the way. Within audioRouteChangeNotification, if currentSampleRate != _audioDescription.mSampleRate then reinitializeWithChanges gets called. (For example if you plug headphones in, the rate will change from 48 -> 44.1).

reinitializeWithChanges in turn calls initAudioSession which sets _playingThroughDeviceSpeaker without change notification.

By the time audioRouteChangeNotification then comes to test _playingThroughDeviceSpeaker around line 2331, it's already been set to its updated value back in initAudioSession. Consequently, the change notifiers will never be called :(

        if ( _playingThroughDeviceSpeaker != playingThroughSpeaker ) {
            [self willChangeValueForKey:@playingThroughDeviceSpeaker];
            _playingThroughDeviceSpeaker = playingThroughSpeaker;
            [self didChangeValueForKey:@playingThroughDeviceSpeaker];

I was relying on observing playingThroughSpeaker and responding to prevent feedback. As a workaround I can observe AEAudioControllerSessionRouteChangeNotification and manually update the app, but it'd be great if I could just rely on KVO of playingThroughDeviceSpeaker.

Sign In or Register to comment.