diff options
author | Nicolas Bacca | 2002-05-01 22:22:22 +0000 |
---|---|---|
committer | Nicolas Bacca | 2002-05-01 22:22:22 +0000 |
commit | 3849080ed771c0b9849d274775513b7c3fb91f6f (patch) | |
tree | 439826944392791b4e10b2164d04e5d36d71eef1 /sound/mixer.cpp | |
parent | c9915a95198d3c1d36a0eb0360352475fac4ebc9 (diff) | |
download | scummvm-rg350-3849080ed771c0b9849d274775513b7c3fb91f6f.tar.gz scummvm-rg350-3849080ed771c0b9849d274775513b7c3fb91f6f.tar.bz2 scummvm-rg350-3849080ed771c0b9849d274775513b7c3fb91f6f.zip |
Pause and start of volume support
svn-id: r4165
Diffstat (limited to 'sound/mixer.cpp')
-rw-r--r-- | sound/mixer.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index c8502685da..5b0be93ee4 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -71,6 +71,10 @@ int SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, mad_tim #endif void SoundMixer::mix(int16 *buf, uint len) { + + if (_paused) + return; + if (_premix_proc) { _premix_proc(_premix_param, buf, len); } else { @@ -117,6 +121,10 @@ void SoundMixer::stop(int index) { _channels[index]->destroy(); } +void SoundMixer::pause(bool paused) { + _paused = paused; +} + bool SoundMixer::has_active_channel() { for(int i=0; i!=NUM_CHANNELS; i++) if (_channels[i]) @@ -282,6 +290,7 @@ static inline int scale_sample(mad_fixed_t sample) void SoundMixer::Channel_MP3::mix(int16 *data, uint len) { mad_fixed_t const *ch; + const int16 *vol_tab = _mixer->_volume_table; if (_to_be_destroyed) { real_destroy(); @@ -294,7 +303,7 @@ void SoundMixer::Channel_MP3::mix(int16 *data, uint len) { if (_silence_cut > 0) { _silence_cut--; } else { - *data++ += scale_sample(*ch++); + *data++ += (int16)((float)scale_sample(*ch++) * ((float)vol_tab[1] / (float)128)); len--; } _pos_in_frame++; @@ -359,6 +368,7 @@ SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* fi void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) { mad_fixed_t const *ch; mad_timer_t frame_duration; + const int16 *vol_tab = _mixer->_volume_table; if (_to_be_destroyed) { real_destroy(); @@ -410,7 +420,7 @@ void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) { // Get samples, play samples ... ch = _synth.pcm.samples[0] + _pos_in_frame; while ((_pos_in_frame < _synth.pcm.length) && (len > 0)) { - *data++ += scale_sample(*ch++); + *data++ += (int16)((float)scale_sample(*ch++) * ((float)vol_tab[1] / (float)128)); len--; _pos_in_frame++; } |