diff options
author | Alejandro Marzini | 2010-06-09 20:09:57 +0000 |
---|---|---|
committer | Alejandro Marzini | 2010-06-09 20:09:57 +0000 |
commit | e991cd8c53ad21af037df1e0a16816aeea2d0fe2 (patch) | |
tree | f647f636fc3898c150db61de50c3522056a65d17 /backends/platform/sdl | |
parent | 4177a1e16df7712c081e41a8eabf0b7d4694230b (diff) | |
download | scummvm-rg350-e991cd8c53ad21af037df1e0a16816aeea2d0fe2.tar.gz scummvm-rg350-e991cd8c53ad21af037df1e0a16816aeea2d0fe2.tar.bz2 scummvm-rg350-e991cd8c53ad21af037df1e0a16816aeea2d0fe2.zip |
- Revised abstract AudioCDManager.
- Removed AudioCDManager Singleton, and changed code for using AudioCDManager in OSystem.
- Added initialization code for new AudioCDManager in BaseBackend and OSystem_SDL.
svn-id: r49548
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 112 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.h | 24 |
2 files changed, 19 insertions, 117 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 6f82ede114..c662fed2bf 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -157,6 +157,10 @@ void OSystem_SDL::initBackend() { _graphicsManager = new SdlGraphicsManager(); } + if (_audiocdManager == 0) { + _audiocdManager = new SdlAudioCDManager(); + } + #if !defined(MACOSX) && !defined(__SYMBIAN32__) // Setup a custom program icon. // Don't set icon on OS X, as we use a nicer external icon there. @@ -172,7 +176,6 @@ void OSystem_SDL::initBackend() { OSystem_SDL::OSystem_SDL() : - _cdrom(0), _scrollLock(false), _joystick(0), #if MIXER_DOUBLE_BUFFERING @@ -184,7 +187,8 @@ OSystem_SDL::OSystem_SDL() _mixer(0), _timer(0), _mutexManager(0), - _graphicsManager(0) { + _graphicsManager(0), + _audiocdManager(0) { // reset mouse state memset(&_km, 0, sizeof(_km)); @@ -384,11 +388,6 @@ bool OSystem_SDL::getFeatureState(Feature f) { } void OSystem_SDL::deinit() { - if (_cdrom) { - SDL_CDStop(_cdrom); - SDL_CDClose(_cdrom); - } - if (_joystick) SDL_JoystickClose(_joystick); @@ -669,96 +668,6 @@ Audio::Mixer *OSystem_SDL::getMixer() { } #pragma mark - -#pragma mark --- CD Audio --- -#pragma mark - - -bool OSystem_SDL::openCD(int drive) { - if (SDL_InitSubSystem(SDL_INIT_CDROM) == -1) - _cdrom = NULL; - else { - _cdrom = SDL_CDOpen(drive); - // Did it open? Check if _cdrom is NULL - if (!_cdrom) { - warning("Couldn't open drive: %s", SDL_GetError()); - } else { - _cdNumLoops = 0; - _cdStopTime = 0; - _cdEndTime = 0; - } - } - - return (_cdrom != NULL); -} - -void OSystem_SDL::stopCD() { /* Stop CD Audio in 1/10th of a second */ - _cdStopTime = SDL_GetTicks() + 100; - _cdNumLoops = 0; -} - -void OSystem_SDL::playCD(int track, int num_loops, int start_frame, int duration) { - if (!num_loops && !start_frame) - return; - - if (!_cdrom) - return; - - if (duration > 0) - duration += 5; - - _cdTrack = track; - _cdNumLoops = num_loops; - _cdStartFrame = start_frame; - - SDL_CDStatus(_cdrom); - if (start_frame == 0 && duration == 0) - SDL_CDPlayTracks(_cdrom, track, 0, 1, 0); - else - SDL_CDPlayTracks(_cdrom, track, start_frame, 0, duration); - _cdDuration = duration; - _cdStopTime = 0; - _cdEndTime = SDL_GetTicks() + _cdrom->track[track].length * 1000 / CD_FPS; -} - -bool OSystem_SDL::pollCD() { - if (!_cdrom) - return false; - - return (_cdNumLoops != 0 && (SDL_GetTicks() < _cdEndTime || SDL_CDStatus(_cdrom) == CD_PLAYING)); -} - -void OSystem_SDL::updateCD() { - if (!_cdrom) - return; - - if (_cdStopTime != 0 && SDL_GetTicks() >= _cdStopTime) { - SDL_CDStop(_cdrom); - _cdNumLoops = 0; - _cdStopTime = 0; - return; - } - - if (_cdNumLoops == 0 || SDL_GetTicks() < _cdEndTime) - return; - - if (_cdNumLoops != 1 && SDL_CDStatus(_cdrom) != CD_STOPPED) { - // Wait another second for it to be done - _cdEndTime += 1000; - return; - } - - if (_cdNumLoops > 0) - _cdNumLoops--; - - if (_cdNumLoops != 0) { - if (_cdStartFrame == 0 && _cdDuration == 0) - SDL_CDPlayTracks(_cdrom, _cdTrack, 0, 1, 0); - else - SDL_CDPlayTracks(_cdrom, _cdTrack, _cdStartFrame, 0, _cdDuration); - _cdEndTime = SDL_GetTicks() + _cdrom->track[_cdTrack].length * 1000 / CD_FPS; - } -} - -#pragma mark - #pragma mark --- Graphics --- #pragma mark - @@ -900,4 +809,13 @@ int OSystem_SDL::getScreenChangeID() const { void OSystem_SDL::displayMessageOnOSD(const char *msg) { _graphicsManager->displayMessageOnOSD(msg); } + +#pragma mark - +#pragma mark --- AudioCD --- +#pragma mark - + +AudioCDManager *OSystem_SDL::getAudioCD() { + return (AudioCDManager *)_audiocdManager; +} + #endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 214a8a988c..ebe8728f51 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -36,6 +36,7 @@ #include "backends/mutex/sdl/sdl-mutex.h" #include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/audiocd/sdl/sdl-audiocd.h" #include "graphics/scaler.h" @@ -69,6 +70,7 @@ public: protected: SdlMutexManager *_mutexManager; SdlGraphicsManager *_graphicsManager; + SdlAudioCDManager *_audiocdManager; public: void beginGFXTransaction(); @@ -164,19 +166,6 @@ public: virtual Audio::Mixer *getMixer(); - // Poll CD status - // Returns true if cd audio is playing - bool pollCD(); - - // Play CD audio track - void playCD(int track, int num_loops, int start_frame, int duration); - - // Stop CD audio track - void stopCD(); - - // Update CD audio status - void updateCD(); - // Quit virtual void quit(); // overloaded by CE backend @@ -210,7 +199,6 @@ public: virtual int getGraphicsMode() const; virtual void setWindowCaption(const char *caption); - virtual bool openCD(int drive); virtual bool hasFeature(Feature f); virtual void setFeatureState(Feature f, bool enable); @@ -228,15 +216,12 @@ public: virtual Common::SeekableReadStream *createConfigReadStream(); virtual Common::WriteStream *createConfigWriteStream(); + virtual AudioCDManager *getAudioCD(); + protected: bool _inited; SDL_AudioSpec _obtainedRate; - // CD Audio - SDL_CD *_cdrom; - int _cdTrack, _cdNumLoops, _cdStartFrame, _cdDuration; - uint32 _cdEndTime, _cdStopTime; - // Keyboard mouse emulation. Disabled by fingolfin 2004-12-18. // I am keeping the rest of the code in for now, since the joystick // code (or rather, "hack") uses it, too. @@ -277,7 +262,6 @@ protected: SDL_TimerID _timerID; Common::TimerManager *_timer; -protected: virtual void fillMouseEvent(Common::Event &event, int x, int y); // overloaded by CE backend void toggleMouseGrab(); |