|
From: Tapio V. <aa...@us...> - 2010-09-16 10:12:48
|
Module: performous
Branch: master
Commit: 7b06c9e65743069503928505496771a4ff940a42
Author: Tapio Vierros <tap...@gm...>
Date: Thu Sep 16 13:07:01 2010 +0300
Print audio devices to console only when in verbose or --audiohelp.
---
game/libda/portaudio.hpp | 20 ++++++++------------
game/main.cc | 8 ++++++++
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/game/libda/portaudio.hpp b/game/libda/portaudio.hpp
index 16c7b83..a298173 100644
--- a/game/libda/portaudio.hpp
+++ b/game/libda/portaudio.hpp
@@ -55,24 +55,20 @@ namespace portaudio {
else devices.push_back(DeviceInfo(info->name, info->maxInputChannels, info->maxOutputChannels));
}
}
- /// Print the devices
- void dump() {
- std::cout << "PortAudio devices:" << std::endl;
+ /// Get a printable dump of the devices
+ std::string dump() {
+ std::ostringstream oss;
+ oss << "PortAudio devices:" << std::endl;
for (unsigned i = 0; i < devices.size(); ++i)
- std::cout << " " << i << " " << devices[i].name << " (" << devices[i].in << " in, " << devices[i].out << " out)" << std::endl;
- std::cout << std::endl;
+ oss << " " << i << " " << devices[i].name << " (" << devices[i].in << " in, " << devices[i].out << " out)" << std::endl;
+ oss << std::endl;
+ return oss.str();
}
DeviceInfos devices;
};
struct Init {
- Init()
- {
- PORTAUDIO_CHECKED(Pa_Initialize, ());
- // Print the devices
- AudioDevices ads;
- ads.dump();
- }
+ Init() { PORTAUDIO_CHECKED(Pa_Initialize, ()); }
~Init() { std::cout << "Pa_Terminate..."; std::cout.flush(); Pa_Terminate(); std::cout << "ok" << std::endl; }
};
diff --git a/game/main.cc b/game/main.cc
index 62bd620..9ac9117 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -115,6 +115,10 @@ void mainLoop(std::string const& songlist) {
ScreenManager sm(window);
sm.loading(_("Audio..."), 0.1);
Audio audio;
+ { // Print the devices
+ portaudio::AudioDevices ads;
+ std::clog << "audio/info:\n" << ads.dump();
+ }
try {
sm.loading(_("Launching background loaders..."), 0.4);
Backgrounds backgrounds;
@@ -334,6 +338,10 @@ int main(int argc, char** argv) try {
}
if (vm.count("audiohelp")) {
Audio audio;
+ // Print the devices
+ portaudio::AudioDevices ads;
+ std::cout << ads.dump();
+ // Some examples
std::cout << "Example --audio parameters" << std::endl;
std::cout << " --audio \"out=2\" # Pick first working two-channel playback device" << std::endl;
std::cout << " --audio \"dev=1 out=2\" # Pick device id 1 and assign stereo playback" << std::endl;
|