Mercurial > hg > svcore
comparison data/fileio/OggVorbisFileReader.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 | c022976d18e8 |
comparison
equal
deleted
inserted
replaced
289:3020904de772 | 290:92e8dbde73cd |
---|---|
30 #include <QFileInfo> | 30 #include <QFileInfo> |
31 #include <QProgressDialog> | 31 #include <QProgressDialog> |
32 | 32 |
33 static int instances = 0; | 33 static int instances = 0; |
34 | 34 |
35 OggVorbisFileReader::OggVorbisFileReader(std::string path, | 35 OggVorbisFileReader::OggVorbisFileReader(QString path, |
36 DecodeMode decodeMode, | 36 DecodeMode decodeMode, |
37 CacheMode mode) : | 37 CacheMode mode) : |
38 CodedAudioFileReader(mode), | 38 CodedAudioFileReader(mode), |
39 m_path(path), | 39 m_path(path), |
40 m_progress(0), | 40 m_progress(0), |
47 { | 47 { |
48 m_frameCount = 0; | 48 m_frameCount = 0; |
49 m_channelCount = 0; | 49 m_channelCount = 0; |
50 m_sampleRate = 0; | 50 m_sampleRate = 0; |
51 | 51 |
52 std::cerr << "OggVorbisFileReader::OggVorbisFileReader(" << path << "): now have " << (++instances) << " instances" << std::endl; | 52 std::cerr << "OggVorbisFileReader::OggVorbisFileReader(" << path.toLocal8Bit().data() << "): now have " << (++instances) << " instances" << std::endl; |
53 | 53 |
54 Profiler profiler("OggVorbisFileReader::OggVorbisFileReader", true); | 54 Profiler profiler("OggVorbisFileReader::OggVorbisFileReader", true); |
55 | 55 |
56 QFileInfo info(path.c_str()); | 56 QFileInfo info(path); |
57 m_fileSize = info.size(); | 57 m_fileSize = info.size(); |
58 | 58 |
59 if (!(m_oggz = oggz_open(path.c_str(), OGGZ_READ))) { | 59 if (!(m_oggz = oggz_open(path.toLocal8Bit().data(), OGGZ_READ))) { |
60 setError("File is not an OGG file", path); | 60 m_error = QString("File %1 is not an OGG file.").arg(path); |
61 return; | 61 return; |
62 } | 62 } |
63 | 63 |
64 FishSoundInfo fsinfo; | 64 FishSoundInfo fsinfo; |
65 m_fishSound = fish_sound_new(FISH_SOUND_DECODE, &fsinfo); | 65 m_fishSound = fish_sound_new(FISH_SOUND_DECODE, &fsinfo); |
68 oggz_set_read_callback(m_oggz, -1, readPacket, this); | 68 oggz_set_read_callback(m_oggz, -1, readPacket, this); |
69 | 69 |
70 if (decodeMode == DecodeAtOnce) { | 70 if (decodeMode == DecodeAtOnce) { |
71 | 71 |
72 m_progress = new QProgressDialog | 72 m_progress = new QProgressDialog |
73 (QObject::tr("Decoding %1...").arg(QFileInfo(path.c_str()).fileName()), | 73 (QObject::tr("Decoding %1...").arg(QFileInfo(path).fileName()), |
74 QObject::tr("Stop"), 0, 100); | 74 QObject::tr("Stop"), 0, 100); |
75 m_progress->hide(); | 75 m_progress->hide(); |
76 | 76 |
77 while (oggz_read(m_oggz, 1024) > 0); | 77 while (oggz_read(m_oggz, 1024) > 0); |
78 | 78 |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 OggVorbisFileReader::~OggVorbisFileReader() | 101 OggVorbisFileReader::~OggVorbisFileReader() |
102 { | 102 { |
103 std::cerr << "OggVorbisFileReader::~OggVorbisFileReader(" << m_path << "): now have " << (--instances) << " instances" << std::endl; | 103 std::cerr << "OggVorbisFileReader::~OggVorbisFileReader(" << m_path.toLocal8Bit().data() << "): now have " << (--instances) << " instances" << std::endl; |
104 if (m_decodeThread) { | 104 if (m_decodeThread) { |
105 m_cancelled = true; | 105 m_cancelled = true; |
106 m_decodeThread->wait(); | 106 m_decodeThread->wait(); |
107 delete m_decodeThread; | 107 delete m_decodeThread; |
108 } | 108 } |
164 | 164 |
165 if (!reader->m_commentsRead) { | 165 if (!reader->m_commentsRead) { |
166 const FishSoundComment *comment = fish_sound_comment_first_byname | 166 const FishSoundComment *comment = fish_sound_comment_first_byname |
167 (fs, "TITLE"); | 167 (fs, "TITLE"); |
168 if (comment && comment->value) { | 168 if (comment && comment->value) { |
169 reader->m_title = comment->value; | 169 reader->m_title = QString::fromUtf8(comment->value); |
170 } | 170 } |
171 reader->m_commentsRead = true; | 171 reader->m_commentsRead = true; |
172 } | 172 } |
173 | 173 |
174 if (reader->m_channelCount == 0) { | 174 if (reader->m_channelCount == 0) { |
196 if (reader->m_cancelled) return 1; | 196 if (reader->m_cancelled) return 1; |
197 return 0; | 197 return 0; |
198 } | 198 } |
199 | 199 |
200 void | 200 void |
201 OggVorbisFileReader::getSupportedExtensions(std::set<std::string> &extensions) | 201 OggVorbisFileReader::getSupportedExtensions(std::set<QString> &extensions) |
202 { | 202 { |
203 extensions.insert("ogg"); | 203 extensions.insert("ogg"); |
204 } | 204 } |
205 | 205 |
206 #endif | 206 #endif |