Does OpenAL 5.1 support output on Mac OS X?

I port the application from Windows to Mac OS X. It uses OpenAL to process sound, but I get strange behavior when initializing the sound engine in Mac OS X (the code works on MacBook Pro).

Here is the code:

int InitSoundEngine(void* data[NB_BUFFERS], size_t data_size[NB_BUFFERS]) { ALCdevice *device; ALCcontext *context; ALenum format; ALuint buffers[NB_BUFFERS]; device = alcOpenDevice(NULL); if (device == NULL) goto failed; context = alcCreateContext(device, NULL); if (context == NULL) goto failed; alcMakeContextCurrent(context); format = alGetEnumValue("AL_FORMAT_51CHN16"); if (format == 0) goto failed; alGenBuffers(NB_BUFFERS, buffers); if (alGetError() != AL_NO_ERROR) goto failed; for (int i = 0; i < NB_BUFFERS; ++ i) { alBufferData(buffers[i], format, data[i], data_size[i], 48000); if (alGetError() != AL_NO_ERROR) goto failed; } return NO_ERROR; failed: /* Cleanup omitted for brievety */ return INITIALIZATION_FAILED; } 

This fails when during an alBufferData call with an AL_INVALID_VALUE error. Tracing the code, we found that alGetEnumValue("AL_FORMAT_51CHN16") returns 0xfffffffful , and we suspect that this is the root of the problem.

alGetEnumValue says:

ALuint alGetEnumValue(const ALchar *enumName);

Returns 0 if the enumeration cannot be found and sets the error condition AL_INVALID_VALUE . Having an enumeration value does not guarantee the applicability of the extension to the current context. A non-zero return only indicates that the implementation is aware of the existence of this extension.

I think I'm using this function correctly. Is there a bug in the implementation of Mac OS X OpenAL? Is 5.1 output supported via OpenAL on Mac OS X? Is it supported through Core Audio (porting to Core Audio might be an option, if true)? Should I convert my sound from 5.1 to another format (3.1, stereo, ...)?

+4
source share
1 answer

This listing refers to the AL_EXT_MCFORMATS extension. It is not available on Mac OS X.

Yes, CoreAudio can handle 5.1 (or any, I think) speaker setup. I do not know the details of how to submit data.

+3
source

Source: https://habr.com/ru/post/1335424/


All Articles