Skip to content

Commit

Permalink
BASE: Implement a command to list all available audio devices on the …
Browse files Browse the repository at this point in the history
…shell.
  • Loading branch information
Johannes Schickel committed Nov 23, 2011
1 parent 658fe0a commit debd94f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions README
Expand Up @@ -956,6 +956,7 @@ arguments -- see the next section.
--themepath=PATH Path to where GUI themes are stored
--list-themes Display list of all usable GUI themes
-e, --music-driver=MODE Select music driver (see also section 7.0)
--list-audio-devices List all available audio devices
-q, --language=LANG Select game's language (see also section 5.2)
-m, --music-volume=NUM Set the music volume, 0-255 (default: 192)
-s, --sfx-volume=NUM Set the sfx volume, 0-255 (default: 192)
Expand Down
24 changes: 24 additions & 0 deletions base/commandLine.cpp
Expand Up @@ -39,6 +39,8 @@

#include "gui/ThemeEngine.h"

#include "audio/musicplugin.h"

#define DETECTOR_TESTING_HACK
#define UPGRADE_ALL_TARGETS_HACK

Expand Down Expand Up @@ -81,6 +83,7 @@ static const char HELP_STRING[] =
" --themepath=PATH Path to where GUI themes are stored\n"
" --list-themes Display list of all usable GUI themes\n"
" -e, --music-driver=MODE Select music driver (see README for details)\n"
" --list-audio-devices List all available audio devices\n"
" -q, --language=LANG Select language (en,de,fr,it,pt,es,jp,zh,kr,se,gb,\n"
" hb,ru,cz)\n"
" -m, --music-volume=NUM Set the music volume, 0-255 (default: 192)\n"
Expand Down Expand Up @@ -381,6 +384,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_OPTION('e', "music-driver")
END_OPTION

DO_LONG_COMMAND("list-audio-devices")
END_OPTION

DO_LONG_OPTION_INT("output-rate")
END_OPTION

Expand Down Expand Up @@ -689,6 +695,21 @@ static void listThemes() {
printf("%-14s %s\n", i->id.c_str(), i->name.c_str());
}

/** Lists all output devices */
static void listAudioDevices() {
MusicPlugin::List pluginList = MusicMan.getPlugins();

printf("ID Description\n");
printf("------------------------------ ------------------------------------------------\n");

for (MusicPlugin::List::const_iterator i = pluginList.begin(), iend = pluginList.end(); i != iend; ++i) {
MusicDevices deviceList = (**i)->getDevices();
for (MusicDevices::iterator j = deviceList.begin(), jend = deviceList.end(); j != jend; ++j) {
printf("%-30s %s\n", Common::String::format("\"%s\"", j->getCompleteId().c_str()).c_str(), j->getCompleteName().c_str());
}
}
}


#ifdef DETECTOR_TESTING_HACK
static void runDetectorTest() {
Expand Down Expand Up @@ -906,6 +927,9 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
} else if (command == "list-themes") {
listThemes();
return true;
} else if (command == "list-audio-devices") {
listAudioDevices();
return true;
} else if (command == "version") {
printf("%s\n", gScummVMFullVersion);
printf("Features compiled in: %s\n", gScummVMFeatures);
Expand Down

0 comments on commit debd94f

Please sign in to comment.