From 866f001cdc3562fb78fbc9625833c8e2826c8722 Mon Sep 17 00:00:00 2001 From: sletz Date: Thu, 15 Dec 2011 10:55:05 +0000 Subject: [PATCH] More cleanup in backends. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4646 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackAudioDriver.cpp | 11 ++++++----- common/JackDriver.cpp | 11 +++++++++++ common/JackDriver.h | 3 +++ common/JackFreewheelDriver.cpp | 17 ++++++++++++----- common/JackFreewheelDriver.h | 3 +++ common/JackLoopbackDriver.cpp | 6 +++--- common/JackMidiDriver.cpp | 8 +++----- 7 files changed, 41 insertions(+), 18 deletions(-) diff --git a/common/JackAudioDriver.cpp b/common/JackAudioDriver.cpp index 2cbbb774..337afe84 100644 --- a/common/JackAudioDriver.cpp +++ b/common/JackAudioDriver.cpp @@ -270,7 +270,7 @@ void JackAudioDriver::ProcessGraphAsyncMaster() jack_error("JackAudioDriver::ProcessGraphAsyncMaster: Process error"); } - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { + if (ResumeRefNum() < 0) { jack_error("JackAudioDriver::ProcessGraphAsyncMaster: ResumeRefNum error"); } @@ -287,8 +287,9 @@ void JackAudioDriver::ProcessGraphAsyncMaster() void JackAudioDriver::ProcessGraphAsyncSlave() { - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) + if (ResumeRefNum() < 0) { jack_error("JackAudioDriver::ProcessGraphAsyncSlave: ResumeRefNum error"); + } } /* @@ -333,7 +334,7 @@ void JackAudioDriver::ProcessGraphSyncMaster() // fBeginDateUst is set in the "low level" layer, fEndDateUst is from previous cycle if (fEngine->Process(fBeginDateUst, fEndDateUst)) { - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { + if (ResumeRefNum() < 0) { jack_error("JackAudioDriver::ProcessGraphSyncMaster: ResumeRefNum error"); } @@ -346,7 +347,7 @@ void JackAudioDriver::ProcessGraphSyncMaster() } // Waits for graph execution end - if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) { + if (SuspendRefNum() < 0) { jack_error("JackAudioDriver::ProcessGraphSync: SuspendRefNum error, engine may now behave abnormally!!"); } @@ -357,7 +358,7 @@ void JackAudioDriver::ProcessGraphSyncMaster() void JackAudioDriver::ProcessGraphSyncSlave() { - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { + if (ResumeRefNum() < 0) { jack_error("JackAudioDriver::ProcessGraphSyncSlave: ResumeRefNum error"); } } diff --git a/common/JackDriver.cpp b/common/JackDriver.cpp index 658a446d..1e117d27 100644 --- a/common/JackDriver.cpp +++ b/common/JackDriver.cpp @@ -530,4 +530,15 @@ void JackDriver::RestoreConnections() } } +int JackDriver::ResumeRefNum() +{ + return fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); +} + +int JackDriver::SuspendRefNum() +{ + return fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs); +} + + } // end of namespace diff --git a/common/JackDriver.h b/common/JackDriver.h index 2ffc6ec3..77837646 100644 --- a/common/JackDriver.h +++ b/common/JackDriver.h @@ -186,6 +186,9 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface virtual int StartSlaves(); virtual int StopSlaves(); + virtual int ResumeRefNum(); + virtual int SuspendRefNum(); + public: JackDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table); diff --git a/common/JackFreewheelDriver.cpp b/common/JackFreewheelDriver.cpp index 2c4bc41f..2bfb1d15 100644 --- a/common/JackFreewheelDriver.cpp +++ b/common/JackFreewheelDriver.cpp @@ -37,12 +37,13 @@ int JackFreewheelDriver::Process() if (fEngine->Process(fBeginDateUst, fEndDateUst)) { - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable)) { // Signal all clients + if (ResumeRefNum()) { // Signal all clients jack_error("JackFreewheelDriver::Process: ResumeRefNum error"); res = -1; } - if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, FREEWHEEL_DRIVER_TIMEOUT * 1000000) < 0) { // Wait for all clients to finish for 10 sec + // Special "SuspendRefNum" with longer timeout + if (SuspendRefNum() < 0) { // Wait for all clients to finish for 10 sec jack_error("JackFreewheelDriver::ProcessSync: SuspendRefNum error"); /* We have a client time-out error, but still continue to process, until a better recovery strategy is chosen */ return 0; @@ -60,7 +61,7 @@ int JackFreewheelDriver::Process() int JackFreewheelDriver::ProcessReadSync() { - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { // Signal all clients + if (ResumeRefNum() < 0) { // Signal all clients jack_error("JackFreewheelDriver::ProcessReadSync: ResumeRefNum error"); return -1; } @@ -69,7 +70,8 @@ int JackFreewheelDriver::ProcessReadSync() int JackFreewheelDriver::ProcessWriteSync() { - if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) { + // Generic "SuspendRefNum" here + if (JackDriver::SuspendRefNum() < 0) { jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error"); return -1; } @@ -78,7 +80,7 @@ int JackFreewheelDriver::ProcessWriteSync() int JackFreewheelDriver::ProcessReadAsync() { - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { // Signal all clients + if (ResumeRefNum() < 0) { // Signal all clients jack_error("JackFreewheelDriver::ProcessReadAsync: ResumeRefNum error"); return -1; } @@ -90,4 +92,9 @@ int JackFreewheelDriver::ProcessWriteAsync() return 0; } +int JackFreewheelDriver::SuspendRefNum() +{ + return fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, FREEWHEEL_DRIVER_TIMEOUT * 1000000); +} + } // end of namespace diff --git a/common/JackFreewheelDriver.h b/common/JackFreewheelDriver.h index 2a3e15c0..15716fb2 100644 --- a/common/JackFreewheelDriver.h +++ b/common/JackFreewheelDriver.h @@ -32,6 +32,9 @@ namespace Jack class JackFreewheelDriver : public JackDriver { + protected: + + int SuspendRefNum(); public: diff --git a/common/JackLoopbackDriver.cpp b/common/JackLoopbackDriver.cpp index 01f120a0..d24ba2db 100644 --- a/common/JackLoopbackDriver.cpp +++ b/common/JackLoopbackDriver.cpp @@ -41,7 +41,7 @@ int JackLoopbackDriver::ProcessReadSync() memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize); } - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { + if (ResumeRefNum() < 0) { jack_error("JackLoopbackDriver::ProcessReadSync - ResumeRefNum error"); res = -1; } @@ -51,7 +51,7 @@ int JackLoopbackDriver::ProcessReadSync() int JackLoopbackDriver::ProcessWriteSync() { - if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) { + if (SuspendRefNum() < 0) { jack_error("JackLoopbackDriver::ProcessWriteSync SuspendRefNum error"); return -1; } @@ -67,7 +67,7 @@ int JackLoopbackDriver::ProcessReadAsync() memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize); } - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { + if (ResumeRefNum() < 0) { jack_error("JackLoopbackDriver::ProcessReadAsync - ResumeRefNum error"); res = -1; } diff --git a/common/JackMidiDriver.cpp b/common/JackMidiDriver.cpp index dcf168ee..de5f295d 100644 --- a/common/JackMidiDriver.cpp +++ b/common/JackMidiDriver.cpp @@ -143,7 +143,7 @@ int JackMidiDriver::ProcessReadSync() res = -1; } - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { + if (ResumeRefNum() < 0) { jack_error("JackMidiDriver::ProcessReadSync: ResumeRefNum error"); res = -1; } @@ -155,9 +155,7 @@ int JackMidiDriver::ProcessWriteSync() { int res = 0; - if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, - DRIVER_TIMEOUT_FACTOR * - fEngineControl->fTimeOutUsecs) < 0) { + if (SuspendRefNum() < 0) { jack_error("JackMidiDriver::ProcessWriteSync: SuspendRefNum error"); res = -1; } @@ -187,7 +185,7 @@ int JackMidiDriver::ProcessReadAsync() res = -1; } - if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { + if (ResumeRefNum() < 0) { jack_error("JackMidiDriver::ProcessReadAsync: ResumeRefNum error"); res = -1; }