some cleanup in audio class, moving implementation from header file

This commit is contained in:
Stephen Birarda 2013-01-29 12:47:04 -08:00
parent bcecd8663f
commit 3188eb7c33
2 changed files with 26 additions and 21 deletions

View file

@ -3,7 +3,7 @@
// interface
//
// Created by Stephen Birarda on 1/22/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
// Copyright (c) 2013 High Fidelity, Inc.. All rights reserved.
//
#include <iostream>
@ -17,6 +17,27 @@ PaStream *Audio::stream;
Audio::AudioData *Audio::data;
Audio::AudioSource::~AudioSource()
{
delete[] audioData;
}
Audio::AudioData::AudioData() {
for(int s = 0; s < NUM_AUDIO_SOURCES; s++) {
sources[s] = AudioSource();
}
samplesToQueue = new int16_t[BUFFER_LENGTH_BYTES / sizeof(int16_t)];
}
Audio::AudioData::~AudioData() {
for (int s = 0; s < NUM_AUDIO_SOURCES; s++) {
sources[s].AudioSource::~AudioSource();
}
delete[] samplesToQueue;
}
/**
* Audio callback used by portaudio.
* Communicates with Audio via a shared pointer to Audio::data.

View file

@ -35,13 +35,8 @@ private:
int lengthInSamples;
int samplePointer;
AudioSource() {
samplePointer = 0;
};
~AudioSource() {
delete[] audioData;
}
AudioSource() { samplePointer = 0; }
~AudioSource();
};
static void readFile(const char *filename, struct AudioSource *source);
@ -53,19 +48,8 @@ private:
int16_t *samplesToQueue;
AudioData() {
sources[0] = AudioSource();
sources[1] = AudioSource();
samplesToQueue = new int16_t[BUFFER_LENGTH_BYTES / sizeof(int16_t)];
}
~AudioData() {
// delete sources[0];
// delete sources[1];
// delete sources[2];
delete[] samplesToQueue;
}
AudioData();
~AudioData();
} *data;
// protects constructor so that public init method is used