comparison data/fileio/MP3FileReader.cpp @ 1279:0a9193dc136b 3.0-integration

Debug output updates
author Chris Cannam
date Tue, 22 Nov 2016 16:40:41 +0000
parents 794b64e62e58
children 16a8e97179d7
comparison
equal deleted inserted replaced
1278:0be27c989c1d 1279:0a9193dc136b
48 CodedAudioFileReader(mode, targetRate, normalised), 48 CodedAudioFileReader(mode, targetRate, normalised),
49 m_source(source), 49 m_source(source),
50 m_path(source.getLocalFilename()), 50 m_path(source.getLocalFilename()),
51 m_decodeThread(0) 51 m_decodeThread(0)
52 { 52 {
53 SVDEBUG << "MP3FileReader: local path: \"" << m_path
54 << "\", decode mode: " << decodeMode << " ("
55 << (decodeMode == DecodeAtOnce ? "DecodeAtOnce" : "DecodeThreaded")
56 << ")" << endl;
57
53 m_channelCount = 0; 58 m_channelCount = 0;
54 m_fileRate = 0; 59 m_fileRate = 0;
55 m_fileSize = 0; 60 m_fileSize = 0;
56 m_bitrateNum = 0; 61 m_bitrateNum = 0;
57 m_bitrateDenom = 0; 62 m_bitrateDenom = 0;
141 while ((m_channelCount == 0 || m_fileRate == 0 || m_sampleRate == 0) 146 while ((m_channelCount == 0 || m_fileRate == 0 || m_sampleRate == 0)
142 && !m_done) { 147 && !m_done) {
143 usleep(10); 148 usleep(10);
144 } 149 }
145 150
146 cerr << "MP3FileReader ctor: exiting with file rate = " << m_fileRate << endl; 151 SVDEBUG << "MP3FileReader ctor: exiting with file rate = " << m_fileRate << endl;
147 } 152 }
148 153
149 if (m_error != "") { 154 if (m_error != "") {
150 cerr << "MP3FileReader::MP3FileReader(\"" << m_path << "\"): ERROR: " << m_error << endl; 155 SVDEBUG << "MP3FileReader::MP3FileReader(\"" << m_path << "\"): ERROR: " << m_error << endl;
151 } 156 }
152 } 157 }
153 158
154 MP3FileReader::~MP3FileReader() 159 MP3FileReader::~MP3FileReader()
155 { 160 {
180 // We can do this a lot more elegantly, but we'll leave that for 185 // We can do this a lot more elegantly, but we'll leave that for
181 // when we implement support for more than just the one tag! 186 // when we implement support for more than just the one tag!
182 187
183 id3_tag *tag = id3_file_tag(file); 188 id3_tag *tag = id3_file_tag(file);
184 if (!tag) { 189 if (!tag) {
185 #ifdef DEBUG_ID3TAG 190 SVDEBUG << "MP3FileReader::loadTags: No ID3 tag found" << endl;
186 cerr << "MP3FileReader::loadTags: No ID3 tag found" << endl;
187 #endif
188 id3_file_close(file); 191 id3_file_close(file);
189 return; 192 return;
190 } 193 }
191 194
192 m_title = loadTag(tag, "TIT2"); // work title 195 m_title = loadTag(tag, "TIT2"); // work title
203 } 206 }
204 207
205 id3_file_close(file); 208 id3_file_close(file);
206 209
207 #else 210 #else
208 #ifdef DEBUG_ID3TAG 211 SVDEBUG << "MP3FileReader::loadTags: ID3 tag support not compiled in"
209 cerr << "MP3FileReader::loadTags: ID3 tag support not compiled in" 212 << endl;
210 << endl;
211 #endif
212 #endif 213 #endif
213 } 214 }
214 215
215 QString 216 QString
216 MP3FileReader::loadTag(void *vtag, const char *name) 217 MP3FileReader::loadTag(void *vtag, const char *name)
431 432
432 return MAD_FLOW_CONTINUE; 433 return MAD_FLOW_CONTINUE;
433 } 434 }
434 435
435 enum mad_flow 436 enum mad_flow
436 MP3FileReader::error(void * /* dp */, 437 MP3FileReader::error(void *dp,
437 struct mad_stream * /* stream */, 438 struct mad_stream *stream,
438 struct mad_frame *) 439 struct mad_frame *)
439 { 440 {
440 // DecoderData *data = (DecoderData *)dp; 441 static bool errorShown = false;
441 442
442 // fprintf(stderr, "decoding error 0x%04x (%s) at byte offset %lu\n", 443 if (!errorShown) {
443 // stream->error, mad_stream_errorstr(stream), 444 DecoderData *data = (DecoderData *)dp;
444 // (unsigned long)(stream->this_frame - data->start)); 445 fprintf(stderr, "Warning: MP3 decoding error 0x%04x (%s) at byte offset %lu\n",
446 stream->error, mad_stream_errorstr(stream),
447 (unsigned long)(stream->this_frame - data->start));
448 fprintf(stderr, "(Suppressing any further errors of this sort)\n");
449 errorShown = true;
450 }
445 451
446 return MAD_FLOW_CONTINUE; 452 return MAD_FLOW_CONTINUE;
447 } 453 }
448 454
449 void 455 void