Skip to content

Commit

Permalink
updated unit test for AudioIO
Browse files Browse the repository at this point in the history
  • Loading branch information
LancePutnam committed Aug 14, 2015
1 parent 6d56fcc commit dc5ec79
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
5 changes: 4 additions & 1 deletion allocore/unitTests/unitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ int main (int argc, char * const argv[]) {

RUNTEST(GraphicsMesh);

#ifndef ALLOCORE_TESTS_NO_AUDIO
RUNTEST(IOAudioIO);
#endif

#ifndef ALLOCORE_TESTS_NO_GUI
// This test should always be run last since it calls exit()
// This test will not run on headless machines.
Expand All @@ -47,7 +51,6 @@ int main (int argc, char * const argv[]) {

// utAsset();
// utGraphicsDraw();
// utIOAudioIO();

return 0;
}
Expand Down
26 changes: 23 additions & 3 deletions allocore/unitTests/utIOAudioIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,30 @@ void audioCB(AudioIOData& io){

int utIOAudioIO(){

AudioDevice::printAll();
AudioIO audioIO(256, 44100, audioCB, 0, 2, 1);
//AudioDevice::printAll();
AudioIO audioIO(256, 44100, audioCB, 0, 1, 1);

// Make sure parameters match those passed to constructor
audioIO.open();
assert(audioIO.framesPerBuffer() == 256);
assert(audioIO.fps() == 44100);
assert(audioIO.channelsOut() == 1);
assert(audioIO.channelsIn() == 1);
audioIO.close();

// Test virtual channels
int maxChansOut = AudioDevice::defaultOutput().channelsOutMax();
int maxChansIn = AudioDevice::defaultInput().channelsInMax();
audioIO.channelsOut(maxChansOut + 1);
audioIO.channelsIn (maxChansIn + 1);
audioIO.open();
assert(audioIO.channelsOutDevice() == maxChansOut); // opened all hardware channels?
assert(audioIO.channelsOut() == (maxChansOut+1)); // got our extra virtual channel?
assert(audioIO.channelsInDevice() == maxChansIn); // opened all hardware channels?
assert(audioIO.channelsIn() == (maxChansIn+1)); // got our extra virtual channel?

audioIO.start();

printf("\nPress 'enter' to quit...\n"); getchar();
//printf("\nPress 'enter' to quit...\n"); getchar();
return 0;
}

0 comments on commit dc5ec79

Please sign in to comment.