mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-08 08:10:30 -10:00
audio/asio: fix CXX_BUILD=1 compilation on Windows
CoCreateInstance's 1st (REFCLSID) and 4th (REFIID) parameters are 'const IID *' in C but 'const IID &' in C++. asio_load_driver passed the CLSID pointer directly, which is correct C but fails to compile under CXX_BUILD=1 with: error: invalid initialization of reference of type 'const IID&' from expression of type 'const CLSID*' Dereference the GUID for the C++ build via __cplusplus, keeping the pointer form for C. ASIO uses the CLSID as both the class ID and the interface ID, so the same GUID is passed for both arguments. The rest of asio.c is already C++-clean: COM methods are invoked through a hand-rolled vtable (IASIO_CALL) rather than interface-struct member calls, and all void* driver-data parameters are explicitly cast. This was the only language-dependent COM call. Follow-up to the CXX_BUILD fixes in 059ca26; asio.c is Windows-only so it was not covered by the earlier Linux build.
This commit is contained in:
1 parent
059ca263df
commit
7712d87b3c
1 file changed
+9
@@ -630,8 +630,17 @@ static int asio_enumerate_drivers(asio_driver_entry_t *entries,
|
||||
static void *asio_load_driver(const CLSID *clsid)
|
||||
{
|
||||
void *iface = NULL;
|
||||
/* In C, REFCLSID/REFIID (CoCreateInstance's 1st and 4th args) are
|
||||
* 'const IID *'; in C++ they are 'const IID &'. ASIO uses the CLSID
|
||||
* as both the class ID and the interface ID, so pass the same GUID
|
||||
* for both, dereferencing under CXX_BUILD. */
|
||||
#ifdef __cplusplus
|
||||
HRESULT hr = CoCreateInstance(*clsid, NULL,
|
||||
CLSCTX_INPROC_SERVER, *clsid, &iface);
|
||||
#else
|
||||
HRESULT hr = CoCreateInstance(clsid, NULL,
|
||||
CLSCTX_INPROC_SERVER, clsid, &iface);
|
||||
#endif
|
||||
if (FAILED(hr))
|
||||
return NULL;
|
||||
return iface;
|
||||
|
||||
Reference in new issue
Block a user