diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2017-09-18 06:00:05 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2017-11-21 05:01:14 -0500 |
commit | aced667f48c29a160aa4e5c0a8df037092b28189 (patch) | |
tree | 66e48e4a27daaf36f01d7ff1ed6876a7de38b0c0 /apps/recorder | |
parent | 5c9688961ef9166cec5225db50d5f73691d8292d (diff) | |
download | rockbox-aced667f48c29a160aa4e5c0a8df037092b28189.tar.gz rockbox-aced667f48c29a160aa4e5c0a8df037092b28189.zip |
Undo hacks to meant to get around string formatting limitations
The new vuprintf makes unnecessary workarounds due to formatting
limitations. I checked grep output for whatever appeared to fit
but it's possible I missed some instances because they weren't
so obvious.
Also, this means sound settings can dynamically work with any
number of decimals rather than the current assumption of one or
two. Add an ipow() function to help and take advantage of dynamic
field width and precision. Consolidate string formatting of sound
settings.
Change-Id: I46caf534859dfd1916cd440cd25e5206b192fcd8
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/recording.c | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 4816b3bad4..7357b469f4 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -548,39 +548,9 @@ static void auto_gain_control(int *peak_l, int *peak_r, int *balance) | |||
548 | } | 548 | } |
549 | #endif /* HAVE_AGC */ | 549 | #endif /* HAVE_AGC */ |
550 | 550 | ||
551 | static const char* const fmtstr[] = | ||
552 | { | ||
553 | "%c%d %s", /* no decimals */ | ||
554 | "%c%d.%d %s ", /* 1 decimal */ | ||
555 | "%c%d.%02d %s " /* 2 decimals */ | ||
556 | }; | ||
557 | |||
558 | static const char factor[] = {1, 10, 100}; | ||
559 | |||
560 | static char *fmt_gain(int snd, int val, char *str, int len) | 551 | static char *fmt_gain(int snd, int val, char *str, int len) |
561 | { | 552 | { |
562 | int i, d, numdec; | 553 | format_sound_value(str, len, snd, val); |
563 | const char *unit; | ||
564 | char sign = ' '; | ||
565 | |||
566 | val = sound_val2phys(snd, val); | ||
567 | if(val < 0) | ||
568 | { | ||
569 | sign = '-'; | ||
570 | val = -val; | ||
571 | } | ||
572 | numdec = sound_numdecimals(snd); | ||
573 | unit = sound_unit(snd); | ||
574 | |||
575 | if(numdec) | ||
576 | { | ||
577 | i = val / factor[numdec]; | ||
578 | d = val % factor[numdec]; | ||
579 | snprintf(str, len, fmtstr[numdec], sign, i, d, unit); | ||
580 | } | ||
581 | else | ||
582 | snprintf(str, len, fmtstr[numdec], sign, val, unit); | ||
583 | |||
584 | return str; | 554 | return str; |
585 | } | 555 | } |
586 | 556 | ||