diff options
author | rubidium42 <rubidium@openttd.org> | 2021-06-12 09:10:17 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-06-13 12:45:45 +0200 |
commit | 55a11710a6c0f7942f3947711f2050c34782c39d (patch) | |
tree | 491b3009324e623236977614e91371a0ea4abac7 /src/music | |
parent | a99ac62c1ab816ee48cac85fdf834f9fdc599cb1 (diff) | |
download | openttd-55a11710a6c0f7942f3947711f2050c34782c39d.tar.xz |
Codechange: convert printf DEBUG statements to fmt Debug statements
Diffstat (limited to 'src/music')
-rw-r--r-- | src/music/allegro_m.cpp | 6 | ||||
-rw-r--r-- | src/music/cocoa_m.cpp | 12 | ||||
-rw-r--r-- | src/music/dmusic.cpp | 54 | ||||
-rw-r--r-- | src/music/extmidi.cpp | 6 | ||||
-rw-r--r-- | src/music/fluidsynth.cpp | 12 | ||||
-rw-r--r-- | src/music/win32_m.cpp | 32 |
6 files changed, 61 insertions, 61 deletions
diff --git a/src/music/allegro_m.cpp b/src/music/allegro_m.cpp index 6d06ce87e..de2df2326 100644 --- a/src/music/allegro_m.cpp +++ b/src/music/allegro_m.cpp @@ -29,20 +29,20 @@ extern int _allegro_instance_count; const char *MusicDriver_Allegro::Start(const StringList ¶m) { if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) { - DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error); + Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error); return "Failed to set up Allegro"; } _allegro_instance_count++; /* Initialise the sound */ if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, nullptr) != 0) { - DEBUG(driver, 0, "allegro: install_sound failed '%s'", allegro_error); + Debug(driver, 0, "allegro: install_sound failed '{}'", allegro_error); return "Failed to set up Allegro sound"; } /* Okay, there's no soundcard */ if (midi_card == MIDI_NONE) { - DEBUG(driver, 0, "allegro: no midi card found"); + Debug(driver, 0, "allegro: no midi card found"); return "No sound card found"; } diff --git a/src/music/cocoa_m.cpp b/src/music/cocoa_m.cpp index 279e0b38a..5fc69b1f9 100644 --- a/src/music/cocoa_m.cpp +++ b/src/music/cocoa_m.cpp @@ -67,7 +67,7 @@ static void DoSetVolume() } } if (output_unit == nullptr) { - DEBUG(driver, 1, "cocoa_m: Failed to get output node to set volume"); + Debug(driver, 1, "cocoa_m: Failed to get output node to set volume"); return; } @@ -119,7 +119,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song) { std::string filename = MidiFile::GetSMFFile(song); - DEBUG(driver, 2, "cocoa_m: trying to play '%s'", filename.c_str()); + Debug(driver, 2, "cocoa_m: trying to play '{}'", filename); this->StopSong(); if (_sequence != nullptr) { @@ -130,7 +130,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song) if (filename.empty()) return; if (NewMusicSequence(&_sequence) != noErr) { - DEBUG(driver, 0, "cocoa_m: Failed to create music sequence"); + Debug(driver, 0, "cocoa_m: Failed to create music sequence"); return; } @@ -138,7 +138,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song) CFAutoRelease<CFURLRef> url(CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8*)os_file.c_str(), os_file.length(), false)); if (MusicSequenceFileLoad(_sequence, url.get(), kMusicSequenceFile_AnyType, 0) != noErr) { - DEBUG(driver, 0, "cocoa_m: Failed to load MIDI file"); + Debug(driver, 0, "cocoa_m: Failed to load MIDI file"); return; } @@ -148,7 +148,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song) MusicSequenceGetAUGraph(_sequence, &graph); AUGraphOpen(graph); if (AUGraphInitialize(graph) != noErr) { - DEBUG(driver, 0, "cocoa_m: Failed to initialize AU graph"); + Debug(driver, 0, "cocoa_m: Failed to initialize AU graph"); return; } @@ -173,7 +173,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song) if (MusicPlayerStart(_player) != noErr) return; _playing = true; - DEBUG(driver, 3, "cocoa_m: playing '%s'", filename.c_str()); + Debug(driver, 3, "cocoa_m: playing '{}'", filename); } diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp index 619a20d8b..d61475827 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -229,7 +229,7 @@ bool DLSFile::ReadDLSRegion(FILE *f, DWORD list_length, std::vector<DLSRegion> & break; default: - DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); break; } @@ -252,11 +252,11 @@ bool DLSFile::ReadDLSRegionList(FILE *f, DWORD list_length, DLSInstrument &instr if (list_type == FOURCC_RGN) { this->ReadDLSRegion(f, chunk.length - sizeof(list_type), instrument.regions); } else { - DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); fseek(f, chunk.length - sizeof(list_type), SEEK_CUR); } } else { - DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); } } @@ -299,7 +299,7 @@ bool DLSFile::ReadDLSInstrument(FILE *f, DWORD list_length) break; default: - DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); break; } @@ -320,15 +320,15 @@ bool DLSFile::ReadDLSInstrumentList(FILE *f, DWORD list_length) if (fread(&list_type, sizeof(list_type), 1, f) != 1) return false; if (list_type == FOURCC_INS) { - DEBUG(driver, 6, "DLS: Reading instrument %d", (int)instruments.size()); + Debug(driver, 6, "DLS: Reading instrument {}", (int)instruments.size()); if (!this->ReadDLSInstrument(f, chunk.length - sizeof(list_type))) return false; } else { - DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); fseek(f, chunk.length - sizeof(list_type), SEEK_CUR); } } else { - DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); } } @@ -387,7 +387,7 @@ bool DLSFile::ReadDLSWave(FILE *f, DWORD list_length, long offset) break; default: - DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); break; } @@ -412,15 +412,15 @@ bool DLSFile::ReadDLSWaveList(FILE *f, DWORD list_length) if (fread(&list_type, sizeof(list_type), 1, f) != 1) return false; if (list_type == FOURCC_wave) { - DEBUG(driver, 6, "DLS: Reading wave %d", (int)waves.size()); + Debug(driver, 6, "DLS: Reading wave {}", waves.size()); if (!this->ReadDLSWave(f, chunk.length - sizeof(list_type), chunk_offset - base_offset)) return false; } else { - DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); fseek(f, chunk.length - sizeof(list_type), SEEK_CUR); } } else { - DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); } } @@ -430,7 +430,7 @@ bool DLSFile::ReadDLSWaveList(FILE *f, DWORD list_length) bool DLSFile::LoadFile(const wchar_t *file) { - DEBUG(driver, 2, "DMusic: Try to load DLS file %s", FS2OTTD(file).c_str()); + Debug(driver, 2, "DMusic: Try to load DLS file {}", FS2OTTD(file)); FILE *f = _wfopen(file, L"rb"); if (f == nullptr) return false; @@ -446,7 +446,7 @@ bool DLSFile::LoadFile(const wchar_t *file) hdr.length -= sizeof(FOURCC); - DEBUG(driver, 2, "DMusic: Parsing DLS file"); + Debug(driver, 2, "DMusic: Parsing DLS file"); DLSHEADER header; MemSetT(&header, 0); @@ -495,7 +495,7 @@ bool DLSFile::LoadFile(const wchar_t *file) break; default: - DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); break; } @@ -585,7 +585,7 @@ static void TransmitNotesOff(IDirectMusicBuffer *buffer, REFERENCE_TIME block_ti static void MidiThreadProc() { - DEBUG(driver, 2, "DMusic: Entering playback thread"); + Debug(driver, 2, "DMusic: Entering playback thread"); REFERENCE_TIME last_volume_time = 0; // timestamp of the last volume change REFERENCE_TIME block_time = 0; // timestamp of the last block sent to the port @@ -617,7 +617,7 @@ static void MidiThreadProc() } if (_playback.do_stop) { - DEBUG(driver, 2, "DMusic thread: Stopping playback"); + Debug(driver, 2, "DMusic thread: Stopping playback"); /* Turn all notes off and wait a bit to allow the messages to be handled. */ clock->GetTime(&cur_time); @@ -632,7 +632,7 @@ static void MidiThreadProc() if (wfso == WAIT_OBJECT_0) { if (_playback.do_start) { - DEBUG(driver, 2, "DMusic thread: Starting playback"); + Debug(driver, 2, "DMusic thread: Starting playback"); { /* New scope to limit the time the mutex is locked. */ std::lock_guard<std::mutex> lock(_thread_mutex); @@ -669,14 +669,14 @@ static void MidiThreadProc() preload_bytes += block.data.size(); if (block.ticktime >= current_segment.start) { if (current_segment.loop) { - DEBUG(driver, 2, "DMusic: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes); + Debug(driver, 2, "DMusic: timer: loop from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime) / 1000.0, preload_bytes); current_segment.start_block = bl; break; } else { /* Skip the transmission delay compensation performed in the Win32 MIDI driver. * The DMusic driver will most likely be used with the MS softsynth, which is not subject to transmission delays. */ - DEBUG(driver, 2, "DMusic: timer: start from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes); + Debug(driver, 2, "DMusic: timer: start from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime) / 1000.0, preload_bytes); playback_start_time -= block.realtime * MIDITIME_TO_REFTIME; break; } @@ -691,7 +691,7 @@ static void MidiThreadProc() /* Check for volume change. */ if (current_volume != _playback.new_volume) { if (current_time - last_volume_time > 10 * MS_TO_REFTIME) { - DEBUG(driver, 2, "DMusic thread: volume change"); + Debug(driver, 2, "DMusic thread: volume change"); current_volume = _playback.new_volume; last_volume_time = current_time; for (int ch = 0; ch < 16; ch++) { @@ -709,7 +709,7 @@ static void MidiThreadProc() /* check that block isn't at end-of-song override */ if (current_segment.end > 0 && block.ticktime >= current_segment.end) { if (current_segment.loop) { - DEBUG(driver, 2, "DMusic thread: Looping song"); + Debug(driver, 2, "DMusic thread: Looping song"); current_block = current_segment.start_block; playback_start_time = current_time - current_file.blocks[current_block].realtime * MIDITIME_TO_REFTIME; } else { @@ -723,13 +723,13 @@ static void MidiThreadProc() if (block.realtime * MIDITIME_TO_REFTIME > playback_time + 3 *_playback.preload_time * MS_TO_REFTIME) { /* Stop the thread loop until we are at the preload time of the next block. */ next_timeout = Clamp(((int64)block.realtime * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000); - DEBUG(driver, 9, "DMusic thread: Next event in %lu ms (music %u, ref " OTTD_PRINTF64 ")", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time); + Debug(driver, 9, "DMusic thread: Next event in {} ms (music {}, ref {})", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time); break; } /* Timestamp of the current block. */ block_time = playback_start_time + block.realtime * MIDITIME_TO_REFTIME; - DEBUG(driver, 9, "DMusic thread: Streaming block " PRINTF_SIZE " (cur=" OTTD_PRINTF64 ", block=" OTTD_PRINTF64 ")", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME)); + Debug(driver, 9, "DMusic thread: Streaming block {} (cur={}, block={})", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME)); const byte *data = block.data.data(); size_t remaining = block.data.size(); @@ -822,7 +822,7 @@ static void MidiThreadProc() } } - DEBUG(driver, 2, "DMusic: Exiting playback thread"); + Debug(driver, 2, "DMusic: Exiting playback thread"); /* Turn all notes off and wait a bit to allow the messages to be handled by real hardware. */ clock->GetTime(&cur_time); @@ -867,7 +867,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls) if (SUCCEEDED(RegQueryValueEx(hkDM, L"GMFilePath", nullptr, nullptr, (LPBYTE)dls_path, &buf_size))) { wchar_t expand_path[MAX_PATH * 2]; ExpandEnvironmentStrings(dls_path, expand_path, lengthof(expand_path)); - if (!dls_file.LoadFile(expand_path)) DEBUG(driver, 1, "Failed to load default GM DLS file from registry"); + if (!dls_file.LoadFile(expand_path)) Debug(driver, 1, "Failed to load default GM DLS file from registry"); } RegCloseKey(hkDM); } @@ -1100,10 +1100,10 @@ const char *MusicDriver_DMusic::Start(const StringList &parm) MemSetT(&caps, 0); caps.dwSize = sizeof(DMUS_PORTCAPS); - DEBUG(driver, 1, "Detected DirectMusic ports:"); + Debug(driver, 1, "Detected DirectMusic ports:"); for (int i = 0; _music->EnumPort(i, &caps) == S_OK; i++) { if (caps.dwClass == DMUS_PC_OUTPUTCLASS) { - DEBUG(driver, 1, " %d: %s%s", i, convert_from_fs(caps.wszDescription, desc, lengthof(desc)), i == pIdx ? " (selected)" : ""); + Debug(driver, 1, " {}: {}{}", i, convert_from_fs(caps.wszDescription, desc, lengthof(desc)), i == pIdx ? " (selected)" : ""); } } } diff --git a/src/music/extmidi.cpp b/src/music/extmidi.cpp index f88245250..cf19f17cf 100644 --- a/src/music/extmidi.cpp +++ b/src/music/extmidi.cpp @@ -110,7 +110,7 @@ bool MusicDriver_ExtMidi::IsSongPlaying() void MusicDriver_ExtMidi::SetVolume(byte vol) { - DEBUG(driver, 1, "extmidi: set volume not implemented"); + Debug(driver, 1, "extmidi: set volume not implemented"); } void MusicDriver_ExtMidi::DoPlay() @@ -127,7 +127,7 @@ void MusicDriver_ExtMidi::DoPlay() } case -1: - DEBUG(driver, 0, "extmidi: couldn't fork: %s", strerror(errno)); + Debug(driver, 0, "extmidi: couldn't fork: {}", strerror(errno)); FALLTHROUGH; default: @@ -153,7 +153,7 @@ void MusicDriver_ExtMidi::DoStop() CSleep(10); } - DEBUG(driver, 0, "extmidi: gracefully stopping failed, trying the hard way"); + Debug(driver, 0, "extmidi: gracefully stopping failed, trying the hard way"); /* Gracefully stopping failed. Do it the hard way * and wait till the process finally died. */ kill(this->pid, SIGKILL); diff --git a/src/music/fluidsynth.cpp b/src/music/fluidsynth.cpp index 1c4b67e12..dc1a0a319 100644 --- a/src/music/fluidsynth.cpp +++ b/src/music/fluidsynth.cpp @@ -65,7 +65,7 @@ const char *MusicDriver_FluidSynth::Start(const StringList ¶m) const char *sfont_name = GetDriverParam(param, "soundfont"); int sfont_id; - DEBUG(driver, 1, "Fluidsynth: sf %s", sfont_name); + Debug(driver, 1, "Fluidsynth: sf {}", sfont_name); /* Create the settings. */ _midi.settings = new_fluid_settings(); @@ -76,7 +76,7 @@ const char *MusicDriver_FluidSynth::Start(const StringList ¶m) /* Install the music render routine and set up the samplerate */ uint32 samplerate = MxSetMusicSource(RenderMusicStream); fluid_settings_setnum(_midi.settings, "synth.sample-rate", samplerate); - DEBUG(driver, 1, "Fluidsynth: samplerate %.0f", (float)samplerate); + Debug(driver, 1, "Fluidsynth: samplerate {:.0f}", (float)samplerate); /* Create the synthesizer. */ _midi.synth = new_fluid_synth(_midi.settings); @@ -143,18 +143,18 @@ void MusicDriver_FluidSynth::PlaySong(const MusicSongInfo &song) _midi.player = new_fluid_player(_midi.synth); if (_midi.player == nullptr) { - DEBUG(driver, 0, "Could not create midi player"); + Debug(driver, 0, "Could not create midi player"); return; } if (fluid_player_add(_midi.player, filename.c_str()) != FLUID_OK) { - DEBUG(driver, 0, "Could not open music file"); + Debug(driver, 0, "Could not open music file"); delete_fluid_player(_midi.player); _midi.player = nullptr; return; } if (fluid_player_play(_midi.player) != FLUID_OK) { - DEBUG(driver, 0, "Could not start midi player"); + Debug(driver, 0, "Could not start midi player"); delete_fluid_player(_midi.player); _midi.player = nullptr; return; @@ -194,6 +194,6 @@ void MusicDriver_FluidSynth::SetVolume(byte vol) * and 0.2. */ double gain = (1.0 * vol) / (128.0 * 5.0); if (fluid_settings_setnum(_midi.settings, "synth.gain", gain) != FLUID_OK) { - DEBUG(driver, 0, "Could not set volume"); + Debug(driver, 0, "Could not set volume"); } } diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp index 792cff5af..8ff8a72ac 100644 --- a/src/music/win32_m.cpp +++ b/src/music/win32_m.cpp @@ -115,7 +115,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW /* check for stop */ if (_midi.do_stop) { - DEBUG(driver, 2, "Win32-MIDI: timer: do_stop is set"); + Debug(driver, 2, "Win32-MIDI: timer: do_stop is set"); midiOutReset(_midi.midi_out); _midi.playing = false; _midi.do_stop = false; @@ -128,7 +128,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW if (timeGetTime() - _midi.playback_start_time < 50) { return; } - DEBUG(driver, 2, "Win32-MIDI: timer: do_start step %d", _midi.do_start); + Debug(driver, 2, "Win32-MIDI: timer: do_start step {}", _midi.do_start); if (_midi.do_start == 1) { /* Send "all notes off" */ @@ -165,7 +165,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW } } else if (!_midi.playing) { /* not playing, stop the timer */ - DEBUG(driver, 2, "Win32-MIDI: timer: not playing, stopping timer"); + Debug(driver, 2, "Win32-MIDI: timer: not playing, stopping timer"); timeKillEvent(uTimerID); _midi.timer_id = 0; return; @@ -175,7 +175,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW static int volume_throttle = 0; if (_midi.current_volume != _midi.new_volume) { if (volume_throttle == 0) { - DEBUG(driver, 2, "Win32-MIDI: timer: volume change"); + Debug(driver, 2, "Win32-MIDI: timer: volume change"); _midi.current_volume = _midi.new_volume; volume_throttle = 20 / _midi.time_period; for (int ch = 0; ch < 16; ch++) { @@ -198,7 +198,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW preload_bytes += block.data.size(); if (block.ticktime >= _midi.current_segment.start) { if (_midi.current_segment.loop) { - DEBUG(driver, 2, "Win32-MIDI: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime)/1000.0, (int)preload_bytes); + Debug(driver, 2, "Win32-MIDI: timer: loop from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime)/1000.0, preload_bytes); _midi.current_segment.start_block = bl; break; } else { @@ -207,7 +207,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW * which have a bitrate of 31,250 bits/sec, and transmit 1+8+1 start/data/stop bits per byte. * The delay compensation is needed to avoid time-compression of following messages. */ - DEBUG(driver, 2, "Win32-MIDI: timer: start from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes); + Debug(driver, 2, "Win32-MIDI: timer: start from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime) / 1000.0, preload_bytes); _midi.playback_start_time -= block.realtime / 1000 - (DWORD)(preload_bytes * 1000 / 3125); break; } @@ -320,11 +320,11 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW void MusicDriver_Win32::PlaySong(const MusicSongInfo &song) { - DEBUG(driver, 2, "Win32-MIDI: PlaySong: entry"); + Debug(driver, 2, "Win32-MIDI: PlaySong: entry"); MidiFile new_song; if (!new_song.LoadSong(song)) return; - DEBUG(driver, 2, "Win32-MIDI: PlaySong: Loaded song"); + Debug(driver, 2, "Win32-MIDI: PlaySong: Loaded song"); std::lock_guard<std::mutex> mutex_lock(_midi.lock); @@ -333,21 +333,21 @@ void MusicDriver_Win32::PlaySong(const MusicSongInfo &song) _midi.next_segment.end = song.override_end; _midi.next_segment.loop = song.loop; - DEBUG(driver, 2, "Win32-MIDI: PlaySong: setting flag"); + Debug(driver, 2, "Win32-MIDI: PlaySong: setting flag"); _midi.do_stop = _midi.playing; _midi.do_start = 1; if (_midi.timer_id == 0) { - DEBUG(driver, 2, "Win32-MIDI: PlaySong: starting timer"); + Debug(driver, 2, "Win32-MIDI: PlaySong: starting timer"); _midi.timer_id = timeSetEvent(_midi.time_period, _midi.time_period, TimerCallback, (DWORD_PTR)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); } } void MusicDriver_Win32::StopSong() { - DEBUG(driver, 2, "Win32-MIDI: StopSong: entry"); + Debug(driver, 2, "Win32-MIDI: StopSong: entry"); std::lock_guard<std::mutex> mutex_lock(_midi.lock); - DEBUG(driver, 2, "Win32-MIDI: StopSong: setting flag"); + Debug(driver, 2, "Win32-MIDI: StopSong: setting flag"); _midi.do_stop = true; } @@ -364,7 +364,7 @@ void MusicDriver_Win32::SetVolume(byte vol) const char *MusicDriver_Win32::Start(const StringList &parm) { - DEBUG(driver, 2, "Win32-MIDI: Start: initializing"); + Debug(driver, 2, "Win32-MIDI: Start: initializing"); int resolution = GetDriverParamInt(parm, "resolution", 5); uint port = (uint)GetDriverParamInt(parm, "port", UINT_MAX); @@ -373,7 +373,7 @@ const char *MusicDriver_Win32::Start(const StringList &parm) /* Enumerate ports either for selecting port by name, or for debug output */ if (portname != nullptr || _debug_driver_level > 0) { uint numports = midiOutGetNumDevs(); - DEBUG(driver, 1, "Win32-MIDI: Found %d output devices:", numports); + Debug(driver, 1, "Win32-MIDI: Found {} output devices:", numports); for (uint tryport = 0; tryport < numports; tryport++) { MIDIOUTCAPS moc{}; if (midiOutGetDevCaps(tryport, &moc, sizeof(moc)) == MMSYSERR_NOERROR) { @@ -384,7 +384,7 @@ const char *MusicDriver_Win32::Start(const StringList &parm) * If multiple ports have the same name, this will select the last matching port, and the debug output will be confusing. */ if (portname != nullptr && strncmp(tryportname, portname, lengthof(tryportname)) == 0) port = tryport; - DEBUG(driver, 1, "MIDI port %2d: %s%s", tryport, tryportname, (tryport == port) ? " [selected]" : ""); + Debug(driver, 1, "MIDI port {:2d}: {}{}", tryport, tryportname, (tryport == port) ? " [selected]" : ""); } } } @@ -410,7 +410,7 @@ const char *MusicDriver_Win32::Start(const StringList &parm) _midi.time_period = std::min(std::max((UINT)resolution, timecaps.wPeriodMin), timecaps.wPeriodMax); if (timeBeginPeriod(_midi.time_period) == MMSYSERR_NOERROR) { /* success */ - DEBUG(driver, 2, "Win32-MIDI: Start: timer resolution is %d", (int)_midi.time_period); + Debug(driver, 2, "Win32-MIDI: Start: timer resolution is {}", _midi.time_period); return nullptr; } } |