Mercurial > hg > svcore
diff data/model/WaveFileModel.cpp @ 316:3a6725f285d6
* Make RemoteFile far more pervasive, and use it for local files as well
so that we can handle both transparently. Make it shallow copy with
reference counting, so it can be used by value without having to worry
about the cache file lifetime. Use RemoteFile for MainWindow file-open
functions, etc
author | Chris Cannam |
---|---|
date | Thu, 18 Oct 2007 15:31:20 +0000 |
parents | 70a232b1f12a |
children | c324d410b096 |
line wrap: on
line diff
--- a/data/model/WaveFileModel.cpp Thu Oct 18 10:24:26 2007 +0000 +++ b/data/model/WaveFileModel.cpp Thu Oct 18 15:31:20 2007 +0000 @@ -39,8 +39,9 @@ PowerOfSqrtTwoZoomConstraint WaveFileModel::m_zoomConstraint; -WaveFileModel::WaveFileModel(QString path, size_t targetRate) : - m_path(path), +WaveFileModel::WaveFileModel(RemoteFile source, size_t targetRate) : + m_source(source), + m_path(source.getLocation()), m_myReader(true), m_startFrame(0), m_fillThread(0), @@ -48,31 +49,22 @@ m_lastFillExtent(0), m_exiting(false) { - m_reader = AudioFileReaderFactory::createReader(path, targetRate); - if (m_reader) std::cerr << "WaveFileModel::WaveFileModel: reader rate: " << m_reader->getSampleRate() << std::endl; + m_source.waitForData(); + if (m_source.isOK()) { + m_reader = AudioFileReaderFactory::createReader(m_source, targetRate); + if (m_reader) { + std::cerr << "WaveFileModel::WaveFileModel: reader rate: " + << m_reader->getSampleRate() << std::endl; + } + } if (m_reader) setObjectName(m_reader->getTitle()); - if (objectName() == "") setObjectName(QFileInfo(path).fileName()); + if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); if (isOK()) fillCache(); } -WaveFileModel::WaveFileModel(QString path, QString originalLocation, size_t targetRate) : - m_path(originalLocation), - m_myReader(true), - m_startFrame(0), - m_fillThread(0), - m_updateTimer(0), - m_lastFillExtent(0), - m_exiting(false) -{ - m_reader = AudioFileReaderFactory::createReader(path, targetRate); - if (m_reader) std::cerr << "WaveFileModel::WaveFileModel: reader rate: " << m_reader->getSampleRate() << std::endl; - if (m_reader) setObjectName(m_reader->getTitle()); - if (objectName() == "") setObjectName(QFileInfo(originalLocation).fileName()); - if (isOK()) fillCache(); -} - -WaveFileModel::WaveFileModel(QString path, AudioFileReader *reader) : - m_path(path), +WaveFileModel::WaveFileModel(RemoteFile source, AudioFileReader *reader) : + m_source(source), + m_path(source.getLocation()), m_myReader(false), m_startFrame(0), m_fillThread(0), @@ -82,7 +74,7 @@ { m_reader = reader; if (m_reader) setObjectName(m_reader->getTitle()); - if (objectName() == "") setObjectName(QFileInfo(path).fileName()); + if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); fillCache(); } @@ -131,7 +123,7 @@ Model * WaveFileModel::clone() const { - WaveFileModel *model = new WaveFileModel(m_path); + WaveFileModel *model = new WaveFileModel(m_source); return model; }