comparison data/fileio/WavFileReader.cpp @ 285:20028c634494

* change some QStrings to std::strings etc
author Chris Cannam
date Thu, 09 Aug 2007 16:29:29 +0000
parents dc46851837d6
children 92e8dbde73cd
comparison
equal deleted inserted replaced
284:41d64b873d87 285:20028c634494
17 17
18 #include <iostream> 18 #include <iostream>
19 19
20 #include <QMutexLocker> 20 #include <QMutexLocker>
21 21
22 WavFileReader::WavFileReader(QString path, bool fileUpdating) : 22 WavFileReader::WavFileReader(std::string path, bool fileUpdating) :
23 m_file(0), 23 m_file(0),
24 m_path(path), 24 m_path(path),
25 m_buffer(0), 25 m_buffer(0),
26 m_bufsiz(0), 26 m_bufsiz(0),
27 m_lastStart(0), 27 m_lastStart(0),
32 m_channelCount = 0; 32 m_channelCount = 0;
33 m_sampleRate = 0; 33 m_sampleRate = 0;
34 34
35 m_fileInfo.format = 0; 35 m_fileInfo.format = 0;
36 m_fileInfo.frames = 0; 36 m_fileInfo.frames = 0;
37 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo); 37 m_file = sf_open(m_path.c_str(), SFM_READ, &m_fileInfo);
38 38
39 if (!m_file || (!fileUpdating && m_fileInfo.channels <= 0)) { 39 if (!m_file || (!fileUpdating && m_fileInfo.channels <= 0)) {
40 std::cerr << "WavFileReader::initialize: Failed to open file (" 40 std::cerr << "WavFileReader::initialize: Failed to open file ("
41 << sf_strerror(m_file) << ")" << std::endl; 41 << sf_strerror(m_file) << ")" << std::endl;
42 42
43 if (m_file) { 43 if (m_file) {
44 m_error = QString("Couldn't load audio file '%1':\n%2") 44 setError("Couldn't load audio file", sf_strerror(m_file));
45 .arg(m_path).arg(sf_strerror(m_file));
46 } else { 45 } else {
47 m_error = QString("Failed to open audio file '%1'") 46 setError("Failed to open audio file");
48 .arg(m_path);
49 } 47 }
50 return; 48 return;
51 } 49 }
52 50
53 if (m_fileInfo.channels > 0) { 51 if (m_fileInfo.channels > 0) {
72 70
73 size_t prevCount = m_fileInfo.frames; 71 size_t prevCount = m_fileInfo.frames;
74 72
75 if (m_file) { 73 if (m_file) {
76 sf_close(m_file); 74 sf_close(m_file);
77 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo); 75 m_file = sf_open(m_path.c_str(), SFM_READ, &m_fileInfo);
78 if (!m_file || m_fileInfo.channels <= 0) { 76 if (!m_file || m_fileInfo.channels <= 0) {
79 std::cerr << "WavFileReader::updateFrameCount: Failed to open file (" 77 std::cerr << "WavFileReader::updateFrameCount: Failed to open file ("
80 << sf_strerror(m_file) << ")" << std::endl; 78 << sf_strerror(m_file) << ")" << std::endl;
81 } 79 }
82 } 80 }
162 160
163 return; 161 return;
164 } 162 }
165 163
166 void 164 void
167 WavFileReader::getSupportedExtensions(std::set<QString> &extensions) 165 WavFileReader::getSupportedExtensions(std::set<std::string> &extensions)
168 { 166 {
169 int count; 167 int count;
170 168
171 if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) { 169 if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) {
172 extensions.insert("wav"); 170 extensions.insert("wav");