mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r16012) -Codechange: Code style clean up.
This commit is contained in:
parent
9acb1dc3f2
commit
6bf1a49475
|
@ -56,8 +56,9 @@ const char *MusicDriver_DMusic::Start(const char * const *parm)
|
|||
if (performance != NULL) return NULL;
|
||||
|
||||
if (proc.CoCreateInstance == NULL) {
|
||||
if (!LoadLibraryList((Function*)&proc, ole_files))
|
||||
if (!LoadLibraryList((Function*)&proc, ole_files)) {
|
||||
return "ole32.dll load failed";
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize COM */
|
||||
|
|
|
@ -52,8 +52,9 @@ void MusicDriver_ExtMidi::StopSong()
|
|||
|
||||
bool MusicDriver_ExtMidi::IsSongPlaying()
|
||||
{
|
||||
if (this->pid != -1 && waitpid(this->pid, NULL, WNOHANG) == this->pid)
|
||||
if (this->pid != -1 && waitpid(this->pid, NULL, WNOHANG) == this->pid) {
|
||||
this->pid = -1;
|
||||
}
|
||||
if (this->pid == -1 && this->song[0] != '\0') this->DoPlay();
|
||||
return this->pid != -1;
|
||||
}
|
||||
|
@ -68,10 +69,8 @@ void MusicDriver_ExtMidi::DoPlay()
|
|||
this->pid = fork();
|
||||
switch (this->pid) {
|
||||
case 0: {
|
||||
int d;
|
||||
|
||||
close(0);
|
||||
d = open("/dev/null", O_RDONLY);
|
||||
int d = open("/dev/null", O_RDONLY);
|
||||
if (d != -1 && dup2(d, 1) != -1 && dup2(d, 2) != -1) {
|
||||
#if defined(MIDI_ARG)
|
||||
execlp(this->command, "extmidi", MIDI_ARG, this->song, (char*)0);
|
||||
|
|
|
@ -38,8 +38,9 @@ void MusicDriver_OS2::PlaySong(const char *filename)
|
|||
{
|
||||
MidiSendCommand("close all");
|
||||
|
||||
if (MidiSendCommand("open %s type sequencer alias song", filename) != 0)
|
||||
if (MidiSendCommand("open %s type sequencer alias song", filename) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
MidiSendCommand("play song from 0");
|
||||
}
|
||||
|
|
|
@ -121,8 +121,9 @@ static bool LoadMovieForMIDIFile(const char *path, Movie *moov)
|
|||
if (ret < 4) return false;
|
||||
|
||||
DEBUG(driver, 3, "qtmidi: header is '%.4s'", magic);
|
||||
if (magic[0] != 'M' || magic[1] != 'T' || magic[2] != 'h' || magic[3] != 'd')
|
||||
if (magic[0] != 'M' || magic[1] != 'T' || magic[2] != 'h' || magic[3] != 'd') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (noErr != FSPathMakeRef((const UInt8 *) path, &fsref, NULL)) return false;
|
||||
SetMIDITypeIfNeeded(&fsref);
|
||||
|
@ -218,13 +219,15 @@ bool MusicDriver_QtMidi::IsSongPlaying()
|
|||
case QT_STATE_STOP:
|
||||
/* Do nothing. */
|
||||
break;
|
||||
|
||||
case QT_STATE_PLAY:
|
||||
MoviesTask(_quicktime_movie, 0);
|
||||
/* Check wether movie ended. */
|
||||
if (IsMovieDone(_quicktime_movie) ||
|
||||
(GetMovieTime(_quicktime_movie, NULL) >=
|
||||
GetMovieDuration(_quicktime_movie)))
|
||||
GetMovieDuration(_quicktime_movie))) {
|
||||
_quicktime_state = QT_STATE_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
return _quicktime_state == QT_STATE_PLAY;
|
||||
|
@ -247,8 +250,11 @@ void MusicDriver_QtMidi::Stop()
|
|||
DEBUG(driver, 3, "qtmidi: stopping not needed, already idle");
|
||||
/* Do nothing. */
|
||||
break;
|
||||
|
||||
case QT_STATE_PLAY:
|
||||
StopSong();
|
||||
/* Fall-through */
|
||||
|
||||
case QT_STATE_STOP:
|
||||
DisposeMovie(_quicktime_movie);
|
||||
}
|
||||
|
@ -272,12 +278,14 @@ void MusicDriver_QtMidi::PlaySong(const char *filename)
|
|||
case QT_STATE_PLAY:
|
||||
StopSong();
|
||||
DEBUG(driver, 3, "qtmidi: previous tune stopped");
|
||||
/* XXX Fall-through -- no break needed. */
|
||||
/* Fall-through -- no break needed. */
|
||||
|
||||
case QT_STATE_STOP:
|
||||
DisposeMovie(_quicktime_movie);
|
||||
DEBUG(driver, 3, "qtmidi: previous tune disposed");
|
||||
_quicktime_state = QT_STATE_IDLE;
|
||||
/* XXX Fall-through -- no break needed. */
|
||||
/* Fall-through -- no break needed. */
|
||||
|
||||
case QT_STATE_IDLE:
|
||||
LoadMovieForMIDIFile(filename, &_quicktime_movie);
|
||||
SetMovieVolume(_quicktime_movie, VOLUME);
|
||||
|
@ -297,11 +305,13 @@ void MusicDriver_QtMidi::StopSong()
|
|||
|
||||
switch (_quicktime_state) {
|
||||
case QT_STATE_IDLE:
|
||||
/* XXX Fall-through -- no break needed. */
|
||||
/* Fall-through -- no break needed. */
|
||||
|
||||
case QT_STATE_STOP:
|
||||
DEBUG(driver, 3, "qtmidi: stop requested, but already idle");
|
||||
/* Do nothing. */
|
||||
break;
|
||||
|
||||
case QT_STATE_PLAY:
|
||||
StopMovie(_quicktime_movie);
|
||||
_quicktime_state = QT_STATE_STOP;
|
||||
|
@ -330,6 +340,7 @@ void MusicDriver_QtMidi::SetVolume(byte vol)
|
|||
case QT_STATE_IDLE:
|
||||
/* Do nothing. */
|
||||
break;
|
||||
|
||||
case QT_STATE_PLAY:
|
||||
case QT_STATE_STOP:
|
||||
SetMovieVolume(_quicktime_movie, VOLUME);
|
||||
|
|
Loading…
Reference in New Issue