From 7d49b2212d8d369672c7ee9fdfaa302f6b246230 Mon Sep 17 00:00:00 2001 From: verybadsoldier Date: Tue, 18 Oct 2016 22:09:00 +0200 Subject: [PATCH] alsa-backend: initialize variable "sub unit dir". This variable is passed into alsa as a pointer. Alsa will write to it but also read (!) from it. So the read will give undesired behavior when variable is not initialized. Depending on current alsa-config/hardware it leads to an error "Invalid argument" when submitting the parameters by invoking "snd_pcm_hw_params" a few lines later. Initializing the variable to -1 fixes it and means "set to exact value or less" (http://alsa.opensrc.org/HowTo_Asynchronous_Playback) --- core/oslib/audiobackend_alsa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/oslib/audiobackend_alsa.cpp b/core/oslib/audiobackend_alsa.cpp index 2ad9ffa6f..870682e53 100644 --- a/core/oslib/audiobackend_alsa.cpp +++ b/core/oslib/audiobackend_alsa.cpp @@ -13,7 +13,7 @@ static void alsa_init() snd_pcm_hw_params_t *params; unsigned int val; - int dir; + int dir=-1; snd_pcm_uframes_t frames; /* Open PCM device for playback. */