diff --git a/libraries/zmusic/CMakeLists.txt b/libraries/zmusic/CMakeLists.txt index 879afd6af..071eeb20d 100644 --- a/libraries/zmusic/CMakeLists.txt +++ b/libraries/zmusic/CMakeLists.txt @@ -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 diff --git a/libraries/zmusic/musicformats/music_cd.cpp b/libraries/zmusic/musicformats/music_cd.cpp index 6cfddefef..daedcd370 100644 --- a/libraries/zmusic/musicformats/music_cd.cpp +++ b/libraries/zmusic/musicformats/music_cd.cpp @@ -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))) diff --git a/libraries/zmusic/musicformats/music_midi.cpp b/libraries/zmusic/musicformats/music_midi.cpp index 909281f99..36d0754af 100644 --- a/libraries/zmusic/musicformats/music_midi.cpp +++ b/libraries/zmusic/musicformats/music_midi.cpp @@ -35,6 +35,8 @@ // HEADER FILES ------------------------------------------------------------ #include +#include +#include #include "zmusic/musinfo.h" #include "mididevices/mididevice.h" #include "midisources/midisource.h" diff --git a/libraries/zmusic/musicformats/win32/i_cd.cpp b/libraries/zmusic/musicformats/win32/i_cd.cpp index 4e1c633b3..8a0cbfa82 100644 --- a/libraries/zmusic/musicformats/win32/i_cd.cpp +++ b/libraries/zmusic/musicformats/win32/i_cd.cpp @@ -36,16 +36,8 @@ #include #include #include - -#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) diff --git a/libraries/zmusic/musicformats/win32/i_cd.h b/libraries/zmusic/musicformats/win32/i_cd.h index f05842721..32b059db2 100644 --- a/libraries/zmusic/musicformats/win32/i_cd.h +++ b/libraries/zmusic/musicformats/win32/i_cd.h @@ -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); diff --git a/src/sound/music/i_music.cpp b/src/sound/music/i_music.cpp index 79b0e72c0..e43da3605 100644 --- a/src/sound/music/i_music.cpp +++ b/src/sound/music/i_music.cpp @@ -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 &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); } //==========================================================================