aboutsummaryrefslogtreecommitdiff
path: root/sound/mixer.cpp
diff options
context:
space:
mode:
authorMax Horn2002-08-18 21:42:22 +0000
committerMax Horn2002-08-18 21:42:22 +0000
commit8786311655e18c8bd16dbbbc3360de031fc62966 (patch)
treec53623b8b5abc4c59567b9354cf1aaad735479d1 /sound/mixer.cpp
parent8e249acb89c5952f98441aac2f25404d49c1de03 (diff)
downloadscummvm-rg350-8786311655e18c8bd16dbbbc3360de031fc62966.tar.gz
scummvm-rg350-8786311655e18c8bd16dbbbc3360de031fc62966.tar.bz2
scummvm-rg350-8786311655e18c8bd16dbbbc3360de031fc62966.zip
move _volume_table creation into constructor, and discard it in destructor
svn-id: r4764
Diffstat (limited to 'sound/mixer.cpp')
-rw-r--r--sound/mixer.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index c49d09b908..f1cab83ff7 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -23,6 +23,16 @@
#include "stdafx.h"
#include "scumm.h"
+SoundMixer::SoundMixer()
+{
+ _volume_table = (int16 *)calloc(256 * sizeof(int16), 1);
+}
+
+SoundMixer::~SoundMixer()
+{
+ free(_volume_table);
+}
+
void SoundMixer::uninsert(Channel * chan)
{
@@ -146,8 +156,6 @@ void SoundMixer::on_generate_samples(void *s, byte *samples, int len)
bool SoundMixer::bind_to_system(OSystem *syst)
{
- _volume_table = (int16 *)calloc(256 * sizeof(int16), 1);
-
uint rate = (uint) syst->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
_output_rate = rate;
@@ -211,10 +219,10 @@ void SoundMixer::set_volume(int volume)
// The volume table takes 8 bit unsigned data as index and returns 16 bit signed
for (i = 0; i < 128; i++)
- _volume_table[i] = i * volume ;
+ _volume_table[i] = i * volume;
for (i = -128; i < 0; i++)
- _volume_table[i+256] = i * volume ;
+ _volume_table[i+256] = i * volume;
}
void SoundMixer::set_music_volume(int volume)