aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound/audiocd.cpp8
-rw-r--r--sound/flac.cpp32
-rw-r--r--sound/mp3.cpp18
-rw-r--r--sound/vorbis.cpp21
4 files changed, 38 insertions, 41 deletions
diff --git a/sound/audiocd.cpp b/sound/audiocd.cpp
index 7892f03202..3e8a995624 100644
--- a/sound/audiocd.cpp
+++ b/sound/audiocd.cpp
@@ -41,7 +41,7 @@ struct TrackFormat {
/**
* Pointer to a function which tries to open the specified track - the only argument
* is the number of the track to be played.
- * Returns either the DigitalTrackInfo object representing the requested track or null
+ * Returns either a DigitalTrackInfo object representing the requested track or null
* in case of an error
*/
DigitalTrackInfo* (*openTrackFunction)(int);
@@ -49,15 +49,15 @@ struct TrackFormat {
static const TrackFormat TRACK_FORMATS[] = {
/* decoderName, openTrackFunction */
-#ifdef USE_FLAC
- { "Flac", getFlacTrack },
-#endif
#ifdef USE_VORBIS
{ "Ogg Vorbis", getVorbisTrack },
#endif
#ifdef USE_MAD
{ "MPEG Layer 3", getMP3Track },
#endif
+#ifdef USE_FLAC
+ { "Flac", getFlacTrack },
+#endif
{ NULL, NULL } // Terminator
};
diff --git a/sound/flac.cpp b/sound/flac.cpp
index c1bfd396aa..94398a6946 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -933,31 +933,25 @@ FlacTrackInfo::~FlacTrackInfo() {
}
DigitalTrackInfo* getFlacTrack(int track) {
- assert(track >=1);
- char track_name[32];
+ assert(track >= 1);
+ char trackName[4][32];
File *file = new File();
- sprintf(track_name, "track%d.flac", track);
- file->open(track_name);
+ 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);
- if (file->isOpen()) {
- FlacTrackInfo *trackInfo = new FlacTrackInfo(file);
- if (!trackInfo->error())
- return trackInfo;
- delete trackInfo;
- }
-
- sprintf(track_name, "track%d.fla", track);
- file->open(track_name);
- if (file->isOpen()) {
- FlacTrackInfo *trackInfo = new FlacTrackInfo(file);
- if (!trackInfo->error())
- return trackInfo;
- delete trackInfo;
+ for (int i = 0; i < 4; ++i) {
+ if (file->open(trackName[i])) {
+ FlacTrackInfo *trackInfo = new FlacTrackInfo(file);
+ if (!trackInfo->error())
+ return trackInfo;
+ delete trackInfo;
+ }
}
-
delete file;
return NULL;
}
diff --git a/sound/mp3.cpp b/sound/mp3.cpp
index ad8c6e5467..c922cca4b0 100644
--- a/sound/mp3.cpp
+++ b/sound/mp3.cpp
@@ -472,17 +472,19 @@ MP3TrackInfo::~MP3TrackInfo() {
}
DigitalTrackInfo *getMP3Track(int track) {
- char track_name[32];
+ char trackName[2][32];
File *file = new File();
- sprintf(track_name, "track%d.mp3", track);
- file->open(track_name);
+ sprintf(trackName[0], "track%d.mp3", track);
+ sprintf(trackName[1], "track%02d.mp3", track);
- if (file->isOpen()) {
- MP3TrackInfo *trackInfo = new MP3TrackInfo(file);
- if (!trackInfo->error())
- return trackInfo;
- delete trackInfo;
+ for (int i = 0; i < 2; ++i) {
+ if (file->open(trackName[i])) {
+ MP3TrackInfo *trackInfo = new MP3TrackInfo(file);
+ if (!trackInfo->error())
+ return trackInfo;
+ delete trackInfo;
+ }
}
delete file;
return NULL;
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp
index eaa8e80b27..7f9fd8d41c 100644
--- a/sound/vorbis.cpp
+++ b/sound/vorbis.cpp
@@ -243,19 +243,20 @@ void VorbisTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int
}
DigitalTrackInfo *getVorbisTrack(int track) {
-//debug(5, "" __FILE__ ":%i", __LINE__);
- char track_name[32];
+ char trackName[2][32];
File *file = new File();
- sprintf(track_name, "track%d.ogg", track);
- file->open(track_name);
+ sprintf(trackName[0], "track%d.ogg", track);
+ sprintf(trackName[1], "track%02d.ogg", track);
- if (file->isOpen()) {
- VorbisTrackInfo *trackInfo = new VorbisTrackInfo(file);
- file->decRef();
- if (!trackInfo->error())
- return trackInfo;
- delete trackInfo;
+ for (int i = 0; i < 2; ++i) {
+ if (file->open(trackName[i])) {
+ VorbisTrackInfo *trackInfo = new VorbisTrackInfo(file);
+ file->decRef();
+ if (!trackInfo->error())
+ return trackInfo;
+ delete trackInfo;
+ }
}
delete file;
return NULL;