diff data/fileio/OggVorbisFileReader.cpp @ 297:c022976d18e8

* Merge from sv-match-alignment branch (excluding alignment-specific document). - add aggregate wave model (not yet complete enough to be added as a true model in a layer, but there's potential) - add play solo mode - add alignment model -- unused in plain SV - fix two plugin leaks - add m3u playlist support (opens all files at once, potentially hazardous) - fix retrieval of pre-encoded URLs - add ability to resample audio files on import, so as to match rates with other files previously loaded; add preference for same - add preliminary support in transform code for range and rate of transform input - reorganise preferences dialog, move dark-background option to preferences, add option for temporary directory location
author Chris Cannam
date Fri, 28 Sep 2007 13:56:38 +0000
parents 92e8dbde73cd
children 3a6725f285d6
line wrap: on
line diff
--- a/data/fileio/OggVorbisFileReader.cpp	Fri Sep 21 09:13:11 2007 +0000
+++ b/data/fileio/OggVorbisFileReader.cpp	Fri Sep 28 13:56:38 2007 +0000
@@ -34,8 +34,9 @@
 
 OggVorbisFileReader::OggVorbisFileReader(QString path,
                                          DecodeMode decodeMode,
-                                         CacheMode mode) :
-    CodedAudioFileReader(mode),
+                                         CacheMode mode,
+                                         size_t targetRate) :
+    CodedAudioFileReader(mode, targetRate),
     m_path(path),
     m_progress(0),
     m_fileSize(0),
@@ -45,9 +46,8 @@
     m_completion(0),
     m_decodeThread(0)
 {
-    m_frameCount = 0;
     m_channelCount = 0;
-    m_sampleRate = 0;
+    m_fileRate = 0;
 
     std::cerr << "OggVorbisFileReader::OggVorbisFileReader(" << path.toLocal8Bit().data() << "): now have " << (++instances) << " instances" << std::endl;
 
@@ -111,6 +111,11 @@
 void
 OggVorbisFileReader::DecodeThread::run()
 {
+    if (m_reader->m_cacheMode == CacheInTemporaryFile) {
+        m_reader->m_completion = 1;
+        m_reader->startSerialised("OggVorbisFileReader::Decode");
+    }
+
     while (oggz_read(m_reader->m_oggz, 1024) > 0);
         
     fish_sound_delete(m_reader->m_fishSound);
@@ -120,6 +125,8 @@
     
     if (m_reader->isDecodeCacheInitialised()) m_reader->finishDecodeCache();
     m_reader->m_completion = 100;
+
+    m_reader->endSerialised();
 } 
 
 int
@@ -175,22 +182,13 @@
 	FishSoundInfo fsinfo;
 	fish_sound_command(fs, FISH_SOUND_GET_INFO,
 			   &fsinfo, sizeof(FishSoundInfo));
+	reader->m_fileRate = fsinfo.samplerate;
 	reader->m_channelCount = fsinfo.channels;
-	reader->m_sampleRate = fsinfo.samplerate;
         reader->initialiseDecodeCache();
     }
 
     if (nframes > 0) {
-
-	reader->m_frameCount += nframes;
-    
-	for (long i = 0; i < nframes; ++i) {
-	    for (size_t c = 0; c < reader->m_channelCount; ++c) {
-                reader->addSampleToDecodeCache(frames[c][i]);
-	    }
-	}
-
-	MUNLOCK_SAMPLEBLOCK(reader->m_data);
+        reader->addSamplesToDecodeCache(frames, nframes);
     }
 
     if (reader->m_cancelled) return 1;