mirror of https://github.com/OpenTTD/OpenTTD.git
Fix: dmusic compilation with MSYS2/MINGW
This commit is contained in:
parent
d418d30947
commit
a4eccd8076
|
@ -29,11 +29,13 @@
|
|||
#include <windows.h>
|
||||
#include <dmksctrl.h>
|
||||
#include <dmusicc.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
#pragma comment(lib, "ole32.lib")
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma comment(lib, "ole32.lib")
|
||||
#endif /* defined(_MSC_VER) */
|
||||
|
||||
static const int MS_TO_REFTIME = 1000 * 10; ///< DirectMusic time base is 100 ns.
|
||||
static const int MIDITIME_TO_REFTIME = 10; ///< Time base of the midi file reader is 1 us.
|
||||
|
@ -231,7 +233,7 @@ bool DLSFile::ReadDLSRegion(FILE *f, DWORD list_length, std::vector<DLSRegion> &
|
|||
break;
|
||||
|
||||
default:
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown chunk %c%c%c%c", chunk.type & 0xFF, (chunk.type >> 8) & 0xFF, (chunk.type >> 16) & 0xFF, (chunk.type >> 24) & 0xFF);
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown chunk %c%c%c%c", (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;
|
||||
}
|
||||
|
@ -254,11 +256,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 unkown list chunk of type %c%c%c%c", list_type & 0xFF, (list_type >> 8) & 0xFF, (list_type >> 16) & 0xFF, (list_type >> 24) & 0xFF);
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown 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));
|
||||
fseek(f, chunk.length - sizeof(list_type), SEEK_CUR);
|
||||
}
|
||||
} else {
|
||||
DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", chunk.type & 0xFF, (chunk.type >> 8) & 0xFF, (chunk.type >> 16) & 0xFF, (chunk.type >> 24) & 0xFF);
|
||||
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));
|
||||
fseek(f, chunk.length, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +303,7 @@ bool DLSFile::ReadDLSInstrument(FILE *f, DWORD list_length)
|
|||
break;
|
||||
|
||||
default:
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown chunk %c%c%c%c", chunk.type & 0xFF, (chunk.type >> 8) & 0xFF, (chunk.type >> 16) & 0xFF, (chunk.type >> 24) & 0xFF);
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown chunk %c%c%c%c", (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;
|
||||
}
|
||||
|
@ -326,11 +328,11 @@ bool DLSFile::ReadDLSInstrumentList(FILE *f, DWORD list_length)
|
|||
|
||||
if (!this->ReadDLSInstrument(f, chunk.length - sizeof(list_type))) return false;
|
||||
} else {
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown list chunk of type %c%c%c%c", list_type & 0xFF, (list_type >> 8) & 0xFF, (list_type >> 16) & 0xFF, (list_type >> 24) & 0xFF);
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown 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));
|
||||
fseek(f, chunk.length - sizeof(list_type), SEEK_CUR);
|
||||
}
|
||||
} else {
|
||||
DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", chunk.type & 0xFF, (chunk.type >> 8) & 0xFF, (chunk.type >> 16) & 0xFF, (chunk.type >> 24) & 0xFF);
|
||||
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));
|
||||
fseek(f, chunk.length, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
@ -389,7 +391,7 @@ bool DLSFile::ReadDLSWave(FILE *f, DWORD list_length, long offset)
|
|||
break;
|
||||
|
||||
default:
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown chunk %c%c%c%c", chunk.type & 0xFF, (chunk.type >> 8) & 0xFF, (chunk.type >> 16) & 0xFF, (chunk.type >> 24) & 0xFF);
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown chunk %c%c%c%c", (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;
|
||||
}
|
||||
|
@ -418,11 +420,11 @@ bool DLSFile::ReadDLSWaveList(FILE *f, DWORD list_length)
|
|||
|
||||
if (!this->ReadDLSWave(f, chunk.length - sizeof(list_type), chunk_offset - base_offset)) return false;
|
||||
} else {
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown list chunk of type %c%c%c%c", list_type & 0xFF, (list_type >> 8) & 0xFF, (list_type >> 16) & 0xFF, (list_type >> 24) & 0xFF);
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown 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));
|
||||
fseek(f, chunk.length - sizeof(list_type), SEEK_CUR);
|
||||
}
|
||||
} else {
|
||||
DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", chunk.type & 0xFF, (chunk.type >> 8) & 0xFF, (chunk.type >> 16) & 0xFF, (chunk.type >> 24) & 0xFF);
|
||||
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));
|
||||
fseek(f, chunk.length, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +499,7 @@ bool DLSFile::LoadFile(const TCHAR *file)
|
|||
break;
|
||||
|
||||
default:
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown chunk %c%c%c%c", chunk.type & 0xFF, (chunk.type >> 8) & 0xFF, (chunk.type >> 16) & 0xFF, (chunk.type >> 24) & 0xFF);
|
||||
DEBUG(driver, 7, "DLS: Ignoring unkown chunk %c%c%c%c", (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;
|
||||
}
|
||||
|
@ -603,7 +605,7 @@ static void MidiThreadProc(void *)
|
|||
REFERENCE_TIME playback_start_time; // timestamp current file began playback
|
||||
MidiFile current_file; // file currently being played from
|
||||
PlaybackSegment current_segment; // segment info for current playback
|
||||
size_t current_block; // next block index to send
|
||||
size_t current_block = 0; // next block index to send
|
||||
byte current_volume = 0; // current effective volume setting
|
||||
byte channel_volumes[16]; // last seen volume controller values in raw data
|
||||
|
||||
|
@ -741,13 +743,13 @@ static void MidiThreadProc(void *)
|
|||
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 %u ms (music %u, ref %lld)", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time);
|
||||
DEBUG(driver, 9, "DMusic thread: Next event in %lu ms (music %u, ref " OTTD_PRINTF64 ")", 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 %Iu (cur=%lld, block=%lld)", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_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));
|
||||
|
||||
byte *data = block.data.Begin();
|
||||
size_t remaining = block.data.Length();
|
||||
|
@ -1013,7 +1015,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
|||
DMUS_INSTRUMENT *inst_data = (DMUS_INSTRUMENT *)instrument;
|
||||
MemSetT(inst_data, 0);
|
||||
offset_table[last_offset++] = (char *)inst_data - inst_base;
|
||||
inst_data->ulPatch = dls_file.instruments[i].hdr.Locale.ulBank & F_INSTRUMENT_DRUMS | ((dls_file.instruments[i].hdr.Locale.ulBank & 0x7F7F) << 8) | dls_file.instruments[i].hdr.Locale.ulInstrument & 0x7F;
|
||||
inst_data->ulPatch = (dls_file.instruments[i].hdr.Locale.ulBank & F_INSTRUMENT_DRUMS) | ((dls_file.instruments[i].hdr.Locale.ulBank & 0x7F7F) << 8) | (dls_file.instruments[i].hdr.Locale.ulInstrument & 0x7F);
|
||||
instrument = inst_data + 1;
|
||||
|
||||
/* Write global articulations. */
|
||||
|
|
Loading…
Reference in New Issue