Etterna
0.74.4
Loading...
Searching...
No Matches
src
RageUtil
Sound
RageSoundReader_FileReader.h
1
/* SoundReader_FileReader - base class for SoundReaders that read from files. */
2
3
#ifndef RAGE_SOUND_READER_FILE_READER_H
4
#define RAGE_SOUND_READER_FILE_READER_H
5
6
#include <memory>
7
#include "RageSoundReader.h"
8
9
class
RageFileBasic
;
10
11
#define SoundReader_FileReader RageSoundReader_FileReader
12
class
RageSoundReader_FileReader
:
public
RageSoundReader
13
{
14
public
:
15
/*
16
* Return OPEN_OK if the file is open and ready to go. Return
17
* OPEN_UNKNOWN_FILE_FORMAT if the file appears to be of a different type.
18
* Return OPEN_FATAL_ERROR if the file appears to be the correct type, but
19
* there was an error initializing the file.
20
*
21
* If the file can not be opened at all, or contains no data, return
22
* OPEN_MATCH_BUT_FAIL.
23
*/
24
enum
OpenResult
25
{
26
OPEN_OK,
27
OPEN_UNKNOWN_FILE_FORMAT = 1,
28
OPEN_FATAL_ERROR = 2,
29
};
30
RageSoundReader_FileReader
(
const
RageSoundReader_FileReader
&);
31
RageSoundReader_FileReader
();
32
33
/* Takes ownership of pFile (even on failure). */
34
virtual
OpenResult Open(
RageFileBasic
* pFile) = 0;
35
float
GetStreamToSourceRatio()
const override
{
return
1.0f; }
36
std::string GetError()
const override
{
return
m_sError; }
37
38
/* Open a file. If pPrebuffer is non-NULL, and the file is sufficiently
39
* small, the (possibly compressed) data will be loaded entirely into
40
* memory, and pPrebuffer will be set to true. */
41
static
RageSoundReader_FileReader
* OpenFile(
const
std::string& filename,
42
std::string& error,
43
bool
* pPrebuffer = NULL);
44
45
protected
:
46
void
SetError(
const
std::string& sError)
const
{ m_sError = sError; }
47
std::unique_ptr<RageFileBasic> m_pFile;
48
49
private
:
50
static
RageSoundReader_FileReader
* TryOpenFile(
RageFileBasic
* pFile,
51
std::string& error,
52
const
std::string& format,
53
bool
& bKeepTrying);
54
mutable
std::string m_sError;
55
};
56
57
#endif
RageFileBasic
Definition
RageFileBasic.h:10
RageSoundReader_FileReader
Definition
RageSoundReader_FileReader.h:13
RageSoundReader
Definition
RageSoundReader.h:7
Generated by
1.9.8