Thanks, Thunder93 - that looked promising but unfortunately I get 'invalid memory access' on the ppMS\Shutdown(). I'm wondering if I need to do something different as ppMS is a pointer-to-a-pointer, because the C++ definition of MFCreateMediaSession is:
Code: Select all
HRESULT MFCreateMediaSession(
IMFAttributes *pConfiguration,
IMFMediaSession **ppMS
);
I've put together a basic trial program which just starts up MF (Media Foundation), creates a session, shuts down the session, and then shuts down MF. If I bypass the session creation and stop, the MF startup and shutdown are successful. If I include the session creation and stop, the session create is successful (but that doesn't use a PB interface function) but the session stop (which does use a PB interface function) crashes with an IMA. Here's the complete code of this trial program:
Code: Select all
EnableExplicit
Interface IMFMediaSession
ClearTopologies()
Close()
GetClock(*ppClock)
GetFullTopology(dwGetFullTopologyFlags, TopoId, *ppFullTopo)
GetSessionCapabilities(*pdwCaps)
Pause()
SetTopology(dwSetTopologyFlags.l, *pTopology)
Shutdown()
Start(*pguidTimeFormat.GUID, *pvarStartPosition)
Stop()
EndInterface
Global ppMS.IMFMediaSession
Prototype.l PR_MFStartup(version.l, dwFlags.l)
Prototype.l PR_MFShutdown()
Prototype.l PR_MFCreateMediaSession(*pConfiguration, *ppMediaSession)
Global MFStartup.PR_MFStartup
Global MFShutdown.PR_MFShutdown
Global MFCreateMediaSession.PR_MFCreateMediaSession
If OSVersion() >= #PB_OS_Windows_7
Global MF_SDK_VERSION = $0002
Else ; Vista
Global MF_SDK_VERSION = $0001
EndIf
#MF_API_VERSION = $0070 ; This value is unused in the Win7 release and left at its Vista release value
Global MF_VERSION = MF_SDK_VERSION << 16 | #MF_API_VERSION
#MFSTARTUP_NOSOCKET = $1
#MFSTARTUP_LITE = #MFSTARTUP_NOSOCKET
#MFSTARTUP_FULL = 0
Procedure MFControl()
Protected hResult.l
hResult = MFStartup(MF_VERSION, #MFSTARTUP_FULL)
Debug "MFStartup returned " + hResult
If 1=1
hResult = MFCreateMediaSession(#Null, @ppMS)
Debug "MFCreateMediaSession(#Null, @ppMS) returned " + hResult
If hResult = #S_OK
ppMS\Shutdown()
EndIf
EndIf
hResult = MFShutdown()
Debug "MFShutdown returned " + hResult
EndProcedure
Procedure LibraryControl()
Protected iMFLibrary.i, iMFPlatLibrary.i
iMFPlatLibrary = OpenLibrary(#PB_Any, "mfplat.dll")
If iMFPlatLibrary
MFStartup.PR_MFStartup = GetFunction(iMFPlatLibrary, "MFStartup")
Debug "MFStartup=" + MFStartup
MFShutdown.PR_MFShutdown = GetFunction(iMFPlatLibrary, "MFShutdown")
Debug "MFShutdown=" + MFShutdown
iMFLibrary = OpenLibrary(#PB_Any, "mf.dll")
If iMFLibrary
MFCreateMediaSession.PR_MFCreateMediaSession = GetFunction(iMFLibrary, "MFCreateMediaSession")
Debug "MFCreateMediaSession=" + MFCreateMediaSession
MFControl()
CloseLibrary(iMFLibrary)
EndIf
CloseLibrary(iMFPlatLibrary)
EndIf
EndProcedure
LibraryControl()
Debug "End of run"
End
As I mentioned earlier in this posting, I suspect the ** is the cause of the problem. Any ideas how to fix this?