Browse code

Fix compile issues because of the earlier std::unique_ptr change in in_xsf.cpp.

Naram Qashat authored on 2021/04/07 00:29:13
Showing 3 changed files
... ...
@@ -28,7 +28,7 @@
28 28
 const char *XSFPlayer::WinampDescription = "NCSF Decoder";
29 29
 const char *XSFPlayer::WinampExts = "ncsf;minincsf\0DS Nitro Composer Sound Format files (*.ncsf;*.minincsf)\0";
30 30
 
31
-extern XSFConfig *xSFConfig;
31
+extern std::unique_ptr<XSFConfig> xSFConfig;
32 32
 
33 33
 XSFPlayer *XSFPlayer::Create(const std::filesystem::path &path)
34 34
 {
... ...
@@ -107,7 +107,7 @@ static bool killSoundViewThread;
107 107
 
108 108
 static DWORD WINAPI soundViewThread(void *b)
109 109
 {
110
-	auto xSFConfig_NCSF = static_cast<XSFConfig_NCSF *>(xSFConfig);
110
+	auto xSFConfig_NCSF = static_cast<XSFConfig_NCSF *>(xSFConfig.get());
111 111
 	xSFConfig_NCSF->CallSoundView(static_cast<XSFPlayer_NCSF *>(b), xSFConfig->GetHInstance(), nullptr);
112 112
 	MSG msg;
113 113
 	while (!killSoundViewThread)
... ...
@@ -220,7 +220,7 @@ void XSFPlayer_NCSF::Terminate()
220 220
 		if (WaitForSingleObject(soundViewThreadHandle, 2000) == WAIT_TIMEOUT)
221 221
 		{
222 222
 			TerminateThread(soundViewThreadHandle, 0);
223
-			static_cast<XSFConfig_NCSF *>(xSFConfig)->CloseSoundView();
223
+			static_cast<XSFConfig_NCSF *>(xSFConfig.get())->CloseSoundView();
224 224
 		}
225 225
 		CloseHandle(soundViewThreadHandle);
226 226
 		soundViewThreadHandle = INVALID_HANDLE_VALUE;
... ...
@@ -47,7 +47,7 @@ public:
47 47
 const char *XSFPlayer::WinampDescription = "SNSF Decoder";
48 48
 const char *XSFPlayer::WinampExts = "snsf;minisnsf\0SNES Sound Format files (*.snsf;*.minisnsf)\0";
49 49
 
50
-extern XSFConfig *xSFConfig;
50
+extern std::unique_ptr<XSFConfig> xSFConfig;
51 51
 
52 52
 XSFPlayer *XSFPlayer::Create(const std::filesystem::path &path)
53 53
 {
... ...
@@ -217,7 +217,7 @@ bool XSFPlayer_SNSF::Load()
217 217
 	Memory.Init();
218 218
 
219 219
 	S9xInitAPU();
220
-	XSFConfig_SNSF *xSFConfig_SNSF = dynamic_cast<XSFConfig_SNSF *>(xSFConfig);
220
+	XSFConfig_SNSF *xSFConfig_SNSF = dynamic_cast<XSFConfig_SNSF *>(xSFConfig.get());
221 221
 	if (xSFConfig_SNSF->resampler == 4)
222 222
 		S9xInitSound<SincResampler>(10, 0);
223 223
 	else if (xSFConfig_SNSF->resampler == 3)
... ...
@@ -7,13 +7,14 @@
7 7
 
8 8
 #include <algorithm>
9 9
 #include <limits>
10
+#include <memory>
10 11
 #include <vector>
11 12
 #include <cstdint>
12 13
 #include "XSFCommon.h"
13 14
 #include "XSFConfig.h"
14 15
 #include "XSFPlayer.h"
15 16
 
16
-extern XSFConfig *xSFConfig;
17
+extern std::unique_ptr<XSFConfig> xSFConfig;
17 18
 
18 19
 XSFPlayer::XSFPlayer() : xSF(), sampleRate(0), detectedSilenceSample(0), detectedSilenceSec(0), skipSilenceOnStartSec(5), lengthSample(0), fadeSample(0), currentSample(0),
19 20
 	prevSampleL(CHECK_SILENCE_BIAS), prevSampleR(CHECK_SILENCE_BIAS), lengthInMS(-1), fadeInMS(-1), volume(1.0), ignoreVolume(false), uses32BitSamplesClampedTo16Bit(false)