WiP: small refactor in sysmgr init procedure

WiP: added filling audio buffers
This commit is contained in:
Mati committed 2019-08-07 19:41:08 +02:00
1 parent 0557c1d4f7
commit 21fff20088
5 files changed
+78 -87

No files matched your search

+12 -15
View File
@@ -42,7 +42,7 @@ namespace sys
InitHandler();
if(userInit){
userInit(this);
userInit();
}
while (enableRunLoop) {
@@ -55,10 +55,12 @@ namespace sys
EndScheduler();
}
void SystemManager::StartSystem()
void SystemManager::StartSystem(std::function<int()> init)
{
LogOutput::Output("Initializing system...");
userInit = init;
// Start System manager
StartService();
@@ -73,7 +75,7 @@ namespace sys
return true;
}
bool SystemManager::CreateService(std::shared_ptr<Service> service,Service* s,TickType_t timeout){
bool SystemManager::CreateService(std::shared_ptr<Service> service,Service* caller,TickType_t timeout){
CriticalSection::Enter();
@@ -83,7 +85,7 @@ namespace sys
service->StartService();
auto msg = std::make_shared<SystemMessage>(SystemMessageType::Start);
auto ret = Bus::SendUnicast(msg,service->GetName(),s,timeout);
auto ret = Bus::SendUnicast(msg,service->GetName(),caller,timeout);
auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);
if(ret.first == ReturnCodes::Success && (resp->retCode == ReturnCodes::Success)){
@@ -94,10 +96,10 @@ namespace sys
}
}
bool SystemManager::DestroyService(const std::string& name,Service* s,TickType_t timeout){
bool SystemManager::DestroyService(const std::string& name,Service* caller,TickType_t timeout){
auto msg = std::make_shared<SystemMessage>(SystemMessageType::Exit);
auto ret = Bus::SendUnicast(msg,name,s,timeout);
auto ret = Bus::SendUnicast(msg,name,caller,timeout);
auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);
if(ret.first == ReturnCodes::Success && (resp->retCode == ReturnCodes::Success)){
@@ -119,10 +121,10 @@ namespace sys
}
}
bool SystemManager::SuspendService(const std::string& name,Service* s,TickType_t timeout){
bool SystemManager::SuspendService(const std::string& name,Service* caller,TickType_t timeout){
auto msg = std::make_shared<SystemMessage>(SystemMessageType::GoSleep);
auto ret = Bus::SendUnicast(msg,name,s,timeout);
auto ret = Bus::SendUnicast(msg,name,caller,timeout);
auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);
if(ret.first == ReturnCodes::Success && (resp->retCode == ReturnCodes::Success)){
@@ -133,10 +135,10 @@ namespace sys
}
}
bool SystemManager::ResumeService(const std::string& name,Service* s,TickType_t timeout){
bool SystemManager::ResumeService(const std::string& name,Service* caller,TickType_t timeout){
auto msg = std::make_shared<SystemMessage>(SystemMessageType::Wakeup);
auto ret = Bus::SendUnicast(msg,name,s,timeout);
auto ret = Bus::SendUnicast(msg,name,caller,timeout);
auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);
if(ret.first == ReturnCodes::Success && (resp->retCode == ReturnCodes::Success)){
@@ -147,11 +149,6 @@ namespace sys
}
}
void SystemManager::RegisterInitFunction(std::function<int(SystemManager* sysmgr)> init)
{
userInit = init;
}
ReturnCodes SystemManager::InitHandler(){
isReady = true;
return ReturnCodes ::Success;