move _volume_table creation into constructor, and discard it in destructor

svn-id: r4764
This commit is contained in:
Max Horn 2002-08-18 21:42:22 +00:00
parent 8e249acb89
commit 8786311655
2 changed files with 16 additions and 4 deletions

View file

@ -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)

View file

@ -24,6 +24,7 @@
#define MIXER_H
#include <stdio.h>
#ifdef COMPRESSED_SOUND_FILE
#include <mad.h>
#endif
@ -146,6 +147,9 @@ public:
Channel *_channels[NUM_CHANNELS];
PlayingSoundHandle *_handles[NUM_CHANNELS];
SoundMixer();
~SoundMixer();
int insert_at(PlayingSoundHandle *handle, int index, Channel * chan);
void append(void *data, uint32 len);
void uninsert(Channel * chan);