Browse Source

Merge remote-tracking branch 'origin/master' into ox-move

[email protected] 8 years ago
parent
commit
cd4d3c4fbb
1 changed files with 15 additions and 9 deletions
  1. 15 9
      src/sound/oal/SoundOAL.cpp

+ 15 - 9
src/sound/oal/SoundOAL.cpp

@@ -17,7 +17,10 @@ namespace oxygine
     {
         char header[4];
         if (file::read(fh, header, 4) != 4)
+        {
+            file::close(fh);
             return;
+        }
 
         file::seek(fh, 0, SEEK_SET);
 
@@ -25,17 +28,20 @@ namespace oxygine
         OggStream oggStream;
         WavStream wavStream;
         SoundStream* stream = init0(header, oggStream, wavStream);
-        stream->init(fh, false);
-
-        bool streaming = _init(*stream);
-        if (streaming)
+        if (stream)
         {
-            if (_fileName.empty())
+            stream->init(fh, false);
+
+            bool streaming = _init(*stream);
+            if (streaming)
             {
-                file::seek(fh, 0, SEEK_SET);
-                file::buffer bf;
-                file::read(fh, bf);
-                std::swap(_fileBuffer, bf.data);
+                if (_fileName.empty())
+                {
+                    file::seek(fh, 0, SEEK_SET);
+                    file::buffer bf;
+                    file::read(fh, bf);
+                    std::swap(_fileBuffer, bf.data);
+                }
             }
         }