comparison data/fileio/WavFileReader.cpp @ 290:92e8dbde73cd

* Revert revision 713. We do like QStrings after all.
author Chris Cannam
date Fri, 24 Aug 2007 11:41:48 +0000
parents 20028c634494
children 3a6725f285d6
comparison
equal deleted inserted replaced
289:3020904de772 290:92e8dbde73cd
17 17
18 #include <iostream> 18 #include <iostream>
19 19
20 #include <QMutexLocker> 20 #include <QMutexLocker>
21 21
22 WavFileReader::WavFileReader(std::string path, bool fileUpdating) : 22 WavFileReader::WavFileReader(QString 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.c_str(), SFM_READ, &m_fileInfo); 37 m_file = sf_open(m_path.toLocal8Bit(), 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 setError("Couldn't load audio file", sf_strerror(m_file)); 44 m_error = QString("Couldn't load audio file '%1':\n%2")
45 .arg(m_path).arg(sf_strerror(m_file));
45 } else { 46 } else {
46 setError("Failed to open audio file"); 47 m_error = QString("Failed to open audio file '%1'")
48 .arg(m_path);
47 } 49 }
48 return; 50 return;
49 } 51 }
50 52
51 if (m_fileInfo.channels > 0) { 53 if (m_fileInfo.channels > 0) {
70 72
71 size_t prevCount = m_fileInfo.frames; 73 size_t prevCount = m_fileInfo.frames;
72 74
73 if (m_file) { 75 if (m_file) {
74 sf_close(m_file); 76 sf_close(m_file);
75 m_file = sf_open(m_path.c_str(), SFM_READ, &m_fileInfo); 77 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo);
76 if (!m_file || m_fileInfo.channels <= 0) { 78 if (!m_file || m_fileInfo.channels <= 0) {
77 std::cerr << "WavFileReader::updateFrameCount: Failed to open file (" 79 std::cerr << "WavFileReader::updateFrameCount: Failed to open file ("
78 << sf_strerror(m_file) << ")" << std::endl; 80 << sf_strerror(m_file) << ")" << std::endl;
79 } 81 }
80 } 82 }
160 162
161 return; 163 return;
162 } 164 }
163 165
164 void 166 void
165 WavFileReader::getSupportedExtensions(std::set<std::string> &extensions) 167 WavFileReader::getSupportedExtensions(std::set<QString> &extensions)
166 { 168 {
167 int count; 169 int count;
168 170
169 if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) { 171 if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) {
170 extensions.insert("wav"); 172 extensions.insert("wav");