# HG changeset patch # User Chris Cannam # Date 1373291368 -3600 # Node ID 06c64a1c6785c3724b7bf37c84eb8532bfff65d7 # Parent bb7ea947c60d7ae76d3a608479f69a6308facd55# Parent 97741fe162058fb9a72a3e44687c1ed425fa0cb1 Merge diff -r 97741fe16205 -r 06c64a1c6785 data/fileio/CoreAudioFileReader.cpp --- 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; } diff -r 97741fe16205 -r 06c64a1c6785 data/fileio/test/AudioFileReaderTest.h --- 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);