[Scummvm-cvs-logs] CVS: scummvm/sound audiocd.h,1.3,1.4 mixer.cpp,1.139,1.140 mixer.h,1.61,1.62 mp3.cpp,1.3,1.4 mp3.h,1.2,1.3 vorbis.cpp,1.3,1.4 vorbis.h,1.2,1.3
Max Horn
fingolfin at users.sourceforge.net
Sat Dec 20 16:46:00 CET 2003
Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv21959
Modified Files:
audiocd.h mixer.cpp mixer.h mp3.cpp mp3.h vorbis.cpp vorbis.h
Log Message:
o Make use of the new LinearMemoryStream feature which allows auto-disposing the sound data
o This allows us to get rid of the ChannelRaw class
o Removed the sound index return value from several methods
o Removed all methods dealing with sound indices (i.e. stopChannel and pauseChannel)
Index: audiocd.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/audiocd.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- audiocd.h 29 Nov 2003 23:40:21 -0000 1.3
+++ audiocd.h 21 Dec 2003 00:44:31 -0000 1.4
@@ -30,7 +30,7 @@
class DigitalTrackInfo {
public:
virtual bool error() = 0;
- virtual int play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) = 0;
+ virtual void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) = 0;
virtual ~DigitalTrackInfo() { }
};
Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- mixer.cpp 19 Dec 2003 01:30:19 -0000 1.139
+++ mixer.cpp 21 Dec 2003 00:44:31 -0000 1.140
@@ -55,13 +55,13 @@
public:
int _id;
- Channel(SoundMixer *mixer, PlayingSoundHandle *handle, bool isMusic, byte volume, int8 pan)
- : _mixer(mixer), _handle(handle), _isMusic(isMusic), _volume(volume), _pan(pan), _paused(false), _converter(0), _input(0), _id(-1) {
+ Channel(SoundMixer *mixer, PlayingSoundHandle *handle, bool isMusic, byte volume, int8 pan, int id = -1)
+ : _mixer(mixer), _handle(handle), _isMusic(isMusic), _volume(volume), _pan(pan), _paused(false), _converter(0), _input(0), _id(id) {
assert(mixer);
}
- Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, bool reverseStereo = false)
- : _mixer(mixer), _handle(handle), _isMusic(isMusic), _volume(volume), _pan(pan), _paused(false), _converter(0), _input(input), _id(-1) {
+ Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, bool reverseStereo = false, int id = -1)
+ : _mixer(mixer), _handle(handle), _isMusic(isMusic), _volume(volume), _pan(pan), _paused(false), _converter(0), _input(input), _id(id) {
assert(mixer);
assert(input);
@@ -92,13 +92,6 @@
}
};
-class ChannelRaw : public Channel {
- byte *_ptr;
-public:
- ChannelRaw(SoundMixer *mixer, PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, byte volume, int8 pan, int id, uint32 loopStart, uint32 loopEnd);
- ~ChannelRaw();
-};
-
class ChannelStream : public Channel {
public:
ChannelStream(SoundMixer *mixer, PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan);
@@ -156,9 +149,9 @@
_premixProc = proc;
}
-int SoundMixer::newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan) {
+void SoundMixer::newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan) {
Common::StackLock lock(_mutex);
- return insertChannel(handle, new ChannelStream(this, handle, sound, size, rate, flags, buffer_size, volume, pan));
+ insertChannel(handle, new ChannelStream(this, handle, sound, size, rate, flags, buffer_size, volume, pan));
}
void SoundMixer::appendStream(PlayingSoundHandle handle, void *sound, uint32 size) {
@@ -214,7 +207,7 @@
}
}
-int SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) {
+void SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) {
int index = -1;
for (int i = 0; i != NUM_CHANNELS; i++) {
if (_channels[i] == NULL) {
@@ -225,56 +218,70 @@
if(index == -1) {
warning("SoundMixer::out of mixer slots");
delete chan;
- return -1;
+ return;
}
_channels[index] = chan;
if (handle)
*handle = index + 1;
- return index;
}
-int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id, byte volume, int8 pan, uint32 loopStart, uint32 loopEnd) {
+void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id, byte volume, int8 pan, uint32 loopStart, uint32 loopEnd) {
Common::StackLock lock(_mutex);
// Prevent duplicate sounds
if (id != -1) {
for (int i = 0; i != NUM_CHANNELS; i++)
if (_channels[i] != NULL && _channels[i]->_id == id)
- return -1;
+ return;
}
- Channel *chan = new ChannelRaw(this, handle, sound, size, rate, flags, volume, pan, id, loopStart, loopEnd);
- return insertChannel(handle, chan);
+ // Create the input stream
+ AudioInputStream *input;
+ const bool autoFreeMemory = (flags & SoundMixer::FLAG_AUTOFREE) != 0;
+ if (flags & SoundMixer::FLAG_LOOP) {
+ if (loopEnd == 0) {
+ input = makeLinearInputStream(rate, flags, (byte *)sound, size, 0, size, autoFreeMemory);
+ } else {
+ assert(loopStart < loopEnd && loopEnd <= size);
+ input = makeLinearInputStream(rate, flags, (byte *)sound, size, loopStart, loopEnd - loopStart, autoFreeMemory);
+ }
+ } else {
+ input = makeLinearInputStream(rate, flags, (byte *)sound, size, 0, 0, autoFreeMemory);
+ }
+
+ // Create the channel
+ Channel *chan = new Channel(this, handle, input, false, volume, pan, (flags & SoundMixer::FLAG_REVERSE_STEREO) != 0, id);
+ insertChannel(handle, chan);
}
#ifdef USE_MAD
-int SoundMixer::playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan) {
+void SoundMixer::playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan) {
// Create the input stream
AudioInputStream *input = makeMP3Stream(file, mad_timer_zero, size);
- return playInputStream(handle, input, false, volume, pan);
+ playInputStream(handle, input, false, volume, pan);
}
-int SoundMixer::playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume, int8 pan) {
+void SoundMixer::playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume, int8 pan) {
// Create the input stream
AudioInputStream *input = makeMP3Stream(file, duration, 0);
- return playInputStream(handle, input, true, volume, pan);
+ playInputStream(handle, input, true, volume, pan);
}
#endif
#ifdef USE_VORBIS
-int SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan) {
+void SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan) {
// Create the input stream
AudioInputStream *input = makeVorbisStream(ov_file, duration);
- return playInputStream(handle, input, is_cd_track, volume, pan);
+ playInputStream(handle, input, is_cd_track, volume, pan);
}
#endif
-int SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan) {
+void SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan) {
Common::StackLock lock(_mutex);
// Create the channel
Channel *chan = new Channel(this, handle, input, isMusic, volume, pan);
- return insertChannel(handle, chan);
+ insertChannel(handle, chan);
}
void SoundMixer::mix(int16 *buf, uint len) {
@@ -311,17 +318,6 @@
_channels[i]->destroy();
}
-void SoundMixer::stopChannel(int index) {
- if ((index < 0) || (index >= NUM_CHANNELS)) {
- warning("soundMixer::stop has invalid index %d", index);
- return;
- }
-
- Common::StackLock lock(_mutex);
- if (_channels[index])
- _channels[index]->destroy();
-}
-
void SoundMixer::stopID(int id) {
Common::StackLock lock(_mutex);
for (int i = 0; i != NUM_CHANNELS; i++) {
@@ -388,17 +384,6 @@
_paused = paused;
}
-void SoundMixer::pauseChannel(int index, bool paused) {
- if ((index < 0) || (index >= NUM_CHANNELS)) {
- warning("soundMixer::pauseChannel has invalid index %d", index);
- return;
- }
-
- Common::StackLock lock(_mutex);
- if (_channels[index])
- _channels[index]->pause(paused);
-}
-
void SoundMixer::pauseID(int id, bool paused) {
Common::StackLock lock(_mutex);
for (int i = 0; i != NUM_CHANNELS; i++) {
@@ -508,35 +493,6 @@
_converter->flow(*_input, data, len, vol_l, vol_r);
}
-}
-
-/* RAW mixer */
-ChannelRaw::ChannelRaw(SoundMixer *mixer, PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, byte volume, int8 pan, int id, uint32 loopStart, uint32 loopEnd)
- : Channel(mixer, handle, false, volume, pan) {
- _id = id;
- _ptr = (byte *)sound;
-
- // Create the input stream
- if (flags & SoundMixer::FLAG_LOOP) {
- if (loopEnd == 0) {
- _input = makeLinearInputStream(rate, flags, _ptr, size, 0, size);
- } else {
- assert(loopStart < loopEnd && loopEnd <= size);
- _input = makeLinearInputStream(rate, flags, _ptr, size, loopStart, loopEnd - loopStart);
- }
- } else {
- _input = makeLinearInputStream(rate, flags, _ptr, size, 0, 0);
- }
-
- if (!(flags & SoundMixer::FLAG_AUTOFREE))
- _ptr = 0;
-
- // Get a rate converter instance
- _converter = makeRateConverter(_input->getRate(), mixer->getOutputRate(), _input->isStereo(), (flags & SoundMixer::FLAG_REVERSE_STEREO) != 0);
-}
-
-ChannelRaw::~ChannelRaw() {
- free(_ptr);
}
ChannelStream::ChannelStream(SoundMixer *mixer, PlayingSoundHandle *handle,
Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- mixer.h 19 Dec 2003 00:32:47 -0000 1.61
+++ mixer.h 21 Dec 2003 00:44:31 -0000 1.62
@@ -97,21 +97,21 @@
void setupPremix(PremixProc *proc, void *param);
// start playing a raw sound
- int playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags,
+ void playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags,
int id = -1, byte volume = 255, int8 pan = 0, uint32 loopStart = 0, uint32 loopEnd = 0);
#ifdef USE_MAD
- int playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume = 255, int8 pan = 0);
- int playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume = 255, int8 pan = 0);
+ void playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume = 255, int8 pan = 0);
+ void playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume = 255, int8 pan = 0);
#endif
#ifdef USE_VORBIS
- int playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume = 255, int8 pan = 0);
+ void playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume = 255, int8 pan = 0);
#endif
- int playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume = 255, int8 pan = 0);
+ void playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume = 255, int8 pan = 0);
/** Start a new stream. */
- int newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume = 255, int8 pan = 0);
+ void newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume = 255, int8 pan = 0);
/** Append to an existing stream. */
void appendStream(PlayingSoundHandle handle, void *sound, uint32 size);
@@ -122,9 +122,6 @@
/** stop all currently playing sounds */
void stopAll();
- /** stop playing the given channel */
- void stopChannel(int channel);
-
/** stop playing the sound with given ID */
void stopID(int id);
@@ -134,9 +131,6 @@
/** pause/unpause all channels */
void pauseAll(bool paused);
- /** pause/unpause the given channel */
- void pauseChannel(int index, bool paused);
-
/** pause/unpause the sound with the given ID */
void pauseID(int id, bool paused);
@@ -168,7 +162,7 @@
uint getOutputRate() const { return _outputRate; }
private:
- int insertChannel(PlayingSoundHandle *handle, Channel *chan);
+ void insertChannel(PlayingSoundHandle *handle, Channel *chan);
/** main mixer method */
void mix(int16 * buf, uint len);
Index: mp3.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mp3.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mp3.cpp 19 Dec 2003 01:30:19 -0000 1.3
+++ mp3.cpp 21 Dec 2003 00:44:31 -0000 1.4
@@ -97,7 +97,7 @@
delete file;
}
-int MP3TrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) {
+void MP3TrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) {
unsigned int offset;
mad_timer_t durationTime;
@@ -116,7 +116,7 @@
}
// Play it
- return mixer->playMP3CDTrack(handle, _file, durationTime);
+ mixer->playMP3CDTrack(handle, _file, durationTime);
}
MP3TrackInfo::~MP3TrackInfo() {
Index: mp3.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mp3.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mp3.h 19 Dec 2003 00:32:47 -0000 1.2
+++ mp3.h 21 Dec 2003 00:44:31 -0000 1.3
@@ -44,7 +44,7 @@
MP3TrackInfo(File *file);
~MP3TrackInfo();
bool error() { return _error_flag; }
- int play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
+ void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
};
AudioInputStream *makeMP3Stream(File *file, mad_timer_t duration, uint size = 0);
Index: vorbis.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/vorbis.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- vorbis.cpp 19 Dec 2003 01:30:19 -0000 1.3
+++ vorbis.cpp 21 Dec 2003 00:44:31 -0000 1.4
@@ -111,13 +111,13 @@
#define VORBIS_TREMOR
#endif
-int VorbisTrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) {
+void VorbisTrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) {
#ifdef VORBIS_TREMOR
ov_time_seek(&_ov_file, (ogg_int64_t)(startFrame / 75.0 * 1000));
#else
ov_time_seek(&_ov_file, startFrame / 75.0);
#endif
- return mixer->playVorbis(handle, &_ov_file,
+ mixer->playVorbis(handle, &_ov_file,
duration * ov_info(&_ov_file, -1)->rate / 75, true);
}
Index: vorbis.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/vorbis.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- vorbis.h 19 Dec 2003 00:32:47 -0000 1.2
+++ vorbis.h 21 Dec 2003 00:44:31 -0000 1.3
@@ -43,7 +43,7 @@
VorbisTrackInfo(File *file);
~VorbisTrackInfo();
bool error() { return _error_flag; }
- int play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
+ void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
};
More information about the Scummvm-git-logs
mailing list