Fix MIDI playback on non-Windows platforms

git-svn-id: https://svn.eduke32.com/eduke32@6889 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-05-19 14:14:18 +00:00
parent 5ee2bbc771
commit 03f2cdd9b3
5 changed files with 9 additions and 7 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)
{

View file

@ -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;