iPhone 5 returns 3 input channels
On iPhone5 (and probably iPad mini) this code returns 3 input channels
// Check the number of input channels. // Find the number of channels UInt32 size = sizeof(self.numInputChannels); UInt32 newNumChannels; CheckError(AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &newNumChannels), "Checking number of input channels"); self.numInputChannels = newNumChannels;
And app crashes
Hard fixed with
// Check the number of input channels.
// Find the number of channels
UInt32 size = sizeof(self.numInputChannels);
UInt32 newNumChannels;
CheckError(AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels,
&size,
&newNumChannels), "Checking number of input channels");
self.numInputChannels = newNumChannels;
DLog(@"Audio input channels: %lu", self.numInputChannels);
if(self.numInputChannels >= 3){
self.numInputChannels = 1;
}
@soulfly, Do you have a general fix you'd like to open a pull request for?
Yes, also tried in iPhone 5C - it has 2 microphones (lol, Apple said that it's exactly a copy of iPhone5)
So, please just update to
if(self.numInputChannels >= 1){ self.numInputChannels = 1; }
works on both devices as well