comparison data/model/ReadOnlyWaveFileModel.cpp @ 1751:77543124651b by-id

Overhaul PlayParameters bits
author Chris Cannam
date Thu, 04 Jul 2019 18:04:21 +0100
parents 70e172e6cc59
children 6d09d68165a4
comparison
equal deleted inserted replaced
1750:d0ef65d8dd89 1751:77543124651b
19 #include "fileio/AudioFileReaderFactory.h" 19 #include "fileio/AudioFileReaderFactory.h"
20 20
21 #include "system/System.h" 21 #include "system/System.h"
22 22
23 #include "base/Preferences.h" 23 #include "base/Preferences.h"
24 #include "base/PlayParameterRepository.h"
24 25
25 #include <QFileInfo> 26 #include <QFileInfo>
26 #include <QTextStream> 27 #include <QTextStream>
27 28
28 #include <iostream> 29 #include <iostream>
29 //#include <unistd.h>
30 #include <cmath> 30 #include <cmath>
31 #include <sndfile.h> 31 #include <sndfile.h>
32 32
33 #include <cassert> 33 #include <cassert>
34 34
83 } 83 }
84 84
85 if (m_reader) setObjectName(m_reader->getTitle()); 85 if (m_reader) setObjectName(m_reader->getTitle());
86 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); 86 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName());
87 if (isOK()) fillCache(); 87 if (isOK()) fillCache();
88
89 PlayParameterRepository::getInstance()->addPlayable
90 (getId().untyped, this);
88 } 91 }
89 92
90 ReadOnlyWaveFileModel::ReadOnlyWaveFileModel(FileSource source, AudioFileReader *reader) : 93 ReadOnlyWaveFileModel::ReadOnlyWaveFileModel(FileSource source, AudioFileReader *reader) :
91 m_source(source), 94 m_source(source),
92 m_path(source.getLocation()), 95 m_path(source.getLocation()),
104 107
105 m_reader = reader; 108 m_reader = reader;
106 if (m_reader) setObjectName(m_reader->getTitle()); 109 if (m_reader) setObjectName(m_reader->getTitle());
107 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); 110 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName());
108 fillCache(); 111 fillCache();
112
113 PlayParameterRepository::getInstance()->addPlayable
114 (getId().untyped, this);
109 } 115 }
110 116
111 ReadOnlyWaveFileModel::~ReadOnlyWaveFileModel() 117 ReadOnlyWaveFileModel::~ReadOnlyWaveFileModel()
112 { 118 {
119 PlayParameterRepository::getInstance()->removePlayable
120 (getId().untyped);
121
113 m_exiting = true; 122 m_exiting = true;
114 if (m_fillThread) m_fillThread->wait(); 123 if (m_fillThread) m_fillThread->wait();
115 if (m_myReader) delete m_reader; 124 if (m_myReader) delete m_reader;
116 m_reader = nullptr; 125 m_reader = nullptr;
117 126