-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1000784 #26
Bug 1000784 #26
Changes from 5 commits
c63b6d1
a1e7bb4
1a1b4cb
8365956
feacb68
41d1ea1
d12fd10
9f710b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,9 @@ int SoundSourceFLAC::parseHeader() { | |
if (xiph) { | ||
processXiphComment(xiph); | ||
} | ||
if (result == ERR) { | ||
qWarning() << "Error parsing header of file" << m_qFilename; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here .. |
||
} | ||
return result ? OK : ERR; | ||
} | ||
|
||
|
@@ -194,7 +202,7 @@ inline FLAC__int16 SoundSourceFLAC::shift(FLAC__int32 sample) const { | |
} else { | ||
return sample << shift; | ||
} | ||
}; | ||
} | ||
|
||
// static | ||
QList<QString> SoundSourceFLAC::supportedFileExtensions() { | ||
|
@@ -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() << "SSFLAC: An unrecoverable error occurred (" << m_qFilename << ")"; | ||
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; | ||
} | ||
} | ||
|
@@ -308,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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here is a type mismatch: const int ERR = -1; bool result |
||
} | ||
return result ? OK : ERR; | ||
} | ||
|
||
int SoundSourceMp3::findFrame(int pos) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same her here I think: const int ERR = -1; bool result |
||
} | ||
return result ? OK : ERR; | ||
} | ||
|
||
/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here: const int ERR = -1; bool result |
||
} | ||
return result ? OK : ERR; | ||
} | ||
|
||
/* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have a consistency problem above:
"result" is not checked before the additional Taglib call but the whole function returns error in this case.
IMHO there are two logical paths: Abort when one call fails, or graceful recover errors and not return ERR if some call succeed.
processTaglibFile fails if f.audioProperties() returns NULL
@rryan: What is the right strategy? I would prefer the early abort. Since this is Legacy code, I would prefer fixing it in a separate branch. There is also my external Tagreader process (slowly) on the way.