[PATCH 5/6] mf: Assign topology identifiers.
Nikolay Sivov
nsivov at codeweavers.com
Mon Feb 25 01:16:12 CST 2019
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
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 87d04e4f82..b817a2c298 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 84387ae0cc..543e08fb24 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 <stdarg.h>
@@ -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;
--
2.20.1
More information about the wine-devel
mailing list