From 8a129a26a95cbf2f7bd523a0bb77a7864d603a81 Mon Sep 17 00:00:00 2001 From: Laxmi Devi Date: Mon, 1 Jul 2019 12:55:12 +0530 Subject: [PATCH] alsa: Exit JackAlsaDriver::Read if the XRUN recovery is not recovering the device Currently on XRUN, Jack tries a recovery and goes back to read again. But in a case where the device is not recovering at all, Jack is looping continuously taking up 100% cpu as there is no other exit condition. Signed-off-by: Laxmi Devi --- linux/alsa/JackAlsaDriver.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linux/alsa/JackAlsaDriver.cpp b/linux/alsa/JackAlsaDriver.cpp index 529ec8d3..4ed85198 100644 --- a/linux/alsa/JackAlsaDriver.cpp +++ b/linux/alsa/JackAlsaDriver.cpp @@ -406,6 +406,9 @@ int JackAlsaDriver::Read() int wait_status; jack_nframes_t nframes; fDelayedUsecs = 0.f; + int retry_cnt = 0; + +#define MAX_RECOVERY_RETRY 10 retry: @@ -420,6 +423,11 @@ retry: */ jack_log("ALSA XRun wait_status = %d", wait_status); NotifyXRun(fBeginDateUst, fDelayedUsecs); + if(retry_cnt >= MAX_RECOVERY_RETRY) { + jack_error("ALSA Device not recovering, tried Xrun recovery for %d times", retry_cnt); + return -1; + } + retry_cnt++; goto retry; /* recoverable error*/ }