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

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: remove ret variable 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..baaf4475b2a3ada4e6efd6bcf14ad9a70d95c5d9 100644
--- a/chromecast/base/chromecast_switches.cc
+++ b/chromecast/base/chromecast_switches.cc
@@ -4,8 +4,16 @@
#include "chromecast/base/chromecast_switches.h"
+#include "base/command_line.h"
+
namespace switches {
+// 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";
+
// Enable the CMA media pipeline.
const char kEnableCmaMediaPipeline[] = "enable-cma-media-pipeline";
@@ -32,6 +40,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 +61,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 +69,28 @@ const char kAlsaCheckCloseTimeout[] = "alsa-check-close-timeout";
const char kAlsaNumOutputChannels[] = "alsa-num-output-channels";
} // namespace switches
+
+namespace chromecast {
+
+bool GetSwitchValueBoolean(const std::string& switch_string,
+ const bool default_value) {
+ const base::CommandLine* command_line =
+ base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switch_string)) {
+ if (command_line->GetSwitchValueASCII(switch_string) !=
+ switches::kSwitchValueTrue &&
+ command_line->GetSwitchValueASCII(switch_string) !=
+ switches::kSwitchValueFalse &&
+ command_line->GetSwitchValueASCII(switch_string) != "") {
byungchul 2016/03/09 18:16:30 Why didn't you use a local var to cache command_li
+ LOG(WARNING) << "Invalid switch value " << switch_string << "="
+ << command_line->GetSwitchValueASCII(switch_string)
+ << "; assuming default value of " << default_value;
+ return default_value;
+ }
+ return command_line->GetSwitchValueASCII(switch_string) !=
+ switches::kSwitchValueFalse;
+ }
+ return default_value;
+}
+
+} // namespace chromecast

Powered by Google App Engine
This is Rietveld 408576698