mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
AGS: Fix wrong detection of mod audio and enable IT playback
* Look for file extension inside the filename, instead of the asset category (and always failing) * Enable playback of ImpulseTracker streams using mikmod (if available) Fixes TRAC #14437 and enables music playback in Heatwave and Death Wore Endless Feathers
This commit is contained in:
1 parent
9cad1778b8
commit
54c57bb23e
1 file changed
+12
-7
@@ -30,6 +30,7 @@
|
||||
#include "ags/engine/media/audio/sound_clip.h"
|
||||
#include "ags/engine/media/audio/clip_my_midi.h"
|
||||
#include "ags/shared/core/asset_manager.h"
|
||||
#include "audio/mods/impulsetracker.h"
|
||||
#include "audio/mods/mod_xm_s3m.h"
|
||||
#include "audio/mods/protracker.h"
|
||||
#include "audio/decoders/mp3.h"
|
||||
@@ -98,27 +99,31 @@ SOUNDCLIP *my_load_mod(const AssetPath &asset_name, bool loop) {
|
||||
Common::SeekableReadStream *data = _GP(AssetMgr)->OpenAssetStream(asset_name.Name, asset_name.Filter);
|
||||
if (data) {
|
||||
// determine the file extension
|
||||
size_t lastDot = asset_name.Filter.FindCharReverse('.');
|
||||
if (lastDot == AGS::Shared::String::NoIndex || lastDot == asset_name.Filter.GetLength() - 1) {
|
||||
size_t lastDot = asset_name.Name.FindCharReverse('.');
|
||||
if (lastDot == AGS::Shared::String::NoIndex || lastDot == asset_name.Name.GetLength() - 1) {
|
||||
delete data;
|
||||
return nullptr;
|
||||
}
|
||||
// get the first char of the extensin
|
||||
char charAfterDot = toupper(asset_name.Filter[lastDot + 1]);
|
||||
// get the first char of the extension
|
||||
char charAfterDot = toupper(asset_name.Name[lastDot + 1]);
|
||||
|
||||
// use the appropriate loader
|
||||
Audio::AudioStream *audioStream = nullptr;
|
||||
if (charAfterDot == 'I') {
|
||||
// Impulse Tracker
|
||||
warning("Impulse Tracker MOD files not yet supported");
|
||||
#ifdef USE_MIKMOD
|
||||
audioStream = Audio::makeImpulseTrackerStream(data, DisposeAfterUse::YES);
|
||||
#else
|
||||
warning("MIKMOD support was not compiled in! Skipping Impulse Tracker audio");
|
||||
audioStream = Audio::makeSilentAudioStream(22050, true);
|
||||
delete data;
|
||||
return nullptr;
|
||||
#endif
|
||||
} else if (charAfterDot == 'X') {
|
||||
audioStream = Audio::makeModXmS3mStream(data, DisposeAfterUse::YES);
|
||||
} else if (charAfterDot == 'S') {
|
||||
audioStream = Audio::makeModXmS3mStream(data, DisposeAfterUse::YES);
|
||||
} else if (charAfterDot == 'M') {
|
||||
audioStream = Audio::makeProtrackerStream(data, DisposeAfterUse::YES);
|
||||
audioStream = Audio::makeProtrackerStream(data);
|
||||
} else {
|
||||
warning("MOD file format not recognized");
|
||||
delete data;
|
||||
|
||||
Reference in new issue
Block a user