aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2015-03-26 21:43:45 -0400
committerDave Reisner <dreisner@archlinux.org>2015-03-26 21:43:45 -0400
commit78ef2f963dc9b0b0c5466ed9d84ea6f29d85db88 (patch)
tree03c8e62a79b2f8ca7da1fa0f90b5b34ce0b4a913
parentbefcf12820411ace8d9531dc829abd20c957fe60 (diff)
downloadmirror-ponymix-78ef2f963dc9b0b0c5466ed9d84ea6f29d85db88.tar.gz
mirror-ponymix-78ef2f963dc9b0b0c5466ed9d84ea6f29d85db88.tar.bz2
mirror-ponymix-78ef2f963dc9b0b0c5466ed9d84ea6f29d85db88.zip
Determine default opt_device after arg parsing
Fixes GHI#30.
-rw-r--r--ponymix.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/ponymix.cc b/ponymix.cc
index a07059d..5f1e98c 100644
--- a/ponymix.cc
+++ b/ponymix.cc
@@ -654,13 +654,17 @@ int main(int argc, char* argv[]) {
ServerInfo defaults = ponymix.GetDefaults();
opt_action = "defaults";
opt_devtype = DEVTYPE_SINK;
- opt_device = defaults.sink.c_str();
opt_maxvolume = 100;
if (!parse_options(argc, argv)) return 1;
argc -= optind;
argv += optind;
+ // Do this after parsing such that we respect any changes to opt_devtype and
+ // explicit opt_device
+ if (opt_device == nullptr)
+ opt_device = defaults.GetDefault(opt_devtype).c_str();
+
try {
#ifdef HAVE_NOTIFY
if (opt_notify) {