summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-01-08 12:05:14 +0000
committerpeter1138 <peter1138@openttd.org>2009-01-08 12:05:14 +0000
commit020dbb180a11d27b2064640953f3960ede09f9c6 (patch)
treefce554a01119cd5d6c7bf58f770a96d121a41f35
parent45f1d83bc76d7d4d47885cf8489669300d072f8c (diff)
downloadopenttd-020dbb180a11d27b2064640953f3960ede09f9c6.tar.xz
(svn r14909) -Codechange: Remove global option for the extmidi driver and make it a driver parameter with the name cmd instead. This means if you have an "extmidi = ..." line in your config you must change it to "musicdriver = extmidi:cmd=...", in the [misc] section.
-rw-r--r--src/music/extmidi.cpp13
-rw-r--r--src/music/extmidi.h1
-rw-r--r--src/settings.cpp5
-rw-r--r--src/sound_type.h1
4 files changed, 12 insertions, 8 deletions
diff --git a/src/music/extmidi.cpp b/src/music/extmidi.cpp
index cba772506..6179501a6 100644
--- a/src/music/extmidi.cpp
+++ b/src/music/extmidi.cpp
@@ -17,10 +17,18 @@
#include <sys/stat.h>
#include <errno.h>
+#ifndef EXTERNAL_PLAYER
+#define EXTERNAL_PLAYER "timidity"
+#endif
+
static FMusicDriver_ExtMidi iFMusicDriver_ExtMidi;
const char* MusicDriver_ExtMidi::Start(const char* const * parm)
{
+ const char *command = GetDriverParam(parm, "cmd");
+ if (StrEmpty(command)) command = EXTERNAL_PLAYER;
+
+ this->command = strdup(command);
this->song[0] = '\0';
this->pid = -1;
return NULL;
@@ -28,6 +36,7 @@ const char* MusicDriver_ExtMidi::Start(const char* const * parm)
void MusicDriver_ExtMidi::Stop()
{
+ free(command);
this->song[0] = '\0';
this->DoStop();
}
@@ -68,9 +77,9 @@ void MusicDriver_ExtMidi::DoPlay()
d = open("/dev/null", O_RDONLY);
if (d != -1 && dup2(d, 1) != -1 && dup2(d, 2) != -1) {
#if defined(MIDI_ARG)
- execlp(msf.extmidi, "extmidi", MIDI_ARG, this->song, (char*)0);
+ execlp(this->command, "extmidi", MIDI_ARG, this->song, (char*)0);
#else
- execlp(msf.extmidi, "extmidi", this->song, (char*)0);
+ execlp(this->command, "extmidi", this->song, (char*)0);
#endif
}
_exit(1);
diff --git a/src/music/extmidi.h b/src/music/extmidi.h
index b5af27722..bae1e1b4f 100644
--- a/src/music/extmidi.h
+++ b/src/music/extmidi.h
@@ -9,6 +9,7 @@
class MusicDriver_ExtMidi: public MusicDriver {
private:
+ char *command;
char song[MAX_PATH];
pid_t pid;
diff --git a/src/settings.cpp b/src/settings.cpp
index c26ad66ae..abbeec8c0 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1127,10 +1127,6 @@ static int32 UpdateRconPassword(int32 p1)
/* End - Callback Functions */
-#ifndef EXTERNAL_PLAYER
-#define EXTERNAL_PLAYER "timidity"
-#endif
-
static const SettingDesc _music_settings[] = {
SDT_VAR(MusicFileSettings, playlist, SLE_UINT8, S, 0, 0, 0, 5, 1, STR_NULL, NULL),
SDT_VAR(MusicFileSettings, music_vol, SLE_UINT8, S, 0, 127, 0, 127, 1, STR_NULL, NULL),
@@ -1139,7 +1135,6 @@ static const SettingDesc _music_settings[] = {
SDT_LIST(MusicFileSettings, custom_2, SLE_UINT8, S, 0, NULL, STR_NULL, NULL),
SDT_BOOL(MusicFileSettings, playing, S, 0, true, STR_NULL, NULL),
SDT_BOOL(MusicFileSettings, shuffle, S, 0, false, STR_NULL, NULL),
- SDT_STR(MusicFileSettings, extmidi, SLE_STRB, S, 0, EXTERNAL_PLAYER, STR_NULL, NULL),
SDT_END()
};
diff --git a/src/sound_type.h b/src/sound_type.h
index 3fdf3aef5..8efc6a22a 100644
--- a/src/sound_type.h
+++ b/src/sound_type.h
@@ -15,7 +15,6 @@ struct MusicFileSettings {
byte custom_2[33];
bool playing;
bool shuffle;
- char extmidi[80];
};
struct FileEntry {