Index: chromecast/base/chromecast_switches.cc |
diff --git a/chromecast/base/chromecast_switches.cc b/chromecast/base/chromecast_switches.cc |
index 426de0c7208b1970dc978d62a6f4e5e374b37ef5..3cd4cf6ba102159ff2f679ae6c3b86ca2f6d05ca 100644 |
--- a/chromecast/base/chromecast_switches.cc |
+++ b/chromecast/base/chromecast_switches.cc |
@@ -5,6 +5,7 @@ |
#include "chromecast/base/chromecast_switches.h" |
#include "base/command_line.h" |
+#include "base/strings/string_number_conversions.h" |
namespace switches { |
@@ -70,6 +71,9 @@ const char kAlsaEnableUpsampling[] = "alsa-enable-upsampling"; |
// Optional flag to set a fixed sample rate for the alsa device. |
const char kAlsaFixedOutputSampleRate[] = "alsa-fixed-output-sample-rate"; |
+// Calibrated max output volume dBa for voice content at 1 meter, if known. |
+const char kMaxOutputVolumeDba1m[] = "max-output-volume-dba1m"; |
+ |
// Some platforms typically have very little 'free' memory, but plenty is |
// available in buffers+cached. For such platforms, configure this amount |
// as the portion of buffers+cached memory that should be treated as |
@@ -111,4 +115,33 @@ bool GetSwitchValueBoolean(const std::string& switch_string, |
return default_value; |
} |
+int GetSwitchValueInt(const std::string& switch_name, const int default_value) { |
+ const base::CommandLine* command_line = |
+ base::CommandLine::ForCurrentProcess(); |
+ if (!command_line->HasSwitch(switch_name)) { |
+ return default_value; |
+ } |
+ |
+ int arg_value; |
+ if (!base::StringToInt(command_line->GetSwitchValueASCII(switch_name), |
+ &arg_value)) { |
+ LOG(DFATAL) << "--" << switch_name << " only accepts integers as arguments"; |
+ return default_value; |
+ } |
+ return arg_value; |
+} |
+ |
+int GetSwitchValueNonNegativeInt(const std::string& switch_name, |
+ const int default_value) { |
+ DCHECK_GE(default_value, 0) |
+ << "--" << switch_name << " must have a non-negative default value"; |
+ |
+ int value = GetSwitchValueInt(switch_name, default_value); |
+ if (value < 0) { |
+ LOG(DFATAL) << "--" << switch_name << " must have a non-negative value"; |
+ return default_value; |
+ } |
+ return value; |
+} |
+ |
} // namespace chromecast |