Commit 62abf3f7 authored by Devin Anderson's avatar Devin Anderson
Browse files

Make freewheel driver 'Start()', 'Process()', etc. methods called via the...

Make freewheel driver 'Start()', 'Process()', etc. methods called via the freewheel driver object when freewheel mode is off, and via the threaded driver wrapper when freewheel mode is on.
parent db132e19
...@@ -324,7 +324,9 @@ int JackDriver::Write() ...@@ -324,7 +324,9 @@ int JackDriver::Write()
int JackDriver::Start() int JackDriver::Start()
{ {
fEngineControl->InitFrameTime(); if (fIsMaster) {
fEngineControl->InitFrameTime();
}
return 0; return 0;
} }
......
...@@ -49,7 +49,16 @@ JackServer::JackServer(bool sync, bool temporary, int timeout, bool rt, int prio ...@@ -49,7 +49,16 @@ JackServer::JackServer(bool sync, bool temporary, int timeout, bool rt, int prio
fGraphManager = JackGraphManager::Allocate(port_max); fGraphManager = JackGraphManager::Allocate(port_max);
fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose, clock, server_name); fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose, clock, server_name);
fEngine = new JackLockedEngine(fGraphManager, GetSynchroTable(), fEngineControl); fEngine = new JackLockedEngine(fGraphManager, GetSynchroTable(), fEngineControl);
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver(fEngine, GetSynchroTable()));
// A distinction is made between the threaded freewheel driver and the
// regular freewheel driver because the freewheel driver needs to run in
// threaded mode when freewheel mode is active and needs to run as a slave
// when freewheel mode isn't active.
JackFreewheelDriver *freewheelDriver =
new JackFreewheelDriver(fEngine, GetSynchroTable());
fThreadedFreewheelDriver = new JackThreadedDriver(freewheelDriver);
fFreewheelDriver = freewheelDriver;
fDriverInfo = new JackDriverInfo(); fDriverInfo = new JackDriverInfo();
fAudioDriver = NULL; fAudioDriver = NULL;
fFreewheel = false; fFreewheel = false;
...@@ -62,7 +71,7 @@ JackServer::~JackServer() ...@@ -62,7 +71,7 @@ JackServer::~JackServer()
{ {
JackGraphManager::Destroy(fGraphManager); JackGraphManager::Destroy(fGraphManager);
delete fDriverInfo; delete fDriverInfo;
delete fFreewheelDriver; delete fThreadedFreewheelDriver;
delete fEngine; delete fEngine;
delete fEngineControl; delete fEngineControl;
} }
...@@ -87,18 +96,26 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params) ...@@ -87,18 +96,26 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params)
goto fail_close3; goto fail_close3;
} }
if (fFreewheelDriver->Open() < 0) {
jack_error("Cannot open freewheel driver");
goto fail_close4;
}
if (fAudioDriver->Attach() < 0) { if (fAudioDriver->Attach() < 0) {
jack_error("Cannot attach audio driver"); jack_error("Cannot attach audio driver");
goto fail_close4; goto fail_close5;
} }
fFreewheelDriver->SetMaster(false); fFreewheelDriver->SetMaster(false);
fAudioDriver->SetMaster(true); fAudioDriver->SetMaster(true);
//fAudioDriver->AddSlave(fFreewheelDriver); fAudioDriver->AddSlave(fFreewheelDriver);
InitTime(); InitTime();
SetClockSource(fEngineControl->fClockSource); SetClockSource(fEngineControl->fClockSource);
return 0; return 0;
fail_close5:
fFreewheelDriver->Close();
fail_close4: fail_close4:
fEngine->Close(); fEngine->Close();
...@@ -120,9 +137,7 @@ int JackServer::Close() ...@@ -120,9 +137,7 @@ int JackServer::Close()
fChannel.Close(); fChannel.Close();
fAudioDriver->Detach(); fAudioDriver->Detach();
fAudioDriver->Close(); fAudioDriver->Close();
if (fFreewheel) { fFreewheelDriver->Close();
fFreewheelDriver->Close();
}
fEngine->Close(); fEngine->Close();
// TODO: move that in reworked JackServerGlobals::Destroy() // TODO: move that in reworked JackServerGlobals::Destroy()
JackMessageBuffer::Destroy(); JackMessageBuffer::Destroy();
...@@ -231,11 +246,11 @@ int JackServer::SetFreewheel(bool onoff) ...@@ -231,11 +246,11 @@ int JackServer::SetFreewheel(bool onoff)
return -1; return -1;
} else { } else {
fFreewheel = false; fFreewheel = false;
fFreewheelDriver->Stop(); fThreadedFreewheelDriver->Stop();
fFreewheelDriver->Close();
fGraphManager->Restore(&fConnectionState); // Restore previous connection state fGraphManager->Restore(&fConnectionState); // Restore previous connection state
fEngine->NotifyFreewheel(onoff); fEngine->NotifyFreewheel(onoff);
fFreewheelDriver->SetMaster(false); fFreewheelDriver->SetMaster(false);
fAudioDriver->SetMaster(true);
return fAudioDriver->Start(); return fAudioDriver->Start();
} }
} else { } else {
...@@ -245,12 +260,9 @@ int JackServer::SetFreewheel(bool onoff) ...@@ -245,12 +260,9 @@ int JackServer::SetFreewheel(bool onoff)
fGraphManager->Save(&fConnectionState); // Save connection state fGraphManager->Save(&fConnectionState); // Save connection state
fGraphManager->DisconnectAllPorts(fAudioDriver->GetClientControl()->fRefNum); fGraphManager->DisconnectAllPorts(fAudioDriver->GetClientControl()->fRefNum);
fEngine->NotifyFreewheel(onoff); fEngine->NotifyFreewheel(onoff);
if (fFreewheelDriver->Open() < 0) { fAudioDriver->SetMaster(false);
jack_error("Cannot open freewheel driver");
return -1;
}
fFreewheelDriver->SetMaster(true); fFreewheelDriver->SetMaster(true);
return fFreewheelDriver->Start(); return fThreadedFreewheelDriver->Start();
} else { } else {
return -1; return -1;
} }
......
...@@ -50,6 +50,7 @@ class SERVER_EXPORT JackServer ...@@ -50,6 +50,7 @@ class SERVER_EXPORT JackServer
JackDriverInfo* fDriverInfo; JackDriverInfo* fDriverInfo;
JackDriverClientInterface* fAudioDriver; JackDriverClientInterface* fAudioDriver;
JackDriverClientInterface* fFreewheelDriver; JackDriverClientInterface* fFreewheelDriver;
JackDriverClientInterface* fThreadedFreewheelDriver;
JackLockedEngine* fEngine; JackLockedEngine* fEngine;
JackEngineControl* fEngineControl; JackEngineControl* fEngineControl;
JackGraphManager* fGraphManager; JackGraphManager* fGraphManager;
......
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