Don't wait for all responses of getStreamIdList() before invoking getStreamConfig(); similarly for devices too - this change should simplify session file open

This commit is contained in:
Srivats P 2016-04-26 20:23:50 +05:30
parent e75ed87dd7
commit 2426632055
2 changed files with 43 additions and 56 deletions

View File

@ -776,43 +776,35 @@ void PortGroup::processStreamIdList(int portIndex, PbRpcController *controller)
mPorts[portIndex]->insertStream(streamId); mPorts[portIndex]->insertStream(streamId);
} }
// Are we done for all ports? getStreamConfigList(portIndex);
if (numPorts() && portIndex >= (numPorts()-1))
{
// FIXME(HI): some way to reset streammodel
getStreamConfigList();
}
_exit: _exit:
delete controller; delete controller;
} }
void PortGroup::getStreamConfigList() void PortGroup::getStreamConfigList(int portIndex)
{ {
qDebug("requesting stream config list ..."); if (mPorts[portIndex]->numStreams() == 0)
return;
for (int portIndex = 0; portIndex < numPorts(); portIndex++) qDebug("requesting stream config list (port %d)...", portIndex);
OstProto::StreamIdList *streamIdList = new OstProto::StreamIdList;
OstProto::StreamConfigList *streamConfigList
= new OstProto::StreamConfigList;
PbRpcController *controller = new PbRpcController(
streamIdList, streamConfigList);
streamIdList->mutable_port_id()->set_id(mPorts[portIndex]->id());
for (int j = 0; j < mPorts[portIndex]->numStreams(); j++)
{ {
if (mPorts[portIndex]->numStreams() == 0) OstProto::StreamId *s = streamIdList->add_stream_id();
continue; s->set_id(mPorts[portIndex]->streamByIndex(j)->id());
OstProto::StreamIdList *streamIdList = new OstProto::StreamIdList;
OstProto::StreamConfigList *streamConfigList
= new OstProto::StreamConfigList;
PbRpcController *controller = new PbRpcController(
streamIdList, streamConfigList);
streamIdList->mutable_port_id()->set_id(mPorts[portIndex]->id());
for (int j = 0; j < mPorts[portIndex]->numStreams(); j++)
{
OstProto::StreamId *s = streamIdList->add_stream_id();
s->set_id(mPorts[portIndex]->streamByIndex(j)->id());
}
serviceStub->getStreamConfig(controller, streamIdList, streamConfigList,
NewCallback(this, &PortGroup::processStreamConfigList,
portIndex, controller));
} }
serviceStub->getStreamConfig(controller, streamIdList, streamConfigList,
NewCallback(this, &PortGroup::processStreamConfigList,
portIndex, controller));
} }
void PortGroup::processStreamConfigList(int portIndex, void PortGroup::processStreamConfigList(int portIndex,
@ -919,45 +911,40 @@ void PortGroup::processDeviceGroupIdList(
mPorts[portIndex]->when_syncComplete(); mPorts[portIndex]->when_syncComplete();
// Are we done for all ports? getDeviceGroupConfigList(portIndex);
if (numPorts() && portIndex >= (numPorts()-1))
getDeviceGroupConfigList();
_exit: _exit:
delete controller; delete controller;
} }
void PortGroup::getDeviceGroupConfigList() void PortGroup::getDeviceGroupConfigList(int portIndex)
{ {
using OstProto::DeviceGroupId; using OstProto::DeviceGroupId;
using OstProto::DeviceGroupIdList; using OstProto::DeviceGroupIdList;
using OstProto::DeviceGroupConfigList; using OstProto::DeviceGroupConfigList;
qDebug("requesting device group config list ..."); if (mPorts[portIndex]->numDeviceGroups() == 0)
return;
for (int portIndex = 0; portIndex < numPorts(); portIndex++) qDebug("requesting device group config list (port %d) ...", portIndex);
DeviceGroupIdList *devGrpIdList = new DeviceGroupIdList;
DeviceGroupConfigList *devGrpCfgList = new DeviceGroupConfigList;
PbRpcController *controller = new PbRpcController(
devGrpIdList, devGrpCfgList);
devGrpIdList->mutable_port_id()->set_id(mPorts[portIndex]->id());
for (int j = 0; j < mPorts[portIndex]->numDeviceGroups(); j++)
{ {
if (mPorts[portIndex]->numDeviceGroups() == 0) DeviceGroupId *dgid = devGrpIdList->add_device_group_id();
continue; dgid->set_id(mPorts[portIndex]->deviceGroupByIndex(j)
->device_group_id().id());
DeviceGroupIdList *devGrpIdList = new DeviceGroupIdList;
DeviceGroupConfigList *devGrpCfgList = new DeviceGroupConfigList;
PbRpcController *controller = new PbRpcController(
devGrpIdList, devGrpCfgList);
devGrpIdList->mutable_port_id()->set_id(mPorts[portIndex]->id());
for (int j = 0; j < mPorts[portIndex]->numDeviceGroups(); j++)
{
DeviceGroupId *dgid = devGrpIdList->add_device_group_id();
dgid->set_id(mPorts[portIndex]->deviceGroupByIndex(j)
->device_group_id().id());
}
serviceStub->getDeviceGroupConfig(controller,
devGrpIdList, devGrpCfgList,
NewCallback(this, &PortGroup::processDeviceGroupConfigList,
portIndex, controller));
} }
serviceStub->getDeviceGroupConfig(controller,
devGrpIdList, devGrpCfgList,
NewCallback(this, &PortGroup::processDeviceGroupConfigList,
portIndex, controller));
} }
void PortGroup::processDeviceGroupConfigList(int portIndex, void PortGroup::processDeviceGroupConfigList(int portIndex,

View File

@ -127,14 +127,14 @@ public:
void getStreamIdList(); void getStreamIdList();
void processStreamIdList(int portIndex, PbRpcController *controller); void processStreamIdList(int portIndex, PbRpcController *controller);
void getStreamConfigList(); void getStreamConfigList(int portIndex);
void processStreamConfigList(int portIndex, PbRpcController *controller); void processStreamConfigList(int portIndex, PbRpcController *controller);
void processModifyStreamAck(OstProto::Ack *ack); void processModifyStreamAck(OstProto::Ack *ack);
void getDeviceGroupIdList(); void getDeviceGroupIdList();
void processDeviceGroupIdList(int portIndex, PbRpcController *controller); void processDeviceGroupIdList(int portIndex, PbRpcController *controller);
void getDeviceGroupConfigList(); void getDeviceGroupConfigList(int portIndex);
void processDeviceGroupConfigList( void processDeviceGroupConfigList(
int portIndex, int portIndex,
PbRpcController *controller); PbRpcController *controller);