[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.148,1.149 mixer.h,1.68,1.69
Max Horn
fingolfin at users.sourceforge.net
Thu Dec 25 18:20:00 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sound audiostream.cpp,1.50,1.51 audiostream.h,1.26,1.27 mixer.cpp,1.147,1.148 rate.cpp,1.30,1.31
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sword1 sound.cpp,1.15,1.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv4812
Modified Files:
mixer.cpp mixer.h
Log Message:
add param to playInputStream which makes it possible to retain an input stream even after it has been given to the mixer for playback
Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- mixer.cpp 26 Dec 2003 01:32:29 -0000 1.148
+++ mixer.cpp 26 Dec 2003 02:19:31 -0000 1.149
@@ -43,6 +43,7 @@
private:
SoundMixer *_mixer;
PlayingSoundHandle *_handle;
+ bool _autofreeStream;
const bool _isMusic;
byte _volume;
int8 _pan;
@@ -56,7 +57,7 @@
public:
Channel(SoundMixer *mixer, PlayingSoundHandle *handle, bool isMusic, byte volume, int8 pan, int id = -1);
- Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, bool reverseStereo = false, int id = -1);
+ Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioInputStream *input, bool autofreeStream, bool isMusic, byte volume, int8 pan, bool reverseStereo = false, int id = -1);
virtual ~Channel();
void mix(int16 *data, uint len);
@@ -243,7 +244,7 @@
}
// Create the channel
- Channel *chan = new Channel(this, handle, input, false, volume, pan, (flags & SoundMixer::FLAG_REVERSE_STEREO) != 0, id);
+ Channel *chan = new Channel(this, handle, input, true, false, volume, pan, (flags & SoundMixer::FLAG_REVERSE_STEREO) != 0, id);
insertChannel(handle, chan);
}
@@ -273,7 +274,7 @@
}
#endif
-void SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, int id) {
+void SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, int id, bool autofreeStream) {
Common::StackLock lock(_mutex);
if (input == 0) {
@@ -285,13 +286,14 @@
if (id != -1) {
for (int i = 0; i != NUM_CHANNELS; i++)
if (_channels[i] != 0 && _channels[i]->getId() == id) {
- delete input;
+ if (autofreeStream)
+ delete input;
return;
}
}
// Create the channel
- Channel *chan = new Channel(this, handle, input, isMusic, volume, pan, false, id);
+ Channel *chan = new Channel(this, handle, input, autofreeStream, isMusic, volume, pan, false, id);
insertChannel(handle, chan);
}
@@ -470,13 +472,17 @@
#pragma mark -
-Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, bool isMusic, byte volume, int8 pan, int id)
- : _mixer(mixer), _handle(handle), _isMusic(isMusic), _volume(volume), _pan(pan), _paused(false), _id(id), _converter(0), _input(0) {
+Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, bool isMusic,
+ byte volume, int8 pan, int id)
+ : _mixer(mixer), _handle(handle), _autofreeStream(true), _isMusic(isMusic),
+ _volume(volume), _pan(pan), _paused(false), _id(id), _converter(0), _input(0) {
assert(mixer);
}
-Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, bool reverseStereo, int id)
- : _mixer(mixer), _handle(handle), _isMusic(isMusic), _volume(volume), _pan(pan), _paused(false), _id(id), _converter(0), _input(input) {
+Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioInputStream *input,
+ bool autofreeStream, bool isMusic, byte volume, int8 pan, bool reverseStereo, int id)
+ : _mixer(mixer), _handle(handle), _autofreeStream(autofreeStream), _isMusic(isMusic),
+ _volume(volume), _pan(pan), _paused(false), _id(id), _converter(0), _input(input) {
assert(mixer);
assert(input);
@@ -486,7 +492,8 @@
Channel::~Channel() {
delete _converter;
- delete _input;
+ if (_autofreeStream)
+ delete _input;
if (_handle)
_handle->resetIndex();
}
Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- mixer.h 24 Dec 2003 17:42:22 -0000 1.68
+++ mixer.h 26 Dec 2003 02:19:31 -0000 1.69
@@ -122,7 +122,7 @@
void playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume = 255, int8 pan = 0, int id = -1);
#endif
- void playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume = 255, int8 pan = 0, int id = -1);
+ void playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume = 255, int8 pan = 0, int id = -1, bool autofreeStream = true);
/** Start a new stream. */
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sound audiostream.cpp,1.50,1.51 audiostream.h,1.26,1.27 mixer.cpp,1.147,1.148 rate.cpp,1.30,1.31
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sword1 sound.cpp,1.15,1.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list