Commit 47cac76e authored by sletz's avatar sletz
Browse files

Add TimeCallback in JackDebugClient class.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1886 0c269be4-1314-0410-8aa9-9f06e86f4224
parent a333a9ed
......@@ -50,7 +50,8 @@ typedef void (*JackShutdownCallback)(void *arg);
class JackClient : public JackClientInterface, public JackRunnableInterface
{
friend class JackDebugClient;
protected:
JackProcessCallback fProcess;
......
......@@ -18,7 +18,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "JackDebugClient.h"
#include "JackEngineControl.h"
#include "JackError.h"
#include "JackTime.h"
#include <iostream>
#include <iomanip>
#include <sstream>
......@@ -438,10 +440,24 @@ void JackDebugClient::OnShutdown(JackShutdownCallback callback, void *arg)
fClient->OnShutdown(callback, arg);
}
int JackDebugClient::TimeCallback(jack_nframes_t nframes, void *arg)
{
JackDebugClient* client = (JackDebugClient*)arg;
jack_time_t t1 = GetMicroSeconds();
int res = client->fProcessTimeCallback(nframes, client->fProcessTimeCallbackArg);
jack_time_t t2 = GetMicroSeconds();
long delta = long((t2 - t1) - client->GetEngineControl()->fPeriodUsecs);
if (delta > 0)
*client->fStream << "!!! ERROR !!! : XRun of " << delta << " us" << endl;
return res;
}
int JackDebugClient::SetProcessCallback(JackProcessCallback callback, void *arg)
{
CheckClient();
return fClient->SetProcessCallback(callback, arg);
fProcessTimeCallback = callback;
fProcessTimeCallbackArg = arg;
return fClient->SetProcessCallback(TimeCallback, this);
}
int JackDebugClient::SetXRunCallback(JackXRunCallback callback, void *arg)
......
......@@ -45,23 +45,22 @@ PortFollower;
/*!
\brief A "decorator" debug client to validate API use.
*/
class JackDebugClient : public JackClient
{
private:
JackClient* fClient;
std::ofstream* fStream;
protected:
PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned...
JackClient* fClient;
std::ofstream* fStream;
PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned...
int fTotalPortNumber; // The total number of port opened and maybe closed. Historical view.
int fOpenPortNumber; // The current number of opened port.
int fIsActivated;
int fIsDeactivated;
int fIsClosed;
char fClientName[JACK_CLIENT_NAME_SIZE];
JackProcessCallback fProcessTimeCallback;
void* fProcessTimeCallbackArg;
public:
......@@ -131,9 +130,9 @@ class JackDebugClient : public JackClient
jack_nframes_t Wait(int status);
JackClientControl* GetClientControl() const;
void CheckClient() const;
static int JackDebugClient::TimeCallback(jack_nframes_t nframes, void *arg);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment