diff options
author | peter1138 <peter1138@openttd.org> | 2007-07-05 12:23:54 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2007-07-05 12:23:54 +0000 |
commit | 5e85e8c5e03105e43cf9f2216e993c0596d7dfec (patch) | |
tree | 52e0cc5b1e4eb6cf9aed8556873ee6833662e11f /src/music/libtimidity.cpp | |
parent | 7884a07b43fd293a2ca5b39b64df98b700959874 (diff) | |
download | openttd-5e85e8c5e03105e43cf9f2216e993c0596d7dfec.tar.xz |
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
Diffstat (limited to 'src/music/libtimidity.cpp')
-rw-r--r-- | src/music/libtimidity.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/music/libtimidity.cpp b/src/music/libtimidity.cpp index f25b0bfff..5368bbd68 100644 --- a/src/music/libtimidity.cpp +++ b/src/music/libtimidity.cpp @@ -44,7 +44,9 @@ static void AudioOutCallback(void *buf, unsigned int _reqn, void *userdata) } #endif /* PSP */ -static const char *LibtimidityMidiStart(const char *const *param) +static FMusicDriver_LibTimidity iFMusicDriver_LibTimidity; + +const char *MusicDriver_LibTimidity::Start(const char *const *param) { _midi.status = MIDI_STOPPED; @@ -53,8 +55,7 @@ static const char *LibtimidityMidiStart(const char *const *param) * If it was not forced via param, try to load it without a * configuration. Who knows that works. */ if (param != NULL || mid_init_no_config() < 0) { - DEBUG(driver, 0, "error initializing timidity"); - return NULL; + return "error initializing timidity"; } } DEBUG(driver, 1, "successfully initialised timidity"); @@ -77,7 +78,7 @@ static const char *LibtimidityMidiStart(const char *const *param) return NULL; } -static void LibtimidityMidiStop() +void MusicDriver_LibTimidity::Stop() { if (_midi.status == MIDI_PLAYING) { _midi.status = MIDI_STOPPED; @@ -86,7 +87,7 @@ static void LibtimidityMidiStop() mid_exit(); } -static void LibtimidityMidiPlaySong(const char *filename) +void MusicDriver_LibTimidity::PlaySong(const char *filename) { _midi.stream = mid_istream_open_file(filename); if (_midi.stream == NULL) { @@ -107,13 +108,13 @@ static void LibtimidityMidiPlaySong(const char *filename) _midi.status = MIDI_PLAYING; } -static void LibtimidityMidiStopSong() +void MusicDriver_LibTimidity::StopSong() { _midi.status = MIDI_STOPPED; mid_song_free(_midi.song); } -static bool LibtimidityMidiIsPlaying() +bool MusicDriver_LibTimidity::IsSongPlaying() { if (_midi.status == MIDI_PLAYING) { _midi.song_position = mid_song_get_time(_midi.song); @@ -126,18 +127,8 @@ static bool LibtimidityMidiIsPlaying() return (_midi.status == MIDI_PLAYING); } -static void LibtimidityMidiSetVolume(byte vol) +void MusicDriver_LibTimidity::SetVolume(byte vol) { if (_midi.song != NULL) mid_song_set_volume(_midi.song, vol); } - -const HalMusicDriver _libtimidity_music_driver = { - LibtimidityMidiStart, - LibtimidityMidiStop, - LibtimidityMidiPlaySong, - LibtimidityMidiStopSong, - LibtimidityMidiIsPlaying, - LibtimidityMidiSetVolume, -}; - |