mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-25 05:34:27 +00:00
BACKENDS: moved the audio cd track path assembly into one location
also added m4a audio cd support as it is supported in openStreamFile() which is called in DefaultAudioCDManager::play()
This commit is contained in:
parent
dcaad26e86
commit
60111294a0
@ -104,6 +104,12 @@ public:
|
||||
* @return a Status struct with playback data.
|
||||
*/
|
||||
virtual Status getStatus() const = 0;
|
||||
|
||||
/**
|
||||
* Checks whether the extracted audio cd tracks exists as files in
|
||||
* the search paths.
|
||||
*/
|
||||
virtual bool existExtractedCDAudioFiles() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "backends/audiocd/default/default-audiocd.h"
|
||||
#include "audio/audiostream.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/file.h"
|
||||
#include "common/system.h"
|
||||
#include "common/util.h"
|
||||
|
||||
@ -55,6 +56,44 @@ void DefaultAudioCDManager::close() {
|
||||
stop();
|
||||
}
|
||||
|
||||
void DefaultAudioCDManager::fillPotentialTrackNames(Common::Array<Common::String> &trackNames, int track) const {
|
||||
trackNames.reserve(4);
|
||||
trackNames.push_back(Common::String::format("track%d", track));
|
||||
trackNames.push_back(Common::String::format("track%02d", track));
|
||||
trackNames.push_back(Common::String::format("track_%d", track));
|
||||
trackNames.push_back(Common::String::format("track_%02d", track));
|
||||
}
|
||||
|
||||
bool DefaultAudioCDManager::existExtractedCDAudioFiles() {
|
||||
// keep this in sync with STREAM_FILEFORMATS
|
||||
const char *extensions[] = {
|
||||
#ifdef USE_VORBIS
|
||||
"ogg",
|
||||
#endif
|
||||
#ifdef USE_FLAC
|
||||
"fla", "flac",
|
||||
#endif
|
||||
#ifdef USE_MAD
|
||||
"mp3",
|
||||
#endif
|
||||
"m4a",
|
||||
nullptr
|
||||
};
|
||||
|
||||
Common::Array<Common::String> trackNames;
|
||||
fillPotentialTrackNames(trackNames, 1);
|
||||
|
||||
for (Common::Array<Common::String>::iterator i = trackNames.begin(); i != trackNames.end(); ++i) {
|
||||
for (const char **ext = extensions; *ext; ++ext) {
|
||||
const Common::String &filename = Common::String::format("%s.%s", i->c_str(), *ext);
|
||||
if (Common::File::exists(filename)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate,
|
||||
Audio::Mixer::SoundType soundType) {
|
||||
stop();
|
||||
@ -68,15 +107,13 @@ bool DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int du
|
||||
// Try to load the track from a compressed data file, and if found, use
|
||||
// that. If not found, attempt to start regular Audio CD playback of
|
||||
// the requested track.
|
||||
Common::String trackName[4];
|
||||
trackName[0] = Common::String::format("track%d", track);
|
||||
trackName[1] = Common::String::format("track%02d", track);
|
||||
trackName[2] = Common::String::format("track_%d", track);
|
||||
trackName[3] = Common::String::format("track_%02d", track);
|
||||
Common::Array<Common::String> trackNames;
|
||||
fillPotentialTrackNames(trackNames, track);
|
||||
Audio::SeekableAudioStream *stream = 0;
|
||||
|
||||
for (int i = 0; !stream && i < ARRAYSIZE(trackName); ++i)
|
||||
stream = Audio::SeekableAudioStream::openStreamFile(trackName[i]);
|
||||
for (Common::Array<Common::String>::iterator i = trackNames.begin(); !stream && i != trackNames.end(); ++i) {
|
||||
stream = Audio::SeekableAudioStream::openStreamFile(*i);
|
||||
}
|
||||
|
||||
if (stream != 0) {
|
||||
Audio::Timestamp start = Audio::Timestamp(0, startFrame, 75);
|
||||
|
@ -40,9 +40,6 @@ public:
|
||||
|
||||
virtual bool open();
|
||||
virtual void close();
|
||||
/**
|
||||
* @note Keep this in sync with Engine::existExtractedCDAudioFiles()
|
||||
*/
|
||||
virtual bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false,
|
||||
Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType);
|
||||
virtual void stop();
|
||||
@ -51,6 +48,10 @@ public:
|
||||
virtual void setBalance(int8 balance);
|
||||
virtual void update();
|
||||
virtual Status getStatus() const; // Subclasses should override for better status results
|
||||
virtual bool existExtractedCDAudioFiles();
|
||||
|
||||
private:
|
||||
void fillPotentialTrackNames(Common::Array<Common::String> &trackNames, int track) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "common/translation.h"
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "backends/audiocd/audiocd.h"
|
||||
#include "backends/keymapper/action.h"
|
||||
#include "backends/keymapper/keymapper.h"
|
||||
#include "base/version.h"
|
||||
@ -465,38 +466,9 @@ void GUIErrorMessageFormat(Common::U32String fmt, ...) {
|
||||
*
|
||||
* @return true if audio files of the expected naming scheme are found, as long as ScummVM
|
||||
* is also built with support to the respective audio format (eg. ogg, flac, mad/mp3)
|
||||
* @note Make sure to keep this in sync with DefaultAudioCDManager::play()
|
||||
*/
|
||||
bool Engine::existExtractedCDAudioFiles() {
|
||||
const char *extensions[] = {
|
||||
#ifdef USE_VORBIS
|
||||
"ogg",
|
||||
#endif
|
||||
#ifdef USE_FLAC
|
||||
"fla", "flac",
|
||||
#endif
|
||||
#ifdef USE_MAD
|
||||
"mp3",
|
||||
#endif
|
||||
nullptr
|
||||
};
|
||||
|
||||
const char *trackName[] = {
|
||||
"track1",
|
||||
"track01",
|
||||
"track_1",
|
||||
"track_01"
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(trackName); ++i) {
|
||||
for (const char **ext = extensions; *ext; ++ext) {
|
||||
const Common::String &filename = Common::String::format("%s.%s", trackName[i], *ext);
|
||||
if (Common::File::exists(filename)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return g_system->getAudioCDManager()->existExtractedCDAudioFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user