Skip to content

Commit df41f05

Browse files
Fixing Bug with ghost connections
1 parent 45a9b04 commit df41f05

20 files changed

+92
-97
lines changed

VBAudioRouter/AudioGraphControl/ConnectionHelper.vb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,26 @@ Namespace AudioGraphControl
2424
Public Shared Sub DisposeNode(nodeControl As NodeControl)
2525
Dim node = DirectCast(nodeControl.NodeContent, IAudioNodeControl)
2626

27-
' Remove visual & graph connections
28-
Dim connections = node.OutgoingConnector.Connections.ToArray()
27+
#Region "' Remove visual & graph connections"
28+
Dim connections As New List(Of NodeConnection)
29+
30+
Dim inputNode = TryCast(nodeControl.NodeContent, IAudioNodeControlInput)
31+
If inputNode IsNot Nothing Then
32+
connections.AddRange(inputNode.IncomingConnector.Connections)
33+
End If
34+
35+
Dim outputNode = TryCast(nodeControl.NodeContent, IAudioNodeControlOutput)
36+
If outputNode IsNot Nothing Then
37+
connections.AddRange(outputNode.OutgoingConnector.Connections)
38+
End If
39+
2940
For Each connection In connections
3041
DeleteConnection(connection)
3142
Next
43+
#End Region
3244

45+
' Dispose audio node
3346
If Not node.BaseAudioNode Is Nothing Then
34-
' Dispose audio node
3547
node.BaseAudioNode.Stop()
3648
node.BaseAudioNode.Dispose()
3749
End If
@@ -57,7 +69,7 @@ Namespace AudioGraphControl
5769
End Sub
5870

5971
<Extension>
60-
Public Sub ReconnectAudioNode(ByRef nodeControl As IAudioNodeControl)
72+
Public Sub ReconnectAudioNode(ByRef nodeControl As IAudioNodeControlOutput)
6173
For Each connection In nodeControl.OutgoingConnector.Connections
6274
Dim node As IAudioNode = connection.DestinationConnector.AttachedNode.BaseAudioNode
6375
DirectCast(nodeControl.BaseAudioNode, IAudioInputNode).AddOutgoingConnection(node)

VBAudioRouter/AudioGraphControl/IAudioNodeControl.vb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,30 @@ Imports Windows.Media.Audio
55
Namespace AudioGraphControl
66

77
Public Interface IAudioNodeControl
8-
#Region "Identity"
9-
ReadOnly Property NodeType As NodeTypeEnum
108
ReadOnly Property BaseAudioNode As IAudioNode
11-
#End Region
129

1310
#Region "State"
1411
Function Initialize(graph As AudioGraph) As Task
1512
Sub OnStateChanged(state As GraphState)
1613
#End Region
1714

18-
ReadOnly Property OutgoingConnector As ConnectorControl
19-
2015
Property Canvas As Canvas
2116
End Interface
2217

18+
Public Interface IAudioNodeControlInput
19+
Inherits IAudioNodeControl
20+
21+
ReadOnly Property IncomingConnector As ConnectorControl
22+
End Interface
23+
24+
Public Interface IAudioNodeControlEffect
25+
Inherits IAudioNodeControl
26+
End Interface
27+
28+
Public Interface IAudioNodeControlOutput
29+
Inherits IAudioNodeControl
30+
31+
ReadOnly Property OutgoingConnector As ConnectorControl
32+
End Interface
33+
2334
End Namespace

VBAudioRouter/Controls/EQNodeControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<ColumnDefinition Width="Auto" />
1616
</Grid.ColumnDefinitions>
1717
<StackPanel Grid.Column="0">
18-
<controls:ConnectorControl x:Name="IngoingConnectorControl" Margin="0,5,0,5" AllowMultipleConnections="True" IsOutgoing="False">
18+
<controls:ConnectorControl x:Name="IncomingConnectorControl" Margin="0,5,0,5" AllowMultipleConnections="True" IsOutgoing="False">
1919
<controls:ConnectorControl.RenderTransform>
2020
<CompositeTransform TranslateX="-18" />
2121
</controls:ConnectorControl.RenderTransform>

