changeset 398:be49bf95d4a5

* Fix hang when using more than one consecutive coded audio file reader in decode-at-once mode
author Chris Cannam
date Wed, 26 Mar 2008 14:35:03 +0000
parents 78491f21061d
children 0f0f08c22552
files base/Serialiser.cpp data/fileio/CodedAudioFileReader.cpp data/fileio/FileSource.cpp data/fileio/MP3FileReader.cpp data/fileio/OggVorbisFileReader.cpp data/fileio/QuickTimeFileReader.cpp data/fileio/ResamplingWavFileReader.cpp
diffstat 7 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/base/Serialiser.cpp	Wed Mar 26 11:18:17 2008 +0000
+++ b/base/Serialiser.cpp	Wed Mar 26 14:35:03 2008 +0000
@@ -31,12 +31,17 @@
     }
 
     m_mutexMap[m_id]->lock();
+
     m_mapMutex.unlock();
 }
 
 Serialiser::~Serialiser()
 {
+    m_mapMutex.lock();
+    
     m_mutexMap[m_id]->unlock();
+
+    m_mapMutex.unlock();
 }
 
 
--- a/data/fileio/CodedAudioFileReader.cpp	Wed Mar 26 11:18:17 2008 +0000
+++ b/data/fileio/CodedAudioFileReader.cpp	Wed Mar 26 14:35:03 2008 +0000
@@ -79,7 +79,7 @@
 void
 CodedAudioFileReader::endSerialised()
 {
-//    std::cerr << "CodedAudioFileReader::endSerialised" << std::endl;
+    std::cerr << "CodedAudioFileReader::endSerialised" << std::endl;
 
     delete m_serialiser;
     m_serialiser = 0;
@@ -107,7 +107,7 @@
                                     m_cacheWriteBufferSize);
         float ratio = float(m_sampleRate) / float(m_fileRate);
         m_resampleBuffer = new float
-            [lrintf(ceilf(m_cacheWriteBufferSize * m_channelCount * ratio))];
+            [lrintf(ceilf(m_cacheWriteBufferSize * m_channelCount * ratio + 1))];
     }
 
     m_cacheWriteBuffer = new float[m_cacheWriteBufferSize * m_channelCount];
--- a/data/fileio/FileSource.cpp	Wed Mar 26 11:18:17 2008 +0000
+++ b/data/fileio/FileSource.cpp	Wed Mar 26 14:35:03 2008 +0000
@@ -28,7 +28,7 @@
 
 #include <iostream>
 
-#define DEBUG_FILE_SOURCE 1
+//#define DEBUG_FILE_SOURCE 1
 
 int
 FileSource::m_count = 0;
--- a/data/fileio/MP3FileReader.cpp	Wed Mar 26 11:18:17 2008 +0000
+++ b/data/fileio/MP3FileReader.cpp	Wed Mar 26 14:35:03 2008 +0000
@@ -121,6 +121,7 @@
         m_filebuffer = 0;
 
         if (isDecodeCacheInitialised()) finishDecodeCache();
+        endSerialised();
 
     } else {
 
--- a/data/fileio/OggVorbisFileReader.cpp	Wed Mar 26 11:18:17 2008 +0000
+++ b/data/fileio/OggVorbisFileReader.cpp	Wed Mar 26 14:35:03 2008 +0000
@@ -85,6 +85,7 @@
         m_oggz = 0;
 
         if (isDecodeCacheInitialised()) finishDecodeCache();
+        endSerialised();
 
     } else {
 
--- a/data/fileio/QuickTimeFileReader.cpp	Wed Mar 26 11:18:17 2008 +0000
+++ b/data/fileio/QuickTimeFileReader.cpp	Wed Mar 26 14:35:03 2008 +0000
@@ -246,6 +246,7 @@
         }
         
         finishDecodeCache();
+        endSerialised();
 
         m_d->err = MovieAudioExtractionEnd(m_d->extractionSessionRef);
         if (m_d->err) {
--- a/data/fileio/ResamplingWavFileReader.cpp	Wed Mar 26 11:18:17 2008 +0000
+++ b/data/fileio/ResamplingWavFileReader.cpp	Wed Mar 26 14:35:03 2008 +0000
@@ -80,6 +80,7 @@
         }
 
         if (isDecodeCacheInitialised()) finishDecodeCache();
+        endSerialised();
 
         delete m_original;
         m_original = 0;