Default MIDI device is now created by sound backend

OpenAL backend now plays music by default
It uses WinMM device on Windows and OPL on other platforms
This commit is contained in:
alexey.lysiuk 2017-03-05 10:01:16 +02:00
parent 938043892a
commit 54ca55f070
7 changed files with 29 additions and 1 deletions

View File

@ -64,6 +64,7 @@ extern HWND Window;
#include "cmdlib.h"
#include "s_sound.h"
#include "files.h"
#include "i_musicinterns.h"
#if FMOD_VERSION > 0x42899 && FMOD_VERSION < 0x43400
#error You are trying to compile with an unsupported version of FMOD.
@ -3478,6 +3479,11 @@ FMOD_RESULT FMODSoundRenderer::SetSystemReverbProperties(const REVERB_PROPERTIES
#endif
}
MIDIDevice* FMODSoundRenderer::CreateMIDIDevice() const
{
return new SndSysMIDIDevice;
}
#endif // NO_FMOD

View File

@ -68,6 +68,8 @@ public:
void DrawWaveDebug(int mode);
virtual MIDIDevice* CreateMIDIDevice() const override;
private:
DWORD ActiveFMODVersion;
int SFXPaused;

View File

@ -250,6 +250,11 @@ public:
{
return "Null sound module has no stats.";
}
virtual MIDIDevice* CreateMIDIDevice() const override
{
return nullptr;
}
};
void I_InitSound ()

View File

@ -85,6 +85,7 @@ public:
typedef bool (*SoundStreamCallback)(SoundStream *stream, void *buff, int len, void *userdata);
struct SoundDecoder;
class MIDIDevice;
class SoundRenderer
{
@ -157,6 +158,8 @@ public:
virtual void DrawWaveDebug(int mode);
virtual MIDIDevice* CreateMIDIDevice() const = 0;
protected:
virtual SoundDecoder *CreateDecoder(FileReader *reader);
};

View File

@ -273,7 +273,7 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype) const
#endif
case MDEV_SNDSYS:
return new SndSysMIDIDevice;
return GSnd->CreateMIDIDevice();
case MDEV_GUS:
return new TimidityMIDIDevice(Args);

View File

@ -2052,6 +2052,16 @@ void OpenALSoundRenderer::PrintDriversList()
}
}
MIDIDevice* OpenALSoundRenderer::CreateMIDIDevice() const
{
#ifdef _WIN32
extern UINT mididevice;
return new WinMIDIDevice(mididevice);
#else
return new OPLMIDIDevice(nullptr);
#endif
}
void OpenALSoundRenderer::PurgeStoppedSources()
{
// Release channels that are stopped

View File

@ -131,6 +131,8 @@ public:
virtual void PrintDriversList();
virtual FString GatherStats();
virtual MIDIDevice* CreateMIDIDevice() const override;
private:
struct {
bool EXT_EFX;