Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/soundsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
47 changes: 16 additions & 31 deletions src/soundsourcecoreaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
***************************************************************************/

#include <QtDebug>
#include <QUrl>
#include <taglib/mpegfile.h>
#include <taglib/mp4file.h>

Expand All @@ -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<const UniChar *>(qurlStr.unicode()), qurlStr.size());
0, reinterpret_cast<const UniChar *>(m_qFilename.unicode()), m_qFilename.size());
CFURLRef urlRef = CFURLCreateWithFileSystemPath(NULL, urlStr, kCFURLPOSIXPathStyle, false);
err = ExtAudioFileOpenURL(urlRef, &m_audioFile);
CFRelease(urlStr);
Expand All @@ -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:
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -239,10 +227,7 @@ int SoundSourceCoreAudio::parseHeader() {
// Feels like 1995 again...
}


if (result)
return OK;
return ERR;
return result ? OK : ERR;
}


Expand Down
5 changes: 3 additions & 2 deletions src/soundsourceffmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 11 additions & 4 deletions src/soundsourceflac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!";
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -168,6 +173,7 @@ int SoundSourceFLAC::parseHeader() {
if (xiph) {
processXiphComment(xiph);
}

return result ? OK : ERR;
}

Expand All @@ -194,7 +200,7 @@ inline FLAC__int16 SoundSourceFLAC::shift(FLAC__int32 sample) const {
} else {
return sample << shift;
}
};
}

// static
QList<QString> SoundSourceFLAC::supportedFileExtensions() {
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/soundsourcemodplug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
28 changes: 11 additions & 17 deletions src/soundsourcemp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -204,15 +205,15 @@ long SoundSourceMp3::seek(long filepos) {
}

if (!isValid()) {
qDebug() << "SSMP3: Error wile seeking file " << m_qFilename;
return 0;
}

// qDebug() << "SEEK " << filepos;

MadSeekFrameType* cur = NULL;

if (filepos==0)
{
if (filepos==0) {
// Seek to beginning of file

// Re-init buffer:
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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...
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -476,7 +473,6 @@ unsigned SoundSourceMp3::read(unsigned long samples_wanted, const SAMPLE * _dest
rest = -1;
return Total_samples_decoded;
}

}

// qDebug() << "Decoding";
Expand Down Expand Up @@ -587,9 +583,7 @@ int SoundSourceMp3::parseHeader()
processAPETag(ape);
}

if (result)
return OK;
return ERR;
return result ? OK : ERR;
}

int SoundSourceMp3::findFrame(int pos)
Expand Down
14 changes: 6 additions & 8 deletions src/soundsourceoggvorbis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

/*
Expand All @@ -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.

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -256,9 +256,7 @@ int SoundSourceOggVorbis::parseHeader() {
processXiphComment(tag);
}

if (result)
return OK;
return ERR;
return result ? OK : ERR;
}

/*
Expand Down
5 changes: 2 additions & 3 deletions src/soundsourceproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading