/* Mednafen - Multi-system Emulator1*2* This program is free software; you can redistribute it and/or modify3* it under the terms of the GNU General Public License as published by4* the Free Software Foundation; either version 2 of the License, or5* (at your option) any later version.6*7* This program is distributed in the hope that it will be useful,8* but WITHOUT ANY WARRANTY; without even the implied warranty of9* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10* GNU General Public License for more details.11*12* You should have received a copy of the GNU General Public License13* along with this program; if not, write to the Free Software14* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA15*/1617// CDAFR_Open(), and CDAFReader, will NOT take "ownership" of the Stream object(IE it won't ever delete it). Though it does assume it has exclusive access18// to it for as long as the CDAFReader object exists.1920// Don't allow exceptions to propagate into the vorbis/musepack/etc. libraries, as it could easily leave the state of the library's decoder "object" in an21// inconsistent state, which would cause all sorts of unfun when we try to destroy it while handling the exception farther up.2223#include "emuware/emuware.h"24#include "CDAFReader.h"25#include "CDAFReader_Vorbis.h"26#include "CDAFReader_MPC.h"2728#ifdef HAVE_LIBSNDFILE29#include "CDAFReader_SF.h"30#endif3132CDAFReader::CDAFReader() : LastReadPos(0)33{3435}3637CDAFReader::~CDAFReader()38{3940}4142CDAFReader* CDAFR_Null_Open(Stream* fp)43{44return NULL;45}4647CDAFReader *CDAFR_Open(Stream *fp)48{49static CDAFReader* (* const OpenFuncs[])(Stream* fp) =50{51#ifdef HAVE_MPC52CDAFR_MPC_Open,53#endif5455#ifdef HAVE_VORBIS56CDAFR_Vorbis_Open, // Must come before CDAFR_SF_Open57#endif5859#ifdef HAVE_LIBSNDFILE60CDAFR_SF_Open,61#endif6263CDAFR_Null_Open64};6566for(int idx=0;idx<ARRAY_SIZE(OpenFuncs);idx++)67{68auto f = OpenFuncs[idx];69try70{71fp->rewind();72return f(fp);73}74catch(int i)75{7677}78}7980return(NULL);81}82838485