summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-04-10 11:03:48 +0000
committerpeter1138 <peter1138@openttd.org>2009-04-10 11:03:48 +0000
commit6bf1a494756aaf38c947ae06863f5ebe89c2614c (patch)
tree77f13324fa57a032679664936a4fcd165e373673 /src
parent9acb1dc3f2111af3d20b853e6fe0d8123a9c3374 (diff)
downloadopenttd-6bf1a494756aaf38c947ae06863f5ebe89c2614c.tar.xz
(svn r16012) -Codechange: Code style clean up.
Diffstat (limited to 'src')
-rw-r--r--src/music/dmusic.cpp3
-rw-r--r--src/music/extmidi.cpp7
-rw-r--r--src/music/os2_m.cpp3
-rw-r--r--src/music/qtmidi.cpp21
4 files changed, 23 insertions, 11 deletions
diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp
index 0c2291a33..7d9f3d100 100644
--- a/src/music/dmusic.cpp
+++ b/src/music/dmusic.cpp
@@ -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 */
diff --git a/src/music/extmidi.cpp b/src/music/extmidi.cpp
index c3af20140..0bcb1cdd7 100644
--- a/src/music/extmidi.cpp
+++ b/src/music/extmidi.cpp
@@ -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);
diff --git a/src/music/os2_m.cpp b/src/music/os2_m.cpp
index d4ceb23e8..6abee6172 100644
--- a/src/music/os2_m.cpp
+++ b/src/music/os2_m.cpp
@@ -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");
}
diff --git a/src/music/qtmidi.cpp b/src/music/qtmidi.cpp
index 074963992..bb4ef91d2 100644
--- a/src/music/qtmidi.cpp
+++ b/src/music/qtmidi.cpp
@@ -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);