mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- cleanup of the remaining music code in the main project
This commit is contained in:
parent
d0cf21654e
commit
c42deda6e6
11 changed files with 47 additions and 75 deletions
|
@ -149,10 +149,11 @@ void SetWgOpn(const void* data, unsigned len);
|
|||
// Set DMXGUS data for running the GUS synth in actual GUS mode.
|
||||
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
|
||||
EMIDIType IdentifyMIDIType(uint32_t *id, int size);
|
||||
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;
|
||||
// Configuration interface. The return value specifies if a music restart is needed.
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "teaminfo.h"
|
||||
#include "r_data/sprites.h"
|
||||
#include "atterm.h"
|
||||
#include "zmusic/zmusic.h"
|
||||
|
||||
|
||||
void ClearSaveGames();
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
#include "p_effect.h"
|
||||
#include "r_utility.h"
|
||||
#include "a_morph.h"
|
||||
#include "i_music.h"
|
||||
#include "thingdef.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "actorinlines.h"
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "a_weapons.h"
|
||||
#include "d_player.h"
|
||||
#include "p_setup.h"
|
||||
#include "i_music.h"
|
||||
#include "am_map.h"
|
||||
#include "v_video.h"
|
||||
#include "gi.h"
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "c_dispatch.h"
|
||||
#include "v_text.h"
|
||||
#include "i_module.h"
|
||||
#include "i_music.h"
|
||||
#include "cmdlib.h"
|
||||
#include "menu/menu.h"
|
||||
#include "zmusic/sounddecoder.h"
|
||||
|
|
|
@ -45,17 +45,19 @@
|
|||
#include "c_dispatch.h"
|
||||
#include "templates.h"
|
||||
#include "stats.h"
|
||||
#include "c_cvars.h"
|
||||
#include "c_console.h"
|
||||
#include "vm.h"
|
||||
#include "v_text.h"
|
||||
#include "i_sound.h"
|
||||
#include "i_soundfont.h"
|
||||
#include "s_music.h"
|
||||
#include "doomstat.h"
|
||||
#include "zmusic/zmusic.h"
|
||||
#include "zmusic/musinfo.h"
|
||||
#include "streamsources/streamsource.h"
|
||||
#include "filereadermusicinterface.h"
|
||||
#include "../libraries/zmusic/midisources/midisource.h"
|
||||
#include "../libraries/dumb/include/dumb.h"
|
||||
|
||||
#define GZIP_ID1 31
|
||||
#define GZIP_ID2 139
|
||||
|
@ -68,9 +70,9 @@
|
|||
#define GZIP_FNAME 8
|
||||
#define GZIP_FCOMMENT 16
|
||||
|
||||
extern int MUSHeaderSearch(const uint8_t *head, int len);
|
||||
|
||||
void I_InitSoundFonts();
|
||||
extern "C" void dumb_exit();
|
||||
|
||||
extern MusPlayingInfo mus_playing;
|
||||
|
||||
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);
|
||||
|
||||
MusInfo *currSong;
|
||||
int nomusic = 0;
|
||||
|
||||
//==========================================================================
|
||||
|
@ -275,16 +276,14 @@ void I_ShutdownMusic(bool onexit)
|
|||
if (MusicDown)
|
||||
return;
|
||||
MusicDown = true;
|
||||
if (currSong)
|
||||
if (mus_playing.handle)
|
||||
{
|
||||
S_StopMusic (true);
|
||||
assert (currSong == nullptr);
|
||||
assert (mus_playing.handle == nullptr);
|
||||
}
|
||||
if (onexit)
|
||||
{
|
||||
// free static data in the backends.
|
||||
TimidityPP_Shutdown();
|
||||
dumb_exit();
|
||||
ZMusic_Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
StreamSource *streamsource = nullptr;
|
||||
|
@ -357,14 +356,13 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
EMidiDevice devtype = device == nullptr ? MDEV_DEFAULT : (EMidiDevice)device->device;
|
||||
#ifndef _WIN32
|
||||
// non-Windows platforms don't support MDEV_MMAPI so map to MDEV_SNDSYS
|
||||
if (devtype == MDEV_MMAPI)
|
||||
devtype = MDEV_SNDSYS;
|
||||
if (device == MDEV_MMAPI)
|
||||
device = MDEV_SNDSYS;
|
||||
#endif
|
||||
|
||||
info = CreateMIDIStreamer(source, devtype, device != nullptr ? device->args.GetChars() : "");
|
||||
info = CreateMIDIStreamer(source, device, Args? Args : "");
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
relative_volume = (float)vol;
|
||||
|
|
|
@ -34,10 +34,6 @@
|
|||
#ifndef __I_MUSIC_H__
|
||||
#define __I_MUSIC_H__
|
||||
|
||||
#include "doomdef.h"
|
||||
#include "zmusic/mididefs.h"
|
||||
#include "i_soundinternal.h"
|
||||
|
||||
class FileReader;
|
||||
struct FOptionValues;
|
||||
|
||||
|
@ -47,17 +43,11 @@ struct FOptionValues;
|
|||
void I_InitMusic ();
|
||||
void I_ShutdownMusic (bool onexit = false);
|
||||
void I_BuildMIDIMenuList (FOptionValues *);
|
||||
void I_UpdateMusic ();
|
||||
|
||||
// Volume.
|
||||
void I_SetRelativeVolume(float);
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,42 +1,32 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include "c_cvars.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 ();
|
||||
#include "zmusic/zmusic.h"
|
||||
|
||||
class MIDISource;
|
||||
class MIDIDevice;
|
||||
class OPLmusicFile;
|
||||
|
||||
|
||||
// Data interface
|
||||
|
||||
// Module played via foo_dumb -----------------------------------------------
|
||||
|
||||
class StreamSource;
|
||||
|
||||
// stream song ------------------------------------------
|
||||
class MusInfo;
|
||||
|
||||
MusInfo *OpenStreamSong(StreamSource *source);
|
||||
const char *GME_CheckFormat(uint32_t header);
|
||||
MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader);
|
||||
MusInfo* CD_OpenSong(int track, int id);
|
||||
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;
|
||||
void MIDIDeviceChanged(int newdev, bool force = false);
|
||||
MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, EMidiDevice device, const char *Args);
|
||||
MusInfo *I_RegisterCDSong (int track, int cdid = 0);
|
||||
|
||||
EXTERN_CVAR (Float, snd_mastervolume)
|
||||
EXTERN_CVAR (Float, snd_musicvolume)
|
||||
void TimidityPP_Shutdown();
|
||||
extern "C" void dumb_exit();
|
||||
|
||||
inline void ZMusic_Shutdown()
|
||||
{
|
||||
// free static data in the backends.
|
||||
TimidityPP_Shutdown();
|
||||
dumb_exit();
|
||||
}
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "i_musicinterns.h"
|
||||
#include <stdint.h>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include "c_cvars.h"
|
||||
#include "s_music.h"
|
||||
#include "zmusic/zmusic.h"
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <mmsystem.h>
|
||||
#endif
|
||||
|
||||
#include "i_musicinterns.h"
|
||||
#include "c_dispatch.h"
|
||||
|
||||
#include "v_text.h"
|
||||
|
|
|
@ -89,6 +89,8 @@
|
|||
#include "filereadermusicinterface.h"
|
||||
#include "zmusic/musinfo.h"
|
||||
|
||||
#include "i_musicinterns.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -269,19 +271,20 @@ void S_ResumeMusic ()
|
|||
|
||||
void S_UpdateMusic ()
|
||||
{
|
||||
I_UpdateMusic();
|
||||
if (mus_playing.handle != nullptr)
|
||||
{
|
||||
mus_playing.handle->Update();
|
||||
|
||||
// [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)
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue