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 // interface
// //
// Created by Stephen Birarda on 1/22/13. // 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> #include <iostream>
@ -17,6 +17,27 @@ PaStream *Audio::stream;
Audio::AudioData *Audio::data; 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. * Audio callback used by portaudio.
* Communicates with Audio via a shared pointer to Audio::data. * Communicates with Audio via a shared pointer to Audio::data.

View file

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