Commit b689f997 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

engine: integrate loguru to replace the existing logging implementation from...

engine: integrate loguru to replace the existing logging implementation from osd.cpp and rework many log messages across the codebase.
parent 8845593a
......@@ -461,6 +461,7 @@
<ClInclude Include="..\..\source\build\include\libdivide_config.h" />
<ClInclude Include="..\..\source\build\include\libtess2.h" />
<ClInclude Include="..\..\source\build\include\linklist.h" />
<ClInclude Include="..\..\source\build\include\log.h" />
<ClInclude Include="..\..\source\build\include\loguru.hpp" />
<ClInclude Include="..\..\source\build\include\lru.h" />
<ClInclude Include="..\..\source\build\include\lz4.h" />
......
......@@ -505,6 +505,9 @@
<ClInclude Include="..\..\source\build\include\loguru.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\source\build\include\log.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\source\build\src\polymost1Frag.glsl">
......
......@@ -85,8 +85,6 @@ int FX_StartDemandFeedPlayback(void (*function)(const char** ptr, uint32_t* leng
int FX_StartDemandFeedPlayback3D(void (*function)(const char** ptr, uint32_t* length, void* userdata), int bitdepth, int channels, int rate, int pitchoffset,
int angle, int distance, int priority, fix16_t volume, intptr_t callbackval, void* userdata);
int FX_SetPrintf(int(*function)(const char *, ...));
extern int FX_ErrorCode;
extern int FX_MixRate;
......
......@@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define MULTIVOC_H_
#include "compat.h"
#include "log.h"
#ifdef __cplusplus
extern "C" {
......@@ -65,8 +66,6 @@ enum MV_Errors
MV_InvalidFile,
};
extern int (*MV_Printf)(const char *fmt, ...);
const char *MV_ErrorString(int ErrorNumber);
extern thread_local int MV_Locked;
......@@ -83,7 +82,7 @@ static FORCE_INLINE void MV_Unlock(void)
if (!--MV_Locked)
SoundDriver_PCM_Unlock();
else if (MV_Locked < 0)
MV_Printf("MV_Unlock(): lockdepth < 0!\n");
LOG_F(ERROR, "PCM lockdepth < 0!");
}
int MV_VoicePlaying(int handle);
......@@ -154,8 +153,6 @@ struct MV_MusicRoutineBuffer
};
struct MV_MusicRoutineBuffer MV_GetMusicRoutineBuffer(void);
static inline void MV_SetPrintf(int (*function)(const char *, ...)) { if (function) MV_Printf = function; }
#ifdef __cplusplus
}
#endif
......
......@@ -127,13 +127,13 @@ static inline void sequence_event(snd_seq_event_t *ev, bool sync_output_queue)
result = snd_seq_event_output(seq, ev);
if (result < 0)
MV_Printf("ALSA could not queue event: err %d\n", result);
LOG_F(ERROR, "Unable to queue ALSA event: snd_seq_event_output error %d", result);
else
{
do { } while ((result = snd_seq_drain_output(seq)) > 0);
if (result < 0)
MV_Printf("ALSA could not drain output: err %d\n", result);
LOG_F(ERROR, "Unable to drain ALSA output: snd_seq_drain_output error %d", result);
if (sync_output_queue)
snd_seq_sync_output_queue(seq);
......@@ -204,7 +204,7 @@ static unsigned int get_tick(void)
int result = snd_seq_get_queue_status(seq, seq_queue, status);
if (result < 0)
{
MV_Printf("ALSA snd_seq_get_queue_status err %d\n", result);
LOG_F(ERROR, "Unable to read ALSA queue status: snd_seq_get_queue_status error %d", result);
return 0;
}
......@@ -268,7 +268,7 @@ int ALSADrv_MIDI_Init(midifuncs * funcs)
result = snd_seq_open(&seq, "default", SND_SEQ_OPEN_OUTPUT, 0);
if (result < 0)
{
MV_Printf("ALSA snd_seq_open err %d\n", result);
LOG_F(ERROR, "Unable to initialize ALSA: snd_seq_open error %d", result);
ErrorCode = ALSAErr_SeqOpen;
return ALSAErr_Error;
}
......@@ -284,7 +284,7 @@ int ALSADrv_MIDI_Init(midifuncs * funcs)
if (!deviceFound)
{
ALSADrv_MIDI_Shutdown();
MV_Printf("ALSA MIDI device not found: %d:%d\n", ALSA_ClientID, ALSA_PortID);
LOG_F(ERROR, "Unable to find ALSA device at %d:%d", ALSA_ClientID, ALSA_PortID);
ErrorCode = ALSAErr_DeviceNotFound;
return ALSAErr_Error;
}
......@@ -295,7 +295,7 @@ int ALSADrv_MIDI_Init(midifuncs * funcs)
if (seq_port < 0)
{
ALSADrv_MIDI_Shutdown();
MV_Printf("ALSA snd_seq_create_simple_port err %d\n", seq_port);
LOG_F(ERROR, "Unable to create ALSA port: snd_seq_create_simple_port error %d", seq_port);
ErrorCode = ALSAErr_CreateSimplePort;
return ALSAErr_Error;
}
......@@ -306,7 +306,7 @@ int ALSADrv_MIDI_Init(midifuncs * funcs)
if (seq_queue < 0)
{
ALSADrv_MIDI_Shutdown();
MV_Printf("ALSA snd_seq_alloc_queue err %d\n", seq_queue);
LOG_F(ERROR, "Unable to allocate ALSA queue: snd_seq_alloc_queue erorr %d", seq_queue);
ErrorCode = ALSAErr_AllocQueue;
return ALSAErr_Error;
}
......@@ -315,7 +315,7 @@ int ALSADrv_MIDI_Init(midifuncs * funcs)
if (result < 0)
{
ALSADrv_MIDI_Shutdown();
MV_Printf("ALSA snd_seq_connect_to err %d\n", result);
LOG_F(ERROR, "Unable to connect ALSA port to device at %d:%d: snd_seq_connect_to error %d", ALSA_ClientID, ALSA_PortID, result);
ErrorCode = ALSAErr_ConnectTo;
return ALSAErr_Error;
}
......@@ -360,7 +360,7 @@ int ALSADrv_MIDI_StartPlayback(void)
if (pthread_create(&thread, NULL, threadProc, NULL))
{
MV_Printf("ALSA pthread_create returned error\n");
LOG_F(ERROR, "Unable to create thread for ALSA playback.");
ALSADrv_MIDI_HaltPlayback();
return ALSAErr_PlayThread;
}
......@@ -378,7 +378,7 @@ void ALSADrv_MIDI_HaltPlayback(void)
void *ret;
if (pthread_join(thread, &ret))
MV_Printf("ALSA pthread_join returned error\n");
LOG_F(ERROR, "Unable to terminate ALSA playback thread.");
ALSADrv_MIDI_QueueStop();
......@@ -416,12 +416,12 @@ void ALSADrv_MIDI_QueueStart(void)
result = snd_seq_start_queue(seq, seq_queue, NULL);
if (result < 0)
MV_Printf("ALSA snd_seq_start_queue err %d\n", result);
LOG_F(ERROR, "Unable to start ALSA queue: snd_seq_start_queue error %d", result);
do { } while ((result = snd_seq_drain_output(seq)) > 0);
if (result < 0)
MV_Printf("ALSA could not drain output: err %d\n", result);
LOG_F(ERROR, "Unable to drain ALSA output: snd_seq_drain_output error %d", result);
snd_seq_sync_output_queue(seq);
......@@ -438,12 +438,12 @@ void ALSADrv_MIDI_QueueStop(void)
result = snd_seq_stop_queue(seq, seq_queue, NULL);
if (result < 0)
MV_Printf("ALSA snd_seq_stop_queue err %d\n", result);
LOG_F(ERROR, "Unable to stop ALSA queue: snd_seq_stop_queue error %d", result);
do { } while ((result = snd_seq_drop_output(seq)) > 0);
if (result < 0)
MV_Printf("ALSA could not drop output: err %d\n", result);
LOG_F(ERROR, "Unable to drop ALSA output: snd_seq_drop_output error %d", result);
snd_seq_sync_output_queue(seq);
......@@ -465,7 +465,7 @@ std::vector<alsa_mididevinfo_t> const ALSADrv_MIDI_ListPorts(void)
result = snd_seq_open(&seq, "default", SND_SEQ_OPEN_OUTPUT, 0);
if (result < 0)
{
MV_Printf("ALSA snd_seq_open err %d\n", result);
LOG_F(ERROR, "Unable to initialize ALSA: snd_seq_open error %d", result);
return devices;
}
}
......
......@@ -28,10 +28,11 @@
#include "driver_directsound.h"
#include "compat.h"
#include "baselayer.h"
#include "multivoc.h"
#include "mutex.h"
#include "windows_inc.h"
#include "winbits.h"
#define MIXBUFFERPOSITIONS 8
......@@ -113,7 +114,7 @@ static void FillBuffer(int bufnum)
continue;
}
fail:
MV_Printf("DirectSound FillBuffer: err %x\n", (uint32_t)err);
LOG_F(ERROR, "Unable to lock DirectSound buffer: IDirectSoundBuffer_Lock error %x", (uint32_t)err);
return;
}
......@@ -134,6 +135,8 @@ static DWORD WINAPI fillDataThread(LPVOID lpParameter)
{
UNREFERENCED_PARAMETER(lpParameter);
debugThreadName("DSound_fillData");
HANDLE handles[MIXBUFFERPOSITIONS+1];
for (int i = 0; i < ARRAY_SSIZE(handles); i++)
......@@ -157,9 +160,14 @@ static DWORD WINAPI fillDataThread(LPVOID lpParameter)
case WAIT_OBJECT_0 + MIXBUFFERPOSITIONS:
ExitThread(0);
break;
case WAIT_FAILED:
{
auto err = GetLastError();
LOG_F(ERROR, "Unable to fill DirectSound buffer: WaitForMultipleObjects failed: %s", windowsGetErrorMessage(err));
}
break;
default:
MV_Printf("DirectSound fillDataThread: wfmo err %d\n", (int)waitret);
LOG_F(ERROR, "Unable to fill DirectSound buffer: WaitForMultipleObjects returned %d", (int)waitret);
break;
}
}
......@@ -172,7 +180,7 @@ static DWORD WINAPI fillDataThread(LPVOID lpParameter)
static void TeardownDSound(HRESULT err)
{
if (FAILED(err))
MV_Printf("Dying error: %x\n", (uint32_t)err);
LOG_F(ERROR, "DirectSound error: %x", (uint32_t)err);
if (lpdsnotify)
IDirectSoundNotify_Release(lpdsnotify), lpdsnotify = nullptr;
......
......@@ -119,12 +119,10 @@ const char *SDLDrv_ErrorString(int ErrorNumber)
#if SDL_MAJOR_VERSION >= 2
void SDLDrv_PCM_PrintDrivers(void)
{
MV_Printf("Available audio drivers: ");
LOG_F(INFO, "Available audio drivers:");
for (int i = 0; i < SDL_GetNumAudioDrivers(); ++i)
MV_Printf("%s ", SDL_GetAudioDriver(i));
MV_Printf("\n");
LOG_F(INFO, "%s", SDL_GetAudioDriver(i));
}
int SDLDrv_PCM_CheckDriverName(char const *dev)
......@@ -230,14 +228,15 @@ int SDLDrv_PCM_Init(int *mixrate, int *numchannels, void * initdata)
else
pdevname = devname;
MV_Printf("SDL %s driver on %s", drivername, pdevname);
VLOG_F(LOG_ASS, "Using SDL %s driver on %s", drivername, pdevname);
Xfree(devname);
Xfree(drivername);
#else
char drivernamestr[64] = "(error)";
SDL_AudioDriverName(drivernamestr, sizeof(drivernamestr));
MV_Printf("SDL %s driver", drivernamestr);
VLOG_F(LOG_ASS, "Using SDL %s driver", drivernamestr);
VLOG_F(LOG_ASS, "SDL %s driver", drivernamestr);
if (actual.freq == 0 || actual.channels == 0)
{
......
......@@ -87,12 +87,12 @@ static int SF2_LoadBank(char const *const filename)
if (sf2_synth)
{
MV_Printf(": loaded \"%s\"", filename);
VLOG_F(LOG_ASS, "Loaded \"%s\"", filename);
return SF2_Ok;
}
}
MV_Printf(": error loading \"%s\"!\n", filename);
LOG_F(ERROR, "Unable to load \"%s\"!", filename);
return SF2_Error;
}
......@@ -119,7 +119,7 @@ int SF2Drv_MIDI_Init(midifuncs* const funcs)
if (!filename[0])
{
MV_Printf(": no .sf2 data found!\n");
LOG_F(WARNING, "No .sf2 data found!");
return SF2_SetError(SF2_BankError);
}
}
......
......@@ -25,7 +25,7 @@
#include "driver_winmm.h"
#include "compat.h"
#include "baselayer.h"
#include "linklist.h"
#include "midi.h"
#include "midifuncs.h"
......@@ -105,9 +105,8 @@ const char *WinMMDrv_ErrorString(int ErrorNumber)
// will append "err nnn (ssss)\n" to the end of the string it emits
static void midi_error(MMRESULT rv, const char * fmt, ...)
static void midi_error(MMRESULT rv, const char *str)
{
va_list va;
const char * errtxt = "?";
switch (rv)
......@@ -135,10 +134,8 @@ static void midi_error(MMRESULT rv, const char * fmt, ...)
default: break;
}
debug_break();
va_start(va, fmt);
MV_Printf(fmt, va);
va_end(va);
MV_Printf(" err %d (%s)\n", (int)rv, errtxt);
LOG_F(ERROR, "%s: %s (0x%08x)", str, errtxt, rv);
}
// AddressSanitizer bug causes heap destruction with some functions from winmm.lib
......@@ -148,12 +145,10 @@ static void midi_dispose_buffer(MidiBuffer *node, const char *caller)
if (node->hdr.dwFlags & MHDR_PREPARED)
{
#if __SANITIZE_ADDRESS__ != 1
#ifdef MME_DEBUG
MV_Printf("MME %s/midi_dispose_buffer unpreparing buffer %p\n", caller, node);
#endif // MME_DEBUG
VLOG_F(LOG_DEBUG, "%s/midi_dispose_buffer unpreparing buffer %p", caller, node);
auto rv = midiOutUnprepareHeader((HMIDIOUT)midiStream, &node->hdr, sizeof(MIDIHDR));
if (rv != MMSYSERR_NOERROR)
midi_error(rv, "MME %s/midi_dispose_buffer midiOutUnprepareHeader", caller);
midi_error(rv, "midi_dispose_buffer: error in midiOutUnprepareHeader");
#endif
node->hdr.dwFlags &= ~MHDR_PREPARED;
}
......@@ -165,9 +160,7 @@ static void midi_dispose_buffer(MidiBuffer *node, const char *caller)
if (++numSpareMidiBuffers > maxSpareMidiBuffers)
maxSpareMidiBuffers = numSpareMidiBuffers;
#ifdef MME_DEBUG
MV_Printf("MME %s/midi_dispose_buffer recycling buffer %p\n", caller, node);
#endif // MME_DEBUG
VLOG_F(LOG_DEBUG, "MME %s/midi_dispose_buffer recycling buffer %p", caller, node);
}
static void midi_gc_buffers(void)
......@@ -192,9 +185,7 @@ static void midi_gc_buffers(void)
LL::Remove(node);
Xfree(node);
numSpareMidiBuffers--;
#ifdef MME_DEBUG
MV_Printf("MME midi_gc_buffers pruning spare buffer %p\n", node);
#endif // MME_DEBUG
VLOG_F(LOG_DEBUG, "MME midi_gc_buffers pruning spare buffer %p", node);
}
}
......@@ -254,7 +245,7 @@ static void midi_flush_current_buffer(void)
auto rv = midiOutPrepareHeader((HMIDIOUT)midiStream, &currentMidiBuffer->hdr, sizeof(MIDIHDR));
if (rv != MMSYSERR_NOERROR)
{
midi_error(rv, "MME midi_flush_current_buffer midiOutPrepareHeader");
midi_error(rv, "midi_flush_current_buffer: error in midiOutPrepareHeader");
return;
}
}
......@@ -264,7 +255,7 @@ static void midi_flush_current_buffer(void)
// midi file playing, so send events to the stream
auto rv = midiStreamOut(midiStream, &currentMidiBuffer->hdr, sizeof(MIDIHDR));
if (rv != MMSYSERR_NOERROR)
midi_error(rv, "MME midi_flush_current_buffer midiStreamOut");
midi_error(rv, "midi_flush_current_buffer: error in midiStreamOut");
//MV_Printf("MME midi_flush_current_buffer queued buffer %p\n", currentMidiBuffer);
}
......@@ -283,7 +274,7 @@ static void midi_flush_current_buffer(void)
//MV_Printf("MME midi_flush_current_buffer sent immediate long\n");
}
else
midi_error(rv, "MME midi_flush_current_buffer midiOutLongMsg");
midi_error(rv, "midi_flush_current_buffer: error in midiOutLongMsg");
midi_dispose_buffer(currentMidiBuffer, "midi_flush_current_buffer");
currentMidiBuffer = 0;
......@@ -292,7 +283,7 @@ static void midi_flush_current_buffer(void)
{
auto rv = midiOutShortMsg((HMIDIOUT)midiStream, evt->dwEvent);
if (rv != MMSYSERR_NOERROR)
midi_error(rv, "MME midi_flush_current_buffer midiOutShortMsg");
midi_error(rv, "midi_flush_current_buffer: error in midiOutShortMsg");
}
return;
}
......@@ -379,7 +370,7 @@ static BOOL midi_get_buffer(int length, unsigned char **data)
currentMidiBuffer = node;
//MV_Printf("MME midi_get_buffer fetched buffer %p\n", node);
VLOG_F(LOG_DEBUG, "MME midi_get_buffer fetched buffer %p", node);
break;
}
}
......@@ -399,9 +390,7 @@ static BOOL midi_get_buffer(int length, unsigned char **data)
currentMidiBuffer = node;
LL::Reset(node);
#ifdef MME_DEBUG
MV_Printf("MME midi_get_buffer allocated buffer %p\n", node);
#endif // MME_DEBUG
VLOG_F(LOG_DEBUG, "MME midi_get_buffer allocated buffer %p", node);
}
midi_setup_event(length, data);
......@@ -437,7 +426,7 @@ static void MME_NoteOff(int channel, int key, int velocity)
midi_sequence_event();
}
else
MV_Printf("MME_NoteOff error\n");
LOG_F(ERROR, "Error in MME_NoteOff()");
}
static void MME_NoteOn(int channel, int key, int velocity)
......@@ -452,7 +441,7 @@ static void MME_NoteOn(int channel, int key, int velocity)
midi_sequence_event();
}
else
MV_Printf("MME_NoteOn error\n");
LOG_F(ERROR, "Error in MME_NoteOn()");
}
static void MME_PolyAftertouch(int channel, int key, int pressure)
......@@ -467,7 +456,7 @@ static void MME_PolyAftertouch(int channel, int key, int pressure)
midi_sequence_event();
}
else
MV_Printf("MME_PolyAftertouch error\n");
LOG_F(ERROR, "Error in MME_PolyAftertouch()");
}
static void MME_ControlChange(int channel, int number, int value)
......@@ -482,7 +471,7 @@ static void MME_ControlChange(int channel, int number, int value)
midi_sequence_event();
}
else
MV_Printf("MME_ControlChange error\n");
LOG_F(ERROR, "Error in MME_ControlChange()");
}
static void MME_ProgramChange(int channel, int program)
......@@ -496,7 +485,7 @@ static void MME_ProgramChange(int channel, int program)
midi_sequence_event();
}
else
MV_Printf("MME_ProgramChange error\n");
LOG_F(ERROR, "Error in MME_ProgramChange()");
}
static void MME_ChannelAftertouch(int channel, int pressure)
......@@ -510,7 +499,7 @@ static void MME_ChannelAftertouch(int channel, int pressure)
midi_sequence_event();
}
else
MV_Printf("MME_ChannelAftertouch error\n");
LOG_F(ERROR, "Error in MME_ChannelAftertouch()");
}
static void MME_PitchBend(int channel, int lsb, int msb)
......@@ -525,7 +514,7 @@ static void MME_PitchBend(int channel, int lsb, int msb)
midi_sequence_event();
}
else
MV_Printf("MME_PitchBend error\n");
LOG_F(ERROR, "Error in MME_PitchBend()");
}
static void MME_SysEx(const unsigned char *data, int length)
......@@ -538,7 +527,7 @@ static void MME_SysEx(const unsigned char *data, int length)
midi_sequence_event();
}
else
MV_Printf("MME_SysEx error\n");
LOG_F(ERROR, "Error in MME_SysEx()");
}
void WinMMDrv_MIDI_PrintDevices(void)
......@@ -549,18 +538,16 @@ void WinMMDrv_MIDI_PrintDevices(void)
for (int i = -1; i < numDevices; i++)
{
if (!midiOutGetDevCaps(i, &midicaps, sizeof(MIDIOUTCAPS)))
MV_Printf("%d: %s ", i, midicaps.szPname);
LOG_F(INFO, "%d: %s ", i, midicaps.szPname);
}
MV_Printf("\n");
}
int WinMMDrv_MIDI_PrintBufferInfo(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
MV_Printf("MME MIDI buffer info:\n");
MV_Printf("%6s: %d (max %d)\n", "active", numActiveMidiBuffers, maxActiveMidiBuffers);
MV_Printf("%6s: %d (max %d)\n", "spare", numSpareMidiBuffers, maxSpareMidiBuffers);
LOG_F(INFO, "MME MIDI buffers:");
LOG_F(INFO, "%6s: %d (max %d)", "active", numActiveMidiBuffers, maxActiveMidiBuffers);
LOG_F(INFO, "%6s: %d (max %d)", "spare", numSpareMidiBuffers, maxSpareMidiBuffers);
return OSDCMD_OK;
}
......@@ -595,14 +582,14 @@ int WinMMDrv_MIDI_Init(midifuncs * funcs)
WinMM_DeviceID = MIDI_MAPPER;
if (!midiOutGetDevCaps(WinMM_DeviceID, &midicaps, sizeof(MIDIOUTCAPS)))
MV_Printf(": [%d] %s", WinMM_DeviceID, midicaps.szPname);
LOG_F(INFO, ": [%d] %s", WinMM_DeviceID, midicaps.szPname);
auto rv = midiStreamOpen(&midiStream, &WinMM_DeviceID, 1, (DWORD_PTR)midi_callback, (DWORD_PTR)0, CALLBACK_FUNCTION);
if (rv != MMSYSERR_NOERROR)
{
WinMMDrv_MIDI_Shutdown();
midi_error(rv, "MME MIDI_Init midiStreamOpen");
midi_error(rv, "WinMMDrv_MIDI_Init: error in midiStreamOpen");
ErrorCode = WinMMErr_MIDIStreamOpen;
return WinMMErr_Error;
}
......@@ -631,7 +618,7 @@ void WinMMDrv_MIDI_Shutdown(void)
// MV_Printf("stopping stream\n");
auto rv = midiStreamClose(midiStream);
if (rv != MMSYSERR_NOERROR)
midi_error(rv, "MME MIDI_HaltPlayback midiStreamClose");
midi_error(rv, "WinMMDrv_MIDI_Shutdown: error in midiStreamClose");
// MV_Printf("stream stopped\n");
midiStream = 0;
......@@ -653,9 +640,7 @@ void WinMMDrv_MIDI_Shutdown(void)
midiInstalled = FALSE;
#ifndef NDEBUG
MV_Printf("MME finished, max active buffers: %d max spare buffers: %d\n", maxActiveMidiBuffers, maxSpareMidiBuffers);
#endif
VLOG_F(LOG_DEBUG, "MME finished, max active buffers: %d max spare buffers: %d", maxActiveMidiBuffers, maxSpareMidiBuffers);
}
static DWORD midi_get_tick(void)
......@@ -668,7 +653,7 @@ static DWORD midi_get_tick(void)
auto rv = midiStreamPosition(midiStream, &mmtime, sizeof(MMTIME));
if (rv != MMSYSERR_NOERROR)
{
midi_error(rv, "MME midi_get_tick midiStreamPosition");
midi_error(rv, "midi_get_tick: error in midiStreamPosition");
return 0;
}
......@@ -704,9 +689,9 @@ static void CALLBACK midi_callback(HMIDIOUT out, UINT msg, DWORD_PTR dwInstance,
static DWORD WINAPI midiDataThread(LPVOID lpParameter)
{
UNREFERENCED_PARAMETER(lpParameter);
#ifndef NDEBUG
debugThreadName("midiDataThread");
#endif
DWORD sleepAmount = 100 / MME_THREAD_QUEUE_INTERVAL;
do
......@@ -813,7 +798,7 @@ int WinMMDrv_MIDI_StartPlayback(void)
auto rv = midiStreamRestart(midiStream);
if (rv != MMSYSERR_NOERROR)
{
midi_error(rv, "MIDI_StartPlayback midiStreamRestart");
midi_error(rv, "WinMMDrv_MIDI_StartPlayback: error in midiStreamRestart");
WinMMDrv_MIDI_HaltPlayback();
ErrorCode = WinMMErr_MIDIStreamRestart;
return WinMMErr_Error;
......@@ -848,16 +833,16 @@ void WinMMDrv_MIDI_SetTempo(int tempo, int division)
{
auto rv = midiStreamStop(midiStream);
if (rv != MMSYSERR_NOERROR)
midi_error(rv, "MME MIDI_SetTempo midiStreamStop");
midi_error(rv, "WinMMDrv_MIDI_SetTempo: error in midiStreamStop");
rv = midiStreamProperty(midiStream, (LPBYTE)&propTimediv, MIDIPROP_SET | MIDIPROP_TIMEDIV);
if (rv != MMSYSERR_NOERROR)
midi_error(rv, "MME MIDI_SetTempo midiStreamProperty timediv");
midi_error(rv, "WinMMDrv_MIDI_SetTempo: error in midiStreamProperty (MIDIPROP_TIMEDIV)");
}
auto rv = midiStreamProperty(midiStream, (LPBYTE)&propTempo, MIDIPROP_SET | MIDIPROP_TEMPO);
if (rv != MMSYSERR_NOERROR)
midi_error(rv, "MME MIDI_SetTempo midiStreamProperty tempo");
midi_error(rv, "WinMMDrv_MIDI_SetTempo: error in midiStreamProperty (MIDIPROP_TEMPO)");
if (midiLastDivision != division)
{
......@@ -876,7 +861,7 @@ void WinMMDrv_MIDI_Lock(void)
{
DWORD err = WaitForSingleObject(midiMutex, INFINITE);
if (err != WAIT_OBJECT_0)
MV_Printf("MME midiMutex lock: wfso %d\n", (int) err);
LOG_F(ERROR, "Error in WinMMDrv_MIDI_Lock(): WaitForSingleObject() returned %d", (int) err);
}
void WinMMDrv_MIDI_Unlock(void) { ReleaseMutex(midiMutex); }
......
......@@ -229,7 +229,7 @@ FLAC__StreamDecoderWriteStatus write_flac_stream(const FLAC__StreamDecoder *deco
{
samples = (FLAC__uint64)(uintptr_t)voice->Loop.End - fd->sample_pos;
if (!FLAC__stream_decoder_seek_absolute(fd->stream, (FLAC__uint64)(uintptr_t)voice->Loop.Start))
MV_Printf("MV_GetNextFLACBlock FLAC__stream_decoder_seek_absolute: LOOP_START %ul, LOOP_END %ul\n",
LOG_F(ERROR, "write_flac_stream: error in FLAC__stream_decoder_seek_absolute (LOOP_START %" PRIu64 ", LOOP_END %" PRIu64 ")",
(FLAC__uint64)(uintptr_t)voice->Loop.Start, (FLAC__uint64)(uintptr_t)voice->Loop.End);
}