BACKENDS: Add a closeCD() function to the AudioCDManager

This commit is contained in:
Matthew Hoops 2015-09-30 00:25:24 -04:00 committed by Johannes Schickel
parent ec5df573cb
commit 30e68efac4
6 changed files with 20 additions and 4 deletions

View file

@ -113,6 +113,11 @@ public:
*/
virtual bool openCD() = 0;
/**
* Close the currently open CD drive
*/
virtual void closeCD() = 0;
/**
* Poll CD status.
* @return true if CD audio is playing

View file

@ -43,6 +43,7 @@ public:
virtual Status getStatus() const; // Subclasses should override for better status results
bool openCD();
virtual void closeCD() {}
/**
* Open a CD using the specified drive index

View file

@ -43,10 +43,7 @@ SdlAudioCDManager::SdlAudioCDManager()
}
SdlAudioCDManager::~SdlAudioCDManager() {
if (_cdrom) {
SDL_CDStop(_cdrom);
SDL_CDClose(_cdrom);
}
closeCD();
}
bool SdlAudioCDManager::openCD(int drive) {
@ -67,6 +64,14 @@ bool SdlAudioCDManager::openCD(int drive) {
return (_cdrom != NULL);
}
void SdlAudioCDManager::closeCD() {
if (_cdrom) {
SDL_CDStop(_cdrom);
SDL_CDClose(_cdrom);
_cdrom = 0;
}
}
void SdlAudioCDManager::stopCD() {
// Stop CD Audio in 1/10th of a second
_cdStopTime = SDL_GetTicks() + 100;

View file

@ -39,6 +39,7 @@ public:
protected:
virtual bool openCD(int drive);
virtual void closeCD();
virtual void updateCD();
virtual bool pollCD() const;
virtual void playCD(int track, int num_loops, int start_frame, int duration);

View file

@ -60,6 +60,9 @@ 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();

View file

@ -131,6 +131,7 @@ public:
// and should be replaced by an AudioCDManager subclass,
// see backends/audiocd/ and common/system.h
virtual bool openCD();
virtual void closeCD() {}
virtual bool pollCD();
virtual void playCD(int track, int num_loops, int start_frame, int duration);
virtual void stopCD();