From f4cac29f3c4b6072282d2e269f6e30c3e8c822b6 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 4 Oct 2024 12:02:15 +0200 Subject: [PATCH 1/3] [channels,audin] fix string to int conversion use strtoul for unsigned values --- channels/audin/client/audin_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 08a670cb9..35d4d89fd 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -941,7 +941,7 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, const ADDIN_ARGV* args) } CommandLineSwitchCase(arg, "rate") { - long val = strtol(arg->Value, NULL, 0); + unsigned long val = strtoul(arg->Value, NULL, 0); if ((errno != 0) || (val == 0) || (val > UINT32_MAX)) return FALSE; From cf46f341f61ef246e73e67e8657332f45a8649ac Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 4 Oct 2024 12:02:49 +0200 Subject: [PATCH 2/3] [channels,audin] fix alsa backend * Fix wrong variable passed to receive * Improve logging/error handling --- channels/audin/client/alsa/audin_alsa.c | 34 +++++++++++++++++-------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c index bacdc3230..f77aa7e1f 100644 --- a/channels/audin/client/alsa/audin_alsa.c +++ b/channels/audin/client/alsa/audin_alsa.c @@ -117,11 +117,13 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) { DWORD error = CHANNEL_RC_OK; BYTE* buffer = NULL; - snd_pcm_t* capture_handle = NULL; AudinALSADevice* alsa = (AudinALSADevice*)arg; - DWORD status = 0; + + WINPR_ASSERT(alsa); + WLog_Print(alsa->log, WLOG_DEBUG, "in"); + snd_pcm_t* capture_handle = NULL; const int rc = snd_pcm_open(&capture_handle, alsa->device_name, SND_PCM_STREAM_CAPTURE, 0); if (rc < 0) { @@ -149,7 +151,7 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) while (1) { size_t frames = alsa->frames_per_packet; - status = WaitForSingleObject(alsa->stopEvent, 0); + const DWORD status = WaitForSingleObject(alsa->stopEvent, 0); if (status == WAIT_FAILED) { @@ -160,26 +162,32 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) } if (status == WAIT_OBJECT_0) + { + WLog_Print(alsa->log, WLOG_DEBUG, "alsa->stopEvent requests termination"); break; + } - snd_pcm_sframes_t err = snd_pcm_readi(capture_handle, buffer, frames); + snd_pcm_sframes_t framesRead = snd_pcm_readi(capture_handle, buffer, frames); - if (err == 0) + if (framesRead == 0) continue; - if (err == -EPIPE) + if (framesRead == -EPIPE) { - snd_pcm_recover(capture_handle, (int)err, 0); + const int rc = snd_pcm_recover(capture_handle, (int)framesRead, 0); + if (rc < 0) + WLog_Print(alsa->log, WLOG_WARN, "snd_pcm_recover (%s)", snd_strerror(rc)); + continue; } - else if (err < 0) + else if (framesRead < 0) { - WLog_Print(alsa->log, WLOG_ERROR, "snd_pcm_readi (%s)", snd_strerror(error)); + WLog_Print(alsa->log, WLOG_ERROR, "snd_pcm_readi (%s)", snd_strerror(framesRead)); error = ERROR_INTERNAL_ERROR; break; } - error = alsa->receive(&alsa->aformat, buffer, (long)error * alsa->bytes_per_frame, + error = alsa->receive(&alsa->aformat, buffer, (long)framesRead * alsa->bytes_per_frame, alsa->user_data); if (error) @@ -193,7 +201,11 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) free(buffer); if (capture_handle) - snd_pcm_close(capture_handle); + { + const int rc = snd_pcm_close(capture_handle); + if (rc < 0) + WLog_Print(alsa->log, WLOG_WARN, "snd_pcm_close (%s)", snd_strerror(rc)); + } out: WLog_Print(alsa->log, WLOG_DEBUG, "out"); From 8ea903091b59c2062bda8bb83912e104da4cb2d6 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 4 Oct 2024 12:03:31 +0200 Subject: [PATCH 3/3] [winpr,platform] disable GCC pragma GCC does not support -Wtautological-constant-out-of-range-compare --- winpr/include/winpr/platform.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/winpr/include/winpr/platform.h b/winpr/include/winpr/platform.h index 2d13cf46a..39319ac64 100644 --- a/winpr/include/winpr/platform.h +++ b/winpr/include/winpr/platform.h @@ -45,8 +45,11 @@ _Pragma("clang diagnostic ignored \"-Wunused-const-variable\"") #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \ _Pragma("clang diagnostic ignored \"-Wformat-security\"") -#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \ - _Pragma("clang diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"") +#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \ + _Pragma("clang diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"") /** @since \ + version \ + 3.9.0 \ + */ #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \ _Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"") /** @since version 3.9.0 */ #define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC /** @since version 3.3.0 */ /* not supported \ @@ -77,8 +80,8 @@ _Pragma("GCC diagnostic ignored \"-Wunused-const-variable\"") #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \ _Pragma("GCC diagnostic ignored \"-Wformat-security\"") -#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \ - _Pragma("GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"") +#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE /* not supported + _Pragma("GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"") */ /** @since version 3.9.0 */ #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \ _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") /** @since version 3.9.0 */ #if __GNUC__ >= 11 @@ -103,7 +106,7 @@ #define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST #define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY -#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE /** @since version 3.9.0 */ #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL /** @since version 3.9.0 */ #define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC /** @since version 3.3.0 */ #define WINPR_PRAGMA_DIAG_POP