From 9cce3d82c14eefc88a1e623cc09fbde29dd29f67 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Fri, 11 Sep 2009 00:38:44 +0000 Subject: [PATCH] fix: gracefully handle unknown file subtypes git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1491 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmAudio.cpp | 9 ++++----- core/AmAudioFile.cpp | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/AmAudio.cpp b/core/AmAudio.cpp index 2d9c6a6c..4790738a 100644 --- a/core/AmAudio.cpp +++ b/core/AmAudio.cpp @@ -359,11 +359,10 @@ int AmAudio::decode(unsigned int size) amci_codec_t* codec = fmt->getCodec(); long h_codec = fmt->getHCodec(); - // if(!codec){ - // ERROR("audio format set, but no codec has been loaded\n"); - // abort(); - // return -1; - // } + if(!codec){ + ERROR("audio format set, but no codec has been loaded\n"); + return -1; + } if(codec->decode){ s = (*codec->decode)(samples.back_buffer(),samples,s, diff --git a/core/AmAudioFile.cpp b/core/AmAudioFile.cpp index 11c1e039..a9a2bbdc 100644 --- a/core/AmAudioFile.cpp +++ b/core/AmAudioFile.cpp @@ -57,20 +57,22 @@ void AmAudioFileFormat::setSubtypeId(int subtype_id) { amci_subtype_t* AmAudioFileFormat::getSubtype() { if(!p_subtype && !name.empty()){ - + // get file format from file name amci_inoutfmt_t* iofmt = AmPlugIn::instance()->fileFormat(name.c_str()); if(!iofmt){ ERROR("AmAudioFileFormat::getSubtype: file format '%s' does not exist\n", name.c_str()); - throw string("AmAudioFileFormat::getSubtype: file format '%s' does not exist\n"); + return NULL; } - else { - p_subtype = AmPlugIn::instance()->subtype(iofmt,subtype); - if(!p_subtype) - ERROR("AmAudioFileFormat::getSubtype: subtype %i in format '%s' does not exist\n", - subtype,iofmt->name); - subtype = p_subtype->type; + + p_subtype = AmPlugIn::instance()->subtype(iofmt,subtype); + if(!p_subtype) { + ERROR("AmAudioFileFormat::getSubtype: subtype %i in format '%s' does not exist\n", + subtype,iofmt->name); + return NULL; } + + subtype = p_subtype->type; } return p_subtype; }