Skip to content

Commit

Permalink
Get channel counts in FlexASIOTest.
Browse files Browse the repository at this point in the history
See #7.
  • Loading branch information
dechamps committed Oct 21, 2018
1 parent 6bb72d4 commit 121666d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions FlexASIOTest/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ namespace flexasio_test {
}
}

ASIOError PrintError(ASIOError error) {
std::cout << "-> " << GetASIOErrorString(error) << std::endl;
return error;
}

std::optional<ASIODriverInfo> Init() {
ASIODriverInfo asioDriverInfo = { 0 };
asioDriverInfo.asioVersion = 2;
std::cout << "ASIOInit(asioVersion = " << asioDriverInfo.asioVersion << ")" << std::endl;
const auto initError = ASIOInit(&asioDriverInfo);
std::cout << "-> " << GetASIOErrorString(initError) << std::endl;
const auto initError = PrintError(ASIOInit(&asioDriverInfo));
std::cout << "ASIODriverInfo::asioVersion: " << asioDriverInfo.asioVersion << std::endl;
std::cout << "ASIODriverInfo::driverVersion: " << asioDriverInfo.asioVersion << std::endl;
std::cout << "ASIODriverInfo::name: " << asioDriverInfo.name << std::endl;
Expand All @@ -41,9 +45,23 @@ namespace flexasio_test {
return asioDriverInfo;
}

std::pair<long, long> GetChannels() {
std::cout << "ASIOGetChannels()" << std::endl;
long numInputChannels, numOutputChannels;
const auto error = PrintError(ASIOGetChannels(&numInputChannels, &numOutputChannels));
if (error != ASE_OK) return { 0, 0 };
std::cout << "Channel count: " << numInputChannels << " input, " << numOutputChannels << " output" << std::endl;
return { numInputChannels, numOutputChannels };
}

bool Run() {
if (!Init()) return false;

std::cout << std::endl;

const auto channelCounts = GetChannels();
if (channelCounts.first == 0 && channelCounts.second == 0) return false;

// Note: we don't call ASIOExit() because it gets confused by our driver setup trickery (see InitAndRun()).
// That said, this doesn't really matter because ASIOExit() is basically a no-op in our case, anyway.
return true;
Expand Down

0 comments on commit 121666d

Please sign in to comment.