Commit b6962bd0 authored by sletz's avatar sletz
Browse files

Correct client time-out setting.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4759 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 41d8bd5b
......@@ -46,25 +46,20 @@ int JackAudioDriver::SetBufferSize(jack_nframes_t buffer_size)
// Update engine and graph manager state
fEngineControl->fBufferSize = buffer_size;
fGraphManager->SetBufferSize(buffer_size);
fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec
if (!fEngineControl->fTimeOut) {
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs);
}
fEngineControl->UpdateTimeOut();
UpdateLatencies();
// Redirect on slaves drivers...
// Redirected on slaves drivers...
return JackDriver::SetBufferSize(buffer_size);
}
int JackAudioDriver::SetSampleRate(jack_nframes_t sample_rate)
{
fEngineControl->fSampleRate = sample_rate;
fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec
if (!fEngineControl->fTimeOut) {
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs);
}
fEngineControl->UpdateTimeOut();
// Redirected on slaves drivers...
return JackDriver::SetSampleRate(sample_rate);
}
......
......@@ -129,10 +129,7 @@ int JackDriver::Open(bool capturing,
strcpy(fCaptureDriverName, capture_driver_name);
strcpy(fPlaybackDriverName, playback_driver_name);
fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec
if (!fEngineControl->fTimeOut) {
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs);
}
fEngineControl->UpdateTimeOut();
fGraphManager->DirectConnect(fClientControl.fRefNum, fClientControl.fRefNum); // Connect driver to itself for "sync" mode
SetupDriverSync(fClientControl.fRefNum, false);
......@@ -183,10 +180,7 @@ int JackDriver::Open(jack_nframes_t buffer_size,
strcpy(fCaptureDriverName, capture_driver_name);
strcpy(fPlaybackDriverName, playback_driver_name);
fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec
if (!fEngineControl->fTimeOut) {
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs);
}
fEngineControl->UpdateTimeOut();
fGraphManager->SetBufferSize(buffer_size);
fGraphManager->DirectConnect(fClientControl.fRefNum, fClientControl.fRefNum); // Connect driver to itself for "sync" mode
......
......@@ -176,7 +176,7 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
void CycleTakeEndTime();
void SetupDriverSync(int ref, bool freewheel);
void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs); // XRun notification sent by the driver
void NotifyBufferSize(jack_nframes_t buffer_size); // BufferSize notification sent by the driver
void NotifySampleRate(jack_nframes_t sample_rate); // SampleRate notification sent by the driver
......
......@@ -163,8 +163,9 @@ void JackEngine::ProcessNext(jack_time_t cur_cycle_begin)
void JackEngine::ProcessCurrent(jack_time_t cur_cycle_begin)
{
if (cur_cycle_begin < fLastSwitchUsecs + 2 * fEngineControl->fPeriodUsecs) // Signal XRun only for the first failing cycle
if (cur_cycle_begin < fLastSwitchUsecs + 2 * fEngineControl->fPeriodUsecs) { // Signal XRun only for the first failing cycle
CheckXRun(cur_cycle_begin);
}
fGraphManager->RunCurrentGraph();
}
......@@ -265,10 +266,12 @@ void JackEngine::NotifyClient(int refnum, int event, int sync, const char* messa
Important for internal clients : unlock before calling the notification callbacks.
*/
bool res = Unlock();
if (client->ClientNotify(refnum, client->GetClientControl()->fName, event, sync, message, value1, value2) < 0)
if (client->ClientNotify(refnum, client->GetClientControl()->fName, event, sync, message, value1, value2) < 0) {
jack_error("NotifyClient fails name = %s event = %ld val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2);
if (res)
}
if (res) {
Lock();
}
} else {
jack_log("JackEngine::NotifyClient: no callback for event = %ld", event);
......@@ -508,13 +511,15 @@ bool JackEngine::ClientCheckName(const char* name)
{
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && (strcmp(client->GetClientControl()->fName, name) == 0))
if (client && (strcmp(client->GetClientControl()->fName, name) == 0)) {
return true;
}
}
for (std::map<int,std::string>::iterator i = fReservationMap.begin(); i != fReservationMap.end(); i++) {
if (i->second == name)
if (i->second == name) {
return true;
}
}
return false;
......@@ -527,8 +532,9 @@ int JackEngine::GetNewUUID()
void JackEngine::EnsureUUID(int uuid)
{
if (uuid > fMaxUUID)
fMaxUUID = uuid+1;
if (uuid > fMaxUUID) {
fMaxUUID = uuid + 1;
}
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
......@@ -542,8 +548,9 @@ int JackEngine::GetClientPID(const char* name)
{
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && (strcmp(client->GetClientControl()->fName, name) == 0))
if (client && (strcmp(client->GetClientControl()->fName, name) == 0)) {
return client->GetClientControl()->fPID;
}
}
return 0;
......@@ -553,8 +560,9 @@ int JackEngine::GetClientRefNum(const char* name)
{
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && (strcmp(client->GetClientControl()->fName, name) == 0))
if (client && (strcmp(client->GetClientControl()->fName, name) == 0)) {
return client->GetClientControl()->fRefNum;
}
}
return -1;
......
......@@ -124,6 +124,14 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem
~JackEngineControl()
{}
void UpdateTimeOut()
{
fPeriodUsecs = jack_time_t(1000000.f / fSampleRate * fBufferSize); // In microsec
if (!(fTimeOut && fTimeOutUsecs > 2 * fPeriodUsecs)) {
fTimeOutUsecs = 2 * fPeriodUsecs;
}
}
// Cycle
void CycleIncTime(jack_time_t callback_usecs)
......
......@@ -136,6 +136,8 @@ int JackMidiDriver::SetBufferSize(jack_nframes_t buffer_size)
int JackMidiDriver::ProcessReadSync()
{
int res = 0;
jack_log("JackMidiDriver::ProcessReadSync");
// Read input buffers for the current cycle
if (Read() < 0) {
......@@ -154,6 +156,8 @@ int JackMidiDriver::ProcessReadSync()
int JackMidiDriver::ProcessWriteSync()
{
int res = 0;
jack_log("JackMidiDriver::ProcessWriteSync");
if (SuspendRefNum() < 0) {
jack_error("JackMidiDriver::ProcessWriteSync: SuspendRefNum error");
......@@ -172,6 +176,8 @@ int JackMidiDriver::ProcessWriteSync()
int JackMidiDriver::ProcessReadAsync()
{
int res = 0;
jack_log("JackMidiDriver::ProcessReadAsync");
// Read input buffers for the current cycle
if (Read() < 0) {
......@@ -195,6 +201,7 @@ int JackMidiDriver::ProcessReadAsync()
int JackMidiDriver::ProcessWriteAsync()
{
jack_log("JackMidiDriver::ProcessWriteAsync");
return 0;
}
......
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