JackWaitThreadedDriver now always running RT.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4523 0c269be4-1314-0410-8aa9-9f06e86f4224
This commit is contained in:
sletz 2011-07-30 06:43:23 +00:00
parent 5a5cc73ac7
commit 7918f1c12a
5 changed files with 28 additions and 34 deletions

View File

@ -41,8 +41,6 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
int ProcessGraphSyncMaster();
int ProcessGraphSyncSlave();
// void WaitUntilNextCycle();
virtual int ProcessAsync();
virtual int ProcessSync();
@ -94,7 +92,7 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
jack_nframes_t playback_latency);
virtual int Process();
virtual int Attach();
virtual int Detach();

View File

@ -140,7 +140,6 @@ void JackEngine::ProcessNext(jack_time_t cur_cycle_begin)
fLastSwitchUsecs = cur_cycle_begin;
if (fGraphManager->RunNextGraph()) { // True if the graph actually switched to a new state
fChannel.Notify(ALL_CLIENTS, kGraphOrderCallback, 0);
//NotifyGraphReorder();
}
fSignal.Signal(); // Signal for threads waiting for next cycle
}
@ -198,13 +197,11 @@ void JackEngine::CheckXRun(jack_time_t callback_usecs) // REVOIR les conditions
if (status != NotTriggered && status != Finished) {
jack_error("JackEngine::XRun: client = %s was not run: state = %ld", client->GetClientControl()->fName, status);
fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients
//NotifyXRun(ALL_CLIENTS);
}
if (status == Finished && (long)(finished_date - callback_usecs) > 0) {
jack_error("JackEngine::XRun: client %s finished after current callback", client->GetClientControl()->fName);
fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients
//NotifyXRun(ALL_CLIENTS);
}
}
}
@ -307,7 +304,6 @@ void JackEngine::NotifyXRun(jack_time_t callback_usecs, float delayed_usecs)
// Use the audio thread => request thread communication channel
fEngineControl->NotifyXRun(callback_usecs, delayed_usecs);
fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0);
//NotifyXRun(ALL_CLIENTS);
}
void JackEngine::NotifyXRun(int refnum)

View File

@ -224,22 +224,30 @@ bool JackThreadedDriver::Execute()
bool JackThreadedDriver::Init()
{
if (fDriver->Initialize()) {
if (fDriver->IsRealTime()) {
jack_log("JackThreadedDriver::Init IsRealTime");
// Will do "something" on OSX only...
GetEngineControl()->fPeriod = GetEngineControl()->fConstraint = GetEngineControl()->fPeriodUsecs * 1000;
GetEngineControl()->fComputation = JackTools::ComputationMicroSec(GetEngineControl()->fBufferSize) * 1000;
fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint);
if (fThread.AcquireSelfRealTime(GetEngineControl()->fServerPriority) < 0) {
jack_error("AcquireSelfRealTime error");
} else {
set_threaded_log_function();
}
}
SetRealTime();
return true;
} else {
return false;
}
}
void JackThreadedDriver::SetRealTime()
{
if (fDriver->IsRealTime()) {
jack_log("JackThreadedDriver::Init real-time");
// Will do "something" on OSX only...
GetEngineControl()->fPeriod = GetEngineControl()->fConstraint = GetEngineControl()->fPeriodUsecs * 1000;
GetEngineControl()->fComputation = JackTools::ComputationMicroSec(GetEngineControl()->fBufferSize) * 1000;
fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint);
if (fThread.AcquireSelfRealTime(GetEngineControl()->fServerPriority) < 0) {
jack_error("AcquireSelfRealTime error");
} else {
set_threaded_log_function();
}
} else {
jack_log("JackThreadedDriver::Init non non-realtime ");
}
}
} // end of namespace

View File

@ -39,6 +39,8 @@ class SERVER_EXPORT JackThreadedDriver : public JackDriverClientInterface, publi
JackThread fThread;
JackDriver* fDriver;
void SetRealTime();
public:
JackThreadedDriver(JackDriver* driver);
@ -72,7 +74,7 @@ class SERVER_EXPORT JackThreadedDriver : public JackDriverClientInterface, publi
virtual int Close();
virtual int Process();
virtual int Attach();
virtual int Detach();

View File

@ -38,6 +38,9 @@ bool JackWaitThreadedDriver::Init()
bool JackWaitThreadedDriver::Execute()
{
try {
SetRealTime();
// Process a null cycle until NetDriver has started
while (!fStarter.fRunning && fThread.GetStatus() == JackThread::kRunning) {
// Use the base method
@ -45,24 +48,11 @@ bool JackWaitThreadedDriver::Execute()
static_cast<JackTimedDriver*>(fDriver)->ProcessNull();
}
// Set RT
if (fDriver->IsRealTime()) {
jack_log("JackWaitThreadedDriver::Init IsRealTime");
// Will do "something" on OSX only...
GetEngineControl()->fPeriod = GetEngineControl()->fConstraint = GetEngineControl()->fPeriodUsecs * 1000;
GetEngineControl()->fComputation = JackTools::ComputationMicroSec(GetEngineControl()->fBufferSize) * 1000;
fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint);
if (fThread.AcquireSelfRealTime(GetEngineControl()->fServerPriority) < 0) {
jack_error("AcquireSelfRealTime error");
} else {
set_threaded_log_function();
}
}
// Switch to keep running even in case of error
while (fThread.GetStatus() == JackThread::kRunning) {
fDriver->Process();
}
return false;
} catch (JackNetException& e) {