VBAudioRouter/Controls/EQNodeControl.xaml.vb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ Namespace Controls
88

99
Public NotInheritable Class EQNodeControl
1010
Inherits UserControl
11-
Implements IAudioNodeControl
11+
Implements IAudioNodeControl, IAudioNodeControlInput, IAudioNodeControlEffect, IAudioNodeControlOutput
1212

1313
#Region "Indentity"
14-
15-
Public ReadOnly Property NodeType As NodeTypeEnum Implements IAudioNodeControl.NodeType
16-
Get
17-
Return NodeTypeEnum.Effect
18-
End Get
19-
End Property
2014
Public Property Canvas As Canvas Implements IAudioNodeControl.Canvas
2115
Public ReadOnly Property BaseAudioNode As IAudioNode Implements IAudioNodeControl.BaseAudioNode
2216

23-
Public ReadOnly Property OutgoingConnector As ConnectorControl Implements IAudioNodeControl.OutgoingConnector
17+
Public ReadOnly Property OutgoingConnector As ConnectorControl Implements IAudioNodeControlOutput.OutgoingConnector
2418
Get
2519
Return OutgoingConnectorControl
2620
End Get
2721
End Property
22+
23+
Public ReadOnly Property IncomingConnector As ConnectorControl Implements IAudioNodeControlInput.IncomingConnector
24+
Get
25+
Return IncomingConnectorControl
26+
End Get
27+
End Property
2828
#End Region
2929

3030
Dim EQEffect As EqualizerEffectDefinition

VBAudioRouter/Controls/EchoNodeControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ColumnDefinition Width="Auto" />
1414
</Grid.ColumnDefinitions>
1515
<StackPanel Grid.Column="0">
16-
<controls:ConnectorControl x:Name="IngoingConnectorControl" Margin="0,5,0,5" AllowMultipleConnections="True" IsOutgoing="False">
16+
<controls:ConnectorControl x:Name="IncomingConnectorControl" Margin="0,5,0,5" AllowMultipleConnections="True" IsOutgoing="False">
1717
<controls:ConnectorControl.RenderTransform>
1818
<CompositeTransform TranslateX="-18" />
1919
</controls:ConnectorControl.RenderTransform>

VBAudioRouter/Controls/EchoNodeControl.xaml.vb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,26 @@ Namespace Controls
66

77
Public NotInheritable Class EchoNodeControl
88
Inherits UserControl
9-
Implements IAudioNodeControl
9+
Implements IAudioNodeControl, IAudioNodeControlInput, IAudioNodeControlEffect, IAudioNodeControlOutput
1010

1111
Public Sub New()
1212
InitializeComponent()
1313
End Sub
1414

1515
#Region "Identity"
16-
17-
Public ReadOnly Property NodeType As NodeTypeEnum Implements IAudioNodeControl.NodeType
18-
Get
19-
Return NodeTypeEnum.Effect
20-
End Get
21-
End Property
2216
Public Property Canvas As Canvas Implements IAudioNodeControl.Canvas
2317
Public ReadOnly Property BaseAudioNode As IAudioNode Implements IAudioNodeControl.BaseAudioNode
2418

25-
Public ReadOnly Property OutgoingConnector As ConnectorControl Implements IAudioNodeControl.OutgoingConnector
19+
Public ReadOnly Property OutgoingConnector As ConnectorControl Implements IAudioNodeControlOutput.OutgoingConnector
2620
Get
2721
Return OutgoingConnectorControl
2822
End Get
2923
End Property
24+
Public ReadOnly Property IncomingConnector As ConnectorControl Implements IAudioNodeControlInput.IncomingConnector
25+
Get
26+
Return IncomingConnectorControl
27+
End Get
28+
End Property
3029
#End Region
3130

3231
Public Property EchoEffect As EchoEffectDefinition

VBAudioRouter/Controls/FileInputNodeControl.xaml.vb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,17 @@ Namespace Controls
99

1010
Public NotInheritable Class FileInputNodeControl
1111
Inherits UserControl
12-
Implements IAudioNodeControl
12+
Implements IAudioNodeControl, IAudioNodeControlOutput
1313

