diff --git a/src/android/i_sound.c b/src/android/i_sound.c index c99f34096..24db3e21d 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -84,6 +84,13 @@ void I_InitMIDIMusic(void){} void I_ShutdownMIDIMusic(void){} +INT32 I_RegisterSong(void *data, size_t len) +{ + (void)data; + (void)len; + return -1; +} + boolean I_PlaySong(INT32 handle, INT32 looping) { (void)handle; diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 6fd743aef..dcf64fa69 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -423,6 +423,19 @@ void I_ShutdownMusic(void) I_ShutdownDigMusic(); } +boolean I_PlaySong(INT32 handle, INT32 looping) +{ + handle = 0; + if (nomidimusic) + return false; + + islooping = looping; + musicdies = gametic + NEWTICRATE*30; + if (play_midi(currsong,looping)==0) + return true; + return false; +} + void I_PauseSong (INT32 handle) { handle = 0; @@ -473,24 +486,11 @@ void I_UnRegisterSong(INT32 handle) //destroy_midi(currsong); } -boolean I_StartDigSong(const char *musicname, INT32 looping) +INT32 I_RegisterSong(void *data, size_t len) { - ///////////////// - // Load the song! - - char *data; - size_t len; - lumpnum_t lumpnum = W_CheckNumForName(va("D_%s",musicname)); - - if (lumpnum == LUMPERROR) - return false; - - data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC); - len = W_LumpLength(lumpnum); - int e = len; //Alam: For error if (nomidimusic) - return false; + return 0; if (memcmp(data,"MThd",4)==0) // support mid file in WAD !!! { @@ -499,25 +499,24 @@ boolean I_StartDigSong(const char *musicname, INT32 looping) else { CONS_Printf("Music Lump is not a MIDI lump\n"); - return false; + return 0; } if (currsong==NULL) { CONS_Printf("Not a valid mid file : %d\n",e); - return false; + return 0; } - ///////////////// - // Play the song! - handle = 0; - if (nomidimusic) - return false; + return 1; +} - islooping = looping; - musicdies = gametic + NEWTICRATE*30; - if (play_midi(currsong,looping)==0) - return true; +/// \todo Add OGG/MP3 support for dos +boolean I_StartDigSong(const char *musicname, INT32 looping) +{ + musicname = NULL; + looping = 0; + //CONS_Printf("I_StartDigSong: Not yet supported under DOS.\n"); return false; } diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 6b2ebeab2..89ccc2b6a 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -83,6 +83,20 @@ void I_InitMIDIMusic(void){} void I_ShutdownMIDIMusic(void){} +INT32 I_RegisterSong(void *data, size_t len) +{ + (void)data; + (void)len; + return -1; +} + +boolean I_PlaySong(INT32 handle, boolean looping) +{ + (void)handle; + (void)looping; + return false; +} + void I_StopSong(INT32 handle) { (void)handle; diff --git a/src/s_sound.c b/src/s_sound.c index b921f733b..6a55523b8 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1308,9 +1308,53 @@ const char *compat_special_music_slots[16] = #define music_playing (music_name[0]) // String is empty if no music is playing static char music_name[7]; // up to 6-character name +static lumpnum_t music_lumpnum; // lump number of music (used??) +static void *music_data; // music raw data +static INT32 music_handle; // once registered, the handle for the music static boolean mus_paused = 0; // whether songs are mus_paused +static boolean S_MIDIMusic(const char *mname, boolean looping) +{ + lumpnum_t mlumpnum; + void *mdata; + INT32 mhandle; + + if (nomidimusic || music_disabled) + return false; // didn't search. + + if (W_CheckNumForName(va("d_%s", mname)) == LUMPERROR) + return false; + mlumpnum = W_GetNumForName(va("d_%s", mname)); + + // load & register it + mdata = W_CacheLumpNum(mlumpnum, PU_MUSIC); + mhandle = I_RegisterSong(mdata, W_LumpLength(mlumpnum)); + +#ifdef MUSSERV + if (msg_id != -1) + { + struct musmsg msg_buffer; + + msg_buffer.msg_type = 6; + memset(msg_buffer.msg_text, 0, sizeof (msg_buffer.msg_text)); + sprintf(msg_buffer.msg_text, "d_%s", mname); + msgsnd(msg_id, (struct msgbuf*)&msg_buffer, sizeof (msg_buffer.msg_text), IPC_NOWAIT); + } +#endif + + // play it + if (!I_PlaySong(mhandle, looping)) + return false; + + strncpy(music_name, mname, 7); + music_name[6] = 0; + music_lumpnum = mlumpnum; + music_data = mdata; + music_handle = mhandle; + return true; +} + static boolean S_DigMusic(const char *mname, boolean looping) { if (nodigimusic || digital_disabled) @@ -1321,6 +1365,9 @@ static boolean S_DigMusic(const char *mname, boolean looping) strncpy(music_name, mname, 7); music_name[6] = 0; + music_lumpnum = LUMPERROR; + music_data = NULL; + music_handle = 0; return true; } @@ -1339,7 +1386,7 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) if (strncmp(music_name, mmusic, 6)) { S_StopMusic(); // shutdown old music - if (!S_DigMusic(mmusic, looping)) + if (!S_DigMusic(mmusic, looping) && !S_MIDIMusic(mmusic, looping)) { CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mmusic); return;