summaryrefslogtreecommitdiffstats
path: root/apps/recorder
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-09-18 06:00:05 -0400
committerMichael Sevakis <jethead71@rockbox.org>2017-11-21 05:01:14 -0500
commitaced667f48c29a160aa4e5c0a8df037092b28189 (patch)
tree66e48e4a27daaf36f01d7ff1ed6876a7de38b0c0 /apps/recorder
parent5c9688961ef9166cec5225db50d5f73691d8292d (diff)
downloadrockbox-aced667f48c29a160aa4e5c0a8df037092b28189.tar.gz
rockbox-aced667f48c29a160aa4e5c0a8df037092b28189.tar.bz2
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.c32
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)
}
#endif /* HAVE_AGC */
-static const char* const fmtstr[] =
-{
- "%c%d %s", /* no decimals */
- "%c%d.%d %s ", /* 1 decimal */
- "%c%d.%02d %s " /* 2 decimals */
-};
-
-static const char factor[] = {1, 10, 100};
-
static char *fmt_gain(int snd, int val, char *str, int len)
{
- int i, d, numdec;
- const char *unit;
- char sign = ' ';
-
- val = sound_val2phys(snd, val);
- if(val < 0)
- {
- sign = '-';
- val = -val;
- }
- numdec = sound_numdecimals(snd);
- unit = sound_unit(snd);
-
- if(numdec)
- {
- i = val / factor[numdec];
- d = val % factor[numdec];
- snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
- }
- else
- snprintf(str, len, fmtstr[numdec], sign, val, unit);
-
+ format_sound_value(str, len, snd, val);
return str;
}