- cleanup of the remaining music code in the main project

This commit is contained in:
Christoph Oelckers 2019-09-30 02:31:12 +02:00
parent d0cf21654e
commit c42deda6e6
11 changed files with 47 additions and 75 deletions

View file

@ -149,10 +149,11 @@ void SetWgOpn(const void* data, unsigned len);
// Set DMXGUS data for running the GUS synth in actual GUS mode. // Set DMXGUS data for running the GUS synth in actual GUS mode.
void SetDmxGus(const void* data, unsigned len); void SetDmxGus(const void* data, unsigned len);
// These exports is needed by the MIDI dumpers which need to remain on the client side. // These exports are needed by the MIDI dumpers which need to remain on the client side.
class MIDISource; // abstract for the client class MIDISource; // abstract for the client
EMIDIType IdentifyMIDIType(uint32_t *id, int size); EMIDIType IdentifyMIDIType(uint32_t *id, int size);
MIDISource *CreateMIDISource(const uint8_t *data, size_t length, EMIDIType miditype); MIDISource *CreateMIDISource(const uint8_t *data, size_t length, EMIDIType miditype);
void MIDIDumpWave(MIDISource* source, EMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate);
class MusInfo; class MusInfo;
// Configuration interface. The return value specifies if a music restart is needed. // Configuration interface. The return value specifies if a music restart is needed.

View file

@ -51,6 +51,7 @@
#include "teaminfo.h" #include "teaminfo.h"
#include "r_data/sprites.h" #include "r_data/sprites.h"
#include "atterm.h" #include "atterm.h"
#include "zmusic/zmusic.h"
void ClearSaveGames(); void ClearSaveGames();

View file

@ -69,7 +69,6 @@
#include "p_effect.h" #include "p_effect.h"
#include "r_utility.h" #include "r_utility.h"
#include "a_morph.h" #include "a_morph.h"
#include "i_music.h"
#include "thingdef.h" #include "thingdef.h"
#include "g_levellocals.h" #include "g_levellocals.h"
#include "actorinlines.h" #include "actorinlines.h"

View file

@ -46,7 +46,6 @@
#include "a_weapons.h" #include "a_weapons.h"
#include "d_player.h" #include "d_player.h"
#include "p_setup.h" #include "p_setup.h"
#include "i_music.h"
#include "am_map.h" #include "am_map.h"
#include "v_video.h" #include "v_video.h"
#include "gi.h" #include "gi.h"

View file

@ -41,7 +41,6 @@
#include "c_dispatch.h" #include "c_dispatch.h"
#include "v_text.h" #include "v_text.h"
#include "i_module.h" #include "i_module.h"
#include "i_music.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "menu/menu.h" #include "menu/menu.h"
#include "zmusic/sounddecoder.h" #include "zmusic/sounddecoder.h"

View file

