title: Audio Unit increases render callback inNumberFrames when proximity sensor is covered
body: <p>I'm using Linphone SDK for a VoIP iOS app. And I found the proximity sensor (the one that will dim your screen when you put the phone close to ear) affects the incoming voice badly. </p>
  
  <p>I found The inBusNumber for input render callback will increase to 1024 when the proximity is covered, normally it's 256. When it happens it also cause about 180ms time gap that Audio Unit doesn't trigger this callback, which destroy Linphone's buffer strategy. </p>
  
  <p>setup render callback:</p>
  
  <pre><code>AURenderCallbackStruct renderCallbackStruct;
  renderCallbackStruct.inputProc       = au_write_cb;
  renderCallbackStruct.inputProcRefCon = card;
  auresult=AudioUnitSetProperty (
                                 card-&gt;io_unit,
                                 kAudioUnitProperty_SetRenderCallback,
                                 kAudioUnitScope_Input,
                                 outputBus,
                                 &amp;renderCallbackStruct,
                                 sizeof (renderCallbackStruct)
                                 );
  </code></pre>
  
  <p>In the render callback:</p>
  
  <pre><code>static OSStatus au_write_cb (
                            void                        *inRefCon,
                            AudioUnitRenderActionFlags  *ioActionFlags,
                            const AudioTimeStamp        *inTimeStamp,
                            UInt32                      inBusNumber,
                            //it changes to 1024 when proximity sensor is triggered
                            UInt32                      inNumberFrames,
                            AudioBufferList             *ioData
                           ) {}
  </code></pre>
  
  <p>In my understanding the inNumberFrames will only change in circumstance of switching playback devices (such as switching earphone to bluetooth). Is there any way that I can fix this figure when the proximity sensor is triggered?</p>
  
  <p>I also try to set kAudioUnitProperty_MaximumFramesPerSlice to 256 and  setPreferredIOBufferDuration of audio session, but both don't work.</p>
  
  <p>I download Apple official demo named Speakerbox, and I found their render callback's inNumberFrames persists to 256 no matter how I trigger the proximity sensor. I compared the Apple's code and mine but I can't find any difference that may cause this. Appreciate any help, thank you. </p>