Got rid of the last traces of DigitalTrackInfo

svn-id: r26477
This commit is contained in:
Max Horn 2007-04-14 18:51:38 +00:00
parent adb0f89ae3
commit 2aeb84f12a
7 changed files with 0 additions and 275 deletions

View File

@ -32,15 +32,6 @@
namespace Audio {
class DigitalTrackInfo {
public:
virtual ~DigitalTrackInfo() {}
virtual void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) = 0;
// virtual void stop();
};
class AudioCDManager : public Common::Singleton<AudioCDManager> {
public:
struct Status {

View File

@ -770,96 +770,6 @@ AudioStream *makeFlacStream(
return input;
}
#pragma mark -
#pragma mark --- Flac Audio CD emulation ---
#pragma mark -
class FlacTrackInfo : public DigitalTrackInfo {
private:
Common::String _filename;
bool _errorFlag;
public:
FlacTrackInfo(const char *filename);
bool error() { return _errorFlag; }
void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
};
FlacTrackInfo::FlacTrackInfo(const char *filename) :
_filename(filename),
_errorFlag(false) {
// Try to open the file
Common::File file;
if (!file.open(_filename)) {
_errorFlag = true;
return;
}
// Next, try to create a FlacInputStream from it
FlacInputStream *tempStream = new FlacInputStream(&file, false);
// If initialising the stream fails, we set the error flag
if (!tempStream || !tempStream->isStreamDecoderReady())
_errorFlag = true;
delete tempStream;
}
void FlacTrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
assert(!_errorFlag);
if (error()) {
debug(1, "FlacTrackInfo::play: invalid state, method should not been called");
}
// Open the file
Common::File *file = new Common::File();
if (!file || !file->open(_filename)) {
warning("FlacTrackInfo::play: failed to open '%s'", _filename.c_str());
delete file;
return;
}
// Convert startFrame & duration from frames (1/75 s) to milliseconds (1/1000s)
uint start = startFrame * 1000 / 75;
uint end = duration ? ((startFrame + duration) * 1000 / 75) : 0;
// ... create an AudioStream ...
FlacInputStream *input = new FlacInputStream(file, true, start, end, numLoops);
if (!input->isStreamDecoderReady()) {
delete input;
return;
}
// ... and play it
mixer->playInputStream(Audio::Mixer::kMusicSoundType, handle, input);
}
DigitalTrackInfo* getFlacTrack(int track) {
assert(track >= 1);
char trackName[4][32];
sprintf(trackName[0], "track%d.flac", track);
sprintf(trackName[1], "track%02d.flac", track);
sprintf(trackName[2], "track%d.fla", track);
sprintf(trackName[3], "track%02d.fla", track);
for (int i = 0; i < 4; ++i) {
if (Common::File::exists(trackName[i])) {
FlacTrackInfo *trackInfo = new FlacTrackInfo(trackName[i]);
if (!trackInfo->error())
return trackInfo;
delete trackInfo;
}
}
return NULL;
}
} // End of namespace Audio
#endif // #ifdef USE_FLAC

View File