@ -45,17 +45,19 @@
#include "c_dispatch.h" #include "c_dispatch.h"
#include "templates.h" #include "templates.h"
#include "stats.h" #include "stats.h"
#include "c_cvars.h"
#include "c_console.h" #include "c_console.h"
#include "vm.h" #include "vm.h"
#include "v_text.h" #include "v_text.h"
#include "i_sound.h"
#include "i_soundfont.h" #include "i_soundfont.h"
#include "s_music.h" #include "s_music.h"
#include "doomstat.h"
#include "zmusic/zmusic.h" #include "zmusic/zmusic.h"
#include "zmusic/musinfo.h" #include "zmusic/musinfo.h"
#include "streamsources/streamsource.h" #include "streamsources/streamsource.h"
#include "filereadermusicinterface.h" #include "filereadermusicinterface.h"
#include "../libraries/zmusic/midisources/midisource.h" #include "../libraries/zmusic/midisources/midisource.h"
#include "../libraries/dumb/include/dumb.h"
#define GZIP_ID1 31 #define GZIP_ID1 31
#define GZIP_ID2 139 #define GZIP_ID2 139
@ -68,9 +70,9 @@
#define GZIP_FNAME 8 #define GZIP_FNAME 8
#define GZIP_FCOMMENT 16 #define GZIP_FCOMMENT 16
extern int MUSHeaderSearch(const uint8_t *head, int len);
void I_InitSoundFonts(); void I_InitSoundFonts();
extern "C" void dumb_exit();
extern MusPlayingInfo mus_playing; extern MusPlayingInfo mus_playing;
EXTERN_CVAR (Int, snd_samplerate) EXTERN_CVAR (Int, snd_samplerate)
@ -80,7 +82,6 @@ static bool MusicDown = true;
static bool ungzip(uint8_t *data, int size, std::vector<uint8_t> &newdata); static bool ungzip(uint8_t *data, int size, std::vector<uint8_t> &newdata);
MusInfo *currSong;
int nomusic = 0; int nomusic = 0;
//========================================================================== //==========================================================================
@ -275,16 +276,14 @@ void I_ShutdownMusic(bool onexit)
if (MusicDown) if (MusicDown)
return; return;
MusicDown = true; MusicDown = true;
if (currSong) if (mus_playing.handle)
{ {
S_StopMusic (true); S_StopMusic (true);
assert (currSong == nullptr); assert (mus_playing.handle == nullptr);
} }
if (onexit) if (onexit)
{ {
// free static data in the backends. ZMusic_Shutdown();
TimidityPP_Shutdown();
dumb_exit();
} }
} }
@ -294,7 +293,7 @@ void I_ShutdownMusic(bool onexit)
// //
//========================================================================== //==========================================================================
MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *device) MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, EMidiDevice device, const char *Args)
{ {
MusInfo *info = nullptr; MusInfo *info = nullptr;
StreamSource *streamsource = nullptr; StreamSource *streamsource = nullptr;
@ -357,14 +356,13 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
return nullptr; return nullptr;
} }
EMidiDevice devtype = device == nullptr ? MDEV_DEFAULT : (EMidiDevice)device->device;
#ifndef _WIN32 #ifndef _WIN32
// non-Windows platforms don't support MDEV_MMAPI so map to MDEV_SNDSYS // non-Windows platforms don't support MDEV_MMAPI so map to MDEV_SNDSYS
if (devtype == MDEV_MMAPI) if (device == MDEV_MMAPI)
devtype = MDEV_SNDSYS; device = MDEV_SNDSYS;
#endif #endif
info = CreateMIDIStreamer(source, devtype, device != nullptr ? device->args.GetChars() : ""); info = CreateMIDIStreamer(source, device, Args? Args : "");
} }
// Check for CDDA "format" // Check for CDDA "format"
@ -546,15 +544,6 @@ static bool ungzip(uint8_t *data, int complen, std::vector<uint8_t> &newdata)
// //
//========================================================================== //==========================================================================
void I_UpdateMusic()
{
if (currSong != nullptr)
{
currSong->Update();
}
}
void I_SetRelativeVolume(float vol) void I_SetRelativeVolume(float vol)
{ {
relative_volume = (float)vol; relative_volume = (float)vol;

View file

@ -34,10 +34,6 @@
#ifndef __I_MUSIC_H__ #ifndef __I_MUSIC_H__
#define __I_MUSIC_H__ #define __I_MUSIC_H__
#include "doomdef.h"
#include "zmusic/mididefs.h"
#include "i_soundinternal.h"
class FileReader; class FileReader;
struct FOptionValues; struct FOptionValues;
@ -47,17 +43,11 @@ struct FOptionValues;
void I_InitMusic (); void I_InitMusic ();
void I_ShutdownMusic (bool onexit = false); void I_ShutdownMusic (bool onexit = false);
void I_BuildMIDIMenuList (FOptionValues *); void I_BuildMIDIMenuList (FOptionValues *);
void I_UpdateMusic ();
// Volume. // Volume.
void I_SetRelativeVolume(float); void I_SetRelativeVolume(float);
void I_SetMusicVolume (double volume); void I_SetMusicVolume (double volume);
// Registers a song handle to song data.
class MusInfo;
struct MidiDeviceSetting;
MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *device);
MusInfo *I_RegisterCDSong (int track, int cdid = 0);
extern int nomusic; extern int nomusic;

View file

@ -1,42 +1,32 @@
#include <stdint.h>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include "c_cvars.h" #include "zmusic/zmusic.h"
#include "i_sound.h"
#include "i_music.h"
#include "s_sound.h"
#include "files.h"
#include "zmusic/midiconfig.h"
#include "zmusic/mididefs.h"
#include "zmusic/..//mididevices/mididevice.h" // this is still needed...
void I_InitMusicWin32 ();
class MIDISource; class MIDISource;
class MIDIDevice; class MIDIDevice;
class OPLmusicFile; class OPLmusicFile;
// Data interface
// Module played via foo_dumb -----------------------------------------------
class StreamSource; class StreamSource;
class MusInfo;
// stream song ------------------------------------------
MusInfo *OpenStreamSong(StreamSource *source); MusInfo *OpenStreamSong(StreamSource *source);
const char *GME_CheckFormat(uint32_t header); const char *GME_CheckFormat(uint32_t header);
MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader); MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader);
MusInfo* CD_OpenSong(int track, int id); MusInfo* CD_OpenSong(int track, int id);
MusInfo* CreateMIDIStreamer(MIDISource *source, EMidiDevice devtype, const char* args); MusInfo* CreateMIDIStreamer(MIDISource *source, EMidiDevice devtype, const char* args);
void MIDIDumpWave(MIDISource* source, EMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate);
// -------------------------------------------------------------------------- // Registers a song handle to song data.
extern MusInfo *currSong; MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, EMidiDevice device, const char *Args);
void MIDIDeviceChanged(int newdev, bool force = false); MusInfo *I_RegisterCDSong (int track, int cdid = 0);
EXTERN_CVAR (Float, snd_mastervolume) void TimidityPP_Shutdown();
EXTERN_CVAR (Float, snd_musicvolume) extern "C" void dumb_exit();
inline void ZMusic_Shutdown()
{
// free static data in the backends.
TimidityPP_Shutdown();
dumb_exit();
}

