From f5238c66d5279bbc9de3272868b08c62adf3bbbd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2018 10:46:20 -0400 Subject: XEEN: Add an optional param to CD playback to specify sound type --- backends/audiocd/audiocd.h | 5 ++++- backends/audiocd/default/default-audiocd.cpp | 5 +++-- backends/audiocd/default/default-audiocd.h | 3 ++- backends/audiocd/win32/win32-audiocd.cpp | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 12 deletions(-) (limited to 'backends') diff --git a/backends/audiocd/audiocd.h b/backends/audiocd/audiocd.h index b3674f2570..1a31cd7b20 100644 --- a/backends/audiocd/audiocd.h +++ b/backends/audiocd/audiocd.h @@ -23,6 +23,7 @@ #ifndef BACKENDS_AUDIOCD_ABSTRACT_H #define BACKENDS_AUDIOCD_ABSTRACT_H +#include "audio/mixer.h" #include "common/scummsys.h" #include "common/noncopyable.h" @@ -65,10 +66,12 @@ public: * @param startFrame the frame at which playback should start (75 frames = 1 second). * @param duration the number of frames to play. * @param onlyEmulate determines if the track should be emulated only + * @param soundType What sound type to play as. By default, it's as music * @note The @c onlyEmulate parameter is deprecated. * @return @c true if the track started playing, @c false otherwise */ - virtual bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false) = 0; + virtual bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false, + Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType) = 0; /** * Get if audio is being played. diff --git a/backends/audiocd/default/default-audiocd.cpp b/backends/audiocd/default/default-audiocd.cpp index c2ce7cedcc..003060c9a6 100644 --- a/backends/audiocd/default/default-audiocd.cpp +++ b/backends/audiocd/default/default-audiocd.cpp @@ -54,7 +54,8 @@ void DefaultAudioCDManager::close() { stop(); } -bool DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate) { +bool DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate, + Audio::Mixer::SoundType soundType) { stop(); if (numLoops != 0 || startFrame != 0) { @@ -84,7 +85,7 @@ bool DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int du repetitions. Finally, -1 means infinitely many */ _emulating = true; - _mixer->playStream(Audio::Mixer::kMusicSoundType, &_handle, + _mixer->playStream(soundType, &_handle, Audio::makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops), -1, _cd.volume, _cd.balance); return true; } diff --git a/backends/audiocd/default/default-audiocd.h b/backends/audiocd/default/default-audiocd.h index e3fbb4b5a1..3c12560faa 100644 --- a/backends/audiocd/default/default-audiocd.h +++ b/backends/audiocd/default/default-audiocd.h @@ -40,7 +40,8 @@ public: virtual bool open(); virtual void close(); - virtual bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false); + virtual bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false, + Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType); virtual void stop(); virtual bool isPlaying() const; virtual void setVolume(byte volume); diff --git a/backends/audiocd/win32/win32-audiocd.cpp b/backends/audiocd/win32/win32-audiocd.cpp index b3cde308b9..6eff1ef0b3 100644 --- a/backends/audiocd/win32/win32-audiocd.cpp +++ b/backends/audiocd/win32/win32-audiocd.cpp @@ -149,13 +149,14 @@ public: Win32AudioCDManager(); ~Win32AudioCDManager(); - bool open(); - void close(); - bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false); + virtual bool open(); + virtual void close(); + virtual bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false, + Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType); protected: - bool openCD(int drive); - bool openCD(const Common::String &drive); + virtual bool openCD(int drive); + virtual bool openCD(const Common::String &drive); private: bool loadTOC(); @@ -254,9 +255,10 @@ void Win32AudioCDManager::close() { _tocEntries.clear(); } -bool Win32AudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate) { +bool Win32AudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate, + Audio::Mixer::SoundType soundType) { // Prefer emulation - if (DefaultAudioCDManager::play(track, numLoops, startFrame, duration, onlyEmulate)) + if (DefaultAudioCDManager::play(track, numLoops, startFrame, duration, onlyEmulate, soundType)) return true; // If we're set to only emulate, or have no CD drive, return here @@ -289,7 +291,7 @@ bool Win32AudioCDManager::play(int track, int numLoops, int startFrame, int dura _emulating = true; _mixer->playStream( - Audio::Mixer::kMusicSoundType, + soundType, &_handle, Audio::makeLoopingAudioStream(audioStream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops), -1, -- cgit v1.2.3