novocaine icon indicating copy to clipboard operation
novocaine copied to clipboard

iPhone 5 returns 3 input channels

Open soulfly opened this issue 12 years ago • 3 comments

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

soulfly avatar Sep 02 '13 13:09 soulfly

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 avatar Sep 02 '13 13:09 soulfly

@soulfly, Do you have a general fix you'd like to open a pull request for?

alexbw avatar Nov 15 '13 04:11 alexbw

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

soulfly avatar Nov 15 '13 08:11 soulfly