Use std::unique_ptr in in_xsf.cpp.
Use std::unique_ptr in in_xsf.cpp.

Also move the code of the NCSF Player's destructor to Terminate() and call Terminate() in the destructor.

--- a/src/in_ncsf/XSFPlayer_NCSF.cpp
+++ b/src/in_ncsf/XSFPlayer_NCSF.cpp
@@ -130,19 +130,7 @@
 
 XSFPlayer_NCSF::~XSFPlayer_NCSF()
 {
-#ifndef NDEBUG
-	if (soundViewThreadHandle != INVALID_HANDLE_VALUE)
-	{
-		killSoundViewThread = true;
-		if (WaitForSingleObject(soundViewThreadHandle, 2000) == WAIT_TIMEOUT)
-		{
-			TerminateThread(soundViewThreadHandle, 0);
-			static_cast<XSFConfig_NCSF *>(xSFConfig)->CloseSoundView();
-		}
-		CloseHandle(soundViewThreadHandle);
-		soundViewThreadHandle = INVALID_HANDLE_VALUE;
-	}
-#endif
+	this->Terminate();
 }
 
 bool XSFPlayer_NCSF::Load()
@@ -232,6 +220,20 @@
 void XSFPlayer_NCSF::Terminate()
 {
 	this->player.Stop(true);
+
+#ifndef NDEBUG
+	if (soundViewThreadHandle != INVALID_HANDLE_VALUE)
+	{
+		killSoundViewThread = true;
+		if (WaitForSingleObject(soundViewThreadHandle, 2000) == WAIT_TIMEOUT)
+		{
+			TerminateThread(soundViewThreadHandle, 0);
+			static_cast<XSFConfig_NCSF *>(xSFConfig)->CloseSoundView();
+		}
+		CloseHandle(soundViewThreadHandle);
+		soundViewThreadHandle = INVALID_HANDLE_VALUE;
+	}
+#endif
 }
 
 #ifndef NDEBUG

--- a/src/in_xsf_framework/in_xsf.cpp
+++ b/src/in_xsf_framework/in_xsf.cpp
@@ -25,8 +25,8 @@
 extern In_Module inMod;
 static const XSFFile *xSFFile = nullptr;
 XSFFile *xSFFileInInfo = nullptr;
-static XSFPlayer *xSFPlayer = nullptr;
-XSFConfig *xSFConfig = nullptr;
+static std::unique_ptr<XSFPlayer> xSFPlayer;
+std::unique_ptr<XSFConfig> xSFConfig;
 static bool paused;
 static int seek_needed;
 static double decode_pos_ms;
@@ -84,7 +84,7 @@
 {
 	xSFConfig->CallConfigDialog(inMod.hDllInstance, hwndParent);
 	if (xSFPlayer)
-		xSFConfig->CopyConfigToMemory(xSFPlayer, false);
+		xSFConfig->CopyConfigToMemory(xSFPlayer.get(), false);
 }
 
 void about(HWND hwndParent)
@@ -94,7 +94,7 @@
 
 void init()
 {
-	xSFConfig = XSFConfig::Create();
+	xSFConfig.reset(XSFConfig::Create());
 	xSFConfig->LoadConfig();
 	xSFConfig->GenerateDialogs();
 	xSFConfig->SetHInstance(inMod.hDllInstance);
@@ -102,8 +102,8 @@
 
 void quit()
 {
-	delete xSFPlayer;
-	delete xSFConfig;
+	xSFPlayer.reset();
+	xSFConfig.reset();
 }
 
 void getFileInfo(const in_char *file, in_char *title, int *length_in_ms)
@@ -196,7 +196,7 @@
 		inMod.VSASetInfo(tmpxSFPlayer->GetSampleRate(), NumChannels);
 		inMod.outMod->SetVolume(-666);
 
-		xSFPlayer = tmpxSFPlayer.release();
+		xSFPlayer = std::move(tmpxSFPlayer);
 		killThread = false;
 		thread_handle = CreateThread(nullptr, 0, playThread, &killThread, 0, nullptr);
 		return 0;
@@ -239,8 +239,7 @@
 	}
 	inMod.outMod->Close();
 	inMod.SAVSADeInit();
-	delete xSFPlayer;
-	xSFPlayer = nullptr;
+	xSFPlayer.reset();
 	xSFFile = nullptr;
 }