src/audio/coreaudio/SDL_coreaudio.m


Log

Author Commit Date CI Message
Pierre Wendling 6c536afd 2022-06-27T15:43:17 Fix C89 declaration for macOS modules. Since Clang 14, `-Wdeclaration-after-statement` is enforced on every standard.
Ryan C. Gordon dc62fec5 2022-05-20T21:07:25 audio: Fix locking in backends that manage their own callback threads. Otherwise you might get a race where an app pauses the device, but the audio callback still manages to run after the pause is in place.
pionere a70bb259 2022-01-20T13:16:03 drop handle parameter of OpenDevice
pionere 47ddb04e 2022-01-20T12:31:02 cleanup/sync the main loop of *_OpenDevice functions to pick audio format II.
pionere 2eafe434 2022-01-20T12:18:59 cleanup/sync the main loop of *_OpenDevice functions to pick audio format
pionere 1043dd8c 2022-01-19T12:58:04 adjust handling of iscapture - drop iscapture parameter of OpenDevice - use SDL_bool for iscapture
pionere 60deadba 2022-01-17T17:22:30 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory
pionere 0dda8a7f 2022-01-17T11:21:01 cleanup init functions of audio - use SDL_bool if possible - assume NULL/SDL_FALSE filled impl - skip zfill of current_audio at the beginning of SDL_AudioInit (done before the init() calls)
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Per Nyblom 86ee383f 2021-05-25T09:59:45 Removed duplicate SDL_AtomicGet()
Ethan Lee 67e8522d 2021-02-27T17:37:25 Add SDL_GetAudioDeviceSpec. This API is supported by pipewire, pulseaudio, coreaudio, wasapi, and disk.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga ff53521b 2020-06-04T12:26:57 Fixed Bluetooth audio output on Apple TV
Sam Lantinga a990a34a 2020-04-14T22:26:02 Cleanly switch between audio recording, playback, and both, on iOS
Sam Lantinga 2ae1c0f5 2020-04-14T09:52:27 Allow Bluetooth headphones for iOS playandrecord mode
Sam Lantinga f3e60967 2020-04-02T12:27:29 Fixed setting the "playandrecord" audio hint on Apple TV The Apple TV doesn't have record capability by default, so activating the audio session with AVAudioSessionCategoryPlayAndRecord fails.
Ryan C. Gordon 55b4f18e 2020-03-29T01:54:00 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.
Sam Lantinga abdc5cbf 2020-03-26T19:30:17 Allow background music to play in the "play and record" case on iOS
Sam Lantinga e3b0713e 2020-02-24T12:07:18 Don't call setPreferredOutputNumberOfChannels on iOS, it breaks audio output
Sam Lantinga 2c9871a4 2020-02-24T10:25:57 Fixed surround sound support on Apple TV
Sam Lantinga f4e23553 2020-02-14T15:19:34 Fixed audio not coming out of the phone speakers while recording on iOS
Sam Lantinga 922b3dc3 2020-02-14T14:18:12 Fixed re-setting the audio session category when closing an audio device
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Ryan C. Gordon 693755f0 2019-09-25T15:07:07 coreaudio: Apple doesn't support U16 data, so convert in that case.
Sam Lantinga 455944c8 2019-08-22T16:12:16 Fixed whitespace
Sam Lantinga b521df66 2019-08-22T16:09:42 [SDL][IOS] Audio fix - applies stream to sound data when resampling or reformatting is required.
Sam Lantinga abcfe804 2019-05-14T14:20:54 [SDL] iOS fix bug with audio interrupted by a phone call not restoring.
Ryan C. Gordon 2fbfe8b9 2019-03-25T12:59:30 coreaudio: Set audio callback thread priority. Fixes Bugzilla #4155.
Ryan C. Gordon 6a3356ab 2019-03-25T12:24:38 Backed out changeset cec31de4e126 This was meant to migrate CoreAudio onto the same SDL_RunAudio() path that most other audio drivers are on, but it introduced a bug because it doesn't deal with dropped audio buffers...and fixing that properly just introduces latency. I might revisit this later, perhaps by reworking SDL_RunAudio to allow for this sort of API better, or redesigning the whole subsystem or something, I don't know. I'm not super-thrilled that this has to exist outside of the usual codepaths, though. Fixes Bugzilla #4481.
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga 8325df25 2018-05-24T07:30:24 Fixed bug 4169 - Crash due to audio session observer race condition Jona The following explains why this bug was happening: This crash was caused because the audio session was being set as active [session setActive:YES error:&err] when the audio device was actually being CLOSED. Certain cases the audio session being set to active would fail and the method would return right away. Because of the way the error was handled we never removed the SDLInterruptionListener thus leaking it. Later when an interruption was received the THIS_ object would contain a pointer to an already released device causing the crash. The fix: When only one device remained open and it was being closed we needed to set the audio session as NOT active and completely ignore the returned error to successfully release the SDLInterruptionListener. I think the user assumed that the open_playback_devices and open_capture_devices would equal 0 when all of them where closed but the truth is that at the end of the closing process that the open devices count is decremented.
Ryan C. Gordon dc8b55e5 2018-04-16T02:11:09 coreaudio: Use the standard SDL audio thread instead of spinning a new one. Fixes corner cases, like the audio callback not firing if the device is disconnected, etc.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Ryan C. Gordon fa156741 2017-10-13T01:15:29 coreaudio: changed device close procedure to prevent long hangs in some cases. The audioqueue thread needs to keep running, and processing the CFRunLoop until the AudioQueue is disposed of, otherwise CoreAudio will hang waiting for final data to feed the device. At least, I think this is how it all works. It definitely fixes the bug here! Since AudioQueueDispose() calls AudioQueueStop() internally, there's no need for our thread to handle this, either, which is good because the AudioQueue would be disposed by this point. So now the AudioQueue is disposed first, and then our thread is joined, and everything works out okay. Just in case, we mark the device "paused" before setting everything in motion, so any further callbacks from CoreAudio will write silence and not fire the app's audio callback again. Fixes Bugzilla #3868.
Sam Lantinga fe6b8f1c 2017-09-22T11:25:52 Fixed Mac OS X build
Sam Lantinga 407e1693 2017-09-22T11:15:14 Fixed audio being silent on older iOS devices Tested on an iPod running iOS 6.1
Sam Lantinga c08a7a74 2017-09-15T17:27:32 Added a hint SDL_HINT_AUDIO_CATEGORY to control the audio category, determining whether the phone mute switch affects the audio
Ryan C. Gordon 6844d92c 2017-05-24T13:28:13 coreaudio: we don't need to track number of allocated audio buffers anymore. CoreAudio takes care of iterating through the buffers and freeing them now, so we don't have to manage this ourselves.
Ryan C. Gordon fc4402e5 2017-05-24T13:25:31 coreaudio: Better handling of audio buffer queue management. We don't fill buffers just to throw them away during shutdown now, we let the AudioQueue free its own buffers during disposal (which fixes possible warnings getting printed to stderr by CoreAudio), and we stop the queue after running any queued audio during shutdown, which prevents dropping the end of the audio playback if you opened the device with an enormous sample buffer. Fixes Bugzilla #3555.
Ryan C. Gordon 3fd35f6b 2017-05-24T01:28:03 coreaudio: looks like we need more like a 10ms buffer minimum, not 50ms.
Ryan C. Gordon 793c788b 2017-05-24T00:12:22 coreaudio: dynamically allocate AudioQueueBuffers. We need more than two buffers to flip between if they are small, or CoreAudio won't make any sound; apparently it needs X milliseconds of audio queued when it needs to play more or it drops any queued buffers. We are currently guessing 50 milliseconds as a minimum, but there's probably a more proper way to get the minimum time period from the system. Fixes Bugzilla #3656.
Ryan C. Gordon c878b59b 2017-05-10T16:18:43 audio: fixed more "spec" references that should have been "callbackspec". This should catch all the ones for audio targets that have provided their own audio threads.
Alex Szpakowski 75fb07a6 2017-05-03T18:05:29 iOS: Only mark interrupted audio devices as non-interrupted if AudioQueueStart is successful.
Sam Lantinga 71a4e8ed 2017-02-23T12:10:02 Stop CoreAudio from doing expensive audio rate conversion
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Philipp Wiesemann 8e88f081 2016-09-21T23:06:49 Mac: Fixed whitespace around function return type.
Alex Szpakowski f0fca288 2016-09-18T19:22:09 Handle audio interruptions on iOS/tvOS. Fixes bugs 2569 and 2960.
Alex Szpakowski 4209a1fd 2016-09-15T19:59:57 CoreAudio iOS/tvOS: Use AVFoundation instead of AudioSession. Fixes audio on tvOS. Note that linking with AVFoundation is now required if you don't disable SDL_audio compilation on iOS and tvOS.