Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/mednadisc/cdrom/CDAFReader.cpp
2 views
1
/* Mednafen - Multi-system Emulator
2
*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*/
17
18
// 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 access
19
// to it for as long as the CDAFReader object exists.
20
21
// 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 an
22
// inconsistent state, which would cause all sorts of unfun when we try to destroy it while handling the exception farther up.
23
24
#include "emuware/emuware.h"
25
#include "CDAFReader.h"
26
#include "CDAFReader_Vorbis.h"
27
#include "CDAFReader_MPC.h"
28
29
#ifdef HAVE_LIBSNDFILE
30
#include "CDAFReader_SF.h"
31
#endif
32
33
CDAFReader::CDAFReader() : LastReadPos(0)
34
{
35
36
}
37
38
CDAFReader::~CDAFReader()
39
{
40
41
}
42
43
CDAFReader* CDAFR_Null_Open(Stream* fp)
44
{
45
return NULL;
46
}
47
48
CDAFReader *CDAFR_Open(Stream *fp)
49
{
50
static CDAFReader* (* const OpenFuncs[])(Stream* fp) =
51
{
52
#ifdef HAVE_MPC
53
CDAFR_MPC_Open,
54
#endif
55
56
#ifdef HAVE_VORBIS
57
CDAFR_Vorbis_Open, // Must come before CDAFR_SF_Open
58
#endif
59
60
#ifdef HAVE_LIBSNDFILE
61
CDAFR_SF_Open,
62
#endif
63
64
CDAFR_Null_Open
65
};
66
67
for(int idx=0;idx<ARRAY_SIZE(OpenFuncs);idx++)
68
{
69
auto f = OpenFuncs[idx];
70
try
71
{
72
fp->rewind();
73
return f(fp);
74
}
75
catch(int i)
76
{
77
78
}
79
}
80
81
return(NULL);
82
}
83
84
85