From d0cf21654e63a5cf9eb1a172eceac647f0cfbcf2 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. --- 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 - 10 files changed, 33 insertions(+), 167 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 f5874b99e..ef6d0d3e9 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 a4b148eb4..b2725779e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -489,8 +489,6 @@ endif() # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES win32/hardware.cpp - win32/helperthread.cpp - win32/i_cd.cpp win32/i_crash.cpp win32/i_input.cpp win32/i_keyboard.cpp @@ -512,7 +510,6 @@ if (HAVE_VULKAN) endif() set( PLAT_POSIX_SOURCES - posix/i_cd.cpp posix/i_steam.cpp ) set( PLAT_SDL_SOURCES posix/sdl/crashcatcher.c @@ -1160,7 +1157,6 @@ set (PCH_SOURCES sound/music/i_soundfont.cpp sound/backend/i_sound.cpp sound/music/music_config.cpp - sound/musicformats/music_cd.cpp rendering/swrenderer/textures/r_swtexture.cpp rendering/swrenderer/textures/warptexture.cpp rendering/swrenderer/textures/swcanvastexture.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 bb865fe37..cf052f8bc 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 12a3de41e..7242bb8c5 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -62,7 +62,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"