aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2003-11-29 13:56:33 +0000
committerMax Horn2003-11-29 13:56:33 +0000
commite68ac71155bf775a32742335a1d8690aad17ecee (patch)
tree64b1923d8e7e2f73f998cc5725c54618a5a76e3c /sound
parentf00cd05b331cb5db1dfee140608d6189385950a4 (diff)
downloadscummvm-rg350-e68ac71155bf775a32742335a1d8690aad17ecee.tar.gz
scummvm-rg350-e68ac71155bf775a32742335a1d8690aad17ecee.tar.bz2
scummvm-rg350-e68ac71155bf775a32742335a1d8690aad17ecee.zip
added API to query CD playback status; renamed AudioCDManager methods
svn-id: r11422
Diffstat (limited to 'sound')
-rw-r--r--sound/audiocd.cpp33
-rw-r--r--sound/audiocd.h31
2 files changed, 39 insertions, 25 deletions
diff --git a/sound/audiocd.cpp b/sound/audiocd.cpp
index 6da8cf28aa..718ed10214 100644
--- a/sound/audiocd.cpp
+++ b/sound/audiocd.cpp
@@ -33,19 +33,21 @@ AudioCDManager::AudioCDManager() {
_current_cache = 0;
}
-void AudioCDManager::playCDTrack(int track, int numLoops, int startFrame, int duration) {
+void AudioCDManager::play(int track, int numLoops, int startFrame, int duration) {
if (numLoops != 0 || startFrame != 0) {
// Try to load the track from a .mp3/.ogg file, and if found, use
// that. If not found, attempt to do regular Audio CD playback of
// the requested track.
int index = getCachedTrack(track);
+
+ _cd.track = track;
+ _cd.numLoops = numLoops;
+ _cd.start = startFrame;
+ _cd.duration = duration;
+
if (index >= 0) {
g_engine->_mixer->stopHandle(_cd.handle);
_cd.playing = true;
- _cd.track = track;
- _cd.numLoops = numLoops;
- _cd.start = startFrame;
- _cd.duration = duration;
_track_info[index]->play(g_engine->_mixer, &_cd.handle, _cd.start, _cd.duration);
} else {
g_system->play_cdrom(track, numLoops, startFrame, duration);
@@ -53,7 +55,7 @@ void AudioCDManager::playCDTrack(int track, int numLoops, int startFrame, int du
}
}
-void AudioCDManager::stopCD() {
+void AudioCDManager::stop() {
if (_cd.playing) {
g_engine->_mixer->stopHandle(_cd.handle);
_cd.playing = false;
@@ -62,7 +64,7 @@ void AudioCDManager::stopCD() {
}
}
-int AudioCDManager::pollCD() const {
+int AudioCDManager::isPlaying() const {
return _cd.playing || g_system->poll_cdrom();
}
@@ -74,12 +76,9 @@ void AudioCDManager::updateCD() {
// to be repeated, and if that's the case, play it again. Else, stop
// the CD explicitly.
if (_cd.numLoops == -1 || --_cd.numLoops > 0) {
-//FIXME _scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0;
-//FIXME if (!_soundsPaused) {
- int index = getCachedTrack(_cd.track);
- assert(index >= 0);
- _track_info[index]->play(g_engine->_mixer, &_cd.handle, _cd.start, _cd.duration);
-//FIXME }
+ int index = getCachedTrack(_cd.track);
+ assert(index >= 0);
+ _track_info[index]->play(g_engine->_mixer, &_cd.handle, _cd.start, _cd.duration);
} else {
g_engine->_mixer->stopHandle(_cd.handle);
_cd.playing = false;
@@ -90,6 +89,14 @@ void AudioCDManager::updateCD() {
}
}
+AudioCDManager::Status AudioCDManager::getStatus() const {
+ // TODO: This could be improved for "real" CD playback.
+ // But to do that, we have to extend the OSystem interface.
+ Status info = _cd;
+ info.playing = isPlaying();
+ return info;
+}
+
int AudioCDManager::getCachedTrack(int track) {
int i;
#if defined(USE_MAD) || defined(USE_VORBIS)
diff --git a/sound/audiocd.h b/sound/audiocd.h
index c02e50f4f6..4065f9f030 100644
--- a/sound/audiocd.h
+++ b/sound/audiocd.h
@@ -37,11 +37,22 @@ public:
class AudioCDManager : public Common::Singleton<AudioCDManager> {
public:
- void playCDTrack(int track, int numLoops, int startFrame, int duration);
- void stopCD();
- int pollCD() const;
+ struct Status {
+ bool playing;
+ int track;
+ int start;
+ int duration;
+ int numLoops;
+ };
+
+ void play(int track, int numLoops, int startFrame, int duration);
+ void stop();
+ int isPlaying() const;
+
void updateCD();
+ Status getStatus() const;
+
private:
friend class Common::Singleton<AudioCDManager>;
AudioCDManager();
@@ -50,6 +61,11 @@ private:
private:
/* used for emulated CD music */
+ struct ExtStatus : Status {
+ PlayingSoundHandle handle;
+ };
+ ExtStatus _cd;
+
enum {
CACHE_TRACKS = 10
};
@@ -57,15 +73,6 @@ private:
DigitalTrackInfo *_track_info[CACHE_TRACKS];
int _current_cache;
- struct {
- PlayingSoundHandle handle;
- int track;
- int start;
- int duration;
- int numLoops;
- bool playing;
- } _cd;
-
};
/** Shortcut for accessing the audio CD manager. */