From fb63394c157967d1c64ade1aa560212a27c9549d Mon Sep 17 00:00:00 2001 From: Daniel Bermond <danielbermond@gmail.com> Date: Fri, 26 Jun 2020 23:20:11 +0000 Subject: [PATCH] Fix build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code fails to build with the following error: ../libndi/libndi.c: In function ‘process_audio_message’: ../libndi/libndi.c:293:33: error: expected ‘;’ before ‘{’ token 293 | } else(bps == 4) { | ^~ | ; The else block does not accept a condition. This can be fixed by changing 'else(bps == 4)' to 'else if(bps == 4)'. After doing this change, another error is shown: ../libndi/libndi.c: In function ‘process_audio_message’: ../libndi/libndi.c:297:57: error: incompatible type for argument 2 of ‘memcpy’ 297 | memcpy(&ndi_data.buf[i]->data[4*j], sf, sizeof(sf)); | ^~ | | | float memcpy src argument needs a pointer, not a direct float value. Both errors are caused by commit 4bd2c9df7c1a3cadb29c66d695c42168ec0f279c. Tested with gcc 10.1.0. --- libndi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libndi.c b/libndi.c index c33342b..7f78f51 100644 --- a/libndi.c +++ b/libndi.c @@ -290,11 +290,11 @@ static int process_audio_message(ndi_ctx *ndi_ctx, uint8_t *data, int header_len if(bps == 2) { ndi_data.buf[i]->data[2*j+0] = data[1]; ndi_data.buf[i]->data[2*j+1] = data[0]; - } else(bps == 4) { + } else if(bps == 4) { float sf = scale_factors[i] / 32767.0f; int16_t sample = ((uint16_t)data[1] << 8) | data[0]; sf *= sample; - memcpy(&ndi_data.buf[i]->data[4*j], sf, sizeof(sf)); + memcpy(&ndi_data.buf[i]->data[4*j], &sf, sizeof(sf)); } data += sizeof(int16_t); } -- GitLab