changeset 821:06c64a1c6785

Merge
author Chris Cannam
date Mon, 08 Jul 2013 14:49:28 +0100
parents bb7ea947c60d (diff) 97741fe16205 (current diff)
children 54829c1e155e f0558e69a074
files
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/CoreAudioFileReader.cpp	Fri May 24 11:57:44 2013 +0100
+++ b/data/fileio/CoreAudioFileReader.cpp	Mon Jul 08 14:49:28 2013 +0100
@@ -33,13 +33,14 @@
 class CoreAudioFileReader::D
 {
 public:
-    D() : blockSize(1024) { }
+    D() : blockSize(1024), valid(false) { }
 
     ExtAudioFileRef file;
     AudioBufferList buffer;
     OSStatus err;
     AudioStreamBasicDescription asbd;
     int blockSize;
+    bool valid;
 };
 
 static QString
@@ -116,6 +117,7 @@
     
     if (m_d->err) {
         m_error = "CoreAudioReadStream: Error in getting basic description: code " + codestr(m_d->err);
+        ExtAudioFileDispose(m_d->file);
         return;
     }
 	
@@ -140,6 +142,7 @@
     
     if (m_d->err) {
         m_error = "CoreAudioReadStream: Error in setting client format: code " + codestr(m_d->err);
+        ExtAudioFileDispose(m_d->file);
         return;
     }
 
@@ -148,6 +151,8 @@
     m_d->buffer.mBuffers[0].mDataByteSize = sizeof(float) * m_channelCount * m_d->blockSize;
     m_d->buffer.mBuffers[0].mData = new float[m_channelCount * m_d->blockSize];
 
+    m_d->valid = true;
+
     initialiseDecodeCache();
 
     if (m_reporter) {
@@ -181,15 +186,18 @@
     endSerialised();
 
     m_completion = 100;
-
-    ExtAudioFileDispose(m_d->file);
 }
 
 
 CoreAudioFileReader::~CoreAudioFileReader()
 {
     std::cerr << "CoreAudioFileReader::~CoreAudioFileReader" << std::endl;
-    delete[] m_d->buffer.mBuffers[0].mData;
+
+    if (m_d->valid) {
+        ExtAudioFileDispose(m_d->file);
+        delete[] m_d->buffer.mBuffers[0].mData;
+    }
+
     delete m_d;
 }
 
--- a/data/fileio/test/AudioFileReaderTest.h	Fri May 24 11:57:44 2013 +0100
+++ b/data/fileio/test/AudioFileReaderTest.h	Mon Jul 08 14:49:28 2013 +0100
@@ -78,7 +78,11 @@
         if (bits.length() > 2) nominalDepth = bits[2].toInt();
 
 	if (!reader) {
+#if ( QT_VERSION >= 0x050000 )
 	    QSKIP("Unsupported file, skipping");
+#else
+	    QSKIP("Unsupported file, skipping", SkipSingle);
+#endif
 	}
 
         QCOMPARE((int)reader->getChannelCount(), nominalChannels);