0
0

Hi,

I’ve got an app with unicode support that I would like to use fmod as player. However, fmod doesn’t seem to work with Unicode filenames under Win32.

In several posts the solution suggested to fix this is to convert to ANSI using WideCharToMultiByte. This will use the active ANSI Code Page to convert the filename. This means that if your Code Page is Chinese Simplified, you will be able to succesfully use this on filenames in Chinese Simplified. If your Code Page is Japanese than Japanese will work fine. However, if your Code Page is different from your filename than you will end up with a filename like this “??????-???????.mp3”

So converting back to ANSI works ONLY if users have only filenames in the language of their language. My Code page however is set to English and I have filenames in Russian, Chinese, Japanese and Hebrew. FMOD cannot currently deal with this as far as I can see. The sole reason unicode was invented in the first place was to deal with this issues.

For now I will try to load the file myself and then pass the data to FMOD.

Cheers.

Bart

Author of MoodAmp (http://www.moodamp.com)

  • You must to post comments
0
0

Temporary fix:

[code:1qh9xc30]char filenamechar[1024];
BOOL ConvertFailed;
WideCharToMultiByte(CP_ACP, 0, filename, -1, filenamechar, 1024, NULL, &ConvertFailed);
if (ConvertFailed)
{
CopyFile(filename, L"C:\Play.mp3", FALSE);
stream = FSOUND_Stream_Open("C:\Play.mp3", FSOUND_NORMAL | FSOUND_MPEGACCURATE, 0, 0);
}
else
{
stream = FSOUND_Stream_Open(filenamechar, FSOUND_NORMAL | FSOUND_MPEGACCURATE, 0, 0);
}
channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, TRUE);[/code:1qh9xc30]
Where filename is a unicode CString
It’s dodgy, but it works. Of course C:\ is not the place to put it, but I put to simplify the example.

  • You must to post comments
0
0

I think we can use FSOUND_OPENCALLBACK

[quote="brett":1c18yafr]hm, i might implement unicode support for FMOD Ex. I’m not sure about fmod 3 you might have to stay with your current hack.[/quote:1c18yafr]

  • You must to post comments
0
0

The solution is:

[code:b6qm7ds8]void * F_CALLBACKAPI OpenCallback(const char name)
{
const WCHAR *wname = (const WCHAR
) name;
HANDLE hFile = CreateFile(wname, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if( hFile == INVALID_HANDLE_VALUE) return 0;
else return hFile;
}

void F_CALLBACKAPI CloseCallback(void *handle)
{
CloseHandle((HANDLE) handle);
}

int F_CALLBACKAPI ReadCallback(void *buffer, int size, void *handle)
{
unsigned long readed;
ReadFile((HANDLE) handle, buffer, size, &readed, 0);
return readed;
}

int F_CALLBACKAPI TellCallback(void *handle)
{
return SetFilePointer((HANDLE)handle,0,NULL, FILE_CURRENT);
}

int F_CALLBACKAPI SeekCallback(void *handle, int pos, signed char mode)
{

DWORD method;
switch( mode )
{
case SEEK_CUR: method = FILE_CURRENT; break;
case SEEK_END: method = FILE_END; break;
case SEEK_SET: method = FILE_BEGIN; break;
}
DWORD dwPtrLow = SetFilePointer((HANDLE)handle, pos, 0, method);
DWORD dwError;
if ( dwPtrLow == INVALID_SET_FILE_POINTER && (dwError = GetLastError()) != NO_ERROR )
    return -1;
else return 0;

}
[/code:b6qm7ds8]

Then use
WCHAR pSound;
m_pCurrentStream = FSOUND_Stream_Open((const char
)pSound, 0, 0, 0);

btw, FMOD 3 could try to open pSound as WCHAR filename in case of failure. Or you can provide with Open_FromHandle function, or separate Stream_OpenW function.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.