Codechange: Add some const in preparation

This commit is contained in:
Niels Martin Hansen 2019-07-04 21:27:18 +02:00
parent c74df8581d
commit 9d8a83bf8d
2 changed files with 10 additions and 10 deletions

View File

@ -539,19 +539,19 @@ static void TransmitChannelMsg(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, by
}
}
static void TransmitSysex(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, byte *&msg_start, size_t &remaining)
static void TransmitSysex(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, const byte *&msg_start, size_t &remaining)
{
/* Find end of message. */
byte *msg_end = msg_start;
const byte *msg_end = msg_start;
while (*msg_end != MIDIST_ENDSYSEX) msg_end++;
msg_end++; // Also include SysEx end byte.
if (buffer->PackUnstructured(rt, 0, msg_end - msg_start, msg_start) == E_OUTOFMEMORY) {
if (buffer->PackUnstructured(rt, 0, msg_end - msg_start, const_cast<LPBYTE>(msg_start)) == E_OUTOFMEMORY) {
/* Buffer is full, clear it and try again. */
_port->PlayBuffer(buffer);
buffer->Flush();
buffer->PackUnstructured(rt, 0, msg_end - msg_start, msg_start);
buffer->PackUnstructured(rt, 0, msg_end - msg_start, const_cast<LPBYTE>(msg_start));
}
/* Update position in buffer. */
@ -559,7 +559,7 @@ static void TransmitSysex(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, byte *&
msg_start = msg_end;
}
static void TransmitSysexConst(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, byte *msg_start, size_t length)
static void TransmitSysexConst(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, const byte *msg_start, size_t length)
{
TransmitSysex(buffer, rt, msg_start, length);
}
@ -752,7 +752,7 @@ static void MidiThreadProc()
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));
byte *data = block.data.data();
const byte *data = block.data.data();
size_t remaining = block.data.size();
byte last_status = 0;
while (remaining > 0) {

View File

@ -74,10 +74,10 @@ static void TransmitChannelMsg(byte status, byte p1, byte p2 = 0)
midiOutShortMsg(_midi.midi_out, status | (p1 << 8) | (p2 << 16));
}
static void TransmitSysex(byte *&msg_start, size_t &remaining)
static void TransmitSysex(const byte *&msg_start, size_t &remaining)
{
/* find end of message */
byte *msg_end = msg_start;
const byte *msg_end = msg_start;
while (*msg_end != MIDIST_ENDSYSEX) msg_end++;
msg_end++; /* also include sysex end byte */
@ -98,7 +98,7 @@ static void TransmitSysex(byte *&msg_start, size_t &remaining)
msg_start = msg_end;
}
static void TransmitSysexConst(byte *msg_start, size_t length)
static void TransmitSysexConst(const byte *msg_start, size_t length)
{
TransmitSysex(msg_start, length);
}
@ -226,7 +226,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
break;
}
byte *data = block.data.data();
const byte *data = block.data.data();
size_t remaining = block.data.size();
byte last_status = 0;
while (remaining > 0) {