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/dmusic.cpp | |
parent | a99ac62c1ab816ee48cac85fdf834f9fdc599cb1 (diff) | |
download | openttd-55a11710a6c0f7942f3947711f2050c34782c39d.tar.xz |
Codechange: convert printf DEBUG statements to fmt Debug statements
Diffstat (limited to 'src/music/dmusic.cpp')
-rw-r--r-- | src/music/dmusic.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
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)" : ""); } } } |