win midi: don't show MessageBox on errors

This commit is contained in:
Roman Fomin 2023-04-04 20:08:39 +07:00
parent 1a278d6105
commit 60eef57795
3 changed files with 12 additions and 7 deletions

View File

@ -28,6 +28,7 @@
#include "i_sound.h"
#include "i_system.h"
#include "m_misc2.h"
#include "m_io.h"
#include "memio.h"
#include "mus2mid.h"
#include "midifile.h"
@ -154,19 +155,19 @@ static buffer_t buffer;
static boolean initial_playback = false;
// Message box for midiStream errors.
// Check for midiStream errors.
static void MidiError(const char *prefix, DWORD dwError)
{
char szErrorBuf[MAXERRORLENGTH];
wchar_t werror[MAXERRORLENGTH];
MMRESULT mmr;
mmr = midiOutGetErrorText(dwError, (LPSTR) szErrorBuf, MAXERRORLENGTH);
mmr = midiOutGetErrorTextW(dwError, (LPWSTR)werror, MAXERRORLENGTH);
if (mmr == MMSYSERR_NOERROR)
{
char *msg = M_StringJoin(prefix, ": ", szErrorBuf, NULL);
MessageBox(NULL, msg, "midiStream Error", MB_ICONEXCLAMATION);
free(msg);
char *error = ConvertWideToUtf8(werror);
fprintf(stderr, "%s: %s.\n", prefix, error);
free(error);
}
else
{

View File

@ -107,7 +107,7 @@ static wchar_t *ConvertUtf8ToWide(const char *str)
return ConvertMultiByteToWide(str, CP_UTF8);
}
static char *ConvertWideToUtf8(const wchar_t *wstr)
char *ConvertWideToUtf8(const wchar_t *wstr)
{
return ConvertWideToMultiByte(wstr, CP_UTF8);
}

View File

@ -49,6 +49,10 @@ int M_access(const char *path, int mode);
void M_MakeDirectory(const char *dir);
char *M_getenv(const char *name);
#ifdef _WIN32
char *ConvertWideToUtf8(const wchar_t *wstr);
#endif
char *M_ConvertSysNativeMBToUtf8(const char *str);
char *M_ConvertUtf8ToSysNativeMB(const char *str);