diff options
author | Travis Howell | 2002-10-27 11:41:08 +0000 |
---|---|---|
committer | Travis Howell | 2002-10-27 11:41:08 +0000 |
commit | a0734ef3f987d1716440e81b5e571c00d3ed891c (patch) | |
tree | c7ec6dba77324497b485c5467a88c37ed4380c27 /sound/mixer.cpp | |
parent | d5473c6f5a7752503bbfc2be46c1ce3fd73d03f3 (diff) | |
download | scummvm-rg350-a0734ef3f987d1716440e81b5e571c00d3ed891c.tar.gz scummvm-rg350-a0734ef3f987d1716440e81b5e571c00d3ed891c.tar.bz2 scummvm-rg350-a0734ef3f987d1716440e81b5e571c00d3ed891c.zip |
Add monster.sog support, patch #629362
Enable ogg support by default in mingw builds and link in ogg lib
svn-id: r5333
Diffstat (limited to 'sound/mixer.cpp')
-rw-r--r-- | sound/mixer.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index e79a91aa98..73aef6178f 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -145,10 +145,10 @@ int SoundMixer::playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_tim #endif #ifdef USE_VORBIS -int SoundMixer::playVorbisCDTrack(PlayingSoundHandle * handle, OggVorbis_File * ov_file, double duration) { +int SoundMixer::playVorbis(PlayingSoundHandle * handle, OggVorbis_File * ov_file, int duration, bool is_cd_track) { for (int i = _beginSlots; i != NUM_CHANNELS; i++) { if (_channels[i] == NULL) { - return insertAt(handle, i, new ChannelVorbis(this, ov_file, duration)); + return insertAt(handle, i, new ChannelVorbis(this, ov_file, duration, is_cd_track)); } } @@ -977,16 +977,17 @@ void SoundMixer::ChannelMP3CDMusic::realDestroy() { #endif #ifdef USE_VORBIS -SoundMixer::ChannelVorbis::ChannelVorbis(SoundMixer * mixer, OggVorbis_File * ov_file, double duration) { +SoundMixer::ChannelVorbis::ChannelVorbis(SoundMixer * mixer, OggVorbis_File * ov_file, int duration, bool is_cd_track) { _mixer = mixer; _ov_file = ov_file; if (duration) - _end_pos = ov_time_tell(ov_file) + duration; + _end_pos = ov_pcm_tell(ov_file) + duration; else _end_pos = 0; _eof_flag = false; + _is_cd_track = is_cd_track; _toBeDestroyed = false; } @@ -1005,7 +1006,8 @@ void SoundMixer::ChannelVorbis::mix(int16 * data, uint len) { uint len_left = len * channels * 2; int16 *samples = new int16[len_left / 2]; char *read_pos = (char *) samples; - int volume = _mixer->_musicVolume; + int volume = _is_cd_track ? _mixer->_musicVolume : + _mixer->_volumeTable[1]; // Read the samples while (len_left > 0) { @@ -1021,6 +1023,10 @@ void SoundMixer::ChannelVorbis::mix(int16 * data, uint len) { memset(read_pos, 0, len_left); break; } + else if (result == OV_HOLE) { + // Possibly recoverable, just warn about it + warning("Corrupted data in Vorbis file"); + } else if (result < 0) { debug(1, "Decode error %d in Vorbis file", result); // Don't delete it yet, that causes problems in @@ -1045,6 +1051,9 @@ void SoundMixer::ChannelVorbis::mix(int16 * data, uint len) { } delete [] samples; + + if (_eof_flag && ! _is_cd_track) + realDestroy(); } void SoundMixer::ChannelVorbis::realDestroy() { @@ -1054,7 +1063,7 @@ void SoundMixer::ChannelVorbis::realDestroy() { bool SoundMixer::ChannelVorbis::soundFinished() { return _eof_flag || (_end_pos > 0 && - ov_time_tell(_ov_file) >= _end_pos); + ov_pcm_tell(_ov_file) >= _end_pos); } #endif |