diff options
author | wm4 <wm4@nowhere> | 2018-01-24 00:02:13 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-01-25 20:18:32 -0800 |
commit | d36ff64b29031f402184e4946969810e7d9db0e0 (patch) | |
tree | e57f501ce20b384d2183af98f3220ddaa4e7d602 /audio/out | |
parent | 3dd5621cecdd41c86117d70f93a24aede5e50bbc (diff) | |
download | mpv-d36ff64b29031f402184e4946969810e7d9db0e0.tar.bz2 mpv-d36ff64b29031f402184e4946969810e7d9db0e0.tar.xz |
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.
Diffstat (limited to 'audio/out')
-rw-r--r-- | audio/out/ao_alsa.c | 2 | ||||
-rw-r--r-- | audio/out/ao_lavc.c | 2 | ||||
-rw-r--r-- | audio/out/ao_openal.c | 2 | ||||
-rw-r--r-- | audio/out/ao_opensles.c | 2 | ||||
-rw-r--r-- | audio/out/ao_oss.c | 2 | ||||
-rw-r--r-- | audio/out/ao_wasapi_utils.c | 2 |
6 files changed, 6 insertions, 6 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index b86bf5d89e..7828abb9d4 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -704,7 +704,7 @@ static int init_device(struct ao *ao, int mode) dump_hw_params(ao, MSGL_DEBUG, "HW params after access:\n", alsa_hwparams); bool found_format = false; - int try_formats[AF_FORMAT_COUNT]; + int try_formats[AF_FORMAT_COUNT + 1]; af_get_best_sample_formats(ao->format, try_formats); for (int n = 0; try_formats[n] && !found_format; n++) { int mp_format = try_formats[n]; diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index f247cba12e..830fbf9b72 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -72,7 +72,7 @@ static bool supports_format(AVCodec *codec, int format) static void select_format(struct ao *ao, AVCodec *codec) { - int formats[AF_FORMAT_COUNT]; + int formats[AF_FORMAT_COUNT + 1]; af_get_best_sample_formats(ao->format, formats); for (int n = 0; formats[n]; n++) { diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c index 715ffddceb..6ae91162d3 100644 --- a/audio/out/ao_openal.c +++ b/audio/out/ao_openal.c @@ -197,7 +197,7 @@ static int init(struct ao *ao) ao->samplerate = freq; p->al_format = AL_FALSE; - int try_formats[AF_FORMAT_COUNT]; + int try_formats[AF_FORMAT_COUNT + 1]; af_get_best_sample_formats(ao->format, try_formats); for (int n = 0; try_formats[n]; n++) { p->al_format = get_al_format(try_formats[n]); diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c index 5357ab4920..76bd91cb91 100644 --- a/audio/out/ao_opensles.c +++ b/audio/out/ao_opensles.c @@ -136,7 +136,7 @@ static int init(struct ao *ao) pcm.formatType = SL_DATAFORMAT_PCM; pcm.numChannels = 2; - int compatible_formats[AF_FORMAT_COUNT]; + int compatible_formats[AF_FORMAT_COUNT + 1]; af_get_best_sample_formats(ao->format, compatible_formats); pcm.bitsPerSample = 0; for (int i = 0; compatible_formats[i] && !pcm.bitsPerSample; ++i) diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index 1300a72043..f037812e70 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -315,7 +315,7 @@ static int reopen_device(struct ao *ao, bool allow_format_changes) } } - int try_formats[AF_FORMAT_COUNT]; + int try_formats[AF_FORMAT_COUNT + 1]; af_get_best_sample_formats(format, try_formats); for (int n = 0; try_formats[n]; n++) { format = try_formats[n]; diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 471cc847ac..55a16da812 100644 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -97,7 +97,7 @@ static const struct wasapi_sample_fmt wasapi_formats[] = { static void wasapi_get_best_sample_formats( int src_format, struct wasapi_sample_fmt *out_formats) { - int mp_formats[AF_FORMAT_COUNT]; + int mp_formats[AF_FORMAT_COUNT + 1]; af_get_best_sample_formats(src_format, mp_formats); for (int n = 0; mp_formats[n]; n++) { for (int i = 0; wasapi_formats[i].mp_format; i++) { |