Hi,

This patch has nothing directly to do with the msvc development. I noticed it when I was trying out the GigWriteTest.

Depending on the constructor, RIFF:File can be allocated by the constructor or passed on. In case DLS::File allocates RIFF::File itself, it never gets destroyed. This results on windows in an open file handle and the next test case can't properly open the file.

I'm not that familiar with the code base so feel free to correct if I got anything wrong. I've made the patch with git, let me know if there are problems applying it. (used --no-prefix)
diff --git src/DLS.cpp src/DLS.cpp
index 8d5001f..57add02 100644
--- src/DLS.cpp
+++ src/DLS.cpp
@@ -1407,6 +1407,7 @@ namespace DLS {
      */
     File::File() : Resource(NULL, pRIFF = new RIFF::File(RIFF_TYPE_DLS)) {
         pRIFF->SetByteOrder(RIFF::endian_little);
+        bOwnAllocRiff = true;
         pVersion = new version_t;
         pVersion->major   = 0;
         pVersion->minor   = 0;
@@ -1437,7 +1438,7 @@ namespace DLS {
     File::File(RIFF::File* pRIFF) : Resource(NULL, pRIFF) {
         if (!pRIFF) throw DLS::Exception("NULL pointer reference to RIFF::File 
object.");
         this->pRIFF = pRIFF;
-
+        bOwnAllocRiff = false;
         RIFF::Chunk* ckVersion = pRIFF->GetSubChunk(CHUNK_ID_VERS);
         if (ckVersion) {
             pVersion = new version_t;
@@ -1509,6 +1510,9 @@ namespace DLS {
         if (pVersion) delete pVersion;
         for (std::list<RIFF::File*>::iterator i = ExtensionFiles.begin() ; i 
!= ExtensionFiles.end() ; i++)
             delete *i;
+        //TODO: Check with mailing list if this is correct
+        if (bOwnAllocRiff)
+            delete pRIFF;
     }
 
     Sample* File::GetFirstSample() {
diff --git src/DLS.h src/DLS.h
index eb4b585..4e81487 100644
--- src/DLS.h
+++ src/DLS.h
@@ -539,6 +539,7 @@ namespace DLS {
             void __ensureMandatoryChunksExist();
             friend class Region; // Region has to look in the wave pool table 
to get its sample
         private:
+            bool bOwnAllocRiff;
             void __UpdateWavePoolTableChunk();
             void __UpdateWavePoolTable();
     };
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to