From c63b6d19155e8329039698e3f0a1663e68ca0f64 Mon Sep 17 00:00:00 2001 From: Nazar Gerasymchuk Date: Tue, 25 Jun 2013 19:52:07 +0300 Subject: [PATCH 1/7] Added verbosity (filenames) on TagLib errors. --- src/soundsourcecoreaudio.cpp | 12 +++++++----- src/soundsourceflac.cpp | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/soundsourcecoreaudio.cpp b/src/soundsourcecoreaudio.cpp index 78416dce898..1d9229e3e67 100644 --- a/src/soundsourcecoreaudio.cpp +++ b/src/soundsourcecoreaudio.cpp @@ -63,7 +63,7 @@ int SoundSourceCoreAudio::open() { if (err != noErr) { - qDebug() << "SSCA: Error opening file."; + qDebug() << "SSCA: Error opening file " << m_qFilename; return ERR; } @@ -74,7 +74,7 @@ int SoundSourceCoreAudio::open() { err = ExtAudioFileGetProperty(m_audioFile, kExtAudioFileProperty_FileDataFormat, &size, &inputFormat); if (err != noErr) { - qDebug() << "SSCA: Error getting file format"; + qDebug() << "SSCA: Error getting file format (" << m_qFilename << ")"; return ERR; } @@ -121,7 +121,7 @@ int SoundSourceCoreAudio::open() { err = ExtAudioFileSetProperty(m_audioFile, kExtAudioFileProperty_ClientDataFormat, size, &clientFormat); if (err != noErr) { - qDebug() << "SSCA: Error setting file property"; + qDebug() << "SSCA: Error setting file property (" << m_qFilename << ")"; return ERR; } @@ -135,7 +135,7 @@ int SoundSourceCoreAudio::open() { err = ExtAudioFileGetProperty(m_audioFile, kExtAudioFileProperty_FileLengthFrames, &dataSize, &totalFrameCount); if (err != noErr) { - qDebug() << "SSCA: Error getting number of frames"; + qDebug() << "SSCA: Error getting number of frames (" << m_qFilename << ")"; return ERR; } @@ -187,7 +187,7 @@ long SoundSourceCoreAudio::seek(long filepos) { //err = ExtAudioFileSeek(m_audioFile, filepos / 2); if (err != noErr) { - qDebug() << "SSCA: Error seeking to" << filepos;// << GetMacOSStatusErrorString(err) << GetMacOSStatusCommentString(err); + qDebug() << "SSCA: Error seeking to" << filepos << " (file " << m_qFilename << ")";// << GetMacOSStatusErrorString(err) << GetMacOSStatusCommentString(err); } return filepos; } @@ -273,6 +273,8 @@ int SoundSourceCoreAudio::parseHeader() { if (result) return OK; + + qDebug() << "Error parsing header (file " << m_qFilename << ")"; return ERR; } diff --git a/src/soundsourceflac.cpp b/src/soundsourceflac.cpp index aafb581e33f..9ddab0646f1 100644 --- a/src/soundsourceflac.cpp +++ b/src/soundsourceflac.cpp @@ -53,7 +53,8 @@ SoundSourceFLAC::~SoundSourceFLAC() { // soundsource overrides int SoundSourceFLAC::open() { - m_file.open(QIODevice::ReadOnly); + m_file.open(QIODevice::ReadOnly); // why? + m_decoder = FLAC__stream_decoder_new(); if (m_decoder == NULL) { qWarning() << "SSFLAC: decoder allocation failed!"; @@ -90,6 +91,8 @@ int SoundSourceFLAC::open() { FLAC__stream_decoder_finish(m_decoder); FLAC__stream_decoder_delete(m_decoder); m_decoder = NULL; + + qWarning() << "SSFLAC: Decoder error at file" << m_file.fileName(); return ERR; } @@ -99,7 +102,9 @@ long SoundSourceFLAC::seek(long filepos) { // but libflac expects a number in time samples. I _think_ this should // be hard-coded at two because *2 is the assumption the caller makes // -- bkgood - FLAC__stream_decoder_seek_absolute(m_decoder, filepos / 2); + bool result = FLAC__stream_decoder_seek_absolute(m_decoder, filepos / 2); + if (!result) + qWarning() << "SSFLAC: Seeking error at file" << m_file.fileName(); m_leftoverBufferLength = 0; // clear internal buffer since we moved return filepos; } @@ -115,7 +120,8 @@ unsigned int SoundSourceFLAC::read(unsigned long size, const SAMPLE *destination if (m_flacBufferLength == 0) { i = 0; if (!FLAC__stream_decoder_process_single(m_decoder)) { - qWarning() << "SSFLAC: decoder_process_single returned false"; + qWarning() << "SSFLAC: decoder_process_single returned false (" + << m_file.fileName() << ")"; break; } else if (m_flacBufferLength == 0) { // EOF @@ -168,6 +174,8 @@ int SoundSourceFLAC::parseHeader() { if (xiph) { processXiphComment(xiph); } + if (result==ERR) + qWarning() << "Error parsing header of file" << m_qFilename; return result ? OK : ERR; } @@ -220,6 +228,7 @@ FLAC__StreamDecoderSeekStatus SoundSourceFLAC::flacSeek(FLAC__uint64 offset) { if (m_file.seek(offset)) { return FLAC__STREAM_DECODER_SEEK_STATUS_OK; } else { + qWarning() << "FLAC: An unrecoverable error occurred (" << m_qFilename << ")"; return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; } } From a1e7bb4d74dec069ae1f4e51f0b0f6d269981f6c Mon Sep 17 00:00:00 2001 From: Nazar Gerasymchuk Date: Tue, 25 Jun 2013 21:13:08 +0300 Subject: [PATCH 2/7] Formated code according to Mixxx' Coding Guidelines --- src/soundsourcecoreaudio.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/soundsourcecoreaudio.cpp b/src/soundsourcecoreaudio.cpp index 1d9229e3e67..dbd7d09e17c 100644 --- a/src/soundsourcecoreaudio.cpp +++ b/src/soundsourcecoreaudio.cpp @@ -61,8 +61,7 @@ int SoundSourceCoreAudio::open() { err = ExtAudioFileOpen(&fsRef, &m_audioFile); */ - if (err != noErr) - { + if (err != noErr) { qDebug() << "SSCA: Error opening file " << m_qFilename; return ERR; } @@ -72,8 +71,7 @@ int SoundSourceCoreAudio::open() { UInt32 size = sizeof(inputFormat); m_inputFormat = inputFormat; err = ExtAudioFileGetProperty(m_audioFile, kExtAudioFileProperty_FileDataFormat, &size, &inputFormat); - if (err != noErr) - { + if (err != noErr) { qDebug() << "SSCA: Error getting file format (" << m_qFilename << ")"; return ERR; } @@ -119,8 +117,7 @@ int SoundSourceCoreAudio::open() { size = sizeof(clientFormat); err = ExtAudioFileSetProperty(m_audioFile, kExtAudioFileProperty_ClientDataFormat, size, &clientFormat); - if (err != noErr) - { + if (err != noErr) { qDebug() << "SSCA: Error setting file property (" << m_qFilename << ")"; return ERR; } @@ -133,8 +130,7 @@ int SoundSourceCoreAudio::open() { SInt64 totalFrameCount; dataSize = sizeof(totalFrameCount); //XXX: This looks sketchy to me - Albert err = ExtAudioFileGetProperty(m_audioFile, kExtAudioFileProperty_FileLengthFrames, &dataSize, &totalFrameCount); - if (err != noErr) - { + if (err != noErr) { qDebug() << "SSCA: Error getting number of frames (" << m_qFilename << ")"; return ERR; } @@ -185,8 +181,7 @@ long SoundSourceCoreAudio::seek(long filepos) { //qDebug() << "SSCA: Seeking to" << segmentStart; //err = ExtAudioFileSeek(m_audioFile, filepos / 2); - if (err != noErr) - { + if (err != noErr) { qDebug() << "SSCA: Error seeking to" << filepos << " (file " << m_qFilename << ")";// << GetMacOSStatusErrorString(err) << GetMacOSStatusCommentString(err); } return filepos; From 1a1b4cbb8aeae9410d562f3e97b8d2675aa79e84 Mon Sep 17 00:00:00 2001 From: Nazar Gerasymchuk Date: Wed, 26 Jun 2013 13:58:09 +0300 Subject: [PATCH 3/7] Specified filenames on errors. coreaudio, flac, modplug, mp3, ogg, snd --- src/soundsourcecoreaudio.cpp | 10 ++++------ src/soundsourceffmpeg.cpp | 5 +++-- src/soundsourceflac.cpp | 18 +++++++++--------- src/soundsourcemodplug.cpp | 4 ++++ src/soundsourcemp3.cpp | 18 +++++++++++------- src/soundsourceoggvorbis.cpp | 11 ++++++----- src/soundsourcesndfile.cpp | 8 +++++--- 7 files changed, 42 insertions(+), 32 deletions(-) diff --git a/src/soundsourcecoreaudio.cpp b/src/soundsourcecoreaudio.cpp index dbd7d09e17c..a397be0cf89 100644 --- a/src/soundsourcecoreaudio.cpp +++ b/src/soundsourcecoreaudio.cpp @@ -265,12 +265,10 @@ int SoundSourceCoreAudio::parseHeader() { // Feels like 1995 again... } - - if (result) - return OK; - - qDebug() << "Error parsing header (file " << m_qFilename << ")"; - return ERR; + if (result==ERR) { + qWarning() << "Error parsing header of file" << m_qFilename; + } + return result ? OK : ERR; } diff --git a/src/soundsourceffmpeg.cpp b/src/soundsourceffmpeg.cpp index a9256839656..8456bba7985 100644 --- a/src/soundsourceffmpeg.cpp +++ b/src/soundsourceffmpeg.cpp @@ -241,7 +241,8 @@ long SoundSourceFFmpeg::seek(long filepos) ret = av_seek_frame(pFormatCtx, audioStream, fspos, AVSEEK_FLAG_BACKWARD /*AVSEEK_FLAG_ANY*/); if (ret){ - qDebug() << "ffmpeg: Seek ERROR ret(" << ret << ") filepos(" << filepos << "d)."; + qDebug() << "ffmpeg: Seek ERROR ret(" << ret << ") filepos(" << filepos << "d) at file" + << m_qFilename; unlock(); return 0; } @@ -379,7 +380,7 @@ int SoundSourceFFmpeg::ParseHeader( TrackInfoObject * Track ) fname = location.toAscii(); FFmpegInit(); - qDebug() << "ffmpeg: pqrsing file:" << fname; + qDebug() << "ffmpeg: parsing file:" << fname; if(av_open_input_file(&FmtCtx, fname.constData(), NULL, 0, NULL)!=0) { qDebug() << "av_open_input_file: cannot open" << fname; diff --git a/src/soundsourceflac.cpp b/src/soundsourceflac.cpp index 9ddab0646f1..4d074939f32 100644 --- a/src/soundsourceflac.cpp +++ b/src/soundsourceflac.cpp @@ -53,7 +53,7 @@ SoundSourceFLAC::~SoundSourceFLAC() { // soundsource overrides int SoundSourceFLAC::open() { - m_file.open(QIODevice::ReadOnly); // why? + m_file.open(QIODevice::ReadOnly); m_decoder = FLAC__stream_decoder_new(); if (m_decoder == NULL) { @@ -92,7 +92,7 @@ int SoundSourceFLAC::open() { FLAC__stream_decoder_delete(m_decoder); m_decoder = NULL; - qWarning() << "SSFLAC: Decoder error at file" << m_file.fileName(); + qWarning() << "SSFLAC: Decoder error at file" << m_qFilename; return ERR; } @@ -104,7 +104,7 @@ long SoundSourceFLAC::seek(long filepos) { // -- bkgood bool result = FLAC__stream_decoder_seek_absolute(m_decoder, filepos / 2); if (!result) - qWarning() << "SSFLAC: Seeking error at file" << m_file.fileName(); + qWarning() << "SSFLAC: Seeking error at file" << m_qFilename; m_leftoverBufferLength = 0; // clear internal buffer since we moved return filepos; } @@ -120,8 +120,7 @@ unsigned int SoundSourceFLAC::read(unsigned long size, const SAMPLE *destination if (m_flacBufferLength == 0) { i = 0; if (!FLAC__stream_decoder_process_single(m_decoder)) { - qWarning() << "SSFLAC: decoder_process_single returned false (" - << m_file.fileName() << ")"; + qWarning() << "SSFLAC: decoder_process_single returned false (" << m_qFilename << ")"; break; } else if (m_flacBufferLength == 0) { // EOF @@ -174,8 +173,9 @@ int SoundSourceFLAC::parseHeader() { if (xiph) { processXiphComment(xiph); } - if (result==ERR) + if (result==ERR) { qWarning() << "Error parsing header of file" << m_qFilename; + } return result ? OK : ERR; } @@ -202,7 +202,7 @@ inline FLAC__int16 SoundSourceFLAC::shift(FLAC__int32 sample) const { } else { return sample << shift; } -}; +} // static QList SoundSourceFLAC::supportedFileExtensions() { @@ -228,7 +228,7 @@ FLAC__StreamDecoderSeekStatus SoundSourceFLAC::flacSeek(FLAC__uint64 offset) { if (m_file.seek(offset)) { return FLAC__STREAM_DECODER_SEEK_STATUS_OK; } else { - qWarning() << "FLAC: An unrecoverable error occurred (" << m_qFilename << ")"; + qWarning() << "SSFLAC: An unrecoverable error occurred (" << m_qFilename << ")"; return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; } } @@ -317,7 +317,7 @@ void SoundSourceFLAC::flacError(FLAC__StreamDecoderErrorStatus status) { break; } qWarning() << "SSFLAC got error" << error << "from libFLAC for file" - << m_file.fileName(); + << m_qFilename; // not much else to do here... whatever function that initiated whatever // decoder method resulted in this error will return an error, and the caller // will bail. libFLAC docs say to not close the decoder here -- bkgood diff --git a/src/soundsourcemodplug.cpp b/src/soundsourcemodplug.cpp index 8e7c5811daf..d47b0e8b87d 100644 --- a/src/soundsourcemodplug.cpp +++ b/src/soundsourcemodplug.cpp @@ -31,6 +31,10 @@ SoundSourceModPlug::SoundSourceModPlug(QString qFilename) : modFile.close(); // get ModPlugFile descriptor for later access m_pModFile = ModPlug::ModPlug_Load(m_fileBuf.data(), m_fileBuf.length()); + + if (m_pModFile==NULL) { + qDebug() << "[ModPlug] Error while ModPlug_Load"; + } } SoundSourceModPlug::~SoundSourceModPlug() diff --git a/src/soundsourcemp3.cpp b/src/soundsourcemp3.cpp index 20c56915ff0..54ab205db99 100644 --- a/src/soundsourcemp3.cpp +++ b/src/soundsourcemp3.cpp @@ -148,6 +148,8 @@ int SoundSourceMp3::open() // This is not a working MP3 file. if (currentframe == 0) { + qDebug() << "SSMP3: This is not a working MP3 file:" + << m_qFilename; return ERR; } @@ -204,6 +206,7 @@ long SoundSourceMp3::seek(long filepos) { } if (!isValid()) { + qDebug() << "SSMP3: Error wile seeking file " << m_qFilename; return 0; } @@ -298,7 +301,7 @@ long SoundSourceMp3::seek(long filepos) { } } - // Synthesize the the samples from the frame which should be discard to reach the requested position + // Synthesize the samples from the frame which should be discard to reach the requested position if (cur != NULL) //the "if" prevents crashes on bad files. discard(filepos-cur->pos); } @@ -347,7 +350,6 @@ long SoundSourceMp3::seek(long filepos) { // Unfortunately we don't know the exact fileposition. The returned position is thus an // approximation only: return filepos; - } inline long unsigned SoundSourceMp3::length() { @@ -432,8 +434,10 @@ unsigned long SoundSourceMp3::discard(unsigned long samples_wanted) { */ unsigned SoundSourceMp3::read(unsigned long samples_wanted, const SAMPLE * _destination) { - if (!isValid()) + if (!isValid()) { + qDebug() << "SSMP3: Error while reading " << m_qFilename; return 0; + } // Ensure that we are reading an even number of samples. Otherwise this function may // go into an infinite loop @@ -476,7 +480,6 @@ unsigned SoundSourceMp3::read(unsigned long samples_wanted, const SAMPLE * _dest rest = -1; return Total_samples_decoded; } - } // qDebug() << "Decoding"; @@ -587,9 +590,10 @@ int SoundSourceMp3::parseHeader() processAPETag(ape); } - if (result) - return OK; - return ERR; + if (result==ERR) { + qWarning() << "Error parsing header of file" << m_qFilename; + } + return result ? OK : ERR; } int SoundSourceMp3::findFrame(int pos) diff --git a/src/soundsourceoggvorbis.cpp b/src/soundsourceoggvorbis.cpp index 3b1e1b1d32c..4317a9384e0 100644 --- a/src/soundsourceoggvorbis.cpp +++ b/src/soundsourceoggvorbis.cpp @@ -113,11 +113,11 @@ int SoundSourceOggVorbis::open() { if (ret == OV_EINVAL) { //The file is not seekable. Not sure if any action is needed. + qDebug() << "oggvorbis: file is not seekable " << m_qFilename; } } return OK; - } /* @@ -146,7 +146,7 @@ long SoundSourceOggVorbis::seek(long filepos) // frames and we pretend to the world that everything is stereo) return ov_pcm_tell(&vf) * 2; } else{ - qDebug() << "ogg vorbis: Seek ERR."; + qDebug() << "ogg vorbis: Seek ERR at file " << m_qFilename; return 0; } } @@ -257,9 +257,10 @@ int SoundSourceOggVorbis::parseHeader() { processXiphComment(tag); } - if (result) - return OK; - return ERR; + if (result==ERR) { + qWarning() << "Error parsing header of file" << m_qFilename; + } + return result ? OK : ERR; } /* diff --git a/src/soundsourcesndfile.cpp b/src/soundsourcesndfile.cpp index 47c95f9d25b..b7bc2a5d983 100644 --- a/src/soundsourcesndfile.cpp +++ b/src/soundsourcesndfile.cpp @@ -153,6 +153,7 @@ unsigned SoundSourceSndFile::read(unsigned long size, const SAMPLE * destination } // The file has errors or is not open. Tell the truth and return 0. + qDebug() << "The file has errors or is not open: " << m_qFilename; return 0; } @@ -228,9 +229,10 @@ int SoundSourceSndFile::parseHeader() } } - if (result) - return OK; - return ERR; + if (result==ERR) { + qWarning() << "Error parsing header of file" << m_qFilename; + } + return result ? OK : ERR; } /* From 8365956233070accd232469d8c678a811f053cda Mon Sep 17 00:00:00 2001 From: Nazar Gerasymchuk Date: Wed, 26 Jun 2013 20:24:16 +0300 Subject: [PATCH 4/7] Added spaces around the == --- src/soundsourcecoreaudio.cpp | 2 +- src/soundsourcemp3.cpp | 2 +- src/soundsourceoggvorbis.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/soundsourcecoreaudio.cpp b/src/soundsourcecoreaudio.cpp index a397be0cf89..4b3a8c2fec8 100644 --- a/src/soundsourcecoreaudio.cpp +++ b/src/soundsourcecoreaudio.cpp @@ -265,7 +265,7 @@ int SoundSourceCoreAudio::parseHeader() { // Feels like 1995 again... } - if (result==ERR) { + if (result == ERR) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; diff --git a/src/soundsourcemp3.cpp b/src/soundsourcemp3.cpp index 54ab205db99..8fc727aaca2 100644 --- a/src/soundsourcemp3.cpp +++ b/src/soundsourcemp3.cpp @@ -590,7 +590,7 @@ int SoundSourceMp3::parseHeader() processAPETag(ape); } - if (result==ERR) { + if (result == ERR) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; diff --git a/src/soundsourceoggvorbis.cpp b/src/soundsourceoggvorbis.cpp index 4317a9384e0..30e46363cc4 100644 --- a/src/soundsourceoggvorbis.cpp +++ b/src/soundsourceoggvorbis.cpp @@ -257,7 +257,7 @@ int SoundSourceOggVorbis::parseHeader() { processXiphComment(tag); } - if (result==ERR) { + if (result == ERR) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; From feacb68947fe7a901fc1efc3e3d6b4f39d08c412 Mon Sep 17 00:00:00 2001 From: Nazar Gerasymchuk Date: Wed, 26 Jun 2013 21:20:19 +0300 Subject: [PATCH 5/7] Added spaces around == --- src/soundsourceflac.cpp | 2 +- src/soundsourcesndfile.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/soundsourceflac.cpp b/src/soundsourceflac.cpp index 4d074939f32..fbfa4a4199c 100644 --- a/src/soundsourceflac.cpp +++ b/src/soundsourceflac.cpp @@ -173,7 +173,7 @@ int SoundSourceFLAC::parseHeader() { if (xiph) { processXiphComment(xiph); } - if (result==ERR) { + if (result == ERR) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; diff --git a/src/soundsourcesndfile.cpp b/src/soundsourcesndfile.cpp index b7bc2a5d983..2a1186e01c5 100644 --- a/src/soundsourcesndfile.cpp +++ b/src/soundsourcesndfile.cpp @@ -229,7 +229,7 @@ int SoundSourceSndFile::parseHeader() } } - if (result==ERR) { + if (result == ERR) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; From d12fd105da654596d958cfae1a4075f2a911c720 Mon Sep 17 00:00:00 2001 From: Nazar Gerasymchuk Date: Tue, 2 Jul 2013 23:23:27 +0300 Subject: [PATCH 6/7] Improved type mismatch errors. Improved errors with const int ERR and bool result; avoided implicit cast in soundsource.cpp. Deleted variable qurlStr. --- src/soundsource.cpp | 2 +- src/soundsourcecoreaudio.cpp | 20 ++++++-------------- src/soundsourceflac.cpp | 2 +- src/soundsourcemp3.cpp | 19 ++++++------------- src/soundsourceoggvorbis.cpp | 8 ++++---- src/soundsourcesndfile.cpp | 2 +- 6 files changed, 19 insertions(+), 34 deletions(-) diff --git a/src/soundsource.cpp b/src/soundsource.cpp index 36286005a29..6329e5f11ab 100644 --- a/src/soundsource.cpp +++ b/src/soundsource.cpp @@ -268,7 +268,7 @@ bool SoundSource::processTaglibFile(TagLib::File& f) { } // If we didn't get any audio properties, this was a failure. - return properties; + return (properties!=NULL); } return false; } diff --git a/src/soundsourcecoreaudio.cpp b/src/soundsourcecoreaudio.cpp index a9cf3064402..c73314ffda7 100644 --- a/src/soundsourcecoreaudio.cpp +++ b/src/soundsourcecoreaudio.cpp @@ -14,7 +14,7 @@ ***************************************************************************/ #include -#include +//#include #include #include @@ -39,13 +39,9 @@ int SoundSourceCoreAudio::open() { //Open the audio file. OSStatus err; - //QUrl blah(m_qFilename); - QString qurlStr = m_qFilename;//blah.toString(); - qDebug() << qurlStr; - /** This code blocks works with OS X 10.5+ only. DO NOT DELETE IT for now. */ CFStringRef urlStr = CFStringCreateWithCharacters( - 0, reinterpret_cast(qurlStr.unicode()), qurlStr.size()); + 0, reinterpret_cast(m_qFilename.unicode()), m_qFilename.size()); CFURLRef urlRef = CFURLCreateWithFileSystemPath(NULL, urlStr, kCFURLPOSIXPathStyle, false); err = ExtAudioFileOpenURL(urlRef, &m_audioFile); CFRelease(urlStr); @@ -86,8 +82,7 @@ int SoundSourceCoreAudio::open() { // set the client format err = ExtAudioFileSetProperty(m_audioFile, kExtAudioFileProperty_ClientDataFormat, sizeof(m_outputFormat), &m_outputFormat); - if (err != noErr) - { + if (err != noErr) { qDebug() << "SSCA: Error setting file property"; return ERR; } @@ -100,8 +95,7 @@ int SoundSourceCoreAudio::open() { SInt64 totalFrameCount; dataSize = sizeof(totalFrameCount); //XXX: This looks sketchy to me - Albert err = ExtAudioFileGetProperty(m_audioFile, kExtAudioFileProperty_FileLengthFrames, &dataSize, &totalFrameCount); - if (err != noErr) - { + if (err != noErr) { qDebug() << "SSCA: Error getting number of frames"; return ERR; } @@ -119,10 +113,8 @@ int SoundSourceCoreAudio::open() { UInt32 piSize=sizeof(AudioConverterPrimeInfo); memset(&primeInfo, 0, piSize); err = AudioConverterGetProperty(acRef, kAudioConverterPrimeInfo, &piSize, &primeInfo); - if(err != kAudioConverterErr_PropertyNotSupported) // Only if decompressing - { + if (err != kAudioConverterErr_PropertyNotSupported) { // Only if decompressing //_ThrowExceptionIfErr(@"kAudioConverterPrimeInfo", err); - m_headerFrames=primeInfo.leadingFrames; } @@ -236,7 +228,7 @@ int SoundSourceCoreAudio::parseHeader() { // Feels like 1995 again... } - if (result == ERR) { + if (!result) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; diff --git a/src/soundsourceflac.cpp b/src/soundsourceflac.cpp index fbfa4a4199c..bb938dd71b8 100644 --- a/src/soundsourceflac.cpp +++ b/src/soundsourceflac.cpp @@ -173,7 +173,7 @@ int SoundSourceFLAC::parseHeader() { if (xiph) { processXiphComment(xiph); } - if (result == ERR) { + if (!result) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; diff --git a/src/soundsourcemp3.cpp b/src/soundsourcemp3.cpp index 8fc727aaca2..6cc8f4fd43d 100644 --- a/src/soundsourcemp3.cpp +++ b/src/soundsourcemp3.cpp @@ -148,8 +148,7 @@ int SoundSourceMp3::open() // This is not a working MP3 file. if (currentframe == 0) { - qDebug() << "SSMP3: This is not a working MP3 file:" - << m_qFilename; + qDebug() << "SSMP3: This is not a working MP3 file:" << m_qFilename; return ERR; } @@ -214,8 +213,7 @@ long SoundSourceMp3::seek(long filepos) { MadSeekFrameType* cur = NULL; - if (filepos==0) - { + if (filepos==0) { // Seek to beginning of file // Re-init buffer: @@ -230,9 +228,7 @@ long SoundSourceMp3::seek(long filepos) { m_currentSeekFrameIndex = 0; cur = getSeekFrame(0); //frameIterator.toFront(); //Might not need to do this -- Albert June 19/2010 (during Qt3 purge) - } - else - { + } else { //qDebug() << "seek precise"; // Perform precise seek accomplished by using a frame in the seek list @@ -248,8 +244,7 @@ long SoundSourceMp3::seek(long filepos) { */ int framePos = findFrame(filepos); - if (framePos==0 || framePos>filepos || m_currentSeekFrameIndex < 5) - { + if (framePos==0 || framePos>filepos || m_currentSeekFrameIndex < 5) { //qDebug() << "Problem finding good seek frame (wanted " << filepos << ", got " << framePos << "), starting from 0"; // Re-init buffer: @@ -262,9 +257,7 @@ long SoundSourceMp3::seek(long filepos) { rest = -1; m_currentSeekFrameIndex = 0; cur = getSeekFrame(m_currentSeekFrameIndex); - } - else - { + } else { // qDebug() << "frame pos " << cur->pos; // Start four frame before wanted frame to get in sync... @@ -590,7 +583,7 @@ int SoundSourceMp3::parseHeader() processAPETag(ape); } - if (result == ERR) { + if (!result) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; diff --git a/src/soundsourceoggvorbis.cpp b/src/soundsourceoggvorbis.cpp index 419e7ebd2d2..d57e204119b 100644 --- a/src/soundsourceoggvorbis.cpp +++ b/src/soundsourceoggvorbis.cpp @@ -132,8 +132,8 @@ long SoundSourceOggVorbis::seek(long filepos) filepos--; } - if (ov_seekable(&vf)){ - if(ov_pcm_seek(&vf, filepos/2) != 0) { + if (ov_seekable(&vf)) { + if (ov_pcm_seek(&vf, filepos/2) != 0) { // This is totally common (i.e. you're at EOF). Let's not leave this // qDebug on. @@ -144,7 +144,7 @@ long SoundSourceOggVorbis::seek(long filepos) // that's what we promised. (Double it because ov_pcm_tell returns // frames and we pretend to the world that everything is stereo) return ov_pcm_tell(&vf) * 2; - } else{ + } else { qDebug() << "ogg vorbis: Seek ERR at file " << m_qFilename; return 0; } @@ -256,7 +256,7 @@ int SoundSourceOggVorbis::parseHeader() { processXiphComment(tag); } - if (result == ERR) { + if (!result) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; diff --git a/src/soundsourcesndfile.cpp b/src/soundsourcesndfile.cpp index 2a1186e01c5..3f997e9b635 100644 --- a/src/soundsourcesndfile.cpp +++ b/src/soundsourcesndfile.cpp @@ -229,7 +229,7 @@ int SoundSourceSndFile::parseHeader() } } - if (result == ERR) { + if (!result) { qWarning() << "Error parsing header of file" << m_qFilename; } return result ? OK : ERR; From 9f710b4dc5b042aa01400e9dc62570a123e95747 Mon Sep 17 00:00:00 2001 From: Nazar Gerasymchuk Date: Wed, 3 Jul 2013 11:47:59 +0300 Subject: [PATCH 7/7] Move all warnings from the bottom of each parseHeader() to soundsourceproxy.cpp --- src/soundsourcecoreaudio.cpp | 4 ---- src/soundsourceflac.cpp | 4 +--- src/soundsourcemp3.cpp | 3 --- src/soundsourceoggvorbis.cpp | 3 --- src/soundsourceproxy.cpp | 5 ++--- src/soundsourcesndfile.cpp | 3 --- 6 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/soundsourcecoreaudio.cpp b/src/soundsourcecoreaudio.cpp index c73314ffda7..ab067c96443 100644 --- a/src/soundsourcecoreaudio.cpp +++ b/src/soundsourcecoreaudio.cpp @@ -14,7 +14,6 @@ ***************************************************************************/ #include -//#include #include #include @@ -228,9 +227,6 @@ int SoundSourceCoreAudio::parseHeader() { // Feels like 1995 again... } - if (!result) { - qWarning() << "Error parsing header of file" << m_qFilename; - } return result ? OK : ERR; } diff --git a/src/soundsourceflac.cpp b/src/soundsourceflac.cpp index bb938dd71b8..6a470c725fd 100644 --- a/src/soundsourceflac.cpp +++ b/src/soundsourceflac.cpp @@ -173,9 +173,7 @@ int SoundSourceFLAC::parseHeader() { if (xiph) { processXiphComment(xiph); } - if (!result) { - qWarning() << "Error parsing header of file" << m_qFilename; - } + return result ? OK : ERR; } diff --git a/src/soundsourcemp3.cpp b/src/soundsourcemp3.cpp index 6cc8f4fd43d..9af2110d07f 100644 --- a/src/soundsourcemp3.cpp +++ b/src/soundsourcemp3.cpp @@ -583,9 +583,6 @@ int SoundSourceMp3::parseHeader() processAPETag(ape); } - if (!result) { - qWarning() << "Error parsing header of file" << m_qFilename; - } return result ? OK : ERR; } diff --git a/src/soundsourceoggvorbis.cpp b/src/soundsourceoggvorbis.cpp index d57e204119b..3f301be3ed3 100644 --- a/src/soundsourceoggvorbis.cpp +++ b/src/soundsourceoggvorbis.cpp @@ -256,9 +256,6 @@ int SoundSourceOggVorbis::parseHeader() { processXiphComment(tag); } - if (!result) { - qWarning() << "Error parsing header of file" << m_qFilename; - } return result ? OK : ERR; } diff --git a/src/soundsourceproxy.cpp b/src/soundsourceproxy.cpp index 0836fb6b2af..90fb023e7c9 100644 --- a/src/soundsourceproxy.cpp +++ b/src/soundsourceproxy.cpp @@ -359,9 +359,8 @@ int SoundSourceProxy::ParseHeader(TrackInfoObject* p) p->setChannels(sndsrc->getChannels()); p->setKey(sndsrc->getKey()); p->setHeaderParsed(true); - } - else - { + } else { + qDebug() << "SoundSourceProxy::ParseHeader() error at file " << qFilename; p->setHeaderParsed(false); } delete sndsrc; diff --git a/src/soundsourcesndfile.cpp b/src/soundsourcesndfile.cpp index 3f997e9b635..9081cffc58d 100644 --- a/src/soundsourcesndfile.cpp +++ b/src/soundsourcesndfile.cpp @@ -229,9 +229,6 @@ int SoundSourceSndFile::parseHeader() } } - if (!result) { - qWarning() << "Error parsing header of file" << m_qFilename; - } return result ? OK : ERR; }