diff options
author | Matthew Hoops | 2015-10-06 22:10:34 -0400 |
---|---|---|
committer | Johannes Schickel | 2016-03-13 13:57:19 +0100 |
commit | aa6ff444408bfd17bcca1d8364e86ce62da327ef (patch) | |
tree | 5990ede855749a13faeaa8b381320cb4e0b4cfa1 /backends/platform | |
parent | dc0d4fcf303458e9044866dd05a30c317e07eef0 (diff) | |
download | scummvm-rg350-aa6ff444408bfd17bcca1d8364e86ce62da327ef.tar.gz scummvm-rg350-aa6ff444408bfd17bcca1d8364e86ce62da327ef.tar.bz2 scummvm-rg350-aa6ff444408bfd17bcca1d8364e86ce62da327ef.zip |
BACKENDS: Only expose one set of functions for AudioCDManager
Engines should only have to call one set of functions and not decide between the two. In fact, the 'emulation' API was documented to just call the 'real CD' API.
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/dc/dc.h | 24 | ||||
-rw-r--r-- | backends/platform/dc/dcmain.cpp | 60 |
2 files changed, 39 insertions, 45 deletions
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index b49080324d..b567142b8f 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -57,24 +57,16 @@ class DCHardware { }; class DCCDManager : public DefaultAudioCDManager { - // Initialize the specified CD drive for audio playback. - bool openCD(); - - // Close the open CD drive - void closeCD() {} - - // Poll cdrom status - // Returns true if cd audio is playing - bool pollCD(); - - // Play cdrom audio track - void playCD(int track, int num_loops, int start_frame, int duration); +public: + // Poll cdrom status + // Returns true if cd audio is playing + bool isPlaying() const; - // Stop cdrom audio track - void stopCD(); + // Play cdrom audio track + void play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false); - // Update cdrom audio status - void updateCD(); + // Stop cdrom audio track + void stop(); }; class OSystem_Dreamcast : private DCHardware, public EventsBaseBackend, public PaletteManager, public FilesystemFactory diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index aa8430afc8..bd66b81b35 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -90,43 +90,45 @@ static bool find_track(int track, int &first_sec, int &last_sec) return false; } -void DCCDManager::playCD(int track, int num_loops, int start_frame, int duration) -{ - int first_sec, last_sec; +void DCCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate) { + DefaultAudioCDManager::play(track, numLoops, startFrame, duration, onlyEmulate); + + // If we're playing now, are set to only emulate, return here + if (isPlaying() || onlyEmulate) + return; + + int firstSec, lastSec; #if 1 - if (num_loops) - --num_loops; + if (numLoops) + --numLoops; #endif - if (num_loops>14) num_loops=14; - else if (num_loops<0) num_loops=15; // infinity - if (!find_track(track, first_sec, last_sec)) - return; - if (duration) - last_sec = first_sec + start_frame + duration; - first_sec += start_frame; - play_cdda_sectors(first_sec, last_sec, num_loops); -} -void DCCDManager::stopCD() -{ - stop_cdda(); -} + if (numLoops > 14) + numLoops = 14; + else if (numLoops < 0) + num_loops = 15; // infinity -bool DCCDManager::pollCD() -{ - extern int getCdState(); - return getCdState() == 3; + if (!find_track(track, firstSec, lastSec)) + return; + + if (duration) + lastSec = firstSec + startFrame + duration; + + firstSec += startFrame; + play_cdda_sectors(firstSec, lastSec, numLoops); } -void DCCDManager::updateCD() -{ - // Dummy. The CD drive takes care of itself. +void DCCDManager::stop() { + DefaultAudioCDManager::stop(); + stop_cdda(); } -bool DCCDManager::openCD() -{ - // Dummy. - return true; +bool DCCDManager::isPlaying() const { + if (DefaultAudioCDManager::isPlaying()) + return true; + + extern int getCdState(); + return getCdState() == 3; } void OSystem_Dreamcast::setWindowCaption(const char *caption) |