diff data/fileio/WavFileReader.cpp @ 187:89b05b679dc3

* Fixes to update logic in writable wave file model
author Chris Cannam
date Thu, 12 Oct 2006 16:10:49 +0000
parents 570794f6f6a7
children f86b74d1b143
line wrap: on
line diff
--- a/data/fileio/WavFileReader.cpp	Thu Oct 12 14:56:28 2006 +0000
+++ b/data/fileio/WavFileReader.cpp	Thu Oct 12 16:10:49 2006 +0000
@@ -36,7 +36,7 @@
     m_fileInfo.frames = 0;
     m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo);
 
-    if (!m_file || m_fileInfo.channels <= 0) {
+    if (!m_file || (!fileUpdating && m_fileInfo.channels <= 0)) {
 	std::cerr << "WavFileReader::initialize: Failed to open file ("
 		  << sf_strerror(m_file) << ")" << std::endl;
 
@@ -50,9 +50,11 @@
 	return;
     }
 
-    m_frameCount = m_fileInfo.frames;
-    m_channelCount = m_fileInfo.channels;
-    m_sampleRate = m_fileInfo.samplerate;
+    if (m_fileInfo.channels > 0) {
+        m_frameCount = m_fileInfo.frames;
+        m_channelCount = m_fileInfo.channels;
+        m_sampleRate = m_fileInfo.samplerate;
+    }
 
     std::cerr << "WavFileReader: Frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << std::endl;
 
@@ -83,6 +85,11 @@
 
     m_frameCount = m_fileInfo.frames;
 
+    if (m_channelCount == 0) {
+        m_channelCount = m_fileInfo.channels;
+        m_sampleRate = m_fileInfo.samplerate;
+    }
+
     if (m_frameCount != prevCount) emit frameCountChanged();
 }