aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-07-29 12:39:41 +0000
committerMax Horn2003-07-29 12:39:41 +0000
commit6b470390f7ca2b17a56e0b79a2b42f4e70309fcb (patch)
tree527d885fec6b2859e9dbaec94d0331eecd2a050c /scumm
parentf1a6025aa2a8b6c99798e0738eaca4c844933c20 (diff)
downloadscummvm-rg350-6b470390f7ca2b17a56e0b79a2b42f4e70309fcb.tar.gz
scummvm-rg350-6b470390f7ca2b17a56e0b79a2b42f4e70309fcb.tar.bz2
scummvm-rg350-6b470390f7ca2b17a56e0b79a2b42f4e70309fcb.zip
cleanup
svn-id: r9281
Diffstat (limited to 'scumm')
-rw-r--r--scumm/sound.cpp59
-rw-r--r--scumm/sound.h1
2 files changed, 24 insertions, 36 deletions
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index 8a308c3d69..d822211928 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -943,25 +943,24 @@ void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle)
int rate, comp;
byte *data;
- if (_scumm->_noDigitalSamples)
+ if (_soundsPaused || _scumm->_noDigitalSamples)
return;
if (file_size > 0) {
int alloc_size = file_size;
+ if (_vorbis_mode) {
+ data = (byte *)calloc(alloc_size, 1);
+
+ if (file->read(data, file_size) != (uint)file_size) {
+ // no need to free the memory since error will shut down
+ error("startSfxSound: cannot read %d bytes", size);
+ }
+ playSfxSound_Vorbis(data, file_size, handle);
+ } else {
#ifdef USE_MAD
- if (!_vorbis_mode)
- alloc_size += MAD_BUFFER_GUARD;
+ _scumm->_mixer->playMP3(handle, file, file_size);
#endif
- data = (byte *)calloc(alloc_size, 1);
-
- if (file->read(data, file_size) != (uint)file_size) {
- /* no need to free the memory since error will shut down */
- error("startSfxSound: cannot read %d bytes", size);
}
- if (_vorbis_mode)
- playSfxSound_Vorbis(data, file_size, handle);
- else
- playSfxSound_MP3(data, file_size, handle);
return;
}
@@ -1429,21 +1428,12 @@ bail:
}
void Sound::playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned, PlayingSoundHandle *handle) {
- if (_soundsPaused)
- return;
byte flags = SoundMixer::FLAG_AUTOFREE;
if (isUnsigned)
flags |= SoundMixer::FLAG_UNSIGNED;
_scumm->_mixer->playRaw(handle, sound, size, rate, flags);
}
-void Sound::playSfxSound_MP3(void *sound, uint32 size, PlayingSoundHandle *handle) {
-#ifdef USE_MAD
- if (!_soundsPaused && !_scumm->_noDigitalSamples)
- _scumm->_mixer->playMP3(handle, sound, size, SoundMixer::FLAG_AUTOFREE);
-#endif
-}
-
#ifdef USE_VORBIS
// Provide a virtual file to vorbisfile based on preloaded data
struct data_file_info {
@@ -1508,20 +1498,19 @@ static ov_callbacks data_wrap = {
void Sound::playSfxSound_Vorbis(void *sound, uint32 size, PlayingSoundHandle *handle) {
#ifdef USE_VORBIS
- if (!_soundsPaused && !_scumm->_noDigitalSamples) {
- OggVorbis_File *ov_file = new OggVorbis_File;
- data_file_info *f = new data_file_info;
- f->data = (char *) sound;
- f->size = size;
- f->curr_pos = 0;
-
- if (ov_open_callbacks((void *) f, ov_file, NULL, 0, data_wrap) < 0) {
- warning("Invalid file format");
- delete ov_file;
- delete f;
- } else
- _scumm->_mixer->playVorbis(handle, ov_file, 0, false);
- }
+ OggVorbis_File *ov_file = new OggVorbis_File;
+ data_file_info *f = new data_file_info;
+ f->data = (char *) sound;
+ f->size = size;
+ f->curr_pos = 0;
+
+ if (ov_open_callbacks((void *) f, ov_file, NULL, 0, data_wrap) < 0) {
+ warning("Invalid file format");
+ delete ov_file;
+ delete f;
+ free(sound);
+ } else
+ _scumm->_mixer->playVorbis(handle, ov_file, 0, false);
#endif
}
diff --git a/scumm/sound.h b/scumm/sound.h
index 77e8e3e056..1bb765770c 100644
--- a/scumm/sound.h
+++ b/scumm/sound.h
@@ -159,7 +159,6 @@ protected:
void stopSfxSound();
bool isSfxFinished() const;
void playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned, PlayingSoundHandle *handle);
- void playSfxSound_MP3(void *sound, uint32 size, PlayingSoundHandle *handle);
void playSfxSound_Vorbis(void *sound, uint32 size, PlayingSoundHandle *handle);
int getCachedTrack(int track);