Chromium Code Reviews| Index: chromecast/base/chromecast_switches.cc |
| diff --git a/chromecast/base/chromecast_switches.cc b/chromecast/base/chromecast_switches.cc |
| index 469768cea65d3114f955b7ea50058dc7ffa7b8e9..0ac57160cb63641ab70fd6f09a641bd02221c4f4 100644 |
| --- a/chromecast/base/chromecast_switches.cc |
| +++ b/chromecast/base/chromecast_switches.cc |
| @@ -4,8 +4,17 @@ |
| #include "chromecast/base/chromecast_switches.h" |
| +#include "base/command_line.h" |
| + |
| namespace switches { |
| +namespace { |
| +// Value indicating whether flag from command line switch is true. |
| +const char kSwitchValueTrue[] = "true"; |
| +// Value indicating whether flag from command line switch is false. |
| +const char kSwitchValueFalse[] = "false"; |
| +} // namespace |
| + |
| // Enable the CMA media pipeline. |
| const char kEnableCmaMediaPipeline[] = "enable-cma-media-pipeline"; |
| @@ -32,6 +41,11 @@ const char kLastLaunchedApp[] = "last-launched-app"; |
| // started. |
| const char kPreviousApp[] = "previous-app"; |
| +// Flag indicating that a resource provider must be set up to provide cast |
| +// receiver with resources. Apps cannot start until provided resources. |
| +// This flag implies --alsa-check-close-timeout=0. |
| +const char kAcceptResourceProvider[] = "accept-resource-provider"; |
| + |
| // Size of the ALSA output buffer in frames. This directly sets the latency of |
| // the output device. Latency can be calculated by multiplying the sample rate |
| // by the output buffer size. |
| @@ -48,7 +62,7 @@ const char kAlsaOutputStartThreshold[] = "alsa-output-start-threshold"; |
| const char kAlsaOutputAvailMin[] = "alsa-output-avail-min"; |
| // Time in ms to wait before closing the PCM handle when no more mixer inputs |
| -// remain. |
| +// remain. Assumed to be 0 if --accept-resource-provider is present. |
| const char kAlsaCheckCloseTimeout[] = "alsa-check-close-timeout"; |
| // Number of channels on the alsa output device that the stream mixer uses. |
| @@ -56,3 +70,29 @@ const char kAlsaCheckCloseTimeout[] = "alsa-check-close-timeout"; |
| const char kAlsaNumOutputChannels[] = "alsa-num-output-channels"; |
| } // namespace switches |
| + |
| +namespace cast { |
| + |
| +bool GetSwitchValueBoolean(const std::string& switch_string, |
| + const bool default_value) { |
| + const base::CommandLine* command_line = |
| + base::CommandLine::ForCurrentProcess(); |
| + bool ret = default_value; |
| + if (command_line->HasSwitch(switch_string)) { |
| + if (command_line->GetSwitchValueASCII(switch_string) |
| + .compare(switches::kSwitchValueTrue) && |
|
kmackay
2016/03/08 17:32:48
I'd really prefer to use == or != rather than comp
jyw
2016/03/08 22:40:51
Done.
|
| + command_line->GetSwitchValueASCII(switch_string) |
| + .compare(switches::kSwitchValueFalse) && |
| + command_line->GetSwitchValueASCII(switch_string).compare("")) { |
| + LOG(WARNING) << "Invalid switch value " << switch_string << "=" |
| + << command_line->GetSwitchValueASCII(switch_string) |
| + << "; assuming default value of " << default_value; |
| + return default_value; |
| + } |
| + ret = command_line->GetSwitchValueASCII(switch_string) |
| + .compare(switches::kSwitchValueFalse); |
| + } |
| + return ret; |
| +} |
| + |
| +} // namespace cast |