From 5c43f5174ea722e658503506b383734fd55465cd Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 25 Feb 2019 11:33:54 +0300 Subject: [PATCH] mf: Assign topology identifiers. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mf/tests/mf.c | 23 +++++++++++++++++++++-- dlls/mf/topology.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 91ddd60842e..c56428d27e9 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -37,7 +37,7 @@ static void test_topology(void) { IMFCollection *collection, *collection2; IMFTopologyNode *node, *node2, *node3; - IMFTopology *topology; + IMFTopology *topology, *topology2; DWORD size; WORD count; HRESULT hr; @@ -47,7 +47,26 @@ static void test_topology(void) ok(hr == E_POINTER, "got %#x\n", hr); hr = MFCreateTopology(&topology); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "Failed to create topology, hr %#x.\n", hr); + hr = IMFTopology_GetTopologyID(topology, &id); + ok(hr == S_OK, "Failed to get id, hr %#x.\n", hr); + ok(id == 1, "Unexpected id.\n"); + + hr = MFCreateTopology(&topology2); + ok(hr == S_OK, "Failed to create topology, hr %#x.\n", hr); + hr = IMFTopology_GetTopologyID(topology2, &id); + ok(hr == S_OK, "Failed to get id, hr %#x.\n", hr); + ok(id == 2, "Unexpected id.\n"); + + IMFTopology_Release(topology); + + hr = MFCreateTopology(&topology); + ok(hr == S_OK, "Failed to create topology, hr %#x.\n", hr); + hr = IMFTopology_GetTopologyID(topology, &id); + ok(hr == S_OK, "Failed to get id, hr %#x.\n", hr); + ok(id == 3, "Unexpected id.\n"); + + IMFTopology_Release(topology2); hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, NULL); ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); diff --git a/dlls/mf/topology.c b/dlls/mf/topology.c index 84387ae0ccf..543e08fb247 100644 --- a/dlls/mf/topology.c +++ b/dlls/mf/topology.c @@ -15,7 +15,9 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ + #include "config.h" +#include "wine/port.h" #include @@ -34,6 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mfplat); static LONG next_node_id; +static TOPOID next_topology_id; struct topology { @@ -41,6 +44,7 @@ struct topology LONG refcount; IMFAttributes *attributes; IMFCollection *nodes; + TOPOID id; }; struct topology_node @@ -412,9 +416,16 @@ static HRESULT WINAPI topology_CopyAllItems(IMFTopology *iface, IMFAttributes *d static HRESULT WINAPI topology_GetTopologyID(IMFTopology *iface, TOPOID *id) { - FIXME("(%p)->(%p)\n", iface, id); + struct topology *topology = impl_from_IMFTopology(iface); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", iface, id); + + if (!id) + return E_POINTER; + + *id = topology->id; + + return S_OK; } static HRESULT topology_get_node_by_id(const struct topology *topology, TOPOID id, IMFTopologyNode **node) @@ -654,6 +665,19 @@ static const IMFTopologyVtbl topologyvtbl = topology_GetOutputNodeCollection, }; +static TOPOID topology_generate_id(void) +{ + TOPOID old; + + do + { + old = next_topology_id; + } + while (interlocked_cmpxchg64((LONG64 *)&next_topology_id, old + 1, old) != old); + + return next_topology_id; +} + /*********************************************************************** * MFCreateTopology (mf.@) */ @@ -684,6 +708,8 @@ HRESULT WINAPI MFCreateTopology(IMFTopology **topology) return hr; } + object->id = topology_generate_id(); + *topology = &object->IMFTopology_iface; return S_OK;