- fixed compilation on Windows.

This commit is contained in:
Christoph Oelckers 2019-09-30 18:21:34 +02:00
parent 2b87941d7d
commit 83e8e5535d
6 changed files with 67 additions and 54 deletions

View file

@ -38,7 +38,7 @@ elseif( FLUIDSYNTH_FOUND )
endif()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../libraries/dumb/include" "${ADL_INCLUDE_DIR}" "${OPN_INCLUDE_DIR}" "${TIMIDITYPP_INCLUDE_DIR}" "${TIMIDITY_INCLUDE_DIR}" "${WILDMIDI_INCLUDE_DIR}" "${OPLSYNTH_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" )
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../libraries/dumb/include" "${ZLIB_INCLUDE_DIR}" "${ADL_INCLUDE_DIR}" "${OPN_INCLUDE_DIR}" "${TIMIDITYPP_INCLUDE_DIR}" "${TIMIDITY_INCLUDE_DIR}" "${WILDMIDI_INCLUDE_DIR}" "${OPLSYNTH_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" )
if (WIN32)
set( PLAT_SOURCES
@ -53,6 +53,7 @@ file( GLOB HEADER_FILES
mididevices/*.h
midisources/*.h
musicformats/*.h
musicformats/win32/*.h
decoder/*.h
streamsources/*.h
thirdparty/*.h

View file

@ -37,7 +37,7 @@
#ifdef _WIN32
#include "zmusic/m_swap.h"
#include "i_cd.h"
#include "win32/i_cd.h"
// CD track/disk played through the multimedia system -----------------------
@ -126,7 +126,7 @@ CDSong::CDSong (int track, int id)
}
else
{
success = CD_Init ();
success = CD_Init (-1);
}
if (success && (track == 0 || CD_CheckTrack (track)))

View file

@ -35,6 +35,8 @@
// HEADER FILES ------------------------------------------------------------
#include <string>
#include <algorithm>
#include <assert.h>
#include "zmusic/musinfo.h"
#include "mididevices/mididevice.h"
#include "midisources/midisource.h"

View file

@ -36,16 +36,8 @@
#include <windows.h>
#include <mmsystem.h>
#include <stdlib.h>
#include "doomtype.h"
#include "c_cvars.h"
#include "m_argv.h"
#include "version.h"
#include "i_system.h"
#include "i_cd.h"
#include "helperthread.h"
#include "atterm.h"
#include "i_cd.h"
extern HWND Window;
extern HINSTANCE g_hInst;
@ -101,36 +93,7 @@ protected:
static FCDThread *CDThread;
static int Inited = NOT_INITED;
//==========================================================================
//
// CVAR: cd_enabled
//
// Use the CD device? Can be overridden with -nocdaudio on the command line
//
//==========================================================================
CUSTOM_CVAR (Bool, cd_enabled, true, CVAR_ARCHIVE|CVAR_NOINITCALL|CVAR_GLOBALCONFIG)
{
if (self)
CD_Init ();
else
CD_Close ();
}
//==========================================================================
//
// CVAR: cd_drive
//
// Which drive (letter) to use for CD audio. If not a valid drive letter,
// let the operating system decide for us.
//
//==========================================================================
CUSTOM_CVAR (String, cd_drive, "", CVAR_ARCHIVE|CVAR_NOINITCALL|CVAR_GLOBALCONFIG)
{
CD_Init ();
}
static int Enabled = false;
//==========================================================================
//
@ -173,7 +136,7 @@ bool FCDThread::Init ()
CD_WindowClass.style = CS_NOCLOSE;
CD_WindowClass.lpfnWndProc = CD_WndProc;
CD_WindowClass.hInstance = g_hInst;
CD_WindowClass.lpszClassName = WGAMENAME " CD Player";
CD_WindowClass.lpszClassName = L"ZNusic CD Player";
CD_WindowAtom = RegisterClass (&CD_WindowClass);
if (CD_WindowAtom == 0)
@ -181,7 +144,7 @@ bool FCDThread::Init ()
CD_Window = CreateWindow (
(LPCTSTR)(INT_PTR)(int)CD_WindowAtom,
WGAMENAME " CD Player",
CD_WindowClass.lpszClassName,
0,
0, 0, 10, 10,
NULL,
@ -453,8 +416,16 @@ static void KillThread ()
//
//==========================================================================
bool CD_Init ()
bool CD_Enable (const char *cd_drive)
{
if (!cd_drive)
{
// lock the CD system.
Enabled = false;
CD_Close();
return false;
}
Enabled = true; // this must have been called at least once to consider the use of the CD system
if ((cd_drive)[0] == 0 || (cd_drive)[1] != 0)
{
return CD_Init (-1);
@ -463,21 +434,22 @@ bool CD_Init ()
{
char drive = toupper ((cd_drive)[0]);
if (drive >= 'A' && drive <= 'Z' && !CD_Init (drive - 'A'))
return CD_Init (-1);
if (drive >= 'A' && drive <= 'Z' && !CD_Init(drive - 'A'))
{
return CD_Init(-1);
}
}
return true;
}
bool CD_Init (int device)
{
if (!cd_enabled || Args->CheckParm ("-nocdaudio"))
return false;
if (!Enabled) return false;
if (CDThread == NULL)
{
CDThread = new FCDThread;
atterm (KillThread);
atexit (KillThread);
}
if (Inited != device)

View file

@ -48,8 +48,8 @@ enum ECDModes
// Opens a CD device. If device is non-negative, it specifies which device
// to open. 0 is drive A:, 1 is drive B:, etc. If device is not specified,
// the user's preference is used to decide which device to open.
bool CD_Init ();
bool CD_Init (int device);
bool CD_Enable (const char *drive);
bool CD_Init (int device = -1);
// Open a CD device containing a specific CD. Tries device guess first.
bool CD_InitID (unsigned int id, int guess=-1);

View file

@ -60,7 +60,6 @@
void I_InitSoundFonts();
extern MusPlayingInfo mus_playing;
@ -74,6 +73,45 @@ static bool ungzip(uint8_t *data, int size, std::vector<uint8_t> &newdata);
int nomusic = 0;
#ifdef _WIN32
void I_InitMusicWin32();
#include "musicformats/win32/i_cd.h"
//==========================================================================
//
// CVAR: cd_drive
//
// Which drive (letter) to use for CD audio. If not a valid drive letter,
// let the operating system decide for us.
//
//==========================================================================
EXTERN_CVAR(Bool, cd_enabled);
CUSTOM_CVAR(String, cd_drive, "", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
{
if (cd_enabled && !Args->CheckParm("-nocdaudio")) CD_Enable(self);
}
//==========================================================================
//
// CVAR: cd_enabled
//
// Use the CD device? Can be overridden with -nocdaudio on the command line
//
//==========================================================================
CUSTOM_CVAR(Bool, cd_enabled, true, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
{
if (self && !Args->CheckParm("-nocdaudio"))
CD_Enable(cd_drive);
else
CD_Enable(nullptr);
}
#endif
//==========================================================================
//
// CVAR snd_musicvolume
@ -299,7 +337,7 @@ void I_SetRelativeVolume(float vol)
void I_SetMusicVolume (double factor)
{
factor = clamp(factor, 0., 2.0);
I_SetRelativeVolume(factor);
I_SetRelativeVolume((float)factor);
}
//==========================================================================