Skip to content

Commit 8312f46

Browse files
committed
Use bool as appropriate for native MIDI code
1 parent 1cd7c62 commit 8312f46

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/codecs/music_nativemidi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void NATIVEMIDI_SetVolume(void *context, int volume)
5656
static bool NATIVEMIDI_IsPlaying(void *context)
5757
{
5858
(void)context;
59-
return native_midi_active() ? true : false;
59+
return native_midi_active();
6060
}
6161

6262
static void NATIVEMIDI_Pause(void *context)

src/codecs/native_midi/native_midi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727
typedef struct _NativeMidiSong NativeMidiSong;
2828

29-
int native_midi_detect(void);
29+
bool native_midi_detect(void);
3030
NativeMidiSong *native_midi_loadsong_IO(SDL_IOStream *src, bool closeio);
3131
void native_midi_freesong(NativeMidiSong *song);
3232
void native_midi_start(NativeMidiSong *song, int loops);
3333
void native_midi_pause(void);
3434
void native_midi_resume(void);
3535
void native_midi_stop(void);
36-
int native_midi_active(void);
36+
bool native_midi_active(void);
3737
void native_midi_setvolume(int volume);
3838
const char *native_midi_error(void);
3939

src/codecs/native_midi/native_midi_haiku.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct _NativeMidiSong {
206206

207207
char lasterr[1024];
208208

209-
int native_midi_detect(void)
209+
bool native_midi_detect(void)
210210
{
211211
status_t res = synth.EnableInput(true, false);
212212
return res == B_OK;
@@ -281,9 +281,9 @@ void native_midi_stop(void)
281281
currentSong = NULL;
282282
}
283283

284-
int native_midi_active(void)
284+
bool native_midi_active(void)
285285
{
286-
if (currentSong == NULL) return 0;
286+
if (currentSong == NULL) return false;
287287
return currentSong->store->IsPlaying();
288288
}
289289

src/codecs/native_midi/native_midi_macosx.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ SetSequenceSoundFont(MusicSequence sequence)
191191
return;
192192
}
193193

194-
int native_midi_detect(void)
194+
bool native_midi_detect(void)
195195
{
196-
return 1; /* always available. */
196+
return true; /* always available. */
197197
}
198198

199199
NativeMidiSong *native_midi_loadsong_IO(SDL_IOStream *src, bool closeio)
@@ -319,22 +319,22 @@ void native_midi_stop(void)
319319
}
320320
}
321321

322-
int native_midi_active(void)
322+
bool native_midi_active(void)
323323
{
324324
MusicTimeStamp currentTime = 0;
325325
if (currentsong == NULL)
326-
return 0;
326+
return false;
327327

328328
MusicPlayerGetTime(currentsong->player, &currentTime);
329329
if ((currentTime < currentsong->endTime) ||
330330
(currentTime >= kMusicTimeStamp_EndOfTrack)) {
331-
return 1;
331+
return true;
332332
} else if (currentsong->loops) {
333333
--currentsong->loops;
334334
MusicPlayerSetTime(currentsong->player, 0);
335-
return 1;
335+
return true;
336336
}
337-
return 0;
337+
return false;
338338
}
339339

340340
void native_midi_setvolume(int volume)

src/codecs/native_midi/native_midi_win32.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#include "native_midi_common.h"
3333

3434
struct _NativeMidiSong {
35-
int MusicLoaded;
36-
int MusicPlaying;
35+
bool MusicLoaded;
36+
bool MusicPlaying;
3737
int Loops;
3838
int CurrentHdr;
3939
MIDIHDR MidiStreamHdr[2];
@@ -159,7 +159,7 @@ static void MIDItoStream(NativeMidiSong *song, MIDIEvent *evntlist)
159159
}
160160
}
161161
song->NewPos=0;
162-
song->MusicLoaded=1;
162+
song->MusicLoaded = true;
163163
}
164164

165165
void CALLBACK MidiProc( HMIDIIN hMidi, UINT uMsg, DWORD_PTR dwInstance,
@@ -188,29 +188,29 @@ void CALLBACK MidiProc( HMIDIIN hMidi, UINT uMsg, DWORD_PTR dwInstance,
188188
song->NewPos=0;
189189
BlockOut(song);
190190
} else {
191-
song->MusicPlaying=0;
191+
song->MusicPlaying = false;
192192
}
193193
}
194194
break;
195195
case MOM_CLOSE:
196-
song->MusicPlaying=0;
196+
song->MusicPlaying = false;
197197
break;
198198
default:
199199
break;
200200
}
201201
SDL_UnlockMutex(song->mutex);
202202
}
203203

204-
int native_midi_detect(void)
204+
bool native_midi_detect(void)
205205
{
206206
MMRESULT merr;
207207
HMIDISTRM MidiStream;
208208

209209
merr=midiStreamOpen(&MidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION);
210-
if (merr!=MMSYSERR_NOERROR)
211-
return 0;
210+
if (merr != MMSYSERR_NOERROR)
211+
return false;
212212
midiStreamClose(MidiStream);
213-
return 1;
213+
return true;
214214
}
215215

216216
NativeMidiSong *native_midi_loadsong_IO(SDL_IOStream *src, bool closeio)
@@ -272,7 +272,7 @@ void native_midi_start(NativeMidiSong *song, int loops)
272272
/* midiStreamStop(hMidiStream); */
273273
currentsong=song;
274274
currentsong->NewPos=0;
275-
currentsong->MusicPlaying=1;
275+
currentsong->MusicPlaying = true;
276276
currentsong->Loops=loops;
277277
mptd.cbStruct=sizeof(MIDIPROPTIMEDIV);
278278
mptd.dwTimeDiv=currentsong->ppqn;
@@ -311,12 +311,12 @@ void native_midi_stop(void)
311311
SDL_UnlockMutex(song->mutex);
312312
}
313313

314-
int native_midi_active(void)
314+
bool native_midi_active(void)
315315
{
316316
if (!hMidiStream)
317-
return 0;
317+
return false;
318318
if (!currentsong)
319-
return 0;
319+
return false;
320320
return currentsong->MusicPlaying;
321321
}
322322

0 commit comments

Comments
 (0)