diff options
author | rubidium <rubidium@openttd.org> | 2007-01-02 19:19:48 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-01-02 19:19:48 +0000 |
commit | 013df98f79866a75f367853c9e436f3c5c79f645 (patch) | |
tree | ad4a63860df2626b22f77e7dac712e958bea54cb /music/extmidi.c | |
parent | 3d32fd3f4bfaceb8a48530fbc2f4bd5db2752596 (diff) | |
download | openttd-013df98f79866a75f367853c9e436f3c5c79f645.tar.xz |
(svn r7759) -Merge: makefile rewrite. This merge features:
- A proper ./configure, so everything needs to be configured only once, not for every make.
- Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies.
- A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC.
- Proper support for OSX universal binaries.
- Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files.
- Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files.
Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy.
Diffstat (limited to 'music/extmidi.c')
-rw-r--r-- | music/extmidi.c | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/music/extmidi.c b/music/extmidi.c deleted file mode 100644 index 901fa4fd7..000000000 --- a/music/extmidi.c +++ /dev/null @@ -1,108 +0,0 @@ -/* $Id$ */ - -#ifndef __MORPHOS__ -#include "../stdafx.h" -#include "../openttd.h" -#include "../sound.h" -#include "../string.h" -#include "../variables.h" -#include "../debug.h" -#include "extmidi.h" -#include <fcntl.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> -#include <signal.h> -#include <sys/stat.h> -#include <errno.h> - -static struct { - char song[MAX_PATH]; - pid_t pid; -} _midi; - -static void DoPlay(void); -static void DoStop(void); - -static const char* ExtMidiStart(const char* const * parm) -{ - _midi.song[0] = '\0'; - _midi.pid = -1; - return NULL; -} - -static void ExtMidiStop(void) -{ - _midi.song[0] = '\0'; - DoStop(); -} - -static void ExtMidiPlaySong(const char* filename) -{ - ttd_strlcpy(_midi.song, filename, lengthof(_midi.song)); - DoStop(); -} - -static void ExtMidiStopSong(void) -{ - _midi.song[0] = '\0'; - DoStop(); -} - -static bool ExtMidiIsPlaying(void) -{ - if (_midi.pid != -1 && waitpid(_midi.pid, NULL, WNOHANG) == _midi.pid) - _midi.pid = -1; - if (_midi.pid == -1 && _midi.song[0] != '\0') DoPlay(); - return _midi.pid != -1; -} - -static void ExtMidiSetVolume(byte vol) -{ - DEBUG(driver, 1, "extmidi: set volume not implemented"); -} - -static void DoPlay(void) -{ - _midi.pid = fork(); - switch (_midi.pid) { - case 0: { - int d; - - close(0); - 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, _midi.song, (char*)0); - #else - execlp(msf.extmidi, "extmidi", _midi.song, (char*)0); - #endif - } - _exit(1); - } - - case -1: - DEBUG(driver, 0, "extmidi: couldn't fork: %s", strerror(errno)); - /* FALLTHROUGH */ - - default: - _midi.song[0] = '\0'; - break; - } -} - -static void DoStop(void) -{ - if (_midi.pid != -1) kill(_midi.pid, SIGTERM); -} - -const HalMusicDriver _extmidi_music_driver = { - ExtMidiStart, - ExtMidiStop, - ExtMidiPlaySong, - ExtMidiStopSong, - ExtMidiIsPlaying, - ExtMidiSetVolume, -}; - -#endif /* __MORPHOS__ */ |