coreaudio: The default SDL audio device now tracks the system output default.

So if you go into System Preferences on a MacBook and toggle between a pair of
connected bluetooth headphones and built-in internal speakers, SDL will
switch the device it is playing sound through, to match this setting, on the
fly.

Likewise if the default output device is a USB thing and is unplugged; as the
default device changes at the system level, SDL will pick this up and carry
on with the new default. This is different from our unplug detection for
specific devices, as in those cases we want to send the app a disconnect
notification, instead of migrating transparently as we now do for default
devices.

Note that this should also work for capture devices; if the device changes,
SDL will start recording from the new default.

Fixes Bugzilla #4851.
This commit is contained in:
Ryan C. Gordon
2020-03-29 01:54:00 -04:00
parent 46bb47cf04
commit 55b4f18e1a
2 changed files with 118 additions and 27 deletions

View File

@@ -47,6 +47,7 @@ struct SDL_PrivateAudioData
{
SDL_Thread *thread;
AudioQueueRef audioQueue;
int numAudioBuffers;
AudioQueueBufferRef *audioBuffer;
void *buffer;
UInt32 bufferOffset;
@@ -57,6 +58,7 @@ struct SDL_PrivateAudioData
SDL_atomic_t shutdown;
#if MACOSX_COREAUDIO
AudioDeviceID deviceID;
SDL_atomic_t device_change_flag;
#else
SDL_bool interrupted;
CFTypeRef interruption_listener;