title: Keep bluetooth sound when initializing AVAudioSession
body: <p>I'm about to go crazy. </p>
  
  <p>I have a recording app. I'm running into a problem that when I open my app, if i'm listening to music on a bluetooth device, it gets automatically routed back to the phone internal speaker.</p>
  
  <p>I want everything to stay the same no matter what. Even when I start recording, if the user is listening to something on a bluetooth speaker, keep doing that. The user has headphones? Keep the music there. Just leave everything as is. </p>
  
  <p>This is how I'm currently initializing my session:</p>
  
  <pre><code>[[AVAudioSession sharedInstance]
      setCategory:AVAudioSessionCategoryPlayAndRecord
      withOptions:AVAudioSessionCategoryOptionMixWithOthers | AudioSessionCategoryOptionAllowBluetooth
      error: nil];
  </code></pre>
  
  <p>I'm allowing it to play, record, mix with others and allow bluetooth, so why is it re routing the audio output back to the internal speaker??? </p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT on May 30th</strong></p>
  
  <p>I managed to get something better but still missing something.</p>
  
  <p>If I add this line: </p>
  
  <pre><code>[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:nil];
  </code></pre>
  
  <p>The music stays in the bluetooth device BUT it sounds horrible. </p>
  
  <p>According to this answer: <a href="https://stackoverflow.com/a/18541874/517688">https://stackoverflow.com/a/18541874/517688</a> it's because </p>
  
  <blockquote>
    <p>EnableBluetoothInput affects both input and output according to this. Also remember, the audio will play at 8000 Hz due to the limitation of bluetooth input devices</p>
  </blockquote>
  
  <p>So there is no way to keep everything the same without distorting sound when using a Blueetooth device??</p>