{"action":"opened","issue":{"url":"https://api.github.com/repos/libpd/libpd/issues/249","repository_url":"https://api.github.com/repos/libpd/libpd","labels_url":"https://api.github.com/repos/libpd/libpd/issues/249/labels{/name}","comments_url":"https://api.github.com/repos/libpd/libpd/issues/249/comments","events_url":"https://api.github.com/repos/libpd/libpd/issues/249/events","html_url":"https://github.com/libpd/libpd/issues/249","id":354835515,"node_id":"MDU6SXNzdWUzNTQ4MzU1MTU=","number":249,"title":"Unable to pair Bluetooth headphones while app is running when using `AVAudioSessionCategoryPlayAndRecord` on iOS","user":{"login":"virusys","id":393711,"node_id":"MDQ6VXNlcjM5MzcxMQ==","avatar_url":"https://avatars3.githubusercontent.com/u/393711?v=4","gravatar_id":"","url":"https://api.github.com/users/virusys","html_url":"https://github.com/virusys","followers_url":"https://api.github.com/users/virusys/followers","following_url":"https://api.github.com/users/virusys/following{/other_user}","gists_url":"https://api.github.com/users/virusys/gists{/gist_id}","starred_url":"https://api.github.com/users/virusys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virusys/subscriptions","organizations_url":"https://api.github.com/users/virusys/orgs","repos_url":"https://api.github.com/users/virusys/repos","events_url":"https://api.github.com/users/virusys/events{/privacy}","received_events_url":"https://api.github.com/users/virusys/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-28T17:45:23Z","updated_at":"2018-08-28T17:45:23Z","closed_at":null,"author_association":"NONE","body":"I am testing on an iPhone 6s using a pair of Mpow Judge Bluetooth headphones (with built-in microphone). \r\n\r\nHere is the code that I am using to setup my `PdAudioController`:\r\n\r\n``` objc\r\nself.pdAudio = [[PdAudioController alloc] init];\r\nfloat samplingRate = 44100;\r\n\r\nif ([self DeviceIs6SOrAbove] && ![self isSamplingRateSwitchNeeded]) {\r\n    samplingRate = 48000;\r\n}\r\n\r\n[self.pdAudio configurePlaybackWithSampleRate:samplingRate numberChannels:2 inputEnabled:YES mixingEnabled:NO];\r\n// bluetooth support\r\nif (@available(iOS 10.0, *)) {\r\n     [PdAudioController setSessionOptions:AVAudioSessionCategoryOptionAllowBluetoothA2DP];\r\n} else {\r\n    // Fallback on earlier versions\r\n    [PdAudioController setSessionOptions:AVAudioSessionCategoryOptionAllowBluetooth];\r\n}\r\n\r\n[self.pdAudio setActive:YES];\r\n```\r\n\r\nIf the headphones are paired before I launch the app, everything works as intended with no issues. However, if I attempt to pair after the app has launched, my headphones will beep and indicate that they are connected, but the status bar on iOS will remain the same (after flickering briefly) and audio will still be routed out of the default speakers. If I move the app into the background and then back to the foreground again, the headphones will pair as soon as I'm in the Springboard and will continue working normally when I am back in the app. \r\n\r\nWhat is also strange is that I will receive an `AVAudioSessionRouteChangeNotification` if I unpair the headphones after they are connected, but if I try pairing them again I will get no notifications whatsoever.\r\n\r\nI have tried replacing the `configurePlaybackWithSampleRate` line with `configureAmbientWithSampleRate`, and there are no issues paring my BT headphones or receiving route changed notifications (but since I need to use input this is not a suitable workaround). \r\n\r\nI have also tried setting `AVAudioSessionCategoryOptionAllowBluetooth` instead of `AVAudioSessionCategoryOptionAllowBluetoothA2DP` and the headphones are able to pair, but audio becomes choppy as soon as they are. \r\n\r\nIf you need any more info please let me know. Thank you!\r\n\r\n"}}
{"actor":{"display_login":"virusys"}}