adds IRoutingSink for readability and adds a protection in ExecuteRoutes if the device happens to be IRoutingSinkWithNoSwitching and IRouting like a codec might potentially be

This commit is contained in:
Nick Genovese
2020-05-28 19:37:45 -04:00
parent 62fdd6a572
commit 8d2d45b5ce
2 changed files with 117 additions and 106 deletions

View File

@@ -22,7 +22,7 @@ namespace PepperDash.Essentials.Core
/// and then attempts a new Route and if sucessful, stores that RouteDescriptor /// and then attempts a new Route and if sucessful, stores that RouteDescriptor
/// in RouteDescriptorCollection.DefaultCollection /// in RouteDescriptorCollection.DefaultCollection
/// </summary> /// </summary>
public static void ReleaseAndMakeRoute(this IRoutingSinkNoSwitching destination, IRoutingOutputs source, eRoutingSignalType signalType) public static void ReleaseAndMakeRoute(this IRoutingSink destination, IRoutingOutputs source, eRoutingSignalType signalType)
{ {
destination.ReleaseRoute(); destination.ReleaseRoute();
@@ -39,7 +39,7 @@ namespace PepperDash.Essentials.Core
/// RouteDescriptorCollection.DefaultCollection /// RouteDescriptorCollection.DefaultCollection
/// </summary> /// </summary>
/// <param name="destination"></param> /// <param name="destination"></param>
public static void ReleaseRoute(this IRoutingInputs destination) public static void ReleaseRoute(this IRoutingSink destination)
{ {
var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination); var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination);
if (current != null) if (current != null)
@@ -56,7 +56,7 @@ namespace PepperDash.Essentials.Core
/// of an audio/video route are discovered a route descriptor is returned. If no route is /// of an audio/video route are discovered a route descriptor is returned. If no route is
/// discovered, then null is returned /// discovered, then null is returned
/// </summary> /// </summary>
public static RouteDescriptor GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) public static RouteDescriptor GetRouteToSource(this IRoutingSink destination, IRoutingOutputs source, eRoutingSignalType signalType)
{ {
var routeDescr = new RouteDescriptor(source, destination, signalType); var routeDescr = new RouteDescriptor(source, destination, signalType);
// if it's a single signal type, find the route // if it's a single signal type, find the route
@@ -265,8 +265,14 @@ namespace PepperDash.Essentials.Core
foreach (var route in Routes) foreach (var route in Routes)
{ {
Debug.Console(2, "ExecuteRoutes: {0}", route.ToString()); Debug.Console(2, "ExecuteRoutes: {0}", route.ToString());
if (route.SwitchingDevice is IRoutingSinkWithSwitching) if (route.SwitchingDevice is IRoutingSink)
(route.SwitchingDevice as IRoutingSinkWithSwitching).ExecuteSwitch(route.InputPort.Selector); {
var device = route.SwitchingDevice as IRoutingSinkWithSwitching;
if (device == null)
continue;
device.ExecuteSwitch(route.InputPort.Selector);
}
else if (route.SwitchingDevice is IRouting) else if (route.SwitchingDevice is IRouting)
{ {
(route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType); (route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType);

View File

@@ -48,10 +48,15 @@ namespace PepperDash.Essentials.Core
RoutingPortCollection<RoutingOutputPort> OutputPorts { get; } RoutingPortCollection<RoutingOutputPort> OutputPorts { get; }
} }
public interface IRoutingSink : IRoutingInputs, IHasCurrentSourceInfoChange
{
}
/// <summary> /// <summary>
/// For fixed-source endpoint devices /// For fixed-source endpoint devices
/// </summary> /// </summary>
public interface IRoutingSinkNoSwitching : IRoutingInputs, IHasCurrentSourceInfoChange public interface IRoutingSinkNoSwitching : IRoutingSink
{ {
} }
@@ -59,7 +64,7 @@ namespace PepperDash.Essentials.Core
/// <summary> /// <summary>
/// Endpoint device like a display, that selects inputs /// Endpoint device like a display, that selects inputs
/// </summary> /// </summary>
public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching, IHasCurrentSourceInfoChange public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching
{ {
//void ClearRoute(); //void ClearRoute();
void ExecuteSwitch(object inputSelector); void ExecuteSwitch(object inputSelector);