[wdmaudiodev] Re: [EXTERNAL] Problem with Friendly Names in Audio Driver

  • From: Tim Roberts <timr@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Fri, 7 Jan 2022 15:46:51 -0800

Jamie Finch wrote:

I am having a problem with adding "public IPinName" to a class with "public IMiniportTopology".

To verify the project setup, I went back to the sysvad sample driver code and the same compiler error happens in that project.
It seem to be missing some detail.  It seems to be simple enough to do.

I get the following compiler error:
Error (active) E0287 derived class "CMicArrayMiniportTopology" contains more than one instance of class "IUnknown"

I can make this compile with a few changes in my MSVAD-derived code.   The key is, when casting between PCMiniportTopology and IUnknown, you must choose one of the interfaces that derives from IUnknown to be an intermediary.  It doesn't matter which one, as long as it's always the same one.  So, making the following 4 changes allows it to compile for me:

--- a/Driver/mintopo.cpp
+++ b/Driver/mintopo.cpp
@@ -69,7 +69,7 @@ CreateMiniportTopologyVendor


-    STD_CREATE_BODY_(CMiniportTopology, Unknown, UnknownOuter, PoolType, PCMiniportTopology);
+    STD_CREATE_BODY_(CMiniportTopology, Unknown, UnknownOuter, PoolType, IMiniportTopology*);
 } // CreateMiniportTopologyKrisp

@@ -355,7 +355,7 @@ PropertyHandler_TopoFilter
     // MajorTarget is a pointer to miniport object for miniports.
-    PCMiniportTopology  pMiniport = (PCMiniportTopology)PropertyRequest->MajorTarget;
+    PCMiniportTopology  pMiniport = (PCMiniportTopology)(IMiniportTopology*)PropertyRequest->MajorTarget;

     if (IsEqualGUIDAligned(*PropertyRequest->PropertyItem->Set, KSPROPSETID_Jack) &&
         (PropertyRequest->PropertyItem->Id == KSPROPERTY_JACK_DESCRIPTION))
@@ -396,7 +396,7 @@ PropertyHandler_Topology
     // MajorTarget is a pointer to miniport object for miniports.
-        ((PCMiniportTopology)
+        ((PCMiniportTopology)(IMiniportTopology*)
@@ -426,7 +426,7 @@ EventHandler_JackState
     ASSERT( IsEqualGUIDAligned(*EventRequest->EventItem->Set, KSEVENTSETID_PinCapsChange) );
     if( EventRequest->Verb == PCEVENT_VERB_ADD )
-        ((PCMiniportTopology)EventRequest->MajorTarget)
+ ((PCMiniportTopology)(IMiniportTopology*)EventRequest->MajorTarget)
             ->AddEventToEventList( EventRequest->EventEntry );

Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.

Other related posts: