You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reported in version: 2.0.5 Reported for operating system, platform: macOS 10.12, x86_64
Comments on the original bug report:
On 2017-05-20 08:38:25 +0000, Lior Halphon wrote:
I upgraded my SDL1.2 project to SDL2, and sound stopped working on macOS. Sound is configured to 96KHz. SDL_OpenAudio returns 0 and returns the correct obtained struct, and my audio callback is being called, but no sound is produced.
Lowering the frequency to 44.1KHz makes the sound play. Downgrading to SDL 2.0.4 allows playback in 96KHz again.
On 2017-05-23 17:42:58 +0000, Ryan C. Gordon wrote:
On 2017-05-23 17:43:46 +0000, Ryan C. Gordon wrote:
Is there some code you can post that reproduces this bug?
On 2017-05-23 18:09:15 +0000, Lior Halphon wrote:
The following code reproduces the problem. It should play white noise for 10 seconds, but only plays for a split second. Changing freq to 96000 or samples to 2048 solves it.
#include <stdlib.h>
#include <SDL2/SDL.h>
static void audio_callback(void *gb, Uint8 *stream, int len)
{
while (len--) {
*(stream++) = rand();
}
}
int main(int argc, char **argv)
{
SDL_AudioSpec want_aspec, have_aspec;
This is a quirk in Mac OS X CoreAudio. If you don't fill audio buffers fast enough they'll stop being used in the audio pipeline. The only answer I've found is to make sure you have 15-20 ms in your audio buffers. Changing your buffer size or reducing your audio rate is the correct workaround.
On 2017-05-23 18:32:20 +0000, Sam Lantinga wrote:
This is true on iOS as well.
On 2017-05-23 18:40:57 +0000, Ryan C. Gordon wrote:
(In reply to Sam Lantinga from comment # 6)
This is true on iOS as well.
Hmm, we might be able to mitigate this now that we have SDL_AudioStream, which can buffer the difference if the app wants too small of a buffer per-callback...
(But it's still possible the issue is me misusing CoreAudio and it only manifests when the buffers are small.)
--ryan.
On 2017-05-23 18:46:33 +0000, Lior Halphon wrote:
How did it work in SDL 2.0.4 and 1.2 then? What was changed to make this an issue?
On 2017-05-23 18:59:28 +0000, Ryan C. Gordon wrote:
(In reply to Lior Halphon from comment # 8)
How did it work in SDL 2.0.4 and 1.2 then? What was changed to make this an
issue?
We moved from Apple's AudioUnits API to AudioQueues.
--ryan.
On 2017-05-24 04:24:10 +0000, Ryan C. Gordon wrote:
This should be fixed by https://hg.libsdl.org/SDL/rev/ad26a063ffff ... poking at Apple's API suggests that what CoreAudio wants is at least X milliseconds of audio available when it's time to feed the audio hardware, and it doesn't care if you queued one gigantic buffer to get there or a dozen tiny ones.
I imagine it's possible that a USB or bluetooth device wants way more buffered at a time than the on-board PCM chip, and there's probably an API to query for that minimum limit, but aiming for being able to buffer two blocks of 50 milliseconds seems to work okay (20ms was too small).
This approach also lets us have the app's callback fire with the originally-desired sample size but also not use a full SDL_AudioStream to buffer the difference.
--ryan.
On 2017-05-24 05:33:43 +0000, Ryan C. Gordon wrote:
(In reply to Ryan C. Gordon from comment # 10)
I imagine it's possible that a USB or bluetooth device wants way more
buffered at a time than the on-board PCM chip, and there's probably an API
to query for that minimum limit, but aiming for being able to buffer two
blocks of 50 milliseconds seems to work okay (20ms was too small).
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: 2.0.5
Reported for operating system, platform: macOS 10.12, x86_64
Comments on the original bug report:
On 2017-05-20 08:38:25 +0000, Lior Halphon wrote:
On 2017-05-23 17:42:58 +0000, Ryan C. Gordon wrote:
On 2017-05-23 17:43:46 +0000, Ryan C. Gordon wrote:
On 2017-05-23 18:09:15 +0000, Lior Halphon wrote:
On 2017-05-23 18:10:07 +0000, Lior Halphon wrote:
On 2017-05-23 18:32:04 +0000, Sam Lantinga wrote:
On 2017-05-23 18:32:20 +0000, Sam Lantinga wrote:
On 2017-05-23 18:40:57 +0000, Ryan C. Gordon wrote:
On 2017-05-23 18:46:33 +0000, Lior Halphon wrote:
On 2017-05-23 18:59:28 +0000, Ryan C. Gordon wrote:
On 2017-05-24 04:24:10 +0000, Ryan C. Gordon wrote:
On 2017-05-24 05:33:43 +0000, Ryan C. Gordon wrote:
The text was updated successfully, but these errors were encountered: