# HG changeset patch # User Chris Cannam # Date 1186676969 0 # Node ID 20028c6344947d770c0baf1213c9898a66577bf9 # Parent 41d64b873d87208d1abbb3a58dc736bda089a585 * change some QStrings to std::strings etc diff -r 41d64b873d87 -r 20028c634494 data/fileio/AudioFileReader.cpp --- a/data/fileio/AudioFileReader.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/AudioFileReader.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -15,3 +15,19 @@ #include "AudioFileReader.h" +void +AudioFileReader::setError(std::string text, std::string arg) +{ + if (arg == "") m_error = text; + else m_error = text + ": " + arg; +} + +void +AudioFileReader::setError(std::string text, int arg) +{ + char *buf = new char(text.length() + 100); + sprintf(buf, "%s: code %d", text.c_str(), arg); + m_error = buf; + delete[] buf; +} + diff -r 41d64b873d87 -r 20028c634494 data/fileio/AudioFileReader.h --- a/data/fileio/AudioFileReader.h Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/AudioFileReader.h Thu Aug 09 16:29:29 2007 +0000 @@ -16,8 +16,10 @@ #ifndef _AUDIO_FILE_READER_H_ #define _AUDIO_FILE_READER_H_ -#include -#include "model/Model.h" // for SampleBlock +#include + +#include +#include class AudioFileReader : public QObject { @@ -26,9 +28,11 @@ public: virtual ~AudioFileReader() { } + typedef std::vector SampleBlock; + bool isOK() const { return (m_channelCount > 0); } - virtual QString getError() const { return ""; } + virtual std::string getError() const { return m_error; } size_t getFrameCount() const { return m_frameCount; } size_t getChannelCount() const { return m_channelCount; } @@ -39,7 +43,7 @@ * may be implemented by subclasses that support file tagging. * This is not the same thing as the file name. */ - virtual QString getTitle() const { return ""; } + virtual std::string getTitle() const { return ""; } /** * The subclass implementations of this function must be @@ -62,6 +66,10 @@ size_t m_frameCount; size_t m_channelCount; size_t m_sampleRate; + + std::string m_error; + void setError(std::string text, std::string arg = ""); + void setError(std::string text, int arg); }; #endif diff -r 41d64b873d87 -r 20028c634494 data/fileio/AudioFileReaderFactory.cpp --- a/data/fileio/AudioFileReaderFactory.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/AudioFileReaderFactory.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -24,10 +24,10 @@ #include #include -QString +std::string AudioFileReaderFactory::getKnownExtensions() { - std::set extensions; + std::set extensions; WavFileReader::getSupportedExtensions(extensions); #ifdef HAVE_MAD @@ -42,8 +42,8 @@ QuickTimeFileReader::getSupportedExtensions(extensions); #endif - QString rv; - for (std::set::const_iterator i = extensions.begin(); + std::string rv; + for (std::set::const_iterator i = extensions.begin(); i != extensions.end(); ++i) { if (i != extensions.begin()) rv += " "; rv += "*." + *i; @@ -53,9 +53,9 @@ } AudioFileReader * -AudioFileReaderFactory::createReader(QString path) +AudioFileReaderFactory::createReader(std::string path) { - QString err; + std::string err; AudioFileReader *reader = 0; @@ -63,8 +63,16 @@ // extension. If we can't identify one or it fails to load the // file, fall back to trying all readers in no particular order. - QString ext = QFileInfo(path).suffix().toLower(); - std::set extensions; + std::string ext; + std::string::size_type idx = path.rfind('.'); + if (idx != std::string::npos) { + ext = path.substr(idx + 1); + for (size_t i = 0; i < ext.length(); ++i) { + ext[i] = std::tolower(ext[i]); + } + } + + std::set extensions; WavFileReader::getSupportedExtensions(extensions); if (extensions.find(ext) != extensions.end()) { @@ -116,11 +124,11 @@ if (reader->isOK()) return reader; if (reader->getError() != "") { std::cerr << "AudioFileReaderFactory: Preferred reader for " - << "extension \"" << ext.toStdString() << "\" failed: \"" - << reader->getError().toStdString() << "\"" << std::endl; + << "extension \"" << ext << "\" failed: \"" + << reader->getError() << "\"" << std::endl; } else { std::cerr << "AudioFileReaderFactory: Preferred reader for " - << "extension \"" << ext.toStdString() << "\" failed" + << "extension \"" << ext << "\" failed" << std::endl; } delete reader; @@ -131,7 +139,7 @@ if (reader->isOK()) return reader; if (reader->getError() != "") { std::cerr << "AudioFileReaderFactory: WAV file reader error: \"" - << reader->getError().toStdString() << "\"" << std::endl; + << reader->getError() << "\"" << std::endl; } else { std::cerr << "AudioFileReaderFactory: WAV file reader failed" << std::endl; @@ -147,7 +155,7 @@ if (reader->isOK()) return reader; if (reader->getError() != "") { std::cerr << "AudioFileReaderFactory: Ogg file reader error: \"" - << reader->getError().toStdString() << "\"" << std::endl; + << reader->getError() << "\"" << std::endl; } else { std::cerr << "AudioFileReaderFactory: Ogg file reader failed" << std::endl; @@ -164,7 +172,7 @@ if (reader->isOK()) return reader; if (reader->getError() != "") { std::cerr << "AudioFileReaderFactory: MP3 file reader error: \"" - << reader->getError().toStdString() << "\"" << std::endl; + << reader->getError() << "\"" << std::endl; } else { std::cerr << "AudioFileReaderFactory: MP3 file reader failed" << std::endl; @@ -180,7 +188,7 @@ if (reader->isOK()) return reader; if (reader->getError() != "") { std::cerr << "AudioFileReaderFactory: QuickTime file reader error: \"" - << reader->getError().toStdString() << "\"" << std::endl; + << reader->getError() << "\"" << std::endl; } else { std::cerr << "AudioFileReaderFactory: QuickTime file reader failed" << std::endl; diff -r 41d64b873d87 -r 20028c634494 data/fileio/AudioFileReaderFactory.h --- a/data/fileio/AudioFileReaderFactory.h Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/AudioFileReaderFactory.h Thu Aug 09 16:29:29 2007 +0000 @@ -16,7 +16,7 @@ #ifndef _AUDIO_FILE_READER_FACTORY_H_ #define _AUDIO_FILE_READER_FACTORY_H_ -#include +#include class AudioFileReader; @@ -28,7 +28,7 @@ * in a format suitable for use with QFileDialog. For example, * "*.wav *.aiff *.ogg". */ - static QString getKnownExtensions(); + static std::string getKnownExtensions(); /** * Return an audio file reader initialised to the file at the @@ -36,7 +36,7 @@ * available or the file cannot be opened. * Caller owns the returned object and must delete it after use. */ - static AudioFileReader *createReader(QString path); + static AudioFileReader *createReader(std::string path); }; #endif diff -r 41d64b873d87 -r 20028c634494 data/fileio/CodedAudioFileReader.cpp --- a/data/fileio/CodedAudioFileReader.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/CodedAudioFileReader.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -44,8 +44,8 @@ if (m_cacheWriteBuffer) delete[] m_cacheWriteBuffer; if (m_cacheFileName != "") { - if (!QFile(m_cacheFileName).remove()) { - std::cerr << "WARNING: CodedAudioFileReader::~CodedAudioFileReader: Failed to delete cache file \"" << m_cacheFileName.toStdString() << "\"" << std::endl; + if (!QFile(m_cacheFileName.c_str()).remove()) { + std::cerr << "WARNING: CodedAudioFileReader::~CodedAudioFileReader: Failed to delete cache file \"" << m_cacheFileName << "\"" << std::endl; } } } @@ -63,14 +63,14 @@ try { QDir dir(TempDirectory::getInstance()->getPath()); m_cacheFileName = dir.filePath(QString("decoded_%1.wav") - .arg((intptr_t)this)); + .arg((intptr_t)this)).toStdString(); SF_INFO fileInfo; fileInfo.samplerate = m_sampleRate; fileInfo.channels = m_channelCount; fileInfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; - m_cacheFileWritePtr = sf_open(m_cacheFileName.toLocal8Bit(), + m_cacheFileWritePtr = sf_open(m_cacheFileName.c_str(), SFM_WRITE, &fileInfo); if (m_cacheFileWritePtr) { @@ -83,14 +83,14 @@ m_cacheFileReader = new WavFileReader(m_cacheFileName); if (!m_cacheFileReader->isOK()) { - std::cerr << "ERROR: CodedAudioFileReader::initialiseDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError().toStdString() << std::endl; + std::cerr << "ERROR: CodedAudioFileReader::initialiseDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError() << std::endl; delete m_cacheFileReader; m_cacheFileReader = 0; m_cacheMode = CacheInMemory; sf_close(m_cacheFileWritePtr); } } else { - std::cerr << "CodedAudioFileReader::initialiseDecodeCache: failed to open cache file \"" << m_cacheFileName.toStdString() << "\" (" << m_channelCount << " channels, sample rate " << m_sampleRate << " for writing, falling back to in-memory cache" << std::endl; + std::cerr << "CodedAudioFileReader::initialiseDecodeCache: failed to open cache file \"" << m_cacheFileName << "\" (" << m_channelCount << " channels, sample rate " << m_sampleRate << " for writing, falling back to in-memory cache" << std::endl; m_cacheMode = CacheInMemory; } @@ -181,7 +181,7 @@ m_cacheFileReader = new WavFileReader(m_cacheFileName); if (!m_cacheFileReader->isOK()) { - std::cerr << "ERROR: CodedAudioFileReader::finishDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError().toStdString() << std::endl; + std::cerr << "ERROR: CodedAudioFileReader::finishDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError() << std::endl; delete m_cacheFileReader; m_cacheFileReader = 0; }*/ diff -r 41d64b873d87 -r 20028c634494 data/fileio/CodedAudioFileReader.h --- a/data/fileio/CodedAudioFileReader.h Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/CodedAudioFileReader.h Thu Aug 09 16:29:29 2007 +0000 @@ -49,7 +49,7 @@ SampleBlock m_data; bool m_initialised; - QString m_cacheFileName; + std::string m_cacheFileName; SNDFILE *m_cacheFileWritePtr; WavFileReader *m_cacheFileReader; float *m_cacheWriteBuffer; diff -r 41d64b873d87 -r 20028c634494 data/fileio/FileFinder.cpp --- a/data/fileio/FileFinder.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/FileFinder.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -68,7 +68,7 @@ settingsKey = "audiopath"; title = "Select an audio file"; filter = tr("Audio files (%1)\nAll files (*.*)") - .arg(AudioFileReaderFactory::getKnownExtensions()); + .arg(AudioFileReaderFactory::getKnownExtensions().c_str()); break; case LayerFile: @@ -79,7 +79,7 @@ case SessionOrAudioFile: settingsKey = "lastpath"; filter = tr("All supported files (*.sv %1)\nSonic Visualiser session files (*.sv)\nAudio files (%1)\nAll files (*.*)") - .arg(AudioFileReaderFactory::getKnownExtensions()); + .arg(AudioFileReaderFactory::getKnownExtensions().c_str()); break; case ImageFile: @@ -90,7 +90,7 @@ case AnyFile: settingsKey = "lastpath"; filter = tr("All supported files (*.sv %1 %2)\nSonic Visualiser session files (*.sv)\nAudio files (%1)\nLayer files (%2)\nAll files (*.*)") - .arg(AudioFileReaderFactory::getKnownExtensions()) + .arg(AudioFileReaderFactory::getKnownExtensions().c_str()) .arg(DataFileReaderFactory::getKnownExtensions()); break; }; diff -r 41d64b873d87 -r 20028c634494 data/fileio/MP3FileReader.cpp --- a/data/fileio/MP3FileReader.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/MP3FileReader.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -34,7 +34,7 @@ #include #include -MP3FileReader::MP3FileReader(QString path, DecodeMode decodeMode, CacheMode mode) : +MP3FileReader::MP3FileReader(std::string path, DecodeMode decodeMode, CacheMode mode) : CodedAudioFileReader(mode), m_path(path), m_decodeThread(0) @@ -52,20 +52,20 @@ m_progress = 0; struct stat stat; - if (::stat(path.toLocal8Bit().data(), &stat) == -1 || stat.st_size == 0) { - m_error = QString("File %1 does not exist.").arg(path); + if (::stat(path.c_str(), &stat) == -1 || stat.st_size == 0) { + setError("File does not exist", path); return; } m_fileSize = stat.st_size; int fd = -1; - if ((fd = ::open(path.toLocal8Bit().data(), O_RDONLY + if ((fd = ::open(path.c_str(), O_RDONLY #ifdef _WIN32 | O_BINARY #endif , 0)) < 0) { - m_error = QString("Failed to open file %1 for reading.").arg(path); + setError("Failed to open file for reading", path); return; } @@ -74,7 +74,7 @@ try { m_filebuffer = new unsigned char[m_fileSize]; } catch (...) { - m_error = QString("Out of memory"); + setError("Out of memory"); ::close(fd); return; } @@ -84,8 +84,7 @@ while (offset < m_fileSize) { sz = ::read(fd, m_filebuffer + offset, m_fileSize - offset); if (sz < 0) { - m_error = QString("Read error for file %1 (after %2 bytes)") - .arg(path).arg(offset); + setError("Read error", path); delete[] m_filebuffer; ::close(fd); return; @@ -105,12 +104,12 @@ if (decodeMode == DecodeAtOnce) { m_progress = new QProgressDialog - (QObject::tr("Decoding %1...").arg(QFileInfo(path).fileName()), + (QObject::tr("Decoding %1...").arg(QFileInfo(path.c_str()).fileName()), QObject::tr("Stop"), 0, 100); m_progress->hide(); if (!decode(m_filebuffer, m_fileSize)) { - m_error = QString("Failed to decode file %1.").arg(path); + setError("Failed to decode file", path); } delete[] m_filebuffer; @@ -148,7 +147,7 @@ #ifdef HAVE_ID3TAG - id3_file *file = id3_file_open(m_path.toLocal8Bit().data(), + id3_file *file = id3_file_open(m_path.c_str(), ID3_FILE_MODE_READONLY); if (!file) return; @@ -204,7 +203,7 @@ return; } - m_title = QString::fromUtf8((const char *)u8str); + m_title = (const char *)u8str; free(u8str); id3_file_close(file); @@ -221,7 +220,7 @@ MP3FileReader::DecodeThread::run() { if (!m_reader->decode(m_reader->m_filebuffer, m_reader->m_fileSize)) { - m_reader->m_error = QString("Failed to decode file %1.").arg(m_reader->m_path); + m_reader->setError("Failed to decode file", m_reader->m_path); } delete[] m_reader->m_filebuffer; @@ -361,7 +360,7 @@ } void -MP3FileReader::getSupportedExtensions(std::set &extensions) +MP3FileReader::getSupportedExtensions(std::set &extensions) { extensions.insert("mp3"); } diff -r 41d64b873d87 -r 20028c634494 data/fileio/MP3FileReader.h --- a/data/fileio/MP3FileReader.h Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/MP3FileReader.h Thu Aug 09 16:29:29 2007 +0000 @@ -35,14 +35,12 @@ DecodeThreaded // decode in a background thread after construction }; - MP3FileReader(QString path, DecodeMode decodeMode, CacheMode cacheMode); + MP3FileReader(std::string path, DecodeMode decodeMode, CacheMode cacheMode); virtual ~MP3FileReader(); - virtual QString getError() const { return m_error; } - - virtual QString getTitle() const { return m_title; } + virtual std::string getTitle() const { return m_title; } - static void getSupportedExtensions(std::set &extensions); + static void getSupportedExtensions(std::set &extensions); virtual int getDecodeCompletion() const { return m_completion; } @@ -51,9 +49,8 @@ } protected: - QString m_path; - QString m_error; - QString m_title; + std::string m_path; + std::string m_title; size_t m_fileSize; double m_bitrateNum; size_t m_bitrateDenom; diff -r 41d64b873d87 -r 20028c634494 data/fileio/OggVorbisFileReader.cpp --- a/data/fileio/OggVorbisFileReader.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/OggVorbisFileReader.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -32,7 +32,7 @@ static int instances = 0; -OggVorbisFileReader::OggVorbisFileReader(QString path, +OggVorbisFileReader::OggVorbisFileReader(std::string path, DecodeMode decodeMode, CacheMode mode) : CodedAudioFileReader(mode), @@ -49,15 +49,15 @@ m_channelCount = 0; m_sampleRate = 0; - std::cerr << "OggVorbisFileReader::OggVorbisFileReader(" << path.toLocal8Bit().data() << "): now have " << (++instances) << " instances" << std::endl; + std::cerr << "OggVorbisFileReader::OggVorbisFileReader(" << path << "): now have " << (++instances) << " instances" << std::endl; Profiler profiler("OggVorbisFileReader::OggVorbisFileReader", true); - QFileInfo info(path); + QFileInfo info(path.c_str()); m_fileSize = info.size(); - if (!(m_oggz = oggz_open(path.toLocal8Bit().data(), OGGZ_READ))) { - m_error = QString("File %1 is not an OGG file.").arg(path); + if (!(m_oggz = oggz_open(path.c_str(), OGGZ_READ))) { + setError("File is not an OGG file", path); return; } @@ -70,7 +70,7 @@ if (decodeMode == DecodeAtOnce) { m_progress = new QProgressDialog - (QObject::tr("Decoding %1...").arg(QFileInfo(path).fileName()), + (QObject::tr("Decoding %1...").arg(QFileInfo(path.c_str()).fileName()), QObject::tr("Stop"), 0, 100); m_progress->hide(); @@ -100,7 +100,7 @@ OggVorbisFileReader::~OggVorbisFileReader() { - std::cerr << "OggVorbisFileReader::~OggVorbisFileReader(" << m_path.toLocal8Bit().data() << "): now have " << (--instances) << " instances" << std::endl; + std::cerr << "OggVorbisFileReader::~OggVorbisFileReader(" << m_path << "): now have " << (--instances) << " instances" << std::endl; if (m_decodeThread) { m_cancelled = true; m_decodeThread->wait(); @@ -166,7 +166,7 @@ const FishSoundComment *comment = fish_sound_comment_first_byname (fs, "TITLE"); if (comment && comment->value) { - reader->m_title = QString::fromUtf8(comment->value); + reader->m_title = comment->value; } reader->m_commentsRead = true; } @@ -198,7 +198,7 @@ } void -OggVorbisFileReader::getSupportedExtensions(std::set &extensions) +OggVorbisFileReader::getSupportedExtensions(std::set &extensions) { extensions.insert("ogg"); } diff -r 41d64b873d87 -r 20028c634494 data/fileio/OggVorbisFileReader.h --- a/data/fileio/OggVorbisFileReader.h Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/OggVorbisFileReader.h Thu Aug 09 16:29:29 2007 +0000 @@ -37,15 +37,13 @@ DecodeThreaded // decode in a background thread after construction }; - OggVorbisFileReader(QString path, DecodeMode decodeMode, + OggVorbisFileReader(std::string path, DecodeMode decodeMode, CacheMode cacheMode); virtual ~OggVorbisFileReader(); - virtual QString getError() const { return m_error; } - - virtual QString getTitle() const { return m_title; } + virtual std::string getTitle() const { return m_title; } - static void getSupportedExtensions(std::set &extensions); + static void getSupportedExtensions(std::set &extensions); virtual int getDecodeCompletion() const { return m_completion; } @@ -54,9 +52,8 @@ } protected: - QString m_path; - QString m_error; - QString m_title; + std::string m_path; + std::string m_title; OGGZ *m_oggz; FishSound *m_fishSound; diff -r 41d64b873d87 -r 20028c634494 data/fileio/QuickTimeFileReader.cpp --- a/data/fileio/QuickTimeFileReader.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/QuickTimeFileReader.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -48,7 +48,7 @@ }; -QuickTimeFileReader::QuickTimeFileReader(QString path, +QuickTimeFileReader::QuickTimeFileReader(std::string path, DecodeMode decodeMode, CacheMode mode) : CodedAudioFileReader(mode), @@ -74,7 +74,7 @@ #else m_d->err = Gestalt(gestaltQuickTime,&QTversion); if ((m_d->err != noErr) || (QTversion < 0x07000000)) { - m_error = QString("Failed to find compatible version of QuickTime (version 7 or above required)"); + setError("Failed to find compatible version of QuickTime (version 7 or above required)"); return; } #endif @@ -100,7 +100,7 @@ (url, 0, &dataRef, &dataRefType); if (m_d->err) { - m_error = QString("Error creating data reference for QuickTime decoder: code %1").arg(m_d->err); + setError("Error creating data reference for QuickTime decoder", m_d->err); return; } @@ -111,7 +111,7 @@ DisposeHandle(dataRef); if (m_d->err) { - m_error = QString("Error creating new movie for QuickTime decoder: code %1").arg(m_d->err); + setError("Error creating new movie for QuickTime decoder", m_d->err); return; } @@ -140,10 +140,10 @@ } if (m_d->err && m_d->err != kQTPropertyNotSupportedErr) { - m_error = QString("Error checking for DRM in QuickTime decoder: code %1").arg(m_d->err); + setError("Error checking for DRM in QuickTime decoder", m_d->err); return; } else if (!m_d->err && isProtected) { - m_error = QString("File is protected with DRM"); + setError("File is protected with DRM"); return; } else if (m_d->err == kQTPropertyNotSupportedErr && !isProtected) { std::cerr << "QuickTime: File is not protected with DRM" << std::endl; @@ -153,18 +153,18 @@ SetMovieActive(m_d->movie, TRUE); m_d->err = GetMoviesError(); if (m_d->err) { - m_error = QString("Error in QuickTime decoder activation: code %1").arg(m_d->err); + setError("Error in QuickTime decoder activation", m_d->err); return; } } else { - m_error = QString("Error in QuickTime decoder: Movie object not valid"); + setError("Error in QuickTime decoder: Movie object not valid"); return; } m_d->err = MovieAudioExtractionBegin (m_d->movie, 0, &m_d->extractionSessionRef); if (m_d->err) { - m_error = QString("Error in QuickTime decoder extraction init: code %1").arg(m_d->err); + setError("Error in QuickTime decoder extraction init", m_d->err); return; } @@ -176,7 +176,7 @@ nil); if (m_d->err) { - m_error = QString("Error in QuickTime decoder property get: code %1").arg(m_d->err); + setError("Error in QuickTime decoder property get", m_d->err); return; } @@ -201,7 +201,7 @@ &m_d->asbd); if (m_d->err) { - m_error = QString("Error in QuickTime decoder property set: code %1").arg(m_d->err); + setError("Error in QuickTime decoder property set", m_d->err); return; } @@ -217,7 +217,7 @@ if (decodeMode == DecodeAtOnce) { m_progress = new QProgressDialog - (QObject::tr("Decoding %1...").arg(QFileInfo(path).fileName()), + (QObject::tr("Decoding %1...").arg(QFileInfo(path.c_str()).fileName()), QObject::tr("Stop"), 0, 100); m_progress->hide(); @@ -229,8 +229,7 @@ (m_d->extractionSessionRef, &framesRead, &m_d->buffer, &extractionFlags); if (m_d->err) { - m_error = QString("Error in QuickTime decoding: code %1") - .arg(m_d->err); + setError("Error in QuickTime decoding", m_d->err); break; } @@ -250,7 +249,7 @@ m_d->err = MovieAudioExtractionEnd(m_d->extractionSessionRef); if (m_d->err) { - m_error = QString("Error ending QuickTime extraction session: code %1").arg(m_d->err); + setError("Error ending QuickTime extraction session", m_d->err); } m_completion = 100; @@ -265,7 +264,7 @@ } } - std::cerr << "QuickTimeFileReader::QuickTimeFileReader: frame count is now " << getFrameCount() << ", error is \"\"" << m_error.toStdString() << "\"" << std::endl; + std::cerr << "QuickTimeFileReader::QuickTimeFileReader: frame count is now " << getFrameCount() << ", error is \"\"" << m_error << "\"" << std::endl; } QuickTimeFileReader::~QuickTimeFileReader() @@ -296,8 +295,8 @@ (m_reader->m_d->extractionSessionRef, &framesRead, &m_reader->m_d->buffer, &extractionFlags); if (m_reader->m_d->err) { - m_reader->m_error = QString("Error in QuickTime decoding: code %1") - .arg(m_reader->m_d->err); + m_reader->setError("Error in QuickTime decoding", + m_reader->m_d->err); break; } @@ -315,14 +314,14 @@ m_reader->m_d->err = MovieAudioExtractionEnd(m_reader->m_d->extractionSessionRef); if (m_reader->m_d->err) { - m_reader->m_error = QString("Error ending QuickTime extraction session: code %1").arg(m_reader->m_d->err); + m_reader->setError("Error ending QuickTime extraction session", m_reader->m_d->err); } m_reader->m_completion = 100; } void -QuickTimeFileReader::getSupportedExtensions(std::set &extensions) +QuickTimeFileReader::getSupportedExtensions(std::set &extensions) { extensions.insert("aiff"); extensions.insert("au"); diff -r 41d64b873d87 -r 20028c634494 data/fileio/QuickTimeFileReader.h --- a/data/fileio/QuickTimeFileReader.h Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/QuickTimeFileReader.h Thu Aug 09 16:29:29 2007 +0000 @@ -37,14 +37,14 @@ DecodeThreaded // decode in a background thread after construction }; - QuickTimeFileReader(QString path, DecodeMode decodeMode, + QuickTimeFileReader(std::string path, + DecodeMode decodeMode, CacheMode cacheMode); virtual ~QuickTimeFileReader(); - virtual QString getError() const { return m_error; } - virtual QString getTitle() const { return m_title; } + virtual std::string getTitle() const { return m_title; } - static void getSupportedExtensions(std::set &extensions); + static void getSupportedExtensions(std::set &extensions); virtual int getDecodeCompletion() const { return m_completion; } @@ -53,9 +53,8 @@ } protected: - QString m_path; - QString m_error; - QString m_title; + std::string m_path; + std::string m_title; class D; D *m_d; diff -r 41d64b873d87 -r 20028c634494 data/fileio/WavFileReader.cpp --- a/data/fileio/WavFileReader.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/WavFileReader.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -19,7 +19,7 @@ #include -WavFileReader::WavFileReader(QString path, bool fileUpdating) : +WavFileReader::WavFileReader(std::string path, bool fileUpdating) : m_file(0), m_path(path), m_buffer(0), @@ -34,18 +34,16 @@ m_fileInfo.format = 0; m_fileInfo.frames = 0; - m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo); + m_file = sf_open(m_path.c_str(), SFM_READ, &m_fileInfo); if (!m_file || (!fileUpdating && m_fileInfo.channels <= 0)) { std::cerr << "WavFileReader::initialize: Failed to open file (" << sf_strerror(m_file) << ")" << std::endl; if (m_file) { - m_error = QString("Couldn't load audio file '%1':\n%2") - .arg(m_path).arg(sf_strerror(m_file)); + setError("Couldn't load audio file", sf_strerror(m_file)); } else { - m_error = QString("Failed to open audio file '%1'") - .arg(m_path); + setError("Failed to open audio file"); } return; } @@ -74,7 +72,7 @@ if (m_file) { sf_close(m_file); - m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo); + m_file = sf_open(m_path.c_str(), SFM_READ, &m_fileInfo); if (!m_file || m_fileInfo.channels <= 0) { std::cerr << "WavFileReader::updateFrameCount: Failed to open file (" << sf_strerror(m_file) << ")" << std::endl; @@ -164,7 +162,7 @@ } void -WavFileReader::getSupportedExtensions(std::set &extensions) +WavFileReader::getSupportedExtensions(std::set &extensions) { int count; diff -r 41d64b873d87 -r 20028c634494 data/fileio/WavFileReader.h --- a/data/fileio/WavFileReader.h Thu Aug 09 14:40:03 2007 +0000 +++ b/data/fileio/WavFileReader.h Thu Aug 09 16:29:29 2007 +0000 @@ -26,11 +26,9 @@ class WavFileReader : public AudioFileReader { public: - WavFileReader(QString path, bool fileUpdating = false); + WavFileReader(std::string path, bool fileUpdating = false); virtual ~WavFileReader(); - virtual QString getError() const { return m_error; } - /** * Must be safe to call from multiple threads with different * arguments on the same object at the same time. @@ -38,7 +36,7 @@ virtual void getInterleavedFrames(size_t start, size_t count, SampleBlock &frames) const; - static void getSupportedExtensions(std::set &extensions); + static void getSupportedExtensions(std::set &extensions); virtual int getDecodeCompletion() const { return 100; } @@ -51,8 +49,7 @@ SF_INFO m_fileInfo; SNDFILE *m_file; - QString m_path; - QString m_error; + std::string m_path; mutable QMutex m_mutex; mutable float *m_buffer; diff -r 41d64b873d87 -r 20028c634494 data/model/Model.h --- a/data/model/Model.h Thu Aug 09 14:40:03 2007 +0000 +++ b/data/model/Model.h Thu Aug 09 16:29:29 2007 +0000 @@ -21,8 +21,6 @@ #include "base/XmlExportable.h" -typedef std::vector SampleBlock; - class ZoomConstraint; /** diff -r 41d64b873d87 -r 20028c634494 data/model/WaveFileModel.cpp --- a/data/model/WaveFileModel.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/model/WaveFileModel.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -46,8 +46,8 @@ m_lastFillExtent(0), m_exiting(false) { - m_reader = AudioFileReaderFactory::createReader(path); - setObjectName(m_reader->getTitle()); + m_reader = AudioFileReaderFactory::createReader(path.toStdString()); + setObjectName(m_reader->getTitle().c_str()); if (objectName() == "") setObjectName(QFileInfo(path).fileName()); if (isOK()) fillCache(); } @@ -60,8 +60,8 @@ m_lastFillExtent(0), m_exiting(false) { - m_reader = AudioFileReaderFactory::createReader(path); - setObjectName(m_reader->getTitle()); + m_reader = AudioFileReaderFactory::createReader(path.toStdString()); + setObjectName(m_reader->getTitle().c_str()); if (objectName() == "") setObjectName(QFileInfo(originalLocation).fileName()); if (isOK()) fillCache(); } @@ -75,7 +75,7 @@ m_exiting(false) { m_reader = reader; - setObjectName(m_reader->getTitle()); + setObjectName(m_reader->getTitle().c_str()); if (objectName() == "") setObjectName(QFileInfo(path).fileName()); fillCache(); } @@ -171,7 +171,7 @@ // << start << ", " << end << "): calling reader" << std::endl; #endif - SampleBlock frames; + AudioFileReader::SampleBlock frames; m_reader->getInterleavedFrames(start, end - start, frames); size_t i = 0; @@ -213,7 +213,7 @@ if (!m_reader || !m_reader->isOK()) return 0; - SampleBlock frames; + AudioFileReader::SampleBlock frames; m_reader->getInterleavedFrames(start, end - start, frames); size_t i = 0; @@ -272,7 +272,7 @@ // matter by putting a single cache in getInterleavedFrames // for short queries. - SampleBlock frames; + AudioFileReader::SampleBlock frames; m_reader->getInterleavedFrames(start, end - start, frames); float max = 0.0, min = 0.0, total = 0.0; size_t i = 0, count = 0; @@ -478,7 +478,7 @@ size_t frame = 0; size_t readBlockSize = 16384; - SampleBlock block; + AudioFileReader::SampleBlock block; if (!m_model.isOK()) return; diff -r 41d64b873d87 -r 20028c634494 data/model/WritableWaveFileModel.cpp --- a/data/model/WritableWaveFileModel.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/data/model/WritableWaveFileModel.cpp Thu Aug 09 16:29:29 2007 +0000 @@ -58,8 +58,8 @@ return; } - m_reader = new WavFileReader(m_writer->getPath(), true); - if (!m_reader->getError().isEmpty()) { + m_reader = new WavFileReader(m_writer->getPath().toStdString(), true); + if (m_reader->getError() != "") { std::cerr << "WritableWaveFileModel: Error in creating wave file reader" << std::endl; delete m_reader; m_reader = 0;