Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8587)

Unified Diff: chromecast/base/chromecast_switches.cc

Issue 1767603003: [chromecast] Add cast_shell --accept-resource-provider switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: use kSwitchValue{True,False} and fix DONOTSUBMIT comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698