mirror of
https://github.com/Genymobile/scrcpy
synced 2025-08-30 22:05:12 +00:00
Do not parse --max-fps float in the client
Many parsing and formatting C functions like strtof() and asprintf() are locale-dependent. Forcing a C locale just for the conversions in a way that works on all platforms is a mess. In practice, this is not a problem, scrcpy always uses the C locale, because it never calls: setlocale(LC_ALL, ""); But the max-fps option should not depend on the locale configuration anyway. Since the value is parsed by the client in Java anyway, just forward the string value as is.
This commit is contained in:
@@ -1447,26 +1447,6 @@ parse_integers_arg(const char *s, const char sep, size_t max_items, long *out,
|
||||
return count;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_float_arg(const char *s, float *out, float min, float max,
|
||||
const char *name) {
|
||||
float value;
|
||||
bool ok = sc_str_parse_float(s, &value);
|
||||
if (!ok) {
|
||||
LOGE("Could not parse %s: %s", name, s);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value < min || value > max) {
|
||||
LOGE("Could not parse %s: value (%f) out-of-range (%f; %f)",
|
||||
name, value, min, max);
|
||||
return false;
|
||||
}
|
||||
|
||||
*out = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_bit_rate(const char *s, uint32_t *bit_rate) {
|
||||
long value;
|
||||
@@ -1493,18 +1473,6 @@ parse_max_size(const char *s, uint16_t *max_size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_max_fps(const char *s, float *max_fps) {
|
||||
float value;
|
||||
bool ok = parse_float_arg(s, &value, 0, (float) (1 << 16), "max fps");
|
||||
if (!ok) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*max_fps = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_buffering_time(const char *s, sc_tick *tick) {
|
||||
long value;
|
||||
@@ -2252,9 +2220,7 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||
"--keyboard=uhid instead.");
|
||||
return false;
|
||||
case OPT_MAX_FPS:
|
||||
if (!parse_max_fps(optarg, &opts->max_fps)) {
|
||||
return false;
|
||||
}
|
||||
opts->max_fps = optarg;
|
||||
break;
|
||||
case 'm':
|
||||
if (!parse_max_size(optarg, &opts->max_size)) {
|
||||
|
Reference in New Issue
Block a user