git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4645 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.8
| @@ -226,16 +226,6 @@ int JackAudioDriver::Process() | |||||
| return (fEngineControl->fSyncMode) ? ProcessSync() : ProcessAsync(); | 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 | 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. | synchronize to the end of client graph execution. | ||||
| @@ -263,22 +253,43 @@ int JackAudioDriver::ProcessAsync() | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| void JackAudioDriver::ProcessGraphSync() | |||||
| void JackAudioDriver::ProcessGraphAsync() | |||||
| { | { | ||||
| // Process graph | // Process graph | ||||
| if (fIsMaster) { | if (fIsMaster) { | ||||
| if (ProcessGraphSyncMaster() < 0) { | |||||
| //jack_error("JackAudioDriver::ProcessSync: process error, skip cycle..."); | |||||
| //goto end; | |||||
| } | |||||
| ProcessGraphAsyncMaster(); | |||||
| } else { | } 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, | The driver SYNC mode: the server does synchronize to the end of client graph execution, | ||||
| @@ -307,85 +318,48 @@ int JackAudioDriver::ProcessSync() | |||||
| return 0; | 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 | // fBeginDateUst is set in the "low level" layer, fEndDateUst is from previous cycle | ||||
| if (fEngine->Process(fBeginDateUst, fEndDateUst)) { | if (fEngine->Process(fBeginDateUst, fEndDateUst)) { | ||||
| if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { | if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) { | ||||
| jack_error("JackAudioDriver::ProcessGraphSyncMaster: ResumeRefNum error"); | jack_error("JackAudioDriver::ProcessGraphSyncMaster: ResumeRefNum error"); | ||||
| res = -1; | |||||
| } | } | ||||
| if (ProcessReadSlaves() < 0) { | if (ProcessReadSlaves() < 0) { | ||||
| jack_error("JackAudioDriver::ProcessGraphSync: ProcessReadSlaves error, engine may now behave abnormally!!"); | jack_error("JackAudioDriver::ProcessGraphSync: ProcessReadSlaves error, engine may now behave abnormally!!"); | ||||
| res = -1; | |||||
| } | } | ||||
| if (ProcessWriteSlaves() < 0) { | if (ProcessWriteSlaves() < 0) { | ||||
| jack_error("JackAudioDriver::ProcessGraphSync: ProcessWriteSlaves error, engine may now behave abnormally!!"); | 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) { | if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) { | ||||
| jack_error("JackAudioDriver::ProcessGraphSync: SuspendRefNum error, engine may now behave abnormally!!"); | jack_error("JackAudioDriver::ProcessGraphSync: SuspendRefNum error, engine may now behave abnormally!!"); | ||||
| res = -1; | |||||
| } | } | ||||
| } else { // Graph not finished: do not activate it | } else { // Graph not finished: do not activate it | ||||
| jack_error("JackAudioDriver::ProcessGraphSync: Process error"); | 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) | jack_default_audio_sample_t* JackAudioDriver::GetInputBuffer(int port_index) | ||||
| @@ -49,8 +49,8 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver | |||||
| int ProcessSync(); | int ProcessSync(); | ||||
| void ProcessGraphSync(); | void ProcessGraphSync(); | ||||
| int ProcessGraphSyncMaster(); | |||||
| int ProcessGraphSyncSlave(); | |||||
| void ProcessGraphSyncMaster(); | |||||
| void ProcessGraphSyncSlave(); | |||||
| public: | public: | ||||
| @@ -84,9 +84,6 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver | |||||
| virtual int Attach(); | virtual int Attach(); | ||||
| virtual int Detach(); | virtual int Detach(); | ||||
| virtual int Start(); | |||||
| virtual int Stop(); | |||||
| virtual int Write(); | virtual int Write(); | ||||
| virtual int SetBufferSize(jack_nframes_t buffer_size); | virtual int SetBufferSize(jack_nframes_t buffer_size); | ||||
| @@ -343,10 +343,30 @@ int JackDriver::ProcessWriteSlaves() | |||||
| int JackDriver::ProcessRead() | int JackDriver::ProcessRead() | ||||
| { | { | ||||
| return 0; | |||||
| return (fEngineControl->fSyncMode) ? ProcessReadSync() : ProcessReadAsync(); | |||||
| } | } | ||||
| int JackDriver::ProcessWrite() | 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; | return 0; | ||||
| } | } | ||||
| @@ -382,13 +402,13 @@ int JackDriver::Start() | |||||
| fEngineControl->InitFrameTime(); | fEngineControl->InitFrameTime(); | ||||
| } | } | ||||
| fIsRunning = true; | fIsRunning = true; | ||||
| return 0; | |||||
| return StartSlaves(); | |||||
| } | } | ||||
| int JackDriver::Stop() | int JackDriver::Stop() | ||||
| { | { | ||||
| fIsRunning = false; | fIsRunning = false; | ||||
| return 0; | |||||
| return StopSlaves(); | |||||
| } | } | ||||
| int JackDriver::StartSlaves() | int JackDriver::StartSlaves() | ||||
| @@ -97,12 +97,20 @@ class SERVER_EXPORT JackDriverInterface | |||||
| virtual std::list<JackDriverInterface*> GetSlaves() = 0; | virtual std::list<JackDriverInterface*> GetSlaves() = 0; | ||||
| // For "master" driver | |||||
| virtual int ProcessReadSlaves() = 0; | virtual int ProcessReadSlaves() = 0; | ||||
| virtual int ProcessWriteSlaves() = 0; | virtual int ProcessWriteSlaves() = 0; | ||||
| // For "slave" driver | |||||
| virtual int ProcessRead() = 0; | virtual int ProcessRead() = 0; | ||||
| virtual int ProcessWrite() = 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 IsRealTime() const = 0; | ||||
| virtual bool IsRunning() 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 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 | 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: | public: | ||||
| JackDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table); | 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(); | ||||
| virtual int Open (bool capturing, | |||||
| virtual int Open(bool capturing, | |||||
| bool playing, | bool playing, | ||||
| int inchannels, | int inchannels, | ||||
| int outchannels, | int outchannels, | ||||
| @@ -212,6 +226,7 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface | |||||
| const char* playback_driver_name, | const char* playback_driver_name, | ||||
| jack_nframes_t capture_latency, | jack_nframes_t capture_latency, | ||||
| jack_nframes_t playback_latency); | jack_nframes_t playback_latency); | ||||
| virtual int Close(); | virtual int Close(); | ||||
| virtual int Process(); | virtual int Process(); | ||||
| @@ -225,17 +240,19 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface | |||||
| virtual int Start(); | virtual int Start(); | ||||
| virtual int Stop(); | virtual int Stop(); | ||||
| virtual int StartSlaves(); | |||||
| virtual int StopSlaves(); | |||||
| // For "master" driver | |||||
| int ProcessReadSlaves(); | int ProcessReadSlaves(); | ||||
| int ProcessWriteSlaves(); | int ProcessWriteSlaves(); | ||||
| // For "slave" driver | |||||
| int ProcessRead(); | int ProcessRead(); | ||||
| int ProcessWrite(); | int ProcessWrite(); | ||||
| virtual void SaveConnections(); | |||||
| virtual void RestoreConnections(); | |||||
| int ProcessReadSync(); | |||||
| int ProcessWriteSync(); | |||||
| int ProcessReadAsync(); | |||||
| int ProcessWriteAsync(); | |||||
| virtual bool IsFixedBufferSize(); | virtual bool IsFixedBufferSize(); | ||||
| virtual int SetBufferSize(jack_nframes_t buffer_size); | virtual int SetBufferSize(jack_nframes_t buffer_size); | ||||
| @@ -26,6 +26,8 @@ | |||||
| namespace Jack | namespace Jack | ||||
| { | { | ||||
| // When used in "master" mode | |||||
| int JackFreewheelDriver::Process() | int JackFreewheelDriver::Process() | ||||
| { | { | ||||
| int res = 0; | int res = 0; | ||||
| @@ -54,15 +56,7 @@ int JackFreewheelDriver::Process() | |||||
| return res; | 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() | int JackFreewheelDriver::ProcessReadSync() | ||||
| { | { | ||||
| @@ -47,9 +47,6 @@ class JackFreewheelDriver : public JackDriver | |||||
| int Process(); | int Process(); | ||||
| int ProcessRead(); | |||||
| int ProcessWrite(); | |||||
| int ProcessReadSync(); | int ProcessReadSync(); | ||||
| int ProcessWriteSync(); | int ProcessWriteSync(); | ||||
| @@ -30,15 +30,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| namespace Jack | 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() | int JackLoopbackDriver::ProcessReadSync() | ||||
| { | { | ||||
| @@ -48,9 +48,6 @@ class JackLoopbackDriver : public JackAudioDriver | |||||
| {} | {} | ||||
| virtual ~JackLoopbackDriver() | virtual ~JackLoopbackDriver() | ||||
| {} | {} | ||||
| virtual int ProcessRead(); | |||||
| virtual int ProcessWrite(); | |||||
| }; | }; | ||||
| } // end of namespace | } // end of namespace | ||||
| @@ -133,16 +133,6 @@ int JackMidiDriver::SetBufferSize(jack_nframes_t buffer_size) | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| int JackMidiDriver::ProcessRead() | |||||
| { | |||||
| return (fEngineControl->fSyncMode) ? ProcessReadSync() : ProcessReadAsync(); | |||||
| } | |||||
| int JackMidiDriver::ProcessWrite() | |||||
| { | |||||
| return (fEngineControl->fSyncMode) ? ProcessWriteSync() : ProcessWriteAsync(); | |||||
| } | |||||
| int JackMidiDriver::ProcessReadSync() | int JackMidiDriver::ProcessReadSync() | ||||
| { | { | ||||
| int res = 0; | int res = 0; | ||||
| @@ -65,9 +65,6 @@ class SERVER_EXPORT JackMidiDriver : public JackDriver | |||||
| virtual int SetBufferSize(jack_nframes_t buffer_size); | virtual int SetBufferSize(jack_nframes_t buffer_size); | ||||
| virtual int ProcessRead(); | |||||
| virtual int ProcessWrite(); | |||||
| virtual int Attach(); | virtual int Attach(); | ||||
| virtual int Detach(); | virtual int Detach(); | ||||
| @@ -55,7 +55,12 @@ int JackThreadedDriver::Open(jack_nframes_t buffer_size, | |||||
| jack_nframes_t capture_latency, | jack_nframes_t capture_latency, | ||||
| jack_nframes_t playback_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() | int JackThreadedDriver::Close() | ||||
| @@ -143,6 +148,26 @@ int JackThreadedDriver::ProcessWrite() | |||||
| return fDriver->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() | std::list<JackDriverInterface*> JackThreadedDriver::GetSlaves() | ||||
| { | { | ||||
| return fDriver->GetSlaves(); | return fDriver->GetSlaves(); | ||||
| @@ -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 | 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(); | ||||
| virtual int Open (bool capturing, | 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; | return -1; | ||||
| } | } | ||||
| @@ -102,6 +102,12 @@ class SERVER_EXPORT JackThreadedDriver : public JackDriverClientInterface, publi | |||||
| virtual int ProcessRead(); | virtual int ProcessRead(); | ||||
| virtual int ProcessWrite(); | 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 int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2); | ||||
| virtual JackClientControl* GetClientControl() const; | virtual JackClientControl* GetClientControl() const; | ||||
| virtual bool IsRealTime() const; | virtual bool IsRealTime() const; | ||||