[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.16,1.17 mixer.h,1.8,1.9
Pawe? Ko?odziejski
aquadran at users.sourceforge.net
Tue Oct 15 14:56:02 CEST 2002
Update of /cvsroot/scummvm/scummvm/sound
In directory usw-pr-cvs1:/tmp/cvs-serv10755/sound
Modified Files:
mixer.cpp mixer.h
Log Message:
changes to imuse
Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mixer.cpp 15 Oct 2002 18:08:20 -0000 1.16
+++ mixer.cpp 15 Oct 2002 21:55:03 -0000 1.17
@@ -27,6 +27,7 @@
SoundMixer::SoundMixer() {
_volumeTable = (int16 *)calloc(256 * sizeof(int16), 1);
+ _beginSlots = 0;
}
SoundMixer::~SoundMixer() {
@@ -67,7 +68,7 @@
int SoundMixer::insertAt(PlayingSoundHandle * handle, int index, Channel * chan) {
if(index == -1) {
- for (int i = 0; i != NUM_CHANNELS; i++)
+ for (int i = _beginSlots; i != NUM_CHANNELS; i++)
if (_channels[i] == NULL) { index = i; break; }
if(index == -1) {
warning("SoundMixer::out of mixer slots");
@@ -85,7 +86,7 @@
}
int SoundMixer::playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags) {
- for (int i = 0; i != NUM_CHANNELS; i++) {
+ for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
if (_channels[i] == NULL) {
return insertAt(handle, i, new ChannelRaw(this, sound, size, rate, flags, -1));
}
@@ -96,7 +97,7 @@
}
int SoundMixer::playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags, int id) {
- for (int i = 0; i != NUM_CHANNELS; i++) {
+ for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
if (_channels[i] == NULL) {
return insertAt(handle, i, new ChannelRaw(this, sound, size, rate, flags, id));
}
@@ -107,24 +108,21 @@
}
int SoundMixer::playStream(PlayingSoundHandle * handle, int idx, void * sound, uint32 size,
- uint rate, byte flags, int32 timeout) {
- return insertAt(handle, idx, new ChannelStream(this, sound, size, rate, flags, timeout));
+ uint rate, byte flags, int32 timeout, int32 buffer_size) {
+ return insertAt(handle, idx, new ChannelStream(this, sound, size, rate, flags, timeout, buffer_size));
}
-void SoundMixer::stopChannel(int index) {
- if ((index < 0) || (index >= NUM_CHANNELS)) {
- warning("soundMixer::stopChannel has invalid index %d", index);
+void SoundMixer::beginSlots(int index) {
+ if ((index < 0) && (index >= NUM_CHANNELS)) {
+ warning("soundMixer::beginSlots has invalid index %d", index);
return;
}
-
- if (_channels[index] != NULL) {
- _channels[index]->_toBeDestroyed = true;
- }
+ _beginSlots = index;
}
#ifdef COMPRESSED_SOUND_FILE
int SoundMixer::playMP3(PlayingSoundHandle * handle, void *sound, uint32 size, byte flags) {
- for (int i = 0; i != NUM_CHANNELS; i++) {
+ for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
if (_channels[i] == NULL) {
return insertAt(handle, i, new ChannelMP3(this, sound, size, flags));
}
@@ -135,7 +133,7 @@
}
int SoundMixer::playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_timer_t duration) {
/* Stop the previously playing CD track (if any) */
- for (int i = 0; i != NUM_CHANNELS; i++) {
+ for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
if (_channels[i] == NULL) {
return insertAt(handle, i, new ChannelMP3CDMusic(this, file, duration));
}
@@ -201,6 +199,11 @@
}
void SoundMixer::stop(int index) {
+ if ((index < 0) || (index >= NUM_CHANNELS)) {
+ warning("soundMixer::stop has invalid index %d", index);
+ return;
+ }
+
if (_channels[index])
_channels[index]->destroy();
}
@@ -210,7 +213,7 @@
}
bool SoundMixer::hasActiveChannel() {
- for (int i = 0; i != NUM_CHANNELS; i++)
+ for (int i = _beginSlots; i != NUM_CHANNELS; i++)
if (_channels[i])
return true;
return false;
@@ -624,10 +627,10 @@
}
SoundMixer::ChannelStream::ChannelStream(SoundMixer * mixer, void * sound, uint32 size, uint rate,
- byte flags, int32 timeout) {
+ byte flags, int32 timeout, int32 buffer_size) {
_mixer = mixer;
_flags = flags;
- _bufferSize = 2000000;
+ _bufferSize = buffer_size;
_ptr = (byte *)malloc(_bufferSize);
memcpy(_ptr, sound, size);
_endOfData = _ptr + size;
Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mixer.h 15 Oct 2002 07:01:34 -0000 1.8
+++ mixer.h 15 Oct 2002 21:55:04 -0000 1.9
@@ -85,7 +85,7 @@
byte _flags;
public:
- ChannelStream(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int32 timout);
+ ChannelStream(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int32 timout, int32 buffer_size);
void append(void * sound, uint32 size);
void mix(int16 * data, uint len);
@@ -163,12 +163,15 @@
Channel * _channels[NUM_CHANNELS];
PlayingSoundHandle * _handles[NUM_CHANNELS];
+ int _beginSlots;
+
SoundMixer();
~SoundMixer();
int insertAt(PlayingSoundHandle * handle, int index, Channel * chan);
void append(void * data, uint32 len);
void unInsert(Channel * chan);
+ void beginSlots(int index);
/* start playing a raw sound */
enum {
@@ -183,8 +186,7 @@
int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags);
int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags, int id);
int playStream(PlayingSoundHandle * handle, int index, void * sound, uint32 size, uint rate,
- byte flags, int32 timeout = 3);
- void stopChannel(int index);
+ byte flags, int32 timeout = 3, int32 buffer_size = 2000000);
#ifdef COMPRESSED_SOUND_FILE
int playMP3(PlayingSoundHandle * handle, void * sound, uint32 size, byte flags);
int playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_timer_t duration);
More information about the Scummvm-git-logs
mailing list