[openal] OpenAL soft on win32: AL lib: (EE) ALCmmdevPlayback_open: Device init failed: 0x80004005

Chris Robinson chris.kcat at gmail.com
Mon Oct 13 09:19:20 EDT 2014


On 10/12/2014 11:29 AM, Chris Robinson wrote:
> Looking at cAudio's source for the fromUTF8 method, though, it seems a
> bit iffy to me.
> <https://github.com/R4stl1n/cAudio/blob/master/cAudio/include/cAudioString.h#L103>
>
> It first converts the UTF-8 string to a WideChar string using Windows'
> MultiByteToWideChar function, then it tries to convert the WideChar
> string back to a multi-byte string using wcstombs (and for added
> confusion, cAudioString may be a basic_string<wchar_t> if UNICODE or
> _UNICODE is set, so it gets converted back to a WideChar string again;
> also, it leaks the 'convert' buffer).
>
> The problem here is that wcstombs does the conversion based on the
> current locale, and also stops converting when it encounters a character
> that can't be represented in that locale. So if the locale is set to
> something that can't handle some characters in the device name, cAudio
> will truncate the name, and so won't get recognized.

Thinking about it more, I think there may even be a more serious issue 
with cAudio here. If the locale isn't UTF-8, the byte representation of 
the characters may be different. So even if it successfully converts all 
characters from UTF-8 to the current locale, specifying that converted 
string as a device name can still fail since it may not match what 
OpenAL Soft originally gave it.

So either cAudioString needs to store UTF-8 strings (recommended, for 
previously specified reasons), or it at least needs to convert back to 
UTF-8 before passing it back to alcOpenDevice.


More information about the openal mailing list