Fix music init code

# Conflicts:
#	source/blood/src/config.cpp
#	source/blood/src/menu.cpp
#	source/blood/src/osdcmd.cpp
This commit is contained in:
nukeykt 2019-10-24 22:56:42 +09:00 committed by Christoph Oelckers
parent e6f53f7c30
commit 7f094d3a73
4 changed files with 29 additions and 5 deletions

View file

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "common_game.h" #include "common_game.h"
#include "build.h" #include "build.h"
#include "cache1d.h" #include "cache1d.h"
#include "sndcards.h"
#include "hash.h" #include "hash.h"
#include "scriplib.h" #include "scriplib.h"
#include "renderlayer.h" #include "renderlayer.h"

View file

@ -573,9 +573,18 @@ int nSoundRateValues[] = {
48000 48000
}; };
int nMusicDeviceValues[] = {
ASS_OPL3,
#ifdef _WIN32
ASS_WinMM,
#endif
};
const char *pzMusicDeviceStrings[] = { const char *pzMusicDeviceStrings[] = {
"OPL3(SB/ADLIB)",
#ifdef _WIN32
"SYSTEM MIDI", "SYSTEM MIDI",
"OPL3(SB/ADLIB)" #endif
}; };
CGameMenuItemTitle itemOptionsSoundTitle("SOUND SETUP", 1, 160, 20, 2038); CGameMenuItemTitle itemOptionsSoundTitle("SOUND SETUP", 1, 160, 20, 2038);
@ -1826,7 +1835,7 @@ void SetSound(CGameMenuItemChain *pItem)
UNREFERENCED_PARAMETER(pItem); UNREFERENCED_PARAMETER(pItem);
snd_mixrate = nSoundRateValues[itemOptionsSoundSampleRate.m_nFocus]; snd_mixrate = nSoundRateValues[itemOptionsSoundSampleRate.m_nFocus];
snd_numvoices = itemOptionsSoundNumVoices.nValue; snd_numvoices = itemOptionsSoundNumVoices.nValue;
//MusicDevice = itemOptionsSoundMusicDevice.m_nFocus; MusicDevice = nMusicDeviceValues[itemOptionsSoundMusicDevice.m_nFocus];
sfxTerm(); sfxTerm();
sndTerm(); sndTerm();
@ -1859,7 +1868,15 @@ void SetupOptionsSound(CGameMenuItemChain *pItem)
} }
} }
itemOptionsSoundNumVoices.nValue = snd_numvoices; itemOptionsSoundNumVoices.nValue = snd_numvoices;
itemOptionsSoundMusicDevice.m_nFocus = 1;// MusicDevice; itemOptionsSoundMusicDevice.m_nFocus = 0;
for (int i = 0; i < 2; i++)
{
if (nMusicDeviceValues[i] == MusicDevice)
{
itemOptionsSoundMusicDevice.m_nFocus = i;
break;
}
}
} }
void UpdatePlayerName(CGameMenuItemZEdit *pItem, CGameMenuEvent *pEvent) void UpdatePlayerName(CGameMenuItemZEdit *pItem, CGameMenuEvent *pEvent)

View file

@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "osd.h" #include "osd.h"
#include "compat.h" #include "compat.h"
#include "mmulti.h" #include "mmulti.h"
#include "sndcards.h"
#include "common_game.h" #include "common_game.h"
#include "config.h" #include "config.h"
#include "blood.h" #include "blood.h"

View file

@ -437,8 +437,13 @@ void DeinitSoundDevice(void)
void InitMusicDevice(void) void InitMusicDevice(void)
{ {
int nStatus = MUSIC_Init(MusicDevice); int nStatus;
if (nStatus != 0) if ((nStatus = MUSIC_Init(MusicDevice)) == MUSIC_Ok)
{
if (MusicDevice == ASS_AutoDetect)
MusicDevice = MIDI_GetDevice();
}
else if ((nStatus = MUSIC_Init(ASS_AutoDetect)) == MUSIC_Ok)
{ {
initprintf("InitMusicDevice: %s\n", MUSIC_ErrorString(nStatus)); initprintf("InitMusicDevice: %s\n", MUSIC_ErrorString(nStatus));
return; return;