summaryrefslogtreecommitdiffstats
path: root/audio/format.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-25 18:24:53 +0200
committerwm4 <wm4@nowhere>2013-08-26 10:09:44 +0200
commitddc973344685b8fee1d7b00e23ba93692d56d7c9 (patch)
tree44bee04409f94675f2455285555ad1a848899d3c /audio/format.c
parent53b5227270ff21c0f4c8aeb8c33a9f4dcbe20600 (diff)
downloadmpv-ddc973344685b8fee1d7b00e23ba93692d56d7c9.tar.bz2
mpv-ddc973344685b8fee1d7b00e23ba93692d56d7c9.tar.xz
audio: don't allow setting unknown formats from command line
af_str2fmt_short(), which is used by the command line option parser, allowed passing a hex number. The user could set arbitrary integers as internal audio formats, even formats which don't exist or make no sense. This is not very useful, so get rid of it.
Diffstat (limited to 'audio/format.c')
-rw-r--r--audio/format.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/audio/format.c b/audio/format.c
index d98de9e5fd..aa6099022f 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -47,11 +47,7 @@ int af_fmt2bits(int format)
char* af_fmt2str(int format, char* str, int size)
{
const char *name = af_fmt2str_short(format);
- if (name) {
- snprintf(str, size, "%s", name);
- } else {
- snprintf(str, size, "%#x", format);
- }
+ snprintf(str, size, "%s", name);
return str;
}
@@ -105,11 +101,6 @@ const char *af_fmt2str_short(int format)
return "??";
}
-static bool af_fmt_valid(int format)
-{
- return (format & AF_FORMAT_MASK) == format;
-}
-
int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate)
{
int bps = (af_fmt2bits(format) / 8);
@@ -122,13 +113,6 @@ int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int sampler
int af_str2fmt_short(bstr str)
{
- if (bstr_startswith0(str, "0x")) {
- bstr rest;
- int fmt = bstrtoll(str, &rest, 16);
- if (rest.len == 0 && af_fmt_valid(fmt))
- return fmt;
- }
-
for (int i = 0; af_fmtstr_table[i].name; i++)
if (!bstrcasecmp0(str, af_fmtstr_table[i].name))
return af_fmtstr_table[i].format;