FREESCAPE: reimplemented playMusic using Audio::SeekableAudioStream::openStreamFile

This commit is contained in:
neuromancer 2022-11-06 20:38:32 +01:00 committed by Eugene Sandulenko
parent 401ebf9c26
commit 5b335031a5
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
2 changed files with 9 additions and 13 deletions

View File

@ -127,8 +127,8 @@ void DrillerEngine::loadAssets() {
_angleRotations.push_back(5.0);
_angleRotations.push_back(9.5);
// Start playing music, if any
playMusic("Matt Gray - The Best Of Reformation - 07 Driller Theme.ogg");
// Start playing music, if any, in any supported format
playMusic("Matt Gray - The Best Of Reformation - 07 Driller Theme");
}
void DrillerEngine::loadAssetsDemo() {

View File

@ -20,8 +20,8 @@
*/
#include "common/file.h"
#include "audio/audiostream.h"
#include "audio/decoders/raw.h"
#include "audio/decoders/vorbis.h"
#include "freescape/freescape.h"
@ -230,17 +230,13 @@ void FreescapeEngine::playWav(const Common::String filename) {
}
void FreescapeEngine::playMusic(const Common::String filename) {
Common::File *file = new Common::File();
if (!file->open(filename)) {
debugC(1, kFreescapeDebugMedia, "Unable to find sound file %s", filename.c_str());
return;
Audio::SeekableAudioStream *stream = nullptr;
stream = Audio::SeekableAudioStream::openStreamFile(filename);
if (stream) {
Audio::LoopingAudioStream *loop = new Audio::LoopingAudioStream(stream, 0);
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, loop);
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume / 4);
}
Audio::LoopingAudioStream *stream;
stream = new Audio::LoopingAudioStream(Audio::makeVorbisStream(file, DisposeAfterUse::YES), 0);
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, stream);
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume / 4);
}
void FreescapeEngine::playSoundFx(int index, bool sync) {