diff options
Diffstat (limited to 'sound/mp3.cpp')
-rw-r--r-- | sound/mp3.cpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/sound/mp3.cpp b/sound/mp3.cpp index ff0e3d61dd..f9efdc4e8c 100644 --- a/sound/mp3.cpp +++ b/sound/mp3.cpp @@ -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 |