mf: Assign topology identifiers.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-02-25 11:33:54 +03:00 committed by Alexandre Julliard
parent 202e9592d5
commit 5c43f5174e
2 changed files with 49 additions and 4 deletions

View File

@ -37,7 +37,7 @@ static void test_topology(void)
{ {
IMFCollection *collection, *collection2; IMFCollection *collection, *collection2;
IMFTopologyNode *node, *node2, *node3; IMFTopologyNode *node, *node2, *node3;
IMFTopology *topology; IMFTopology *topology, *topology2;
DWORD size; DWORD size;
WORD count; WORD count;
HRESULT hr; HRESULT hr;
@ -47,7 +47,26 @@ static void test_topology(void)
ok(hr == E_POINTER, "got %#x\n", hr); ok(hr == E_POINTER, "got %#x\n", hr);
hr = MFCreateTopology(&topology); 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); hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);

View File

@ -15,7 +15,9 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#include <stdarg.h> #include <stdarg.h>
@ -34,6 +36,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat); WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
static LONG next_node_id; static LONG next_node_id;
static TOPOID next_topology_id;
struct topology struct topology
{ {
@ -41,6 +44,7 @@ struct topology
LONG refcount; LONG refcount;
IMFAttributes *attributes; IMFAttributes *attributes;
IMFCollection *nodes; IMFCollection *nodes;
TOPOID id;
}; };
struct topology_node 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) 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) 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, 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.@) * MFCreateTopology (mf.@)
*/ */
@ -684,6 +708,8 @@ HRESULT WINAPI MFCreateTopology(IMFTopology **topology)
return hr; return hr;
} }
object->id = topology_generate_id();
*topology = &object->IMFTopology_iface; *topology = &object->IMFTopology_iface;
return S_OK; return S_OK;