View file

@ -33,7 +33,9 @@
** **
*/ */
#include "i_musicinterns.h" #include <stdint.h>
#include <mutex>
#include <string>
#include "c_cvars.h" #include "c_cvars.h"
#include "s_music.h" #include "s_music.h"
#include "zmusic/zmusic.h" #include "zmusic/zmusic.h"

View file

@ -38,7 +38,6 @@
#include <mmsystem.h> #include <mmsystem.h>
#endif #endif
#include "i_musicinterns.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "v_text.h" #include "v_text.h"

View file

@ -89,6 +89,8 @@
#include "filereadermusicinterface.h" #include "filereadermusicinterface.h"
#include "zmusic/musinfo.h" #include "zmusic/musinfo.h"
#include "i_musicinterns.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -269,17 +271,18 @@ void S_ResumeMusic ()
void S_UpdateMusic () void S_UpdateMusic ()
{ {
I_UpdateMusic(); if (mus_playing.handle != nullptr)
// [RH] Update music and/or playlist. IsPlaying() must be called
// to attempt to reconnect to broken net streams and to advance the
// playlist when the current song finishes.
if (mus_playing.handle != nullptr &&
!mus_playing.handle->IsPlaying() &&
PlayList)
{ {
PlayList->Advance(); mus_playing.handle->Update();
S_ActivatePlayList(false);
// [RH] Update music and/or playlist. IsPlaying() must be called
// to attempt to reconnect to broken net streams and to advance the
// playlist when the current song finishes.
if (!mus_playing.handle->IsPlaying() && PlayList)
{
PlayList->Advance();
S_ActivatePlayList(false);
}
} }
} }
@ -540,7 +543,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
try try
{ {
auto mreader = new FileReaderMusicInterface(reader); auto mreader = new FileReaderMusicInterface(reader);
mus_playing.handle = I_RegisterSong(mreader, devp); mus_playing.handle = I_RegisterSong(mreader, devp? (EMidiDevice)devp->device : MDEV_DEFAULT, devp? devp->args.GetChars() : "");
} }
catch (const std::runtime_error& err) catch (const std::runtime_error& err)
{ {