From db59a1c1a76f9a4c5390b47d715aabd7dfd2e83e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Tue, 31 Jan 2023 00:31:25 +0100 Subject: [PATCH] audio/chmap: link string buffer size to MP_NUM_CHANNELS --- audio/chmap.h | 6 ++++-- audio/out/ao_wasapi_utils.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/audio/chmap.h b/audio/chmap.h index 6fbb60d025..35f569d9cc 100644 --- a/audio/chmap.h +++ b/audio/chmap.h @@ -124,10 +124,12 @@ void mp_chmap_get_reorder(int src[MP_NUM_CHANNELS], const struct mp_chmap *from, int mp_chmap_diffn(const struct mp_chmap *a, const struct mp_chmap *b); char *mp_chmap_to_str_buf(char *buf, size_t buf_size, const struct mp_chmap *src); -#define mp_chmap_to_str(m) mp_chmap_to_str_buf((char[64]){0}, 64, (m)) +#define mp_chmap_to_str_(m, sz) mp_chmap_to_str_buf((char[sz]){0}, sz, (m)) +#define mp_chmap_to_str(m) mp_chmap_to_str_(m, MP_NUM_CHANNELS * 4) char *mp_chmap_to_str_hr_buf(char *buf, size_t buf_size, const struct mp_chmap *src); -#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_buf((char[128]){0}, 128, (m)) +#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m)) +#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4) bool mp_chmap_from_str(struct mp_chmap *dst, bstr src); diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 97a8e17b2f..d2261bfb6c 100644 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -236,7 +236,8 @@ static char *waveformat_to_str_buf(char *buf, size_t buf_size, WAVEFORMATEX *wf) (unsigned) wf->nSamplesPerSec); return buf; } -#define waveformat_to_str(wf) waveformat_to_str_buf((char[64]){0}, 64, (wf)) +#define waveformat_to_str_(wf, sz) waveformat_to_str_buf((char[sz]){0}, sz, (wf)) +#define waveformat_to_str(wf) waveformat_to_str_(wf, MP_NUM_CHANNELS * 4 + 42) static void waveformat_copy(WAVEFORMATEXTENSIBLE* dst, WAVEFORMATEX* src) {