Author Topic: Bluetooth Headset Mac OS Sierra Doesn't switch device  (Read 81 times)

Clancey

  • Posts: 11
If you are playing audio and you connect a bluetooth headset the audio does not automatically switch until Kill everything and start again.
If I restart my application and Init bass again, audio plays out of the bluetooth headset which is the default device.
Likewise, when I disconnect a bluetooth headset while it is playing audio, everything locks up. If I check the current playback device, I still get the device info for the bluetooth device that is no longer connected.

Ian @ un4seen

  • Administrator
  • Posts: 20393
If you would like to have the output follow default device changes, you can use AudioObjectAddPropertyListener to request kAudioHardwarePropertyDefaultOutputDevice notifications, and then initialize the new default device and move your stream(s) to it when you receive such a notification. You would also free the old device after doing that. The device switching part could look something like this:

Code: [Select]
BASS_DEVICEINFO di;
for (int d=1; BASS_GetDeviceInfo(d, &di); d++) {
if (di.flags&BASS_DEVICE_DEFAULT) { // found new default
int od=BASS_GetDevice(); // get current device
if (od==d) break; // just in case
BASS_Init(d, 44100, 0, 0, 0); // initialize new device
BASS_ChannelSetDevice(stream, d); // move the stream to it
BASS_SetDevice(od);
BASS_Free(); // free the old device
break;
}
}

Clancey

  • Posts: 11
It already switches between the standard HeadphoneJack and the internal speakers. Bluetooth headsets just cause everything to lock up.

Ian @ un4seen

  • Administrator
  • Posts: 20393
Does your program lock up (become unresponsive), or does the sound just stop? If the latter, moving the stream(s) to another device should get them going again.

Regarding the internal speakers/headphones switch, they are the same "Built-in Output" device, so there is no need to actually change device in that case.