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 c920b31244a..ab067c96443 100644 --- a/src/soundsourcecoreaudio.cpp +++ b/src/soundsourcecoreaudio.cpp @@ -14,7 +14,6 @@ ***************************************************************************/ #include -#include #include #include @@ -39,13 +38,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); @@ -59,21 +54,19 @@ int SoundSourceCoreAudio::open() { err = ExtAudioFileOpen(&fsRef, &m_audioFile); */ - if (err != noErr) - { - qDebug() << "SSCA: Error opening file."; - return ERR; - } + if (err != noErr) { + qDebug() << "SSCA: Error opening file " << m_qFilename; + return ERR; + } // get the input file format CAStreamBasicDescription inputFormat; UInt32 size = sizeof(inputFormat); m_inputFormat = inputFormat; err = ExtAudioFileGetProperty(m_audioFile, kExtAudioFileProperty_FileDataFormat, &size, &inputFormat); - if (err != noErr) - { - qDebug() << "SSCA: Error getting file format"; - return ERR; + if (err != noErr) { + qDebug() << "SSCA: Error getting file format (" << m_qFilename << ")"; + return ERR; } //Debugging: @@ -88,8 +81,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; } @@ -102,8 +94,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; } @@ -121,10 +112,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; } @@ -153,11 +142,10 @@ long SoundSourceCoreAudio::seek(long filepos) { //_ThrowExceptionIfErr(@"ExtAudioFileSeek", err); //qDebug() << "SSCA: Seeking to" << segmentStart; - //err = ExtAudioFileSeek(m_audioFile, filepos / 2); - if (err != noErr) - { - qDebug() << "SSCA: Error seeking to" << filepos;// << GetMacOSStatusErrorString(err) << GetMacOSStatusCommentString(err); - } + //err = ExtAudioFileSeek(m_audioFile, filepos / 2); + if (err != noErr) { + qDebug() << "SSCA: Error seeking to" << filepos << " (file " << m_qFilename << ")";// << GetMacOSStatusErrorString(err) << GetMacOSStatusCommentString(err); + } return filepos; } @@ -239,10 +227,7 @@ int SoundSourceCoreAudio::parseHeader() { // Feels like 1995 again... } - - if (result) - return OK; - return ERR; + 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 aafb581e33f..6a470c725fd 100644 --- a/src/soundsourceflac.cpp +++ b/src/soundsourceflac.cpp @@ -54,6 +54,7 @@ SoundSourceFLAC::~SoundSourceFLAC() { // soundsource overrides int SoundSourceFLAC::open() { m_file.open(QIODevice::ReadOnly); + 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_qFilename; 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_qFilename; m_leftoverBufferLength = 0; // clear internal buffer since we moved return filepos; } @@ -115,7 +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"; + qWarning() << "SSFLAC: decoder_process_single returned false (" << m_qFilename << ")"; break; } else if (m_flacBufferLength == 0) { // EOF @@ -168,6 +173,7 @@ int SoundSourceFLAC::parseHeader() { if (xiph) { processXiphComment(xiph); } + return result ? OK : ERR; } @@ -194,7 +200,7 @@ inline FLAC__int16 SoundSourceFLAC::shift(FLAC__int32 sample) const { } else { return sample << shift; } -}; +} // static QList SoundSourceFLAC::supportedFileExtensions() { @@ -220,6 +226,7 @@ FLAC__StreamDecoderSeekStatus SoundSourceFLAC::flacSeek(FLAC__uint64 offset) { if (m_file.seek(offset)) { return FLAC__STREAM_DECODER_SEEK_STATUS_OK; } else { + qWarning() << "SSFLAC: An unrecoverable error occurred (" << m_qFilename << ")"; return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; } } @@ -308,7 +315,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..9af2110d07f 100644 --- a/src/soundsourcemp3.cpp +++ b/src/soundsourcemp3.cpp @@ -148,6 +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; return ERR; } @@ -204,6 +205,7 @@ long SoundSourceMp3::seek(long filepos) { } if (!isValid()) { + qDebug() << "SSMP3: Error wile seeking file " << m_qFilename; return 0; } @@ -211,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: @@ -227,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 @@ -245,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: @@ -259,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... @@ -298,7 +294,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 +343,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 +427,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 +473,6 @@ unsigned SoundSourceMp3::read(unsigned long samples_wanted, const SAMPLE * _dest rest = -1; return Total_samples_decoded; } - } // qDebug() << "Decoding"; @@ -587,9 +583,7 @@ int SoundSourceMp3::parseHeader() processAPETag(ape); } - if (result) - return OK; - return ERR; + return result ? OK : ERR; } int SoundSourceMp3::findFrame(int pos) diff --git a/src/soundsourceoggvorbis.cpp b/src/soundsourceoggvorbis.cpp index 75b85173125..3f301be3ed3 100644 --- a/src/soundsourceoggvorbis.cpp +++ b/src/soundsourceoggvorbis.cpp @@ -112,11 +112,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; - } /* @@ -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,8 +144,8 @@ 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{ - qDebug() << "ogg vorbis: Seek ERR."; + } else { + qDebug() << "ogg vorbis: Seek ERR at file " << m_qFilename; return 0; } } @@ -256,9 +256,7 @@ int SoundSourceOggVorbis::parseHeader() { processXiphComment(tag); } - if (result) - return OK; - return ERR; + 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 47c95f9d25b..9081cffc58d 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,7 @@ int SoundSourceSndFile::parseHeader() } } - if (result) - return OK; - return ERR; + return result ? OK : ERR; } /*