From b226bdfd5370fecae9234851716110f3056ec851 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 29 Dec 2020 21:17:03 +0000 Subject: [PATCH] Small changes to improve compatibility with GCC. (PR #902) * Fix GCC build. 1) do not fwd declare enums 2) include only base class header file IPropertySheet. * DSInit(): make sure sound devices are cleaned before the 2nd call. And use std::string to avoid need of memory management. --- source/Interface.h | 2 +- source/NTSC.h | 3 ++- source/SoundCore.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/Interface.h b/source/Interface.h index 119b39a7..bc13d7f0 100644 --- a/source/Interface.h +++ b/source/Interface.h @@ -11,7 +11,7 @@ #include "Video.h" Video& GetVideo(void); -#include "Configuration/PropertySheet.h" +#include "Configuration/IPropertySheet.h" IPropertySheet& GetPropertySheet(void); #include "FrameBase.h" diff --git a/source/NTSC.h b/source/NTSC.h index fc629553..c010057e 100644 --- a/source/NTSC.h +++ b/source/NTSC.h @@ -1,5 +1,7 @@ #pragma once +#include "Video.h" + // Globals (Public) extern uint16_t g_nVideoClockVert; extern uint16_t g_nVideoClockHorz; @@ -21,7 +23,6 @@ extern void NTSC_VideoUpdateCycles( UINT cycles6502 ); extern void NTSC_VideoRedrawWholeScreen( void ); - enum VideoRefreshRate_e; void NTSC_SetRefreshRate(VideoRefreshRate_e rate); UINT NTSC_GetCyclesPerFrame(void); UINT NTSC_GetCyclesPerLine(void); diff --git a/source/SoundCore.cpp b/source/SoundCore.cpp index 7bd01739..68a2336a 100644 --- a/source/SoundCore.cpp +++ b/source/SoundCore.cpp @@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define MAX_SOUND_DEVICES 10 -static char *sound_devices[MAX_SOUND_DEVICES]; +static std::string sound_devices[MAX_SOUND_DEVICES]; static GUID sound_device_guid[MAX_SOUND_DEVICES]; static int num_sound_devices = 0; @@ -67,7 +67,9 @@ static BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrv return TRUE; if(lpGUID != NULL) memcpy(&sound_device_guid[i], lpGUID, sizeof (GUID)); - sound_devices[i] = _strdup(lpszDesc); + else + memset(&sound_device_guid[i], 0, sizeof(GUID)); + sound_devices[i] = lpszDesc; if(g_fh) fprintf(g_fh, "%d: %s - %s\n",i,lpszDesc,lpszDrvName); @@ -491,6 +493,7 @@ bool DSInit() return true; // Already initialised successfully } + num_sound_devices = 0; HRESULT hr = DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc, NULL); if(FAILED(hr)) {