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

Side by Side Diff: chromecast/base/chromecast_switches.cc

Issue 2738873002: [Chromecast] Implement new volume control API (Closed)
Patch Set: no need for ALSA volume control Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/base/chromecast_switches.h" 5 #include "chromecast/base/chromecast_switches.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
8 9
9 namespace switches { 10 namespace switches {
10 11
11 // Value indicating whether flag from command line switch is true. 12 // Value indicating whether flag from command line switch is true.
12 const char kSwitchValueTrue[] = "true"; 13 const char kSwitchValueTrue[] = "true";
13 14
14 // Value indicating whether flag from command line switch is false. 15 // Value indicating whether flag from command line switch is false.
15 const char kSwitchValueFalse[] = "false"; 16 const char kSwitchValueFalse[] = "false";
16 17
17 // Server url to upload crash data to. 18 // Server url to upload crash data to.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // remain. Assumed to be 0 if --accept-resource-provider is present. 64 // remain. Assumed to be 0 if --accept-resource-provider is present.
64 const char kAlsaCheckCloseTimeout[] = "alsa-check-close-timeout"; 65 const char kAlsaCheckCloseTimeout[] = "alsa-check-close-timeout";
65 66
66 // Flag that enables resampling audio with sample rate below 32kHz up to 48kHz. 67 // Flag that enables resampling audio with sample rate below 32kHz up to 48kHz.
67 // Should be set to true for internal audio products. 68 // Should be set to true for internal audio products.
68 const char kAlsaEnableUpsampling[] = "alsa-enable-upsampling"; 69 const char kAlsaEnableUpsampling[] = "alsa-enable-upsampling";
69 70
70 // Optional flag to set a fixed sample rate for the alsa device. 71 // Optional flag to set a fixed sample rate for the alsa device.
71 const char kAlsaFixedOutputSampleRate[] = "alsa-fixed-output-sample-rate"; 72 const char kAlsaFixedOutputSampleRate[] = "alsa-fixed-output-sample-rate";
72 73
74 // Calibrated max output volume dBa for voice content at 1 meter, if known.
75 const char kMaxOutputVolumeDba1m[] = "max-output-volume-dba1m";
76
73 // Some platforms typically have very little 'free' memory, but plenty is 77 // Some platforms typically have very little 'free' memory, but plenty is
74 // available in buffers+cached. For such platforms, configure this amount 78 // available in buffers+cached. For such platforms, configure this amount
75 // as the portion of buffers+cached memory that should be treated as 79 // as the portion of buffers+cached memory that should be treated as
76 // unavailable. If this switch is not used, a simple pressure heuristic based 80 // unavailable. If this switch is not used, a simple pressure heuristic based
77 // purely on free memory will be used. 81 // purely on free memory will be used.
78 const char kMemPressureSystemReservedKb[] = "mem-pressure-system-reserved-kb"; 82 const char kMemPressureSystemReservedKb[] = "mem-pressure-system-reserved-kb";
79 83
80 // Used to pass initial screen resolution to GPU process. This allows us to set 84 // Used to pass initial screen resolution to GPU process. This allows us to set
81 // screen size correctly (so no need to resize when first window is created). 85 // screen size correctly (so no need to resize when first window is created).
82 const char kCastInitialScreenWidth[] = "cast-initial-screen-width"; 86 const char kCastInitialScreenWidth[] = "cast-initial-screen-width";
(...skipping 21 matching lines...) Expand all
104 << command_line->GetSwitchValueASCII(switch_string) 108 << command_line->GetSwitchValueASCII(switch_string)
105 << "; assuming default value of " << default_value; 109 << "; assuming default value of " << default_value;
106 return default_value; 110 return default_value;
107 } 111 }
108 return command_line->GetSwitchValueASCII(switch_string) != 112 return command_line->GetSwitchValueASCII(switch_string) !=
109 switches::kSwitchValueFalse; 113 switches::kSwitchValueFalse;
110 } 114 }
111 return default_value; 115 return default_value;
112 } 116 }
113 117
118 int GetSwitchValueInt(const std::string& switch_name, const int default_value) {
119 const base::CommandLine* command_line =
120 base::CommandLine::ForCurrentProcess();
121 if (!command_line->HasSwitch(switch_name)) {
122 return default_value;
123 }
124
125 int arg_value;
126 if (!base::StringToInt(command_line->GetSwitchValueASCII(switch_name),
127 &arg_value)) {
128 LOG(DFATAL) << "--" << switch_name << " only accepts integers as arguments";
129 return default_value;
130 }
131 return arg_value;
132 }
133
134 int GetSwitchValueNonNegativeInt(const std::string& switch_name,
135 const int default_value) {
136 DCHECK_GE(default_value, 0)
137 << "--" << switch_name << " must have a non-negative default value";
138
139 int value = GetSwitchValueInt(switch_name, default_value);
140 if (value < 0) {
141 LOG(DFATAL) << "--" << switch_name << " must have a non-negative value";
142 return default_value;
143 }
144 return value;
145 }
146
114 } // namespace chromecast 147 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698