在使用MFPACK库时,core audio apis库的函数排列顺序非常重要,要与MSDN的说明一致。
如:IPart/IDeviceTopology 的声明函数顺序应该与MSDN中说明顺序相同,否则调用时会产生错误 $80004003(Para error) or $8004007(Pointer Error)。
下面为正确顺序:
DeviceTopology = interface(IUnknown) ['{2A07407E-6497-4A18-9787-32F79BD0D98F}'] function GetConnectorCount(out pCount: UINT): HRESULT; stdcall; function GetConnector(const nIndex: UINT; out ppConnector: IConnector): HRESULT; stdcall; function GetSubunitCount(out pCount: UINT): HRESULT; stdcall; function GetSubunit(const nIndex: UINT; out ppSubunit: ISubUnit): HRESULT; stdcall; function GetPartById(const nId: UINT; out ppPart: IPart): HRESULT; stdcall; function GetDeviceId(out ppwstrDeviceId: LPWSTR): HRESULT; stdcall; function GetSignalPath(pIPartFrom: IPart; pIPartTo: IPart; const bRejectMixedPaths: BOOL; out ppParts: IPartsList): HRESULT; stdcall; end; IPart = interface(IUnknown) ['{AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9}'] // The interface id for the requested control function. // The client should set this parameter to one of the following REFIID values: // IID_IAudioAutoGainControl, IID_IAudioBass, IID_IAudioChannelConfig, IID_IAudioInputSelector, IID_IAudioLoudness // IID_IAudioMidrange, IID_IAudioMute, IID_IAudioOutputSelector, IID_IAudioPeakMeter, IID_IAudioTreble, IID_IAudioVolumeLevel // IID_IDeviceSpecificProperty, IID_IKsFormatSupport, IID_IKsJackDescription function GetName(out ppwstrName: LPWSTR): HRESULT; stdcall; // Description: // Gets the name of this Part. // Parameters: // ppwstrName - [out] The name of this Part // Remarks: // The returned string must be freed by the caller using CoTaskMemFree. // Return values: // S_OK if successful // E_NOTFOUND if the part does not have a name // function GetLocalId(out pnId: UINT): HRESULT; stdcall; // Description: // Gets the local ID of this Part // Parameters: // pnId - [out] The local ID of this Part. This ID is only valid in the context of the parent DeviceTopology object. // Return values: // S_OK if successful // function GetGlobalId(out ppwstrGlobalId: LPWSTR): HRESULT; stdcall; // Description: // Gets the global ID of this Part // Parameters: // ppwstrId - [out] The global ID of this Part. // This ID is globally unique and can be used to get an interface to a Part on // any DeviceTopology object. // Remarks: // The returned string must be freed by the caller using CoTaskMemFree. // Return values: // S_OK if successful // function GetPartType(out PPartType: PartType): HRESULT; stdcall; // Description: // Gets the type of this Part (Connector or Subunit) // Parameters: // pPartType - [out] The type of this Part (Connector or Subunit) // Return values: // S_OK if successful // function GetSubType(out pSubType: TGUID): HRESULT; stdcall; function GetControlInterfaceCount(out pCount: UINT): HRESULT; stdcall; function GetControlInterface(const nIndex: UINT; out ppFunction: IControlInterface): HRESULT; stdcall; function EnumPartsIncoming(out ppParts: IPartsList): HRESULT; stdcall; function EnumPartsOutgoing(out ppParts: IPartsList): HRESULT; stdcall; function GetTopologyObject(out ppTopology: IDeviceTopology): HRESULT; stdcall; function Activate(const dwClsContext: DWORD; const refiid: refiid; out ppvObject): HRESULT; stdcall; function UnregisterControlChangeCallback(pNotify: IControlChangeNotify): HRESULT; stdcall; function RegisterControlChangeCallback(const riid: REFGUID; pNotify: IControlChangeNotify): HRESULT; stdcall; end;