aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/audiocd.cpp171
-rw-r--r--sound/audiocd.h96
-rw-r--r--sound/decoders/flac.cpp1
-rw-r--r--sound/decoders/mp3.cpp1
-rw-r--r--sound/decoders/vorbis.cpp1
-rw-r--r--sound/mixer.cpp1
-rw-r--r--sound/mixer.h3
-rw-r--r--sound/module.mk1
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_audio.cpp5
9 files changed, 4 insertions, 276 deletions
diff --git a/sound/audiocd.cpp b/sound/audiocd.cpp
deleted file mode 100644
index f1288131fa..0000000000
--- a/sound/audiocd.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/* 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.
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "sound/audiocd.h"
-#include "sound/audiostream.h"
-#include "sound/decoders/mp3.h"
-#include "sound/decoders/vorbis.h"
-#include "sound/decoders/flac.h"
-#include "engines/engine.h"
-#include "common/util.h"
-#include "common/system.h"
-
-DECLARE_SINGLETON(Audio::AudioCDManager)
-
-namespace Audio {
-
-AudioCDManager::AudioCDManager() {
- _cd.playing = false;
- _cd.track = 0;
- _cd.start = 0;
- _cd.duration = 0;
- _cd.numLoops = 0;
- _cd.volume = Mixer::kMaxChannelVolume;
- _cd.balance = 0;
- _mixer = g_system->getMixer();
- _emulating = false;
- assert(_mixer);
-}
-
-void AudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool only_emulate) {
- if (numLoops != 0 || startFrame != 0) {
- _cd.track = track;
- _cd.numLoops = numLoops;
- _cd.start = startFrame;
- _cd.duration = duration;
-
- // Try to load the track from a compressed data file, and if found, use
- // that. If not found, attempt to start regular Audio CD playback of
- // the requested track.
- char trackName[2][16];
- sprintf(trackName[0], "track%d", track);
- sprintf(trackName[1], "track%02d", track);
- Audio::SeekableAudioStream *stream = 0;
-
- for (int i = 0; !stream && i < 2; ++i)
- stream = SeekableAudioStream::openStreamFile(trackName[i]);
-
- // Stop any currently playing emulated track
- _mixer->stopHandle(_handle);
-
- if (stream != 0) {
- Timestamp start = Timestamp(0, startFrame, 75);
- Timestamp end = duration ? Timestamp(0, startFrame + duration, 75) : stream->getLength();
-
- /*
- FIXME: Seems numLoops == 0 and numLoops == 1 both indicate a single repetition,
- while all other positive numbers indicate precisely the number of desired
- repetitions. Finally, -1 means infinitely many
- */
- _emulating = true;
- _mixer->playStream(Mixer::kMusicSoundType, &_handle,
- makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops), -1, _cd.volume, _cd.balance);
-
- } else {
- _emulating = false;
- if (!only_emulate)
- g_system->playCD(track, numLoops, startFrame, duration);
- }
- }
-}
-
-void AudioCDManager::stop() {
- if (_emulating) {
- // Audio CD emulation
- _mixer->stopHandle(_handle);
- _emulating = false;
- } else {
- // Real Audio CD
- g_system->stopCD();
- }
-}
-
-bool AudioCDManager::isPlaying() const {
- if (_emulating) {
- // Audio CD emulation
- return _mixer->isSoundHandleActive(_handle);
- } else {
- // Real Audio CD
- return g_system->pollCD();
- }
-}
-
-void AudioCDManager::setVolume(byte volume) {
- _cd.volume = volume;
- if (_emulating) {
- // Audio CD emulation
- if (_mixer->isSoundHandleActive(_handle))
- _mixer->setChannelVolume(_handle, _cd.volume);
- } else {
- // Real Audio CD
-
- // Unfortunately I can't implement this atm
- // since SDL doesn't seem to offer an interface method for this.
-
- // g_system->setVolumeCD(_cd.volume);
- }
-}
-
-void AudioCDManager::setBalance(int8 balance) {
- _cd.balance = balance;
- if (_emulating) {
- // Audio CD emulation
- if (isPlaying())
- _mixer->setChannelBalance(_handle, _cd.balance);
- } else {
- // Real Audio CD
-
- // Unfortunately I can't implement this atm
- // since SDL doesn't seem to offer an interface method for this.
-
- // g_system->setBalanceCD(_cd.balance);
- }
-}
-
-void AudioCDManager::updateCD() {
- if (_emulating) {
- // Check whether the audio track stopped playback
- if (!_mixer->isSoundHandleActive(_handle)) {
- // FIXME: We do not update the numLoops parameter here (and in fact,
- // currently can't do that). Luckily, only one engine ever checks
- // this part of the AudioCD status, namely the SCUMM engine; and it
- // only checks whether the track is currently set to infinite looping
- // or not.
- _emulating = false;
- }
- } else {
- g_system->updateCD();
- }
-}
-
-AudioCDManager::Status AudioCDManager::getStatus() const {
- // TODO: This could be improved for "real" CD playback.
- // But to do that, we would have to extend the OSystem interface.
- Status info = _cd;
- info.playing = isPlaying();
- return info;
-}
-
-} // End of namespace Audio
diff --git a/sound/audiocd.h b/sound/audiocd.h
deleted file mode 100644
index abc45a1640..0000000000
--- a/sound/audiocd.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* 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.
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SOUND_AUDIOCD_H
-#define SOUND_AUDIOCD_H
-
-#include "common/scummsys.h"
-#include "common/singleton.h"
-#include "sound/mixer.h"
-
-
-namespace Audio {
-
-
-class AudioCDManager : public Common::Singleton<AudioCDManager> {
-public:
- struct Status {
- bool playing;
- int track;
- int start;
- int duration;
- int numLoops;
- int volume;
- int balance;
- };
-
- /**
- * 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)
- * @param only_emulate if true, don't try to play from a real CD
- */
- void play(int track, int numLoops, int startFrame, int duration, bool only_emulate = false);
- void stop();
- bool isPlaying() const;
-
- void setVolume(byte volume);
- void setBalance(int8 balance);
-
- void updateCD();
-
- Status getStatus() const;
-
-private:
- friend class Common::Singleton<SingletonBaseType>;
- AudioCDManager();
-
- // 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
- // along with it the Mixer will be destroyed before the AudioCDManager, thus
- // 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.
-
- /* used for emulated CD music */
- SoundHandle _handle;
- bool _emulating;
-
- Status _cd;
- Mixer *_mixer;
-};
-
-/** Shortcut for accessing the audio CD manager. */
-#define AudioCD Audio::AudioCDManager::instance()
-
-} // End of namespace Audio
-
-#endif
diff --git a/sound/decoders/flac.cpp b/sound/decoders/flac.cpp
index 1264e869ad..560b83e1ee 100644
--- a/sound/decoders/flac.cpp
+++ b/sound/decoders/flac.cpp
@@ -32,7 +32,6 @@
#include "common/util.h"
#include "sound/audiostream.h"
-#include "sound/audiocd.h"
#define FLAC__NO_DLL // that MS-magic gave me headaches - just link the library you like
#include <FLAC/export.h>
diff --git a/sound/decoders/mp3.cpp b/sound/decoders/mp3.cpp
index 848ee7e280..e06b82a9e2 100644
--- a/sound/decoders/mp3.cpp
+++ b/sound/decoders/mp3.cpp
@@ -31,7 +31,6 @@
#include "common/stream.h"
#include "common/util.h"
-#include "sound/audiocd.h"
#include "sound/audiostream.h"
#include <mad.h>
diff --git a/sound/decoders/vorbis.cpp b/sound/decoders/vorbis.cpp
index 7673c53010..5aeb40c139 100644
--- a/sound/decoders/vorbis.cpp
+++ b/sound/decoders/vorbis.cpp
@@ -32,7 +32,6 @@
#include "common/util.h"
#include "sound/audiostream.h"
-#include "sound/audiocd.h"
#ifdef USE_TREMOR
#if defined(__GP32__) // custom libtremor locations
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index c40aa95d73..cb3cc2a0f3 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -435,7 +435,6 @@ int MixerImpl::getVolumeForSoundType(SoundType type) const {
return _volumeForSoundType[type];
}
-
#pragma mark -
#pragma mark --- Channel implementations ---
#pragma mark -
diff --git a/sound/mixer.h b/sound/mixer.h
index 65d5d18cc6..5c7d902337 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -28,6 +28,7 @@
#include "common/types.h"
#include "common/mutex.h"
+#include "common/noncopyable.h"
#include "sound/timestamp.h"
@@ -61,7 +62,7 @@ public:
* The main audio mixer handles mixing of an arbitrary number of
* audio streams (in the form of AudioStream instances).
*/
-class Mixer {
+class Mixer : Common::NonCopyable {
public:
enum SoundType {
kPlainSoundType = 0,
diff --git a/sound/module.mk b/sound/module.mk
index 7992d3822b..6cfa165a95 100644
--- a/sound/module.mk
+++ b/sound/module.mk
@@ -1,7 +1,6 @@
MODULE := sound
MODULE_OBJS := \
- audiocd.o \
audiostream.o \
fmopl.o \
mididrv.o \
diff --git a/sound/softsynth/fmtowns_pc98/towns_audio.cpp b/sound/softsynth/fmtowns_pc98/towns_audio.cpp
index aa6df1db5a..e6da237881 100644
--- a/sound/softsynth/fmtowns_pc98/towns_audio.cpp
+++ b/sound/softsynth/fmtowns_pc98/towns_audio.cpp
@@ -24,7 +24,6 @@
*/
#include "sound/softsynth/fmtowns_pc98/towns_audio.h"
-#include "sound/audiocd.h"
#include "common/endian.h"
@@ -1406,8 +1405,8 @@ void TownsAudioInterface::updateOutputVolume() {
int volume = (int)(((float)(maxVol * 255) / 63.0f));
int balance = maxVol ? (int)( ( ((int)_outputLevel[13] - _outputLevel[12]) * 127) / (float)maxVol) : 0;
- AudioCD.setVolume(volume);
- AudioCD.setBalance(balance);
+ g_system->getAudioCDManager()->setVolume(volume);
+ g_system->getAudioCDManager()->setBalance(balance);
}
const uint8 TownsAudioInterface::_chanFlags[] = {