Microsoft DirectX 8.0 (C++) |
Initializes the performance and optionally sets up a default audiopath. This method must be called before the performance can play using audiopaths.
This method should be used in most cases instead of IDirectMusicPerformance8::Init.
HRESULT InitAudio( IDirectMusic** ppDirectMusic, IDirectSound** ppDirectSound, HWND hWnd, DWORD dwDefaultPathType, DWORD dwPChannelCount, DWORD dwFlags, DMUS_AUDIOPARAMS *pParams );
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.
If the variable pointed to by ppDirectMusic contains NULL, a DirectMusic object is created and the 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 an IDirectSound interface pointer is passed to the method in ppDirectSound. In that case the application is responsible for setting the window handle by using 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 |
DSERR_BUFFERLOST |
DSERR_PRIOLEVELNEEDED |
DSERR_UNINITIALIZED |
E_NOINTERFACE |
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 the following ways.
If you specify an interface pointer in ppDirectSound, it must be an interface to an object of class CLSID_DirectSound8. Objects of this class support both IDirectSound and IDirectSound8, but the IDirectSound interface must be passed. For information on how to create an object of this class, see the Remarks for IDirectSound8. The DirectSound object must be fully initialized before being passed to InitAudio. If the object was created by using CoCreateInstance, call IDirectSound8::Initialize. Set the cooperative level to DSSCL_PRIORITY by using IDirectSound8::SetCooperativeLevel.
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.
The parameters set in dwFlags and pParams apply to the default audiopath and any audiopaths created subsequently.
The method fails with DSERR_BUFFERLOST if a value other than zero is passed in dwDefaultPathType and any application has initialized DirectSound with the write-primary cooperative level.
The performance must be terminated by using the IDirectMusicPerformance8::CloseDown method before being released.
Header: Declared in dmusici.h.