summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStephane Letz <letz@grame.fr>2011-03-26 12:52:52 +0100
committerStephane Letz <letz@grame.fr>2011-03-26 12:52:52 +0100
commit03e695ba1e3af55d685f58b534f4ada1cc592185 (patch)
tree588744016bffc066277381e1ed3c81b7abfd7f4c /common
parentfaf29128cf7925735ac671ae50dfe55fff89639b (diff)
downloadjack2-03e695ba1e3af55d685f58b534f4ada1cc592185.tar.gz
Correct loopback driver for new activation model.
Diffstat (limited to 'common')
-rw-r--r--common/JackDriver.h13
-rw-r--r--common/JackLoopbackDriver.cpp55
-rw-r--r--common/JackLoopbackDriver.h11
-rw-r--r--common/JackMidiDriver.cpp14
4 files changed, 65 insertions, 28 deletions
diff --git a/common/JackDriver.h b/common/JackDriver.h
index e619f6e4..45d695af 100644
--- a/common/JackDriver.h
+++ b/common/JackDriver.h
@@ -232,19 +232,6 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
};
-/*
-class SERVER_EXPORT JackSlaveDriverInterface
-{
-
- public:
-
- virtual int ProcessRead() { return 0; }
- virtual int ProcessWrite() { return 0; }
-
-};
-
-*/
-
} // end of namespace
#endif
diff --git a/common/JackLoopbackDriver.cpp b/common/JackLoopbackDriver.cpp
index e91cce1e..07778417 100644
--- a/common/JackLoopbackDriver.cpp
+++ b/common/JackLoopbackDriver.cpp
@@ -30,20 +30,61 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
namespace Jack
{
-int JackLoopbackDriver::Process()
+int JackLoopbackDriver::ProcessRead()
{
+ return (fEngineControl->fSyncMode) ? ProcessReadSync() : ProcessReadAsync();
+}
+
+int JackLoopbackDriver::ProcessWrite()
+{
+ return (fEngineControl->fSyncMode) ? ProcessWriteSync() : ProcessWriteAsync();
+}
+
+int JackLoopbackDriver::ProcessReadSync()
+{
+ int res = 0;
+
// Loopback copy
for (int i = 0; i < fCaptureChannels; i++) {
memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize);
}
- fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); // Signal all clients
- if (fEngineControl->fSyncMode) {
- if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) {
- jack_error("JackLoopbackDriver::ProcessSync SuspendRefNum error");
- return -1;
- }
+ if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) {
+ jack_error("JackLoopbackDriver::ProcessReadSync - ResumeRefNum error");
+ res = -1;
+ }
+
+ return res;
+}
+
+int JackLoopbackDriver::ProcessWriteSync()
+{
+ if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) {
+ jack_error("JackLoopbackDriver::ProcessWriteSync SuspendRefNum error");
+ return -1;
+ }
+ return 0;
+}
+
+int JackLoopbackDriver::ProcessReadAsync()
+{
+ int res = 0;
+
+ // Loopback copy
+ for (int i = 0; i < fCaptureChannels; i++) {
+ memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize);
+ }
+
+ if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) {
+ jack_error("JackLoopbackDriver::ProcessReadAsync - ResumeRefNum error");
+ res = -1;
}
+
+ return res;
+}
+
+int JackLoopbackDriver::ProcessWriteAsync()
+{
return 0;
}
diff --git a/common/JackLoopbackDriver.h b/common/JackLoopbackDriver.h
index 5c542e3a..8fe22266 100644
--- a/common/JackLoopbackDriver.h
+++ b/common/JackLoopbackDriver.h
@@ -33,6 +33,14 @@ namespace Jack
class JackLoopbackDriver : public JackAudioDriver
{
+ private:
+
+ virtual int ProcessReadSync();
+ virtual int ProcessWriteSync();
+
+ virtual int ProcessReadAsync();
+ virtual int ProcessWriteAsync();
+
public:
JackLoopbackDriver(JackLockedEngine* engine, JackSynchro* table)
@@ -41,7 +49,8 @@ class JackLoopbackDriver : public JackAudioDriver
virtual ~JackLoopbackDriver()
{}
- int Process();
+ virtual int ProcessRead();
+ virtual int ProcessWrite();
};
} // end of namespace
diff --git a/common/JackMidiDriver.cpp b/common/JackMidiDriver.cpp
index a2fffa83..4de11989 100644
--- a/common/JackMidiDriver.cpp
+++ b/common/JackMidiDriver.cpp
@@ -164,12 +164,12 @@ int JackMidiDriver::ProcessReadSync()
// Read input buffers for the current cycle
if (Read() < 0) {
- jack_error("JackMidiDriver::ProcessSync: read error, skip cycle");
+ jack_error("JackMidiDriver::ProcessReadSync: read error, skip cycle");
res = -1;
}
if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) {
- jack_error("JackMidiDriver::ProcessSync - ResumeRefNum error");
+ jack_error("JackMidiDriver::ProcessReadSync - ResumeRefNum error");
res = -1;
}
@@ -183,13 +183,13 @@ int JackMidiDriver::ProcessWriteSync()
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable,
DRIVER_TIMEOUT_FACTOR *
fEngineControl->fTimeOutUsecs) < 0) {
- jack_error("JackMidiDriver::ProcessSync - SuspendRefNum error");
+ jack_error("JackMidiDriver::ProcessWriteSync - SuspendRefNum error");
res = -1;
}
// Write output buffers from the current cycle
if (Write() < 0) {
- jack_error("JackMidiDriver::ProcessSync - Write error");
+ jack_error("JackMidiDriver::ProcessWriteSync - Write error");
res = -1;
}
@@ -202,18 +202,18 @@ int JackMidiDriver::ProcessReadAsync()
// Read input buffers for the current cycle
if (Read() < 0) {
- jack_error("JackMidiDriver::ProcessAsync: read error, skip cycle");
+ jack_error("JackMidiDriver::ProcessReadAsync: read error, skip cycle");
res = -1;
}
// Write output buffers from the previous cycle
if (Write() < 0) {
- jack_error("JackMidiDriver::ProcessAsync - Write error");
+ jack_error("JackMidiDriver::ProcessReadAsync - Write error");
res = -1;
}
if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) {
- jack_error("JackMidiDriver::ProcessAsync - ResumeRefNum error");
+ jack_error("JackMidiDriver::ProcessReadAsync - ResumeRefNum error");
res = -1;
}