1414
Private WithEvents ControlsWrapper As Utils.MediaTransportControlsWrapper
1515

1616
Public Property MediaSource As MediaSource
1717

1818
#Region "Identity"
19-
20-
Public ReadOnly Property NodeType As NodeTypeEnum Implements IAudioNodeControl.NodeType
21-
Get
22-
Return NodeTypeEnum.Input
23-
End Get
24-
End Property
2519
Public Property Canvas As Canvas Implements IAudioNodeControl.Canvas
2620
Public ReadOnly Property BaseAudioNode As IAudioNode Implements IAudioNodeControl.BaseAudioNode
2721

28-
Public ReadOnly Property OutgoingConnector As ConnectorControl Implements IAudioNodeControl.OutgoingConnector
22+
Public ReadOnly Property OutgoingConnector As ConnectorControl Implements IAudioNodeControlOutput.OutgoingConnector
2923
Get
3024
Return OutgoingConnectorControl
3125
End Get

VBAudioRouter/Controls/GainNodeControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<ColumnDefinition Width="Auto" />
1616
</Grid.ColumnDefinitions>
1717
<StackPanel Grid.Column="0">
18-
<controls:ConnectorControl x:Name="IngoingConnectorControl" Margin="0,5,0,5" AllowMultipleConnections="True" IsOutgoing="False">
18+
<controls:ConnectorControl x:Name="IncomingConnectorControl" Margin="0,5,0,5" AllowMultipleConnections="True" IsOutgoing="False">
1919
<controls:ConnectorControl.RenderTransform>
2020
<CompositeTransform TranslateX="-18" />
2121
</controls:ConnectorControl.RenderTransform>

VBAudioRouter/Controls/GainNodeControl.xaml.vb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11

22
Imports VBAudioRouter.AudioGraphControl
3-
Imports VBAudioRouter.Utils
43
Imports Windows.Media.Audio
54

65
Namespace Controls
76

87
Public NotInheritable Class GainNodeControl
98
Inherits UserControl
10-
Implements IAudioNodeControl
9+
Implements IAudioNodeControl, IAudioNodeControlInput, IAudioNodeControlEffect, IAudioNodeControlOutput
1110

1211
Public Sub New()
1312
InitializeComponent()
1413
End Sub
1514

1615
#Region "Identity"
17-
18-
Public ReadOnly Property NodeType As NodeTypeEnum Implements IAudioNodeControl.NodeType
19-
Get
20-
Return NodeTypeEnum.Effect
21-
End Get
22-
End Property
2316
Public Property Canvas As Canvas Implements IAudioNodeControl.Canvas
2417
Public ReadOnly Property BaseAudioNode As IAudioNode Implements IAudioNodeControl.BaseAudioNode
2518

26-
Public ReadOnly Property OutgoingConnector As ConnectorControl Implements IAudioNodeControl.OutgoingConnector
19+
Public ReadOnly Property OutgoingConnector As ConnectorControl Implements IAudioNodeControlOutput.OutgoingConnector
2720
Get
2821
Return OutgoingConnectorControl
2922
End Get
3023
End Property
24+
Public ReadOnly Property IncomingConnector As ConnectorControl Implements IAudioNodeControlInput.IncomingConnector
25+
Get
26+
Return IncomingConnectorControl
27+
End Get
28+
End Property
3129
#End Region
3230

3331
Public Async Function Initialize(graph As AudioGraph) As Task Implements IAudioNodeControl.Initialize

VBAudioRouter/Controls/LimiterNodeControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ColumnDefinition Width="Auto" />
1414
</Grid.ColumnDefinitions>
1515
<StackPanel Grid.Column="0">
16-
<controls:ConnectorControl x:Name="IngoingConnectorControl" Margin="0,5,0,5" AllowMultipleConnections="True" IsOutgoing="False">
16+
<controls:ConnectorControl x:Name="IncomingConnectorControl" Margin="0,5,0,5" AllowMultipleConnections="True" IsOutgoing="False">
1717
<controls:ConnectorControl.RenderTransform>
1818
<CompositeTransform TranslateX="-18" />
1919
</controls:ConnectorControl.RenderTransform>

0 commit comments

Comments
 (0)