mf: Disconnect removed nodes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
184f999459
commit
37a7b65140
|
@ -589,10 +589,9 @@ static void test_topology(void)
|
||||||
hr = IMFTopology_Clear(topology);
|
hr = IMFTopology_Clear(topology);
|
||||||
ok(hr == S_OK, "Failed to clear topology, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to clear topology, hr %#x.\n", hr);
|
||||||
|
|
||||||
todo_wine {
|
|
||||||
EXPECT_REF(node, 1);
|
EXPECT_REF(node, 1);
|
||||||
EXPECT_REF(node2, 1);
|
EXPECT_REF(node2, 1);
|
||||||
}
|
|
||||||
/* Removing connected node breaks connection. */
|
/* Removing connected node breaks connection. */
|
||||||
hr = IMFTopology_AddNode(topology, node);
|
hr = IMFTopology_AddNode(topology, node);
|
||||||
ok(hr == S_OK, "Failed to add a node, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to add a node, hr %#x.\n", hr);
|
||||||
|
@ -606,12 +605,10 @@ todo_wine {
|
||||||
hr = IMFTopology_RemoveNode(topology, node);
|
hr = IMFTopology_RemoveNode(topology, node);
|
||||||
ok(hr == S_OK, "Failed to remove a node, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to remove a node, hr %#x.\n", hr);
|
||||||
|
|
||||||
todo_wine {
|
|
||||||
EXPECT_REF(node, 1);
|
EXPECT_REF(node, 1);
|
||||||
EXPECT_REF(node2, 2);
|
EXPECT_REF(node2, 2);
|
||||||
}
|
|
||||||
hr = IMFTopologyNode_GetOutput(node, 0, &node3, &index);
|
hr = IMFTopologyNode_GetOutput(node, 0, &node3, &index);
|
||||||
todo_wine
|
|
||||||
ok(hr == MF_E_NOT_FOUND, "Unexpected hr %#x.\n", hr);
|
ok(hr == MF_E_NOT_FOUND, "Unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IMFTopology_AddNode(topology, node);
|
hr = IMFTopology_AddNode(topology, node);
|
||||||
|
@ -623,10 +620,9 @@ todo_wine
|
||||||
hr = IMFTopology_RemoveNode(topology, node2);
|
hr = IMFTopology_RemoveNode(topology, node2);
|
||||||
ok(hr == S_OK, "Failed to remove a node, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to remove a node, hr %#x.\n", hr);
|
||||||
|
|
||||||
todo_wine {
|
|
||||||
EXPECT_REF(node, 2);
|
EXPECT_REF(node, 2);
|
||||||
EXPECT_REF(node2, 1);
|
EXPECT_REF(node2, 1);
|
||||||
}
|
|
||||||
IMFTopologyNode_Release(node);
|
IMFTopologyNode_Release(node);
|
||||||
IMFTopologyNode_Release(node2);
|
IMFTopologyNode_Release(node2);
|
||||||
|
|
||||||
|
|
|
@ -174,12 +174,81 @@ static ULONG WINAPI topology_AddRef(IMFTopology *iface)
|
||||||
return refcount;
|
return refcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT topology_node_disconnect_output(struct topology_node *node, DWORD output_index)
|
||||||
|
{
|
||||||
|
struct topology_node *connection = NULL;
|
||||||
|
struct node_stream *stream;
|
||||||
|
DWORD connection_stream;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
EnterCriticalSection(&node->cs);
|
||||||
|
|
||||||
|
if (output_index < node->outputs.count)
|
||||||
|
{
|
||||||
|
stream = &node->outputs.streams[output_index];
|
||||||
|
|
||||||
|
if (stream->connection)
|
||||||
|
{
|
||||||
|
connection = stream->connection;
|
||||||
|
connection_stream = stream->connection_stream;
|
||||||
|
stream->connection = NULL;
|
||||||
|
stream->connection_stream = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hr = MF_E_NOT_FOUND;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hr = E_INVALIDARG;
|
||||||
|
|
||||||
|
LeaveCriticalSection(&node->cs);
|
||||||
|
|
||||||
|
if (connection)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&connection->cs);
|
||||||
|
|
||||||
|
if (connection_stream < connection->inputs.count)
|
||||||
|
{
|
||||||
|
stream = &connection->inputs.streams[connection_stream];
|
||||||
|
|
||||||
|
if (stream->connection)
|
||||||
|
{
|
||||||
|
stream->connection = NULL;
|
||||||
|
stream->connection_stream = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection(&connection->cs);
|
||||||
|
|
||||||
|
IMFTopologyNode_Release(&connection->IMFTopologyNode_iface);
|
||||||
|
IMFTopologyNode_Release(&node->IMFTopologyNode_iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void topology_node_disconnect(struct topology_node *node)
|
||||||
|
{
|
||||||
|
struct node_stream *stream;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < node->outputs.count; ++i)
|
||||||
|
topology_node_disconnect_output(node, i);
|
||||||
|
|
||||||
|
for (i = 0; i < node->inputs.count; ++i)
|
||||||
|
{
|
||||||
|
stream = &node->inputs.streams[i];
|
||||||
|
if (stream->connection)
|
||||||
|
topology_node_disconnect_output(stream->connection, stream->connection_stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void topology_clear(struct topology *topology)
|
static void topology_clear(struct topology *topology)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < topology->nodes.count; ++i)
|
for (i = 0; i < topology->nodes.count; ++i)
|
||||||
{
|
{
|
||||||
|
topology_node_disconnect(topology->nodes.nodes[i]);
|
||||||
IMFTopologyNode_Release(&topology->nodes.nodes[i]->IMFTopologyNode_iface);
|
IMFTopologyNode_Release(&topology->nodes.nodes[i]->IMFTopologyNode_iface);
|
||||||
}
|
}
|
||||||
heap_free(topology->nodes.nodes);
|
heap_free(topology->nodes.nodes);
|
||||||
|
@ -551,6 +620,8 @@ static HRESULT WINAPI topology_RemoveNode(IMFTopology *iface, IMFTopologyNode *n
|
||||||
{
|
{
|
||||||
if (&topology->nodes.nodes[i]->IMFTopologyNode_iface == node)
|
if (&topology->nodes.nodes[i]->IMFTopologyNode_iface == node)
|
||||||
{
|
{
|
||||||
|
topology_node_disconnect(topology->nodes.nodes[i]);
|
||||||
|
IMFTopologyNode_Release(&topology->nodes.nodes[i]->IMFTopologyNode_iface);
|
||||||
count = topology->nodes.count - i - 1;
|
count = topology->nodes.count - i - 1;
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
|
@ -1248,58 +1319,6 @@ static HRESULT WINAPI topology_node_GetOutputCount(IMFTopologyNode *iface, DWORD
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT topology_node_disconnect_output(struct topology_node *node, DWORD output_index)
|
|
||||||
{
|
|
||||||
struct topology_node *connection = NULL;
|
|
||||||
struct node_stream *stream;
|
|
||||||
DWORD connection_stream;
|
|
||||||
HRESULT hr = S_OK;
|
|
||||||
|
|
||||||
EnterCriticalSection(&node->cs);
|
|
||||||
|
|
||||||
if (output_index < node->outputs.count)
|
|
||||||
{
|
|
||||||
stream = &node->outputs.streams[output_index];
|
|
||||||
|
|
||||||
if (stream->connection)
|
|
||||||
{
|
|
||||||
connection = stream->connection;
|
|
||||||
connection_stream = stream->connection_stream;
|
|
||||||
stream->connection = NULL;
|
|
||||||
stream->connection_stream = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
hr = MF_E_NOT_FOUND;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
hr = E_INVALIDARG;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&node->cs);
|
|
||||||
|
|
||||||
if (connection)
|
|
||||||
{
|
|
||||||
EnterCriticalSection(&connection->cs);
|
|
||||||
|
|
||||||
if (connection_stream < connection->inputs.count)
|
|
||||||
{
|
|
||||||
stream = &connection->inputs.streams[connection_stream];
|
|
||||||
|
|
||||||
if (stream->connection)
|
|
||||||
{
|
|
||||||
stream->connection = NULL;
|
|
||||||
stream->connection_stream = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LeaveCriticalSection(&connection->cs);
|
|
||||||
|
|
||||||
IMFTopologyNode_Release(&connection->IMFTopologyNode_iface);
|
|
||||||
IMFTopologyNode_Release(&node->IMFTopologyNode_iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI topology_node_ConnectOutput(IMFTopologyNode *iface, DWORD output_index,
|
static HRESULT WINAPI topology_node_ConnectOutput(IMFTopologyNode *iface, DWORD output_index,
|
||||||
IMFTopologyNode *peer, DWORD input_index)
|
IMFTopologyNode *peer, DWORD input_index)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue