2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2003-11-29 12:11:01 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-11-29 12:11:01 +00:00
|
|
|
*
|
2006-02-11 10:05:31 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-11-29 12:11:01 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SOUND_AUDIOCD_H
|
|
|
|
#define SOUND_AUDIOCD_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/singleton.h"
|
|
|
|
#include "sound/mixer.h"
|
|
|
|
|
2006-04-29 22:33:31 +00:00
|
|
|
|
|
|
|
namespace Audio {
|
|
|
|
|
2006-10-21 12:44:10 +00:00
|
|
|
|
2003-11-29 12:11:01 +00:00
|
|
|
class AudioCDManager : public Common::Singleton<AudioCDManager> {
|
|
|
|
public:
|
2003-11-29 13:56:33 +00:00
|
|
|
struct Status {
|
|
|
|
bool playing;
|
|
|
|
int track;
|
|
|
|
int start;
|
|
|
|
int duration;
|
|
|
|
int numLoops;
|
2010-08-04 16:53:09 +00:00
|
|
|
int volume;
|
|
|
|
int balance;
|
2003-11-29 13:56:33 +00:00
|
|
|
};
|
|
|
|
|
2007-02-20 16:13:45 +00:00
|
|
|
/**
|
|
|
|
* Start playback of the specified "CD" track. This method mimics
|
|
|
|
* the interface of OSystem::playCD (which it in fact may call, if an Audio CD is
|
|
|
|
* present), but also can play digital audio tracks in various formats.
|
|
|
|
*
|
|
|
|
* @param track the track to play.
|
|
|
|
* @param num_loops how often playback should be repeated (-1 = infinitely often).
|
|
|
|
* @param start_frame the frame at which playback should start (75 frames = 1 second).
|
|
|
|
* @param duration the number of frames to play (0: play until end)
|
2009-01-24 01:29:52 +00:00
|
|
|
* @param only_emulate if true, don't try to play from a real CD
|
2007-02-20 16:13:45 +00:00
|
|
|
*/
|
2009-01-24 01:29:52 +00:00
|
|
|
void play(int track, int numLoops, int startFrame, int duration, bool only_emulate = false);
|
2003-11-29 13:56:33 +00:00
|
|
|
void stop();
|
2003-11-29 23:40:21 +00:00
|
|
|
bool isPlaying() const;
|
2003-11-29 13:56:33 +00:00
|
|
|
|
2010-08-04 16:53:09 +00:00
|
|
|
void setVolume(byte volume);
|
|
|
|
void setBalance(int8 balance);
|
|
|
|
|
2003-11-29 12:11:01 +00:00
|
|
|
void updateCD();
|
|
|
|
|
2003-11-29 13:56:33 +00:00
|
|
|
Status getStatus() const;
|
|
|
|
|
2003-11-29 12:11:01 +00:00
|
|
|
private:
|
2005-01-06 18:38:34 +00:00
|
|
|
friend class Common::Singleton<SingletonBaseType>;
|
2003-11-29 12:11:01 +00:00
|
|
|
AudioCDManager();
|
|
|
|
|
2009-08-18 15:32:26 +00:00
|
|
|
// FIXME: It might make sense to stop CD playback, when the AudioCDManager singleton
|
|
|
|
// is destroyed. Currently we can not do this, since in worst case the OSystem and
|
2009-08-18 15:41:00 +00:00
|
|
|
// along with it the Mixer will be destroyed before the AudioCDManager, thus
|
2009-08-18 15:32:26 +00:00
|
|
|
// leading to invalid memory access. If we can fix up the code to destroy the
|
|
|
|
// AudioCDManager before OSystem in *all* cases, that is including calling
|
|
|
|
// OSystem::quit, we might be able to implement it via a simple "stop()"
|
|
|
|
// call in a custom destructor of AudioCDManager.
|
|
|
|
|
2003-11-29 12:11:01 +00:00
|
|
|
/* used for emulated CD music */
|
2009-01-24 01:23:04 +00:00
|
|
|
SoundHandle _handle;
|
|
|
|
bool _emulating;
|
2003-11-29 13:56:33 +00:00
|
|
|
|
2009-01-24 01:23:04 +00:00
|
|
|
Status _cd;
|
2006-10-21 12:44:10 +00:00
|
|
|
Mixer *_mixer;
|
2003-11-29 12:11:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Shortcut for accessing the audio CD manager. */
|
2006-04-29 22:33:31 +00:00
|
|
|
#define AudioCD Audio::AudioCDManager::instance()
|
|
|
|
|
|
|
|
} // End of namespace Audio
|
2003-11-29 12:11:01 +00:00
|
|
|
|
|
|
|
#endif
|