From d36ff64b29031f402184e4946969810e7d9db0e0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 24 Jan 2018 00:02:13 +0100 Subject: audio: fix annyoing af_get_best_sample_formats() definition The af_get_best_sample_formats() function had an argument of int[AF_FORMAT_COUNT], which is slightly incorrect, because it's 0 terminated and should in theory have AF_FORMAT_COUNT+1 entries. It won't actually write this many formats (since some formats are fundamentally incompatible), but it still feels annoying and incorrect. So fix it, and require that callers pass an AF_FORMAT_COUNT+1 array. Note that the array size has no meaning in C function arguments (just another issue with C static arrays being weird and stupid), so get rid of it completely. Not changing the af_lavcac3enc use, since that is rewritten in another branch anyway. --- audio/format.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'audio/format.c') diff --git a/audio/format.c b/audio/format.c index 3df11ba301..b6d6761b65 100644 --- a/audio/format.c +++ b/audio/format.c @@ -209,10 +209,11 @@ static int cmp_entry(const void *a, const void *b) // and the list is terminated with 0 (AF_FORMAT_UNKNOWN). // Keep in mind that this also returns formats with flipped interleaving // (e.g. for s16, it returns [s16, s16p, ...]). -void af_get_best_sample_formats(int src_format, int out_formats[AF_FORMAT_COUNT]) +// out_formats must be an int[AF_FORMAT_COUNT + 1] array. +void af_get_best_sample_formats(int src_format, int *out_formats) { int num = 0; - struct entry e[AF_FORMAT_COUNT]; + struct entry e[AF_FORMAT_COUNT + 1]; for (int fmt = 1; fmt < AF_FORMAT_COUNT; fmt++) { int score = af_format_conversion_score(fmt, src_format); if (score > INT_MIN) -- cgit v1.2.3