Browse Source

Add exceptions management to distinguish drivers recoverable errors from non recoverable ones. Will be used in special threaded drivers (for network).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2191 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
89269bf12a
8 changed files with 78 additions and 17 deletions
  1. +4
    -0
      ChangeLog
  2. +18
    -10
      common/JackAudioDriver.cpp
  3. +0
    -1
      common/JackDummyDriver.cpp
  4. +3
    -1
      common/JackFreewheelDriver.cpp
  5. +9
    -0
      common/JackThread.h
  6. +27
    -1
      common/JackThreadedDriver.cpp
  7. +17
    -3
      common/JackThreadedDriver.h
  8. +0
    -1
      macosx/JackCoreAudioDriver.cpp

+ 4
- 0
ChangeLog View File

@@ -20,6 +20,10 @@ Fernando Lopez-Lezcano
Jackdmp changes log Jackdmp changes log
--------------------------- ---------------------------


2008-04-28 Stephane Letz <letz@grame.fr>
* Add exceptions management to distinguish drivers recoverable errors from non recoverable ones. Will be used in special threaded drivers (for network).

2008-04-25 Stephane Letz <letz@grame.fr> 2008-04-25 Stephane Letz <letz@grame.fr>
* Correct JackServerGlobals::Init: now check is server is already started. * Correct JackServerGlobals::Init: now check is server is already started.


+ 18
- 10
common/JackAudioDriver.cpp View File

@@ -30,6 +30,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackPort.h" #include "JackPort.h"
#include "JackGraphManager.h" #include "JackGraphManager.h"
#include "JackEngine.h" #include "JackEngine.h"
#include "JackException.h"
#include <assert.h> #include <assert.h>


namespace Jack namespace Jack
@@ -175,7 +176,12 @@ int JackAudioDriver::Write()


int JackAudioDriver::Process() int JackAudioDriver::Process()
{ {
return (fEngineControl->fSyncMode) ? ProcessSync() : ProcessAsync();
try {
return (fEngineControl->fSyncMode) ? ProcessSync() : ProcessAsync();
} catch (JackException e) {
e.PrintMessage();
return -1;
}
} }


/* /*
@@ -186,13 +192,13 @@ synchronize to the end of client graph execution.
int JackAudioDriver::ProcessAsync() int JackAudioDriver::ProcessAsync()
{ {
if (Read() < 0) { // Read input buffers for the current cycle if (Read() < 0) { // Read input buffers for the current cycle
jack_error("ProcessAsync: read error");
return 0;
jack_error("ProcessAsync: read error, skip cycle");
return -1;
} }


if (Write() < 0) { // Write output buffers from the previous cycle if (Write() < 0) { // Write output buffers from the previous cycle
jack_error("ProcessAsync: write error");
return 0;
jack_error("ProcessAsync: write error, skip cycle");
return -1;
} }


if (fIsMaster) { if (fIsMaster) {
@@ -215,8 +221,8 @@ output buffers computed at the *current cycle* are used.
int JackAudioDriver::ProcessSync() int JackAudioDriver::ProcessSync()
{ {
if (Read() < 0) { // Read input buffers for the current cycle if (Read() < 0) { // Read input buffers for the current cycle
jack_error("ProcessSync: read error");
return 0;
jack_error("ProcessSync: read error, skip cycle");
return -1;
} }


if (fIsMaster) { if (fIsMaster) {
@@ -231,9 +237,11 @@ int JackAudioDriver::ProcessSync()
jack_error("ProcessSync: error"); jack_error("ProcessSync: error");
} }


if (Write() < 0) // Write output buffers for the current cycle
jack_error("ProcessSync: write error");

if (Write() < 0) { // Write output buffers for the current cycle
jack_error("ProcessSync: write error, skip cycle");
return -1;
}
} else { } else {
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); fGraphManager->ResumeRefNum(fClientControl, fSynchroTable);
} }


+ 0
- 1
common/JackDummyDriver.cpp View File

@@ -21,7 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackDummyDriver.h" #include "JackDummyDriver.h"
#include "JackEngineControl.h" #include "JackEngineControl.h"
#include "JackGraphManager.h" #include "JackGraphManager.h"
#include "driver_interface.h"
#include "JackDriverLoader.h" #include "JackDriverLoader.h"
#include "JackThreadedDriver.h" #include "JackThreadedDriver.h"
#include <iostream> #include <iostream>


+ 3
- 1
common/JackFreewheelDriver.cpp View File

@@ -36,8 +36,10 @@ int JackFreewheelDriver::Process()
fLastWaitUst = GetMicroSeconds(); fLastWaitUst = GetMicroSeconds();
fEngine->Process(fLastWaitUst); fEngine->Process(fLastWaitUst);
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); // Signal all clients fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); // Signal all clients
if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, 10 * 1000000) < 0) // Wait for all clients to finish for 10 sec
if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, 10 * 1000000) < 0) { // Wait for all clients to finish for 10 sec
jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error"); jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error");
return -1;
}
} else { } else {
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); // Signal all clients fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); // Signal all clients
if (fEngineControl->fSyncMode) { if (fEngineControl->fSyncMode) {


+ 9
- 0
common/JackThread.h View File

@@ -86,6 +86,15 @@ class JackThread
virtual int AcquireRealTime() = 0; virtual int AcquireRealTime() = 0;
virtual int AcquireRealTime(int priority) = 0; virtual int AcquireRealTime(int priority) = 0;
virtual int DropRealTime() = 0; virtual int DropRealTime() = 0;
virtual bool GetRunning()
{
return fRunning;
}
virtual void SetRunning(bool state)
{
fRunning = state;
}


virtual void SetParams(UInt64 period, UInt64 computation, UInt64 constraint) // Empty implementation, will only make sense on OSX... virtual void SetParams(UInt64 period, UInt64 computation, UInt64 constraint) // Empty implementation, will only make sense on OSX...
{} {}


+ 27
- 1
common/JackThreadedDriver.cpp View File

@@ -27,6 +27,7 @@
#include "JackGlobals.h" #include "JackGlobals.h"
#include "JackClient.h" #include "JackClient.h"
#include "JackEngineControl.h" #include "JackEngineControl.h"
#include "JackException.h"


namespace Jack namespace Jack
{ {
@@ -86,7 +87,15 @@ int JackThreadedDriver::Stop()


bool JackThreadedDriver::Execute() bool JackThreadedDriver::Execute()
{ {
return (Process() == 0);
try {
// Keep running even in case of error
Process();
return true;
} catch (JackException e) {
e.PrintMessage();
jack_error("Driver is stopped");
return false;
}
} }


bool JackThreadedDriver::Init() bool JackThreadedDriver::Init()
@@ -94,4 +103,21 @@ bool JackThreadedDriver::Init()
return fDriver->Init(); return fDriver->Init();
} }


bool JackRestartThreadedDriver::Execute()
{
while (fThread->GetRunning()) {
try {
// Keep running even in case of error
while (true) {
Process();
}
} catch (JackException e) {
e.PrintMessage();
jack_log("Driver is restarted...");
Init();
}
}
return false;
}

} // end of namespace } // end of namespace

+ 17
- 3
common/JackThreadedDriver.h View File

@@ -34,7 +34,7 @@ namespace Jack
class JackThreadedDriver : public JackDriverClientInterface, public JackRunnableInterface class JackThreadedDriver : public JackDriverClientInterface, public JackRunnableInterface
{ {


private:
protected:


JackThread* fThread; JackThread* fThread;
JackDriverClient* fDriver; JackDriverClient* fDriver;
@@ -143,11 +143,25 @@ class JackThreadedDriver : public JackDriverClientInterface, public JackRunnable
} }


// JackRunnableInterface interface // JackRunnableInterface interface
bool Execute();
bool Init();
virtual bool Execute();
virtual bool Init();


}; };


class JackRestartThreadedDriver : public JackThreadedDriver
{
public:

JackRestartThreadedDriver(JackDriverClient* driver):JackThreadedDriver(driver)
{}
virtual ~JackRestartThreadedDriver()
{}

// JackRunnableInterface interface
virtual bool Execute();
};


} // end of namespace } // end of namespace






+ 0
- 1
macosx/JackCoreAudioDriver.cpp View File

@@ -25,7 +25,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackClientControl.h" #include "JackClientControl.h"
#include "JackDriverLoader.h" #include "JackDriverLoader.h"
#include "JackGlobals.h" #include "JackGlobals.h"
#include "driver_interface.h"
#include <iostream> #include <iostream>


namespace Jack namespace Jack


Loading…
Cancel
Save