From d7db010217671be898bbc597a0641ce2390de0c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Sep 2019 02:22:53 +0200 Subject: [PATCH] - moved the CD Audio code to ZMusic, too. This was the last player class. This code was also cleaned up for non-Windows systems where CD Audio is not implemented. Instead of providing an empty implementation, all related code is now explicitly deactivated. # Conflicts: # src/CMakeLists.txt --- libraries/zmusic/CMakeLists.txt | 11 +- .../zmusic}/musicformats/music_cd.cpp | 22 ++- .../musicformats}/win32/helperthread.cpp | 2 +- .../zmusic/musicformats}/win32/helperthread.h | 0 .../zmusic/musicformats}/win32/i_cd.cpp | 0 .../zmusic/musicformats/win32}/i_cd.h | 0 src/CMakeLists.txt | 4 - src/posix/i_cd.cpp | 154 ------------------ src/sound/s_music.cpp | 6 +- src/sound/s_sound.cpp | 1 - src/statistics.cpp | 15 -- 11 files changed, 33 insertions(+), 182 deletions(-) rename {src/sound => libraries/zmusic}/musicformats/music_cd.cpp (94%) rename {src => libraries/zmusic/musicformats}/win32/helperthread.cpp (99%) rename {src => libraries/zmusic/musicformats}/win32/helperthread.h (100%) rename {src => libraries/zmusic/musicformats}/win32/i_cd.cpp (100%) rename {src/sound/music => libraries/zmusic/musicformats/win32}/i_cd.h (100%) delete mode 100644 src/posix/i_cd.cpp diff --git a/libraries/zmusic/CMakeLists.txt b/libraries/zmusic/CMakeLists.txt index aaa7db274..0350202a3 100644 --- a/libraries/zmusic/CMakeLists.txt +++ b/libraries/zmusic/CMakeLists.txt @@ -41,8 +41,11 @@ endif() include_directories( "../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}" ) if (WIN32) -set( PLAT_WIN32_SOURCES - mididevices/music_win_mididevice.cpp) +set( PLAT_SOURCES + mididevices/music_win_mididevice.cpp + musicformats/win32/i_cd.cpp + musicformats/win32/helperthread.cpp + ) endif() file( GLOB HEADER_FILES @@ -79,11 +82,12 @@ add_library( zmusic STATIC streamsources/music_xa.cpp musicformats/music_stream.cpp musicformats/music_midi.cpp + musicformats/music_cd.cpp decoder/sounddecoder.cpp decoder/sndfile_decoder.cpp decoder/mpg123_decoder.cpp zmusic/configuration.cpp - ${PLAT_WIN32_SOURCES} + ${PLAT_SOURCES} ) target_link_libraries( zmusic ) @@ -91,6 +95,7 @@ target_link_libraries( zmusic ) source_group("MIDI Devices" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mididevices/.+") source_group("MIDI Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/midisources/.+") source_group("Music Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/musicformats/.+") +source_group("Music Formats\\Win32" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/musicformats/win32/.+") source_group("Public Interface" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/zmusic/.+") source_group("Sound Decoding" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/decoder/.+") source_group("Stream Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/streamsources/.+") diff --git a/src/sound/musicformats/music_cd.cpp b/libraries/zmusic/musicformats/music_cd.cpp similarity index 94% rename from src/sound/musicformats/music_cd.cpp rename to libraries/zmusic/musicformats/music_cd.cpp index e6aeedf71..2a586f6de 100644 --- a/src/sound/musicformats/music_cd.cpp +++ b/libraries/zmusic/musicformats/music_cd.cpp @@ -31,8 +31,11 @@ ** */ -#include "zmusic/musinfo.h" #include "zmusic/zmusic.h" +#include "zmusic/musinfo.h" + +#ifdef _WIN32 + #include "zmusic/m_swap.h" #include "i_cd.h" @@ -189,4 +192,19 @@ MusInfo* CD_OpenSong(int track, int id) MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader) { return new CDDAFile(reader); -} \ No newline at end of file +} + +#else + +MusInfo* CD_OpenSong(int track, int id) +{ + throw std::runtime_error("CD Audio playback not supported"); +} + +MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader) +{ + throw std::runtime_error("CD Audio playback not supported"); +} + + +#endif diff --git a/src/win32/helperthread.cpp b/libraries/zmusic/musicformats/win32/helperthread.cpp similarity index 99% rename from src/win32/helperthread.cpp rename to libraries/zmusic/musicformats/win32/helperthread.cpp index f6f74554f..377ae887e 100644 --- a/src/win32/helperthread.cpp +++ b/libraries/zmusic/musicformats/win32/helperthread.cpp @@ -3,7 +3,7 @@ ** ** Implements FHelperThread, the base class for helper threads. Includes ** a message queue for passing messages from the main thread to the -** helper thread. +** helper thread. (Only used by the CD Audio player) ** **--------------------------------------------------------------------------- ** Copyright 1998-2006 Randy Heit diff --git a/src/win32/helperthread.h b/libraries/zmusic/musicformats/win32/helperthread.h similarity index 100% rename from src/win32/helperthread.h rename to libraries/zmusic/musicformats/win32/helperthread.h diff --git a/src/win32/i_cd.cpp b/libraries/zmusic/musicformats/win32/i_cd.cpp similarity index 100% rename from src/win32/i_cd.cpp rename to libraries/zmusic/musicformats/win32/i_cd.cpp diff --git a/src/sound/music/i_cd.h b/libraries/zmusic/musicformats/win32/i_cd.h similarity index 100% rename from src/sound/music/i_cd.h rename to libraries/zmusic/musicformats/win32/i_cd.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f70f2d4b7..df7e5523f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -512,8 +512,6 @@ set( PLAT_WIN32_SOURCES win32/fb_d3d9_wipe.cpp win32/fb_ddraw.cpp win32/hardware.cpp - win32/helperthread.cpp - win32/i_cd.cpp win32/i_crash.cpp win32/i_input.cpp win32/i_keyboard.cpp @@ -528,7 +526,6 @@ set( PLAT_WIN32_SOURCES win32/win32gliface.cpp win32/win32video.cpp ) set( PLAT_POSIX_SOURCES - posix/i_cd.cpp posix/i_steam.cpp ) set( PLAT_SDL_SOURCES posix/sdl/crashcatcher.c @@ -1157,7 +1154,6 @@ set (PCH_SOURCES sound/music/i_soundfont.cpp sound/backend/i_sound.cpp sound/music/music_config.cpp - sound/musicformats/music_cd.cpp events.cpp atterm.cpp GuillotineBinPack.cpp diff --git a/src/posix/i_cd.cpp b/src/posix/i_cd.cpp deleted file mode 100644 index 96b59934c..000000000 --- a/src/posix/i_cd.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include "i_cd.h" - -//========================================================================== -// -// CD_Init -// -//========================================================================== - -bool CD_Init () -{ - return false; -} - -bool CD_Init (int device) -{ - return false; -} - -//========================================================================== -// -// CD_InitID -// -//========================================================================== - -bool CD_InitID (unsigned int id, int guess) -{ - return false; -} - -//========================================================================== -// -// CD_Close -// -//========================================================================== - -void CD_Close () -{ -} - -//========================================================================== -// -// CD_Eject -// -//========================================================================== - -void CD_Eject () -{ -} - -//========================================================================== -// -// CD_UnEject -// -//========================================================================== - -bool CD_UnEject () -{ - return false; -} - -//========================================================================== -// -// CD_Stop -// -//========================================================================== - -void CD_Stop () -{ -} - -//========================================================================== -// -// CD_Play -// -//========================================================================== - -bool CD_Play (int track, bool looping) -{ - return false; -} - -//========================================================================== -// -// CD_PlayNoWait -// -//========================================================================== - -void CD_PlayNoWait (int track, bool looping) -{ -} - -//========================================================================== -// -// CD_PlayCD -// -//========================================================================== - -bool CD_PlayCD (bool looping) -{ - return false; -} - -//========================================================================== -// -// CD_PlayCDNoWait -// -//========================================================================== - -void CD_PlayCDNoWait (bool looping) -{ -} - -//========================================================================== -// -// CD_Pause -// -//========================================================================== - -void CD_Pause () -{ -} - -//========================================================================== -// -// CD_Resume -// -//========================================================================== - -bool CD_Resume () -{ - return false; -} - -//========================================================================== -// -// CD_GetMode -// -//========================================================================== - -ECDModes CD_GetMode () -{ - return CDMode_Unknown; -} - -//========================================================================== -// -// CD_CheckTrack -// -//========================================================================== - -bool CD_CheckTrack (int track) -{ - return false; -} diff --git a/src/sound/s_music.cpp b/src/sound/s_music.cpp index 7f435eed7..95dd4a03a 100644 --- a/src/sound/s_music.cpp +++ b/src/sound/s_music.cpp @@ -57,12 +57,13 @@ #include #ifdef _WIN32 #include +#include "musicformats/win32/i_cd.h" #endif #include "i_system.h" #include "i_sound.h" #include "i_music.h" -#include "i_cd.h" + #include "s_sound.h" #include "s_sndseq.h" #include "s_playlist.h" @@ -827,6 +828,7 @@ CCMD (cd_play) S_ChangeMusic (musname, 0, true); } +#ifdef _WIN32 //========================================================================== // // CCMD cd_stop @@ -881,7 +883,7 @@ CCMD (cd_resume) { CD_Resume (); } - +#endif //========================================================================== // // CCMD playlist diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index 2208783d5..0a09d805e 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -63,7 +63,6 @@ #include "i_system.h" #include "i_sound.h" #include "i_music.h" -#include "i_cd.h" #include "s_sound.h" #include "s_sndseq.h" #include "s_playlist.h" diff --git a/src/statistics.cpp b/src/statistics.cpp index 4c10bc1d4..e552d5750 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -42,38 +42,23 @@ #include "gstrings.h" #include "doomstat.h" #include "d_player.h" -#include "configfile.h" #include "c_dispatch.h" -#include "c_console.h" -#include "d_gui.h" -#include "d_dehacked.h" #include "d_net.h" #include "g_game.h" #include "m_png.h" -#include "m_misc.h" #include "doomerrors.h" #include "w_wad.h" -#include "hu_stuff.h" #include "p_local.h" -#include "m_png.h" #include "p_setup.h" #include "s_sound.h" -#include "wi_stuff.h" -#include "sc_man.h" #include "cmdlib.h" #include "p_terrain.h" #include "decallib.h" -#include "autosegs.h" -#include "i_cd.h" #include "stats.h" #include "a_sharedglobal.h" -#include "v_text.h" -#include "r_sky.h" #include "p_lnspec.h" -#include "m_crc32.h" #include "serializer.h" #include "g_levellocals.h" -#include "files.h" CVAR(Int, savestatistics, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(String, statfile, "zdoomstat.txt", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)