(svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
authorpasky
Sun, 27 Mar 2005 15:42:25 +0000
changeset 1584 aa7fe51c4368
parent 1583 3e1dc56326ae
child 1585 3dc279e97623
(svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
Makefile
extmidi.c
settings.c
sound.h
--- a/Makefile	Sun Mar 27 15:13:51 2005 +0000
+++ b/Makefile	Sun Mar 27 15:42:25 2005 +0000
@@ -62,7 +62,8 @@
 # RELEASE: this will be the released version number. It replaces all places
 #          where it normally would print the revision number
 # MIDI: if set, it will use it as custom path to midi player.
-#  If unset, it will use the hardcoded path in the c code
+#       If unset, it will use the hardcoded path in the c code
+#       This can still be overriden by the music.extmidi openttd.cfg option.
 # WITH_NETWORK: enable networking
 # DEDICATED: allows compilation on UNIX without SDL. Useful for dedicated servers
 #
--- a/extmidi.c	Sun Mar 27 15:13:51 2005 +0000
+++ b/extmidi.c	Sun Mar 27 15:42:25 2005 +0000
@@ -4,6 +4,7 @@
 
 #include "ttd.h"
 #include "hal.h"
+#include "sound.h"
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -11,10 +12,6 @@
 #include <sys/stat.h>
 #include <errno.h>
 
-#ifndef EXTERNAL_PLAYER
-#define EXTERNAL_PLAYER "timidity"
-#endif
-
 static pid_t _pid;
 
 static void extmidi_kill(void)
@@ -50,9 +47,9 @@
 
 	if (_pid == 0) {
 		#if defined(MIDI_ARG)
-			execlp(EXTERNAL_PLAYER, "extmidi", MIDI_ARG, filename, NULL);
+			execlp(msf.extmidi, "extmidi", MIDI_ARG, filename, NULL);
 		#else
-			execlp(EXTERNAL_PLAYER, "extmidi", filename, NULL);
+			execlp(msf.extmidi, "extmidi", filename, NULL);
 		#endif
 		fprintf(stderr, "extmidi: couldn't execl: %s\n", strerror(errno));
 		exit(0);
--- a/settings.c	Sun Mar 27 15:13:51 2005 +0000
+++ b/settings.c	Sun Mar 27 15:42:25 2005 +0000
@@ -716,6 +716,10 @@
 // TTD specific INI stuff
 //***************************
 
+#ifndef EXTERNAL_PLAYER
+#define EXTERNAL_PLAYER "timidity"
+#endif
+
 static const SettingDesc music_settings[] = {
 	{"playlist",	SDT_UINT8,	(void*)0,			&msf.playlist, NULL},
 	{"music_vol", SDT_UINT8,	(void*)128,		&msf.music_vol, NULL},
@@ -724,6 +728,7 @@
 	{"custom_2",	SDT_INTLIST | SDT_UINT8 | lengthof(msf.custom_2) << 16, NULL, &msf.custom_2, NULL},
 	{"playing",		SDT_BOOL,		(void*)true,	&msf.btn_down, NULL},
 	{"shuffle",		SDT_BOOL,		(void*)false, &msf.shuffle, NULL},
+	{"extmidi",   SDT_STRINGBUF | (lengthof(msf.extmidi)<<16), EXTERNAL_PLAYER, &msf.extmidi, NULL},
 	{NULL,				0,					NULL,					NULL,																NULL}
 };
 
--- a/sound.h	Sun Mar 27 15:13:51 2005 +0000
+++ b/sound.h	Sun Mar 27 15:42:25 2005 +0000
@@ -9,6 +9,7 @@
 	byte custom_2[33];
 	bool btn_down;
 	bool shuffle;
+	char extmidi[80];
 } MusicFileSettings;
 
 VARDEF byte _music_wnd_cursong;