git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3482 0c269be4-1314-0410-8aa9-9f06e86f4224tags/v1.9.3
@@ -18,12 +18,17 @@ Fernando Lopez-Lezcano | |||
Romain Moret | |||
Florian Faber | |||
Michael Voigt | |||
Torben Hohn | |||
Torben Hohn | |||
Paul Davis | |||
--------------------------- | |||
Jackdmp changes log | |||
--------------------------- | |||
2009-04-03 Stephane Letz <letz@grame.fr> | |||
* Simplify JackClient RT code, jack_thread_wait API marked deprecated." | |||
2009-03-29 Stephane Letz <letz@grame.fr> | |||
* Cleanup JackInternalClient code. | |||
@@ -842,7 +842,8 @@ EXPORT jack_nframes_t jack_thread_wait(jack_client_t* ext_client, int status) | |||
jack_error("jack_thread_wait called with a NULL client"); | |||
return 0; | |||
} else { | |||
return client->Wait(status); | |||
jack_error("jack_thread_wait: deprecated, use jack_cycle_wait/jack_cycle_signal"); | |||
return -1; | |||
} | |||
} | |||
@@ -355,6 +355,7 @@ int JackClient::StartThread() | |||
/*! | |||
\brief RT thread. | |||
*/ | |||
bool JackClient::Execute() | |||
{ | |||
if (!jack_tls_set(JackGlobals::fRealTime, this)) | |||
@@ -362,73 +363,59 @@ bool JackClient::Execute() | |||
if (GetEngineControl()->fRealTime) | |||
set_threaded_log_function(); | |||
// Execute a dummy cycle to be sure thread has the correct properties | |||
DummyCycle(); | |||
if (fThreadFun) { | |||
// Execute a dummy cycle to be sure thread has the correct properties (ensure thread creation is finished) | |||
WaitSync(); | |||
SignalSync(); | |||
fThreadFun(fThreadFunArg); | |||
} else { | |||
if (WaitFirstSync()) | |||
ExecuteThread(); | |||
ExecuteThread(); | |||
} | |||
return false; | |||
} | |||
inline bool JackClient::WaitFirstSync() | |||
void JackClient::DummyCycle() | |||
{ | |||
while (true) { | |||
// Start first cycle | |||
WaitSync(); | |||
if (IsActive()) { | |||
CallSyncCallback(); | |||
// Finish first cycle | |||
if (Wait(CallProcessCallback()) != GetEngineControl()->fBufferSize) | |||
return false; | |||
return true; | |||
} else { | |||
jack_log("Process called for an inactive client"); | |||
} | |||
SignalSync(); | |||
} | |||
return false; | |||
WaitSync(); | |||
SignalSync(); | |||
} | |||
inline void JackClient::ExecuteThread() | |||
{ | |||
while (Wait(CallProcessCallback()) == GetEngineControl()->fBufferSize); | |||
while (true) { | |||
CycleWaitAux(); | |||
CycleSignalAux(CallProcessCallback()); | |||
} | |||
} | |||
jack_nframes_t JackClient::Wait(int status) | |||
{ | |||
if (status == 0) | |||
CallTimebaseCallback(); | |||
SignalSync(); | |||
if (status != 0) | |||
End(); // Terminates the thread | |||
if (!WaitSync()) | |||
Error(); // Terminates the thread | |||
CallSyncCallback(); | |||
return GetEngineControl()->fBufferSize; | |||
} | |||
jack_nframes_t JackClient::CycleWait() | |||
inline jack_nframes_t JackClient::CycleWaitAux() | |||
{ | |||
if (!WaitSync()) | |||
Error(); // Terminates the thread | |||
CallSyncCallback(); | |||
CallSyncCallbackAux(); | |||
return GetEngineControl()->fBufferSize; | |||
} | |||
void JackClient::CycleSignal(int status) | |||
inline void JackClient::CycleSignalAux(int status) | |||
{ | |||
if (status == 0) | |||
CallTimebaseCallback(); | |||
CallTimebaseCallbackAux(); | |||
SignalSync(); | |||
if (status != 0) | |||
End(); // Terminates the thread | |||
} | |||
jack_nframes_t JackClient::CycleWait() | |||
{ | |||
return CycleWaitAux(); | |||
} | |||
void JackClient::CycleSignal(int status) | |||
{ | |||
CycleSignalAux(status); | |||
} | |||
inline int JackClient::CallProcessCallback() | |||
{ | |||
return (fProcess != NULL) ? fProcess(GetEngineControl()->fBufferSize, fProcessArg) : 0; | |||
@@ -696,7 +683,13 @@ void JackClient::TransportStop() | |||
// Never called concurently with the server | |||
// TODO check concurrency with SetSyncCallback | |||
void JackClient::CallSyncCallback() | |||
{ | |||
CallSyncCallbackAux(); | |||
} | |||
inline void JackClient::CallSyncCallbackAux() | |||
{ | |||
if (GetClientControl()->fTransportSync) { | |||
@@ -717,6 +710,11 @@ void JackClient::CallSyncCallback() | |||
} | |||
void JackClient::CallTimebaseCallback() | |||
{ | |||
CallTimebaseCallbackAux(); | |||
} | |||
inline void JackClient::CallTimebaseCallbackAux() | |||
{ | |||
JackTransportEngine& transport = GetEngineControl()->fTransport; | |||
int master; | |||
@@ -97,14 +97,18 @@ class JackClient : public JackClientInterface, public JackRunnableInterface | |||
virtual int ClientNotifyImp(int refnum, const char* name, int notify, int sync, int value1, int value); | |||
inline bool WaitFirstSync(); | |||
inline void DummyCycle(); | |||
inline void ExecuteThread(); | |||
inline bool WaitSync(); | |||
inline void SignalSync(); | |||
inline int CallProcessCallback(); | |||
inline void End(); | |||
inline void Error(); | |||
inline jack_nframes_t CycleWaitAux(); | |||
inline void CycleSignalAux(int status); | |||
inline void CallSyncCallbackAux(); | |||
inline void CallTimebaseCallbackAux(); | |||
public: | |||
JackClient(); | |||
@@ -172,10 +176,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface | |||
virtual int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va); | |||
virtual void InternalClientUnload(int ref, jack_status_t* status); | |||
// Fons Adriaensen thread model | |||
virtual jack_nframes_t Wait(int status); | |||
virtual jack_nframes_t CycleWait(); | |||
jack_nframes_t CycleWait(); | |||
void CycleSignal(int status); | |||
int SetProcessThread(JackThreadCallback fun, void *arg); | |||
@@ -521,11 +521,5 @@ void JackDebugClient::InternalClientUnload(int ref, jack_status_t* status) | |||
fClient->InternalClientUnload(ref, status); | |||
} | |||
jack_nframes_t JackDebugClient::Wait(int status) | |||
{ | |||
CheckClient(); | |||
return fClient->Wait(status); | |||
} | |||
} // end of namespace | |||
@@ -127,9 +127,6 @@ class JackDebugClient : public JackClient | |||
int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va); | |||
void InternalClientUnload(int ref, jack_status_t* status); | |||
// Fons Adriaensen thread model | |||
jack_nframes_t Wait(int status); | |||
JackClientControl* GetClientControl() const; | |||
void CheckClient() const; | |||
@@ -95,7 +95,7 @@ main (int argc, char *argv[]) | |||
int c; | |||
extern int optind, opterr; | |||
int show_usage = 0; | |||
char *optstring = "d:f"; | |||
char *optstring = "d:f:h"; | |||
struct option long_options[] = { | |||
{ "help", 1, 0, 'h' }, | |||
{ "duration", 1, 0, 'd' }, | |||