Commit 64928200 authored by sletz's avatar sletz
Browse files

Cleanup in JackTransportEngine, move some code that was in JackClient class.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2700 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 068e599f
......@@ -24,6 +24,7 @@ Romain Moret
2008-07-18 Stephane Letz <letz@grame.fr>
* Correct audioadapter when a sample rate value different from jack server one is chosen.
* Cleanup in JackTransportEngine, move some code that was in JackClient class.
2008-07-12 Stephane Letz <letz@grame.fr>
......
......@@ -1427,7 +1427,8 @@ EXPORT int jack_transport_locate(jack_client_t* ext_client, jack_nframes_t frame
jack_error("jack_transport_locate called with a NULL client");
return -1;
} else {
return client->TransportLocate(frame);
client->TransportLocate(frame);
return 0;
}
}
......@@ -1469,7 +1470,8 @@ EXPORT int jack_transport_reposition(jack_client_t* ext_client, jack_position_t*
jack_error("jack_transport_reposition called with a NULL client");
return -1;
} else {
return client->TransportReposition(pos);
client->TransportReposition(pos);
return 0;
}
}
......
......@@ -637,38 +637,31 @@ int JackClient::SetTimebaseCallback(int conditional, JackTimebaseCallback timeba
}
// Must be RT safe
int JackClient::RequestNewPos(jack_position_t* pos)
{
JackTransportEngine& transport = GetEngineControl()->fTransport;
jack_position_t* request = transport.WriteNextStateStart(2);
pos->unique_1 = pos->unique_2 = transport.GenerateUniqueID();
JackTransportEngine::TransportCopyPosition(pos, request);
jack_log("RequestNewPos pos = %ld", pos->frame);
transport.WriteNextStateStop(2);
return 0;
}
int JackClient::TransportLocate(jack_nframes_t frame)
void JackClient::TransportLocate(jack_nframes_t frame)
{
jack_position_t pos;
pos.frame = frame;
pos.valid = (jack_position_bits_t)0;
jack_log("TransportLocate pos = %ld", pos.frame);
return RequestNewPos(&pos);
GetEngineControl()->fTransport.RequestNewPos(&pos);
}
int JackClient::TransportReposition(jack_position_t* pos)
{
jack_position_t tmp = *pos;
jack_log("TransportReposition pos = %ld", pos->frame);
return (tmp.valid & ~JACK_POSITION_MASK) ? EINVAL : RequestNewPos(&tmp);
if (tmp.valid & ~JACK_POSITION_MASK) {
return EINVAL;
} else {
GetEngineControl()->fTransport.RequestNewPos(pos);
return 0;
}
}
jack_transport_state_t JackClient::TransportQuery(jack_position_t* pos)
{
if (pos)
GetEngineControl()->fTransport.ReadCurrentPos(pos);
return GetEngineControl()->fTransport.GetState();
return GetEngineControl()->fTransport.Query(pos);
}
jack_nframes_t JackClient::GetCurrentTransportFrame()
......
......@@ -97,8 +97,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
void CallSyncCallback();
void CallTimebaseCallback();
int RequestNewPos(jack_position_t* pos);
virtual int ClientNotifyImp(int refnum, const char* name, int notify, int sync, int value1, int value);
// Fons Adriaensen thread model
......@@ -149,7 +148,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
virtual int SetSyncCallback(JackSyncCallback sync_callback, void* arg);
virtual int SetSyncTimeout(jack_time_t timeout);
virtual int SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg);
virtual int TransportLocate(jack_nframes_t frame);
virtual void TransportLocate(jack_nframes_t frame);
virtual jack_transport_state_t TransportQuery(jack_position_t* pos);
virtual jack_nframes_t GetCurrentTransportFrame();
virtual int TransportReposition(jack_position_t* pos);
......
......@@ -374,10 +374,10 @@ int JackDebugClient::SetTimebaseCallback(int conditional, JackTimebaseCallback t
return fClient->SetTimebaseCallback( conditional, timebase_callback, arg);
}
int JackDebugClient::TransportLocate(jack_nframes_t frame)
void JackDebugClient::TransportLocate(jack_nframes_t frame)
{
CheckClient();
return fClient->TransportLocate(frame);
fClient->TransportLocate(frame);
}
jack_transport_state_t JackDebugClient::TransportQuery(jack_position_t* pos)
......
......@@ -101,7 +101,7 @@ class JackDebugClient : public JackClient
int SetSyncCallback(JackSyncCallback sync_callback, void* arg);
int SetSyncTimeout(jack_time_t timeout);
int SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg);
int TransportLocate(jack_nframes_t frame);
void TransportLocate(jack_nframes_t frame);
jack_transport_state_t TransportQuery(jack_position_t* pos);
jack_nframes_t GetCurrentTransportFrame();
int TransportReposition(jack_position_t* pos);
......
......@@ -245,6 +245,22 @@ void JackTransportEngine::ReadCurrentPos(jack_position_t* pos)
} while (cur_index != next_index); // Until a coherent state has been read
}
void JackTransportEngine::RequestNewPos(jack_position_t* pos)
{
jack_position_t* request = WriteNextStateStart(2);
pos->unique_1 = pos->unique_2 = GenerateUniqueID();
TransportCopyPosition(pos, request);
jack_log("RequestNewPos pos = %ld", pos->frame);
WriteNextStateStop(2);
}
jack_transport_state_t JackTransportEngine::Query(jack_position_t* pos)
{
if (pos)
ReadCurrentPos(pos);
return GetState();
}
// RT, client
void JackTransportEngine::TransportCopyPosition(jack_position_t* from, jack_position_t* to)
{
......
......@@ -166,6 +166,10 @@ class EXPORT JackTransportEngine : public JackAtomicArrayState<jack_position_t>
{
return (jack_unique_t)INC_ATOMIC(&fWriteCounter);
}
void RequestNewPos(jack_position_t* pos);
jack_transport_state_t Query(jack_position_t* pos);
static void TransportCopyPosition(jack_position_t* from, jack_position_t* to);
......
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