summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224>2011-12-15 10:08:10 +0000
committersletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224>2011-12-15 10:08:10 +0000
commit4f60f19c2fc30725257e5e0aad399c41b131d7f0 (patch)
tree92c42aeee7b84839dfc06b8aea66014dd08849da
parent9f9f682ab294f2a0427d596320863b9933c11c3d (diff)
downloadjack2-4f60f19c2fc30725257e5e0aad399c41b131d7f0.tar.gz
Cleanup of backend stack.
git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4645 0c269be4-1314-0410-8aa9-9f06e86f4224
-rw-r--r--common/JackAudioDriver.cpp112
-rw-r--r--common/JackAudioDriver.h7
-rw-r--r--common/JackDriver.cpp26
-rw-r--r--common/JackDriver.h29
-rw-r--r--common/JackFreewheelDriver.cpp12
-rw-r--r--common/JackFreewheelDriver.h3
-rw-r--r--common/JackLoopbackDriver.cpp10
-rw-r--r--common/JackLoopbackDriver.h3
-rw-r--r--common/JackMidiDriver.cpp10
-rw-r--r--common/JackMidiDriver.h3
-rw-r--r--common/JackThreadedDriver.cpp27
-rw-r--r--common/JackThreadedDriver.h24
12 files changed, 136 insertions, 130 deletions
diff --git a/common/JackAudioDriver.cpp b/common/JackAudioDriver.cpp
index b44d5bc2..2cbbb774 100644
--- a/common/JackAudioDriver.cpp
+++ b/common/JackAudioDriver.cpp
@@ -226,16 +226,6 @@ int JackAudioDriver::Process()
return (fEngineControl->fSyncMode) ? ProcessSync() : ProcessAsync();
}
-void JackAudioDriver::ProcessGraphAsync()
-{
- // Process graph
- if (fIsMaster) {
- ProcessGraphAsyncMaster();
- } else {
- ProcessGraphAsyncSlave();
- }
-}
-
/*
The driver ASYNC mode: output buffers computed at the *previous cycle* are used, the server does not
synchronize to the end of client graph execution.
@@ -263,22 +253,43 @@ int JackAudioDriver::ProcessAsync()
return 0;
}
-void JackAudioDriver::ProcessGraphSync()
+void JackAudioDriver::ProcessGraphAsync()
{
// Process graph
if (fIsMaster) {
- if (ProcessGraphSyncMaster() < 0) {
- //jack_error("JackAudioDriver::ProcessSync: process error, skip cycle...");
- //goto end;
- }
+ ProcessGraphAsyncMaster();
} else {
- if (ProcessGraphSyncSlave() < 0) {
- //jack_error("JackAudioDriver::ProcessSync: process error, skip cycle...");
- //goto end;
- }
+ ProcessGraphAsyncSlave();
}
}
+void JackAudioDriver::ProcessGraphAsyncMaster()
+{
+ // fBeginDateUst is set in the "low level" layer, fEndDateUst is from previous cycle
+ if (!fEngine->Process(fBeginDateUst, fEndDateUst)) {
+ jack_error("JackAudioDriver::ProcessGraphAsyncMaster: Process error");
+ }
+
+ if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) {
+ jack_error("JackAudioDriver::ProcessGraphAsyncMaster: ResumeRefNum error");
+ }
+
+ if (ProcessReadSlaves() < 0) {
+ jack_error("JackAudioDriver::ProcessGraphAsyncMaster: ProcessReadSlaves error");
+ }
+
+ if (ProcessWriteSlaves() < 0) {
+ jack_error("JackAudioDriver::ProcessGraphAsyncMaster: ProcessWriteSlaves error");
+ }
+
+ // Does not wait on graph execution end
+}
+
+void JackAudioDriver::ProcessGraphAsyncSlave()
+{
+ if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0)
+ jack_error("JackAudioDriver::ProcessGraphAsyncSlave: ResumeRefNum error");
+}
/*
The driver SYNC mode: the server does synchronize to the end of client graph execution,
@@ -307,85 +318,48 @@ int JackAudioDriver::ProcessSync()
return 0;
}
-void JackAudioDriver::ProcessGraphAsyncMaster()
-{
- // fBeginDateUst is set in the "low level" layer, fEndDateUst is from previous cycle
- if (!fEngine->Process(fBeginDateUst, fEndDateUst))
- jack_error("JackAudioDriver::ProcessGraphAsyncMaster: Process error");
-
- if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0)
- jack_error("JackAudioDriver::ProcessGraphAsyncMaster: ResumeRefNum error");
-
- if (ProcessReadSlaves() < 0)
- jack_error("JackAudioDriver::ProcessGraphAsyncMaster: ProcessReadSlaves error");
-
- if (ProcessWriteSlaves() < 0)
- jack_error("JackAudioDriver::ProcessGraphAsyncMaster: ProcessWriteSlaves error");
-}
-
-void JackAudioDriver::ProcessGraphAsyncSlave()
+void JackAudioDriver::ProcessGraphSync()
{
- if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0)
- jack_error("JackAudioDriver::ProcessGraphAsyncSlave: ResumeRefNum error");
+ // Process graph
+ if (fIsMaster) {
+ ProcessGraphSyncMaster();
+ } else {
+ ProcessGraphSyncSlave();
+ }
}
-int JackAudioDriver::ProcessGraphSyncMaster()
+void JackAudioDriver::ProcessGraphSyncMaster()
{
- int res = 0;
-
// fBeginDateUst is set in the "low level" layer, fEndDateUst is from previous cycle
if (fEngine->Process(fBeginDateUst, fEndDateUst)) {
if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) {
jack_error("JackAudioDriver::ProcessGraphSyncMaster: ResumeRefNum error");
- res = -1;
}
if (ProcessReadSlaves() < 0) {
jack_error("JackAudioDriver::ProcessGraphSync: ProcessReadSlaves error, engine may now behave abnormally!!");
- res = -1;
}
if (ProcessWriteSlaves() < 0) {
jack_error("JackAudioDriver::ProcessGraphSync: ProcessWriteSlaves error, engine may now behave abnormally!!");
- res = -1;
}
+ // Waits for graph execution end
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) {
jack_error("JackAudioDriver::ProcessGraphSync: SuspendRefNum error, engine may now behave abnormally!!");
- res = -1;
}
+
} else { // Graph not finished: do not activate it
jack_error("JackAudioDriver::ProcessGraphSync: Process error");
- res = -1;
}
-
- return res;
}
-int JackAudioDriver::ProcessGraphSyncSlave()
+void JackAudioDriver::ProcessGraphSyncSlave()
{
- return fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable);
-}
-
-int JackAudioDriver::Start()
-{
- int res = JackDriver::Start();
- if ((res >= 0) && fIsMaster) {
- res = StartSlaves();
- }
- return res;
-}
-
-int JackAudioDriver::Stop()
-{
- int res = JackDriver::Stop();
- if (fIsMaster) {
- if (StopSlaves() < 0) {
- res = -1;
- }
+ if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) {
+ jack_error("JackAudioDriver::ProcessGraphSyncSlave: ResumeRefNum error");
}
- return res;
}
jack_default_audio_sample_t* JackAudioDriver::GetInputBuffer(int port_index)
diff --git a/common/JackAudioDriver.h b/common/JackAudioDriver.h
index 4f3b8149..6df49bac 100644
--- a/common/JackAudioDriver.h
+++ b/common/JackAudioDriver.h
@@ -49,8 +49,8 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
int ProcessSync();
void ProcessGraphSync();
- int ProcessGraphSyncMaster();
- int ProcessGraphSyncSlave();
+ void ProcessGraphSyncMaster();
+ void ProcessGraphSyncSlave();
public:
@@ -84,9 +84,6 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
virtual int Attach();
virtual int Detach();
- virtual int Start();
- virtual int Stop();
-
virtual int Write();
virtual int SetBufferSize(jack_nframes_t buffer_size);
diff --git a/common/JackDriver.cpp b/common/JackDriver.cpp
index 7099af4d..658a446d 100644
--- a/common/JackDriver.cpp
+++ b/common/JackDriver.cpp
@@ -343,11 +343,31 @@ int JackDriver::ProcessWriteSlaves()
int JackDriver::ProcessRead()
{
- return 0;
+ return (fEngineControl->fSyncMode) ? ProcessReadSync() : ProcessReadAsync();
}
int JackDriver::ProcessWrite()
{
+ return (fEngineControl->fSyncMode) ? ProcessWriteSync() : ProcessWriteAsync();
+}
+
+int JackDriver::ProcessReadSync()
+{
+ return 0;
+}
+
+int JackDriver::ProcessWriteSync()
+{
+ return 0;
+}
+
+int JackDriver::ProcessReadAsync()
+{
+ return 0;
+}
+
+int JackDriver::ProcessWriteAsync()
+{
return 0;
}
@@ -382,13 +402,13 @@ int JackDriver::Start()
fEngineControl->InitFrameTime();
}
fIsRunning = true;
- return 0;
+ return StartSlaves();
}
int JackDriver::Stop()
{
fIsRunning = false;
- return 0;
+ return StopSlaves();
}
int JackDriver::StartSlaves()
diff --git a/common/JackDriver.h b/common/JackDriver.h
index 05502b04..2ffc6ec3 100644
--- a/common/JackDriver.h
+++ b/common/JackDriver.h
@@ -97,12 +97,20 @@ class SERVER_EXPORT JackDriverInterface
virtual std::list<JackDriverInterface*> GetSlaves() = 0;
+ // For "master" driver
virtual int ProcessReadSlaves() = 0;
virtual int ProcessWriteSlaves() = 0;
+ // For "slave" driver
virtual int ProcessRead() = 0;
virtual int ProcessWrite() = 0;
+ virtual int ProcessReadSync() = 0;
+ virtual int ProcessWriteSync() = 0;
+
+ virtual int ProcessReadAsync() = 0;
+ virtual int ProcessWriteAsync() = 0;
+
virtual bool IsRealTime() const = 0;
virtual bool IsRunning() const = 0;
};
@@ -172,6 +180,12 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
void NotifySampleRate(jack_nframes_t sample_rate); // SampleRate notification sent by the driver
void NotifyFailure(int code, const char* reason); // Failure notification sent by the driver
+ virtual void SaveConnections();
+ virtual void RestoreConnections();
+
+ virtual int StartSlaves();
+ virtual int StopSlaves();
+
public:
JackDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
@@ -191,7 +205,7 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
virtual int Open();
- virtual int Open (bool capturing,
+ virtual int Open(bool capturing,
bool playing,
int inchannels,
int outchannels,
@@ -212,6 +226,7 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
const char* playback_driver_name,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency);
+
virtual int Close();
virtual int Process();
@@ -225,17 +240,19 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
virtual int Start();
virtual int Stop();
- virtual int StartSlaves();
- virtual int StopSlaves();
-
+ // For "master" driver
int ProcessReadSlaves();
int ProcessWriteSlaves();
+ // For "slave" driver
int ProcessRead();
int ProcessWrite();
- virtual void SaveConnections();
- virtual void RestoreConnections();
+ int ProcessReadSync();
+ int ProcessWriteSync();
+
+ int ProcessReadAsync();
+ int ProcessWriteAsync();
virtual bool IsFixedBufferSize();
virtual int SetBufferSize(jack_nframes_t buffer_size);
diff --git a/common/JackFreewheelDriver.cpp b/common/JackFreewheelDriver.cpp
index 94987c44..2c4bc41f 100644
--- a/common/JackFreewheelDriver.cpp
+++ b/common/JackFreewheelDriver.cpp
@@ -26,6 +26,8 @@
namespace Jack
{
+// When used in "master" mode
+
int JackFreewheelDriver::Process()
{
int res = 0;
@@ -54,15 +56,7 @@ int JackFreewheelDriver::Process()
return res;
}
-int JackFreewheelDriver::ProcessRead()
-{
- return (fEngineControl->fSyncMode) ? ProcessReadSync() : ProcessReadAsync();
-}
-
-int JackFreewheelDriver::ProcessWrite()
-{
- return (fEngineControl->fSyncMode) ? ProcessWriteSync() : ProcessWriteAsync();
-}
+// When used in "slave" mode
int JackFreewheelDriver::ProcessReadSync()
{
diff --git a/common/JackFreewheelDriver.h b/common/JackFreewheelDriver.h
index 02a9cf76..2a3e15c0 100644
--- a/common/JackFreewheelDriver.h
+++ b/common/JackFreewheelDriver.h
@@ -47,9 +47,6 @@ class JackFreewheelDriver : public JackDriver
int Process();
- int ProcessRead();
- int ProcessWrite();
-
int ProcessReadSync();
int ProcessWriteSync();
diff --git a/common/JackLoopbackDriver.cpp b/common/JackLoopbackDriver.cpp
index 5c0376d9..01f120a0 100644
--- a/common/JackLoopbackDriver.cpp
+++ b/common/JackLoopbackDriver.cpp
@@ -30,15 +30,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
namespace Jack
{
-int JackLoopbackDriver::ProcessRead()
-{
- return (fEngineControl->fSyncMode) ? ProcessReadSync() : ProcessReadAsync();
-}
-
-int JackLoopbackDriver::ProcessWrite()
-{
- return (fEngineControl->fSyncMode) ? ProcessWriteSync() : ProcessWriteAsync();
-}
+// When used in "slave" mode
int JackLoopbackDriver::ProcessReadSync()
{
diff --git a/common/JackLoopbackDriver.h b/common/JackLoopbackDriver.h
index 247f852e..ed1ff601 100644
--- a/common/JackLoopbackDriver.h
+++ b/common/JackLoopbackDriver.h
@@ -48,9 +48,6 @@ class JackLoopbackDriver : public JackAudioDriver
{}
virtual ~JackLoopbackDriver()
{}
-
- virtual int ProcessRead();
- virtual int ProcessWrite();
};
} // end of namespace
diff --git a/common/JackMidiDriver.cpp b/common/JackMidiDriver.cpp
index f1ec84ba..dcf168ee 100644
--- a/common/JackMidiDriver.cpp
+++ b/common/JackMidiDriver.cpp
@@ -133,16 +133,6 @@ int JackMidiDriver::SetBufferSize(jack_nframes_t buffer_size)
return 0;
}
-int JackMidiDriver::ProcessRead()
-{
- return (fEngineControl->fSyncMode) ? ProcessReadSync() : ProcessReadAsync();
-}
-
-int JackMidiDriver::ProcessWrite()
-{
- return (fEngineControl->fSyncMode) ? ProcessWriteSync() : ProcessWriteAsync();
-}
-
int JackMidiDriver::ProcessReadSync()
{
int res = 0;
diff --git a/common/JackMidiDriver.h b/common/JackMidiDriver.h
index 5e6edb6f..204d6bbf 100644
--- a/common/JackMidiDriver.h
+++ b/common/JackMidiDriver.h
@@ -65,9 +65,6 @@ class SERVER_EXPORT JackMidiDriver : public JackDriver
virtual int SetBufferSize(jack_nframes_t buffer_size);
- virtual int ProcessRead();
- virtual int ProcessWrite();
-
virtual int Attach();
virtual int Detach();
diff --git a/common/JackThreadedDriver.cpp b/common/JackThreadedDriver.cpp
index a88926f0..78843095 100644
--- a/common/JackThreadedDriver.cpp
+++ b/common/JackThreadedDriver.cpp
@@ -55,7 +55,12 @@ int JackThreadedDriver::Open(jack_nframes_t buffer_size,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency)
{
- return fDriver->Open(buffer_size, samplerate, capturing, playing, inchannels, outchannels, monitor, capture_driver_name, playback_driver_name, capture_latency, playback_latency);
+ return fDriver->Open(buffer_size,
+ samplerate, capturing,
+ playing, inchannels,
+ outchannels, monitor,
+ capture_driver_name, playback_driver_name,
+ capture_latency, playback_latency);
}
int JackThreadedDriver::Close()
@@ -143,6 +148,26 @@ int JackThreadedDriver::ProcessWrite()
return fDriver->ProcessWrite();
}
+int JackThreadedDriver::ProcessReadSync()
+{
+ return fDriver->ProcessReadSync();
+}
+
+int JackThreadedDriver::ProcessWriteSync()
+{
+ return fDriver->ProcessWriteSync();
+}
+
+int JackThreadedDriver::ProcessReadAsync()
+{
+ return fDriver->ProcessReadAsync();
+}
+
+int JackThreadedDriver::ProcessWriteAsync()
+{
+ return fDriver->ProcessWriteAsync();
+}
+
std::list<JackDriverInterface*> JackThreadedDriver::GetSlaves()
{
return fDriver->GetSlaves();
diff --git a/common/JackThreadedDriver.h b/common/JackThreadedDriver.h
index 12d77471..763a4c28 100644
--- a/common/JackThreadedDriver.h
+++ b/common/JackThreadedDriver.h
@@ -28,7 +28,7 @@ namespace Jack
{
/*!
-\brief The base class for threaded drivers. Threaded drivers are used with blocking devices.
+\brief The base class for threaded drivers using a "decorator" pattern. Threaded drivers are used with blocking devices.
*/
class SERVER_EXPORT JackThreadedDriver : public JackDriverClientInterface, public JackRunnableInterface
@@ -49,14 +49,14 @@ class SERVER_EXPORT JackThreadedDriver : public JackDriverClientInterface, publi
virtual int Open();
virtual int Open (bool capturing,
- bool playing,
- int inchannels,
- int outchannels,
- bool monitor,
- const char* capture_driver_name,
- const char* playback_driver_name,
- jack_nframes_t capture_latency,
- jack_nframes_t playback_latency)
+ bool playing,
+ int inchannels,
+ int outchannels,
+ bool monitor,
+ const char* capture_driver_name,
+ const char* playback_driver_name,
+ jack_nframes_t capture_latency,
+ jack_nframes_t playback_latency)
{
return -1;
}
@@ -102,6 +102,12 @@ class SERVER_EXPORT JackThreadedDriver : public JackDriverClientInterface, publi
virtual int ProcessRead();
virtual int ProcessWrite();
+ virtual int ProcessReadSync();
+ virtual int ProcessWriteSync();
+
+ virtual int ProcessReadAsync();
+ virtual int ProcessWriteAsync();
+
virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
virtual JackClientControl* GetClientControl() const;
virtual bool IsRealTime() const;