diff options
Diffstat (limited to 'sound/flac.cpp')
-rw-r--r-- | sound/flac.cpp | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/sound/flac.cpp b/sound/flac.cpp index 61e8800c31..215ccee26e 100644 --- a/sound/flac.cpp +++ b/sound/flac.cpp @@ -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 |