From 7dfb47b0672c93303d97dc040c7372d8b33abc5c Mon Sep 17 00:00:00 2001 From: sletz Date: Wed, 3 Nov 2010 17:48:53 +0000 Subject: [PATCH] Improve backend error handling: fatal error returned by Read/Write now cause a Process failure (so a thread exit for blocking backends). Recoverable ones (XRuns..) are now treated internally in ALSA, FreeBob and FFADO backends. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4079 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 4 ++++ common/JackAudioDriver.cpp | 22 +++++++++++----------- linux/alsa/JackAlsaDriver.cpp | 4 +++- linux/firewire/JackFFADODriver.cpp | 4 +++- linux/freebob/JackFreebobDriver.cpp | 4 +++- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66269eb1..f147ff48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,10 @@ David Garcia Garzon Jackdmp changes log --------------------------- +2010-11-03 Stephane Letz + + * Improve backend error handling: fatal error returned by Read/Write now cause a Process failure (so a thread exit for blocking backends). Recoverable ones (XRuns..) are now treated internally in ALSA, FreeBob and FFADO backends. + 2010-10-30 Stephane Letz * Correct JackServer::Open to avoid a race when control API is used on OSX. diff --git a/common/JackAudioDriver.cpp b/common/JackAudioDriver.cpp index dc53077c..72db9c7f 100644 --- a/common/JackAudioDriver.cpp +++ b/common/JackAudioDriver.cpp @@ -215,14 +215,14 @@ int JackAudioDriver::ProcessAsync() { // Read input buffers for the current cycle if (Read() < 0) { - jack_error("JackAudioDriver::ProcessAsync: read error, skip cycle"); - return 0; // Skip cycle, but continue processing... + jack_error("JackAudioDriver::ProcessAsync: read error, stopping..."); + return -1; } // Write output buffers from the previous cycle if (Write() < 0) { - jack_error("JackAudioDriver::ProcessAsync: write error, skip cycle"); - return 0; // Skip cycle, but continue processing... + jack_error("JackAudioDriver::ProcessAsync: write error, stopping..."); + return -1; } if (fIsMaster) { @@ -244,9 +244,9 @@ output buffers computed at the *current cycle* are used. int JackAudioDriver::ProcessSync() { // Read input buffers for the current cycle - if (Read() < 0) { - jack_error("JackAudioDriver::ProcessSync: read error, skip cycle"); - return 0; // Skip cycle, but continue processing... + if (Read() < 0) { + jack_error("JackAudioDriver::ProcessSync: read error, stopping..."); + return -1; } if (fIsMaster) { @@ -255,10 +255,10 @@ int JackAudioDriver::ProcessSync() fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); } - // Write output buffers for the current cycle - if (Write() < 0) { - jack_error("JackAudioDriver::ProcessSync: write error, skip cycle"); - return 0; // Skip cycle, but continue processing... + // Write output buffers from the previous cycle + if (Write() < 0) { + jack_error("JackAudioDriver::ProcessSync: write error, stopping..."); + return -1; } // Keep end cycle time diff --git a/linux/alsa/JackAlsaDriver.cpp b/linux/alsa/JackAlsaDriver.cpp index 1975301d..fcf655b7 100644 --- a/linux/alsa/JackAlsaDriver.cpp +++ b/linux/alsa/JackAlsaDriver.cpp @@ -2316,6 +2316,8 @@ int JackAlsaDriver::Read() jack_nframes_t nframes; fDelayedUsecs = 0.f; +retry: + nframes = alsa_driver_wait((alsa_driver_t *)fDriver, -1, &wait_status, &fDelayedUsecs); if (wait_status < 0) @@ -2327,7 +2329,7 @@ int JackAlsaDriver::Read() */ jack_log("ALSA XRun wait_status = %d", wait_status); NotifyXRun(fBeginDateUst, fDelayedUsecs); - return -1; + goto retry; /* recoverable error*/ } if (nframes != fEngineControl->fBufferSize) diff --git a/linux/firewire/JackFFADODriver.cpp b/linux/firewire/JackFFADODriver.cpp index 89f7a9fe..5400df76 100644 --- a/linux/firewire/JackFFADODriver.cpp +++ b/linux/firewire/JackFFADODriver.cpp @@ -664,6 +664,8 @@ int JackFFADODriver::Read() int wait_status = 0; fDelayedUsecs = 0.f; +retry: + jack_nframes_t nframes = ffado_driver_wait(driver, -1, &wait_status, &fDelayedUsecs); @@ -678,7 +680,7 @@ int JackFFADODriver::Read() */ jack_log("FFADO XRun"); NotifyXRun(fBeginDateUst, fDelayedUsecs); - return -1; + goto retry; /* recoverable error*/ } if (nframes != fEngineControl->fBufferSize) diff --git a/linux/freebob/JackFreebobDriver.cpp b/linux/freebob/JackFreebobDriver.cpp index 57d8b9cb..47860f21 100644 --- a/linux/freebob/JackFreebobDriver.cpp +++ b/linux/freebob/JackFreebobDriver.cpp @@ -854,6 +854,8 @@ int JackFreebobDriver::Read() int wait_status = 0; fDelayedUsecs = 0.f; +retry: + jack_nframes_t nframes = freebob_driver_wait (driver, -1, &wait_status, &fDelayedUsecs); @@ -868,7 +870,7 @@ int JackFreebobDriver::Read() */ jack_log("FreeBoB XRun"); NotifyXRun(fBeginDateUst, fDelayedUsecs); - return -1; + goto retry; /* recoverable error*/ } if (nframes != fEngineControl->fBufferSize)