| @@ -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 | |||
| @@ -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; | |||
| } | |||
| @@ -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 | |||
| @@ -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; | |||
| } | |||