private int SaveRouting(Routing routingNew, bool audioList)
{
int depth = routingNew.depth + 1;
Routing routingCurrent = routingNew;
if (routingNew == null)
return -1;
Trace.WriteLineIf(trace.TraceInfo, string.Format("SaveRouting, Depth={0}, NumberOfRoutings={1}",
depth, (audioList ? this.audioRoutingList : this.videoRoutingList).Count + 1));
Routing[] routings = new Routing[depth];
for (int j = 0; j < depth; j++)
{
routings[j] = new Routing(routingCurrent);
//ASSERT (pCurrent.pXbar != null);
// We're holding onto this interface, so AddRef
//pCurrent.pXbar.AddRef();
routingCurrent = routingCurrent.rightRouting;
// Pointers were stack based during recursive search, so update them
// in the allocated array
if (j == 0) // first element
routings[j].leftRouting = null;
else
routings[j].leftRouting = routings[j - 1];
if (j == (depth - 1)) // last element
routings[j].rightRouting = null;
else
routings[j].rightRouting = routings[j + 1];
}
(audioList ? this.audioRoutingList : this.videoRoutingList).AddRange(routings);
return 0;
}