Microsoft DirectX 8.0 (C++) |
Associates the performance with a DirectMusic object and a DirectSound object. If the application is not using audiopaths, this method must be called before the performance can play.
For applications that use audiopaths, this method has been superseded by IDirectMusicPerformance8::InitAudio.
HRESULT Init( IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd );
If the variable pointed to by ppDirectMusic contains a valid IDirectMusic or IDirectMusic8 interface pointer, the existing object is assigned to the performance. The reference count of the interface is incremented. Ports passed to the IDirectMusicPerformance8::AddPort method must be created from this DirectMusic object.
If the variable pointed to by ppDirectMusic contains NULL, a DirectMusic object is created and an IDirectMusic interface pointer is returned. Use QueryInterface to obtain IDirectMusic8.
If ppDirectMusic is NULL, a DirectMusic object is created and used internally by the performance.
See Remarks.
This parameter is ignored if pDirectSound is not NULL, in which case the application is responsible for setting the window handle in a call to IDirectSound8::SetCooperativeLevel.
If the method succeeds, the return value is S_OK.
If it fails, the method can return one of the following error values:
DMUS_E_ALREADY_INITED |
E_OUTOFMEMORY |
E_POINTER |
This method can be called only once. It cannot be used to retrieve an existing IDirectMusic8 interface.
A DirectMusic object can be associated with the performance in any of the following ways:
The performance must be terminated by using the IDirectMusicPerformance8::CloseDown method before being released.
You can pass NULL in the hWnd parameter to pass the current foreground window handle to DirectSound. However, do not assume that the application window will be in the foreground during initialization. It is best to pass the top-level application window handle.
Header: Declared in dmusici.h.