From 03f2cdd9b303d51294cc2147a8f93c9b527686b9 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 19 May 2018 14:14:18 +0000 Subject: [PATCH] Fix MIDI playback on non-Windows platforms git-svn-id: https://svn.eduke32.com/eduke32@6889 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/audiolib/include/music.h | 2 +- source/duke3d/src/music.cpp | 4 +++- source/duke3d/src/sdlmusic.cpp | 6 +++--- source/duke3d/src/sounds.cpp | 2 +- source/sw/src/sounds.cpp | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/audiolib/include/music.h b/source/audiolib/include/music.h index 02263642d..63989bc36 100644 --- a/source/audiolib/include/music.h +++ b/source/audiolib/include/music.h @@ -65,7 +65,7 @@ void MUSIC_SetLoopFlag( int32_t loopflag ); void MUSIC_Continue( void ); void MUSIC_Pause( void ); int32_t MUSIC_StopSong( void ); -int32_t MUSIC_PlaySong( char *song, int32_t loopflag ); +int32_t MUSIC_PlaySong( char *song, int32_t songsize, int32_t loopflag ); void MUSIC_Update(void); #endif diff --git a/source/duke3d/src/music.cpp b/source/duke3d/src/music.cpp index bfb2eadab..d8fdcafec 100644 --- a/source/duke3d/src/music.cpp +++ b/source/duke3d/src/music.cpp @@ -89,8 +89,10 @@ int32_t MUSIC_StopSong(void) } -int32_t MUSIC_PlaySong(char *song, int32_t loopflag) +int32_t MUSIC_PlaySong(char *song, int32_t songsize, int32_t loopflag) { + UNREFERENCED_PARAMETER(songsize); + MUSIC_SetErrorCode(MUSIC_Ok) if (MIDI_PlaySong(song, loopflag) != MIDI_Ok) diff --git a/source/duke3d/src/sdlmusic.cpp b/source/duke3d/src/sdlmusic.cpp index 9cb35d98e..abe37d78f 100644 --- a/source/duke3d/src/sdlmusic.cpp +++ b/source/duke3d/src/sdlmusic.cpp @@ -405,7 +405,7 @@ static void sigchld_handler(int signo) // Duke3D-specific. --ryan. // void MUSIC_PlayMusic(char *_filename) -int32_t MUSIC_PlaySong(char *song, int32_t loopflag) +int32_t MUSIC_PlaySong(char *song, int32_t songsize, int32_t loopflag) { // initprintf("MUSIC_PlaySong"); // TODO: graceful failure @@ -435,7 +435,7 @@ int32_t MUSIC_PlaySong(char *song, int32_t loopflag) fp = Bfopen(external_midi_tempfn, "wb"); if (fp) { - fwrite(song, 1, g_musicSize, fp); + fwrite(song, 1, songsize, fp); Bfclose(fp); #if defined FORK_EXEC_MIDI @@ -450,7 +450,7 @@ int32_t MUSIC_PlaySong(char *song, int32_t loopflag) else initprintf("%s: fopen: %s\n", __func__, strerror(errno)); } else - music_musicchunk = Mix_LoadMUS_RW(SDL_RWFromMem(song, g_musicSize) + music_musicchunk = Mix_LoadMUS_RW(SDL_RWFromMem(song, songsize) #if (SDL_MAJOR_VERSION > 1) , SDL_FALSE #endif diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index 702f4d3a7..55a73488e 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -230,7 +230,7 @@ static int32_t S_PlayMusic(const char *fn) if (!Bmemcmp(MyMusicPtr, "MThd", 4)) { - int32_t retval = MUSIC_PlaySong(MyMusicPtr, MUSIC_LoopSong); + int32_t retval = MUSIC_PlaySong(MyMusicPtr, MyMusicSize, MUSIC_LoopSong); if (retval != MUSIC_Ok) { diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index ab43120b7..049c0ac20 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -501,7 +501,7 @@ PlaySong(char *song_file_name, int cdaudio_track, SWBOOL loop, SWBOOL restart) if (!memcmp(SongPtr, "MThd", 4)) { - MUSIC_PlaySong(SongPtr, /*SongLength,*/ MUSIC_LoopSong); + MUSIC_PlaySong(SongPtr, SongLength, MUSIC_LoopSong); SongType = SongTypeMIDI; SongName = strdup(song_file_name); return TRUE;