@ -36,9 +36,6 @@ namespace Common {
namespace Audio {
class AudioStream;
class DigitalTrackInfo;
DigitalTrackInfo *getFlacTrack(int track);
/**
* Create a new AudioStream from the FLAC data in the given

View File

@ -339,93 +339,6 @@ AudioStream *makeMP3Stream(
return new MP3InputStream(stream, disposeAfterUse, start, end, numLoops);
}
#pragma mark -
#pragma mark --- MP3 Audio CD emulation ---
#pragma mark -
class MP3TrackInfo : public DigitalTrackInfo {
private:
Common::String _filename;
bool _errorFlag;
public:
MP3TrackInfo(const char *filename);
bool error() { return _errorFlag; }
void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
};
MP3TrackInfo::MP3TrackInfo(const char *filename) :
_filename(filename),
_errorFlag(false) {
// Try to open the file
Common::File file;
if (!file.open(_filename)) {
_errorFlag = true;
return;
}
// Next, try to create an MP3InputStream from it
MP3InputStream *tempStream = new MP3InputStream(&file, false);
// If we see EOS here then that means that not (enough) valid input
// data was given.
_errorFlag = tempStream->endOfData();
// Clean up again
delete tempStream;
}
void MP3TrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
assert(!_errorFlag);
mad_timer_t start;
mad_timer_t end;
// Both startFrame and duration are given in frames, where 75 frames are one second.
// Calculate the appropriate mad_timer_t values from them.
mad_timer_set(&start, startFrame / 75, startFrame % 75, 75);
if (duration == 0) {
end = mad_timer_zero;
} else {
int endFrame = startFrame + duration;
mad_timer_set(&end, endFrame / 75, endFrame % 75, 75);
}
// Open the file
Common::File *file = new Common::File();
if (!file || !file->open(_filename)) {
warning("MP3TrackInfo::play: failed to open '%s'", _filename.c_str());
delete file;
return;
}
// ... create an AudioStream ...
MP3InputStream *input = new MP3InputStream(file, true, start, end, numLoops);
// ... and play it
mixer->playInputStream(Audio::Mixer::kMusicSoundType, handle, input);
}
DigitalTrackInfo *getMP3Track(int track) {
char trackName[2][32];
sprintf(trackName[0], "track%d.mp3", track);
sprintf(trackName[1], "track%02d.mp3", track);
for (int i = 0; i < 2; ++i) {
if (Common::File::exists(trackName[i])) {
MP3TrackInfo *trackInfo = new MP3TrackInfo(trackName[i]);
if (!trackInfo->error())
return trackInfo;
delete trackInfo;
}
}
return NULL;
}
} // End of namespace Audio
#endif // #ifdef USE_MAD

View File

@ -36,9 +36,6 @@ namespace Common {
namespace Audio {
class AudioStream;
class DigitalTrackInfo;
DigitalTrackInfo *getMP3Track(int track);
/**
* Create a new AudioStream from the MP3 data in the given

View File

@ -293,86 +293,6 @@ AudioStream *makeVorbisStream(
}
#pragma mark -
#pragma mark --- Ogg Vorbis Audio CD emulation ---
#pragma mark -
class VorbisTrackInfo : public DigitalTrackInfo {
private:
Common::String _filename;
bool _errorFlag;
public:
VorbisTrackInfo(const char *filename);
bool error() { return _errorFlag; }
void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
};
VorbisTrackInfo::VorbisTrackInfo(const char *filename) :
_filename(filename),
_errorFlag(false) {
// Try to open the file
Common::File file;
if (!file.open(_filename)) {
_errorFlag = true;
return;
}
// Next, try to create a VorbisInputStream from it
VorbisInputStream *tempStream = new VorbisInputStream(&file, false);
// If an error occured...
// TODO: add an error or init method to VorbisInputStream
_errorFlag = tempStream->endOfData();
// Clean up again
delete tempStream;
}
void VorbisTrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
assert(!_errorFlag);
// Open the file
Common::File *file = new Common::File();
if (!file || !file->open(_filename)) {
warning("VorbisTrackInfo::play: failed to open '%s'", _filename.c_str());
delete file;
return;
}
// Convert startFrame & duration from frames (1/75 s) to milliseconds (1/1000s),
// i.e. multiply with a factor of 1000/75 = 40/3.
uint start = startFrame * 40 / 3;
uint end = duration ? ((startFrame + duration) * 40 / 3) : 0;
// ... create an AudioStream ...
VorbisInputStream *input = new VorbisInputStream(file, true, start, end, numLoops);
// ... and play it
mixer->playInputStream(Audio::Mixer::kMusicSoundType, handle, input);
}
DigitalTrackInfo *getVorbisTrack(int track) {
char trackName[2][32];
sprintf(trackName[0], "track%d.ogg", track);
sprintf(trackName[1], "track%02d.ogg", track);
for (int i = 0; i < 2; ++i) {
if (Common::File::exists(trackName[i])) {
VorbisTrackInfo *trackInfo = new VorbisTrackInfo(trackName[i]);
if (!trackInfo->error())
return trackInfo;
delete trackInfo;
}
}
return NULL;
}
} // End of namespace Audio
#endif // #ifdef USE_VORBIS

View File

@ -36,9 +36,6 @@ namespace Common {
namespace Audio {
class AudioStream;
class DigitalTrackInfo;
DigitalTrackInfo *getVorbisTrack(int track);
/**
* Create a new AudioStream from the Ogg Vorbis data in the given