SDL_mixer
SDL_mixer copied to clipboard
Unable to open an audio device on macOS
I'm running SDL 2.0.22 and SDL_mixer 2.60 on macOS 12.5.
I'm attempting to open an audio device as follows, after calling SDL_Init
(audio and video), and Mix_Init
:
Mix_OpenAudio(
MIX_DEFAULT_FREQUENCY,
MIX_DEFAULT_FORMAT,
MIX_DEFAULT_CHANNELS,
2048
)
The error I get is as follows:
MEMixerChannel.cpp:1636 client <AudioQueueObject@0x10c013800; [0]; play> got error 2003332927 while sending format information
I'm also having the same issue calling Mix_CloseAudio()
The error I get is as follows:
Is 2003332927 the actual value Mix_OpenAudio() returns?
@icculus, I think this is actually an SDL issue. Can you look at this for the 2.24.0 milestone?
Yeah, I'll try to reproduce it today.
Is 2003332927 the actual value Mix_OpenAudio() returns?
No, it returns 0. The audio device does seem to be open and working fine (I hadn't gotten around to playing sounds yet yesterday) but there is an error thrown somewhere.
Is 2003332927 the actual value Mix_OpenAudio() returns?
No, it returns 0. The audio device does seem to be open and working fine but there is an error thrown somewhere.
If Mix_OpenAudio returns 0 and device is working fine, then there are no actual errors: You should check errors only if the function you called really returns an error. @icculus, @slouken: This should be closed as invalid.
And we should document error checking better I guess.
@sezero I didn't check for errors, nor does my code print them. I only noticed this because my debugger was set to pauze on C++ errors being thrown. I assume at MEMixerChannel.cpp:1636
?
I can reproduce this with just:
#include <SDL2/SDL.h>
#include <SDL2_mixer/SDL_mixer.h>
#include <stdio.h>
int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
Mix_Init(0); // or any other flags
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048);
Mix_CloseAudio();
Mix_Quit();
SDL_Quit();
}
The full output I get for this in Xcode is:
2022-08-07 10:42:38.089133+0200 SDL_C[2362:74204] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x100c3b110> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2022-08-07 10:42:38.151530+0200 SDL_C[2362:74687] [aqme] MEMixerChannel.cpp:1636 client <AudioQueueObject@0x101824a00; [0]; play> got error 2003332927 while sending format information
2022-08-07 10:42:38.227740+0200 SDL_C[2362:74204] [aqme] MEMixerChannel.cpp:1636 client <AudioQueueObject@0x101824a00; [0]; play> got error 2003332927 while sending format information
2022-08-07 10:42:38.263413+0200 SDL_C[2362:74204] AudioObjectGetPropertyData: no object with given ID 0
Program ended with exit code: 0
MEMixerChannel.cpp isn't our code; this is an error message in CoreAudio's codebase, or a plugin that CoreAudio is using.
I'm still going to see if I can reproduce it here, but this might be beyond our control.
What sort of Mac is this? Is there any sort of unusual audio hardware plugged into it? (a USB headset? A PS4 controller where the Mac is seeing its headphone jack? etc)
When this happens is audio functional? If so, it might just be the system CoreAudio being more chatty than usual.