aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2xsai.cpp8
-rw-r--r--gfx.cpp1
-rw-r--r--resource.cpp2
-rw-r--r--scumm.h4
-rw-r--r--scummvm.cpp1
-rw-r--r--sound.cpp8
-rw-r--r--sound/mixer.cpp29
-rw-r--r--sound/mixer.h24
8 files changed, 33 insertions, 44 deletions
diff --git a/2xsai.cpp b/2xsai.cpp
index 97ea6ca40d..992d424993 100644
--- a/2xsai.cpp
+++ b/2xsai.cpp
@@ -742,15 +742,15 @@ void AdvMame2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint3
for(int j = 0; j < height; ++j) {
for(int i = 0; i < width; ++i) {
- short A = *(p + i - nextlineSrc - 1);
+ // short A = *(p + i - nextlineSrc - 1);
short B = *(p + i - nextlineSrc);
- short C = *(p + i - nextlineSrc + 1);
+ // short C = *(p + i - nextlineSrc + 1);
short D = *(p + i - 1);
short E = *(p + i );
short F = *(p + i + 1);
- short G = *(p + i + nextlineSrc - 1);
+ // short G = *(p + i + nextlineSrc - 1);
short H = *(p + i + nextlineSrc);
- short I = *(p + i + nextlineSrc + 1);
+ // short I = *(p + i + nextlineSrc + 1);
*(q + (i << 1)) = D == B && B != F && D != H ? D : E;
*(q + (i << 1) + 1) = B == F && B != D && F != H ? F : E;
diff --git a/gfx.cpp b/gfx.cpp
index 9df61625a8..7b8f24a778 100644
--- a/gfx.cpp
+++ b/gfx.cpp
@@ -208,7 +208,6 @@ void Gdi::drawStripToScreen(VirtScreen * vs, int x, int w, int t, int b)
{
byte *ptr;
int scrollY;
- int width = w;
int height;
height = b - t;
diff --git a/resource.cpp b/resource.cpp
index 3b3b26d324..a92f003787 100644
--- a/resource.cpp
+++ b/resource.cpp
@@ -423,7 +423,7 @@ void Scumm::loadCharset(int no)
memset(_charsetData, 0, sizeof(_charsetData));
- assert(no < sizeof(_charsetData)/16);
+ assert(no < (int) sizeof(_charsetData)/16);
checkRange(_maxCharsets - 1, 1, no, "Loading illegal charset %d");
// ensureResourceLoaded(6, no);
diff --git a/scumm.h b/scumm.h
index 4e8c8d209b..421ff60225 100644
--- a/scumm.h
+++ b/scumm.h
@@ -972,7 +972,6 @@ public:
#ifdef COMPRESSED_SOUND_FILE
#define CACHE_TRACKS 10
- #define MP3_BUFFER_SIZE 200000
/* used for mp3 CD music */
@@ -981,8 +980,7 @@ public:
struct mad_header _mad_header[CACHE_TRACKS];
long _mp3_size[CACHE_TRACKS];
FILE* _mp3_tracks[CACHE_TRACKS];
- void* _mp3_buffer;
- PlayingSoundHandle _mp3_handle;
+ int _mp3_index;
int getCachedTrack(int track);
int playMP3CDTrack(int track, int num_loops, int start, int delay);
diff --git a/scummvm.cpp b/scummvm.cpp
index 7818eec41c..bf48a135f7 100644
--- a/scummvm.cpp
+++ b/scummvm.cpp
@@ -170,7 +170,6 @@ void Scumm::scummInit()
#ifdef COMPRESSED_SOUND_FILE
_current_cache = 0;
- _mp3_buffer = NULL;
#endif
}
diff --git a/sound.cpp b/sound.cpp
index 4f4cde0dff..5f845a25fc 100644
--- a/sound.cpp
+++ b/sound.cpp
@@ -145,7 +145,7 @@ void Scumm::processSfxQueues()
act = _vars[VAR_TALK_ACTOR];
if (_talkChannel < 0)
finished = false;
- else if (this->_mixer->_channels[_talkChannel] == NULL)
+ else if (_mixer->_channels[_talkChannel] == NULL)
finished = true;
else
finished = false;
@@ -707,8 +707,6 @@ int Scumm::getCachedTrack(int track) {
fseek(file, 0, SEEK_END);
_mp3_size[current_index] = ftell(file);
_mp3_tracks[current_index] = file;
- if (!_mp3_buffer)
- _mp3_buffer = malloc(MP3_BUFFER_SIZE);
return current_index;
@@ -729,7 +727,7 @@ int Scumm::playMP3CDTrack(int track, int num_loops, int start, int delay) {
return 0;
if (!num_loops && !start) {
- _mixer->stop(_mp3_handle);
+ _mixer->stop(_mp3_index);
return 0;
}
@@ -751,7 +749,7 @@ int Scumm::playMP3CDTrack(int track, int num_loops, int start, int delay) {
// Go
fseek(_mp3_tracks[index], offset, SEEK_SET);
- _mixer->play_mp3_cdtrack(&_mp3_handle, _mp3_tracks[index], _mp3_buffer, MP3_BUFFER_SIZE, duration);
+ _mp3_index = _mixer->play_mp3_cdtrack(NULL, _mp3_index, _mp3_tracks[index], duration);
return 0;
}
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index d73ad86958..ccbe3e354c 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -64,10 +64,10 @@ int SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, u
int SoundMixer::play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags) {
return insert(handle, new Channel_MP3(this, sound, size, flags));
}
-void SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration) {
- if (*handle)
- stop(*handle);
- insert(handle, new Channel_MP3_CDMUSIC(this, file, buffer, buffer_size, duration));
+int SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, int index, FILE* file, mad_timer_t duration) {
+ /* Stop the previously playing CD track (if any) */
+ stop(index);
+ return insert(handle, new Channel_MP3_CDMUSIC(this, file, duration));
}
#endif
@@ -113,6 +113,10 @@ void SoundMixer::stop(PlayingSoundHandle psh) {
_channels[psh-1]->destroy();
}
+void SoundMixer::stop(int index) {
+ if (_channels[index])
+ _channels[index]->destroy();
+}
bool SoundMixer::has_active_channel() {
for(int i=0; i!=NUM_CHANNELS; i++)
@@ -327,15 +331,15 @@ void SoundMixer::Channel_MP3::real_destroy() {
}
/* MP3 CD music */
+#define MP3CD_BUFFERING_SIZE 131072
-SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration) {
+SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, mad_timer_t duration) {
_mixer = mixer;
_file = file;
_duration = duration;
_initialized = false;
- _buffer_size = buffer_size;
- _ptr = buffer;
- _flags = 0;
+ _buffer_size = MP3CD_BUFFERING_SIZE;
+ _ptr = malloc(MP3CD_BUFFERING_SIZE);
_to_be_destroyed = false;
mad_stream_init(&_stream);
@@ -345,8 +349,6 @@ SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* fi
#endif
mad_frame_init(&_frame);
mad_synth_init(&_synth);
-
- //debug(1, "CRE %d", getpid());
}
void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) {
@@ -358,8 +360,6 @@ void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) {
return;
}
- //debug(1, "MIX %d", getpid());
-
if (!_initialized) {
int skip_loop;
// just skipped
@@ -451,15 +451,12 @@ void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) {
}
void SoundMixer::Channel_MP3_CDMUSIC::real_destroy() {
- if (_flags & FLAG_AUTOFREE)
- free(_ptr);
+ free(_ptr);
_mixer->uninsert(this);
mad_synth_finish(&_synth);
mad_frame_finish(&_frame);
mad_stream_finish(&_stream);
- //debug(1, "DES %d", getpid());
-
delete this;
}
diff --git a/sound/mixer.h b/sound/mixer.h
index 4f7bb6568e..7986f384a6 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -78,22 +78,19 @@ private:
class Channel_MP3_CDMUSIC : public Channel {
SoundMixer *_mixer;
void *_ptr;
- struct mad_stream _stream;
- struct mad_frame _frame;
- struct mad_synth _synth;
- uint32 _pos_in_frame;
- uint32 _size;
- uint32 _buffer_size;
- mad_timer_t _duration;
- FILE *_file;
+ struct mad_stream _stream;
+ struct mad_frame _frame;
+ struct mad_synth _synth;
+ uint32 _pos_in_frame;
+ uint32 _size;
+ uint32 _buffer_size;
+ mad_timer_t _duration;
+ FILE *_file;
bool _initialized;
- byte _flags;
public:
void mix(int16 *data, uint len);
- Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration);
+ Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, mad_timer_t duration);
void real_destroy();
-
-
};
#endif
@@ -129,7 +126,7 @@ public:
int play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags);
#ifdef COMPRESSED_SOUND_FILE
int play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags);
- void play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration);
+ int play_mp3_cdtrack(PlayingSoundHandle *handle, int index, FILE* file, mad_timer_t duration);
#endif
/* Premix procedure, useful when using fmopl adlib */
@@ -143,6 +140,7 @@ public:
/* stop playing a specific sound */
void stop(PlayingSoundHandle psh);
+ void stop(int index);
/* is any channel active? */
bool has_active_channel();