RSX 3D  Contents  Interfaces  Data Structures  Previous  Next

Creating Emitters and Listeners

To create emitters and listeners there are 3 general steps you must follow.

  1. Get an IUnknown pointer to an RSX20 object.
  2. Create the emitter or listener.
  3. Initialize the emitter or listener

 


1. Getting the IUnknown pointer to an RSX20 object

There are two ways to get an IUnknown pointer to an RSX20 object.

IMPORTANT: To use the GUID IID_IUnknown you must link your application to uuid.lib.

Method One:
When you create the RSX20 object ask for an IUnknown interface:

// Create the RSX20 object and get an IUnknown pointer to the object
IUnknown* m_lpUnk;
hr = CoCreateInstance(CLSID_RSX20,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_IUnknown,
			(void ** ) &m_lpUnk);	

Method Two:
QueryInterface on the RSX20 object for an IUnknown interface

// Create an RSX20 object and get some interface other than IUnknown
// Possible interfaces are IRSX2 and IRSX20

IUnknown* m_lpUnk;
IRSX2* m_lpRSX;
hr = CoCreateInstance(CLSID_RSX20,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_IRSX2,
			(void ** ) &m_lpRSX);
if(SUCCEEDED(hr)) {
	// Query the object for an IUnknown interface
	hr = m_lpRSX->QueryInterface(IID_IUnknown, (void**)&m_lpUnk);
} // endif

2. Create the emitter or listener

Create emitters, cached or streaming, and listeners, direct or streaming, by creating the appropriate COM object.

Examples:

Create a cached emitter

IRSXCachedEmitter* m_lpRSXCE;

hr = CoCreateInstance(CLSID_RSXCACHEDEMITTER,
	NULL,
	CLSCTX_INPROC_SERVER,
	IID_IRSXCachedEmitter,
	(void ** ) &m_lpRSXCE);

 

Create a streaming emitter

IRSXStreamingEmitter* m_lpRSXSE;

hr = CoCreateInstance(CLSID_RSXSTREAMINGEMITTER,
	NULL,
	CLSCTX_INPROC_SERVER,
	IID_IRSXStreamingEmitter,
	(void ** ) &m_lpRSXSE);

 

Create a direct listener

IRSXDirectListener* m_lpRSXDL;

hr = CoCreateInstance(CLSID_RSXDIRECTLISTENER,
	NULL,
	CLSCTX_INPROC_SERVER,
	IID_IRSXDirectListener,
	(void ** ) &m_lpRSXDL);

 

Create a streaming listener

IRSXStreamingListener* m_lpRSXSL;

hr = CoCreateInstance(CLSID_RSXSTREAMINGLISTENER,
	NULL,
	CLSCTX_INPROC_SERVER,
	IID_IRSXStreamingListener,
	(void ** ) &m_lpRSXSL);

3. Initialize the emitter or listener

After an emitter or listener is created it must be initialized before it can be used. Only IUnknown interface functions (QueryInterface, AddRef, Release) can be called on an emitter or listener object before it has been initialized.

IMPORTANT: An object can be initialized once and only once.

Initializing an object initializes the attributes for the object and attaches the object to an RSX20 object.

IMPORTANT: You may have multiple RSX20 objects in your application (although there are very few cases where this is practical). You may have multiple emitter objects attached to each RSX20 object. You may have one and only one listener object (direct or streaming) attached to each RSX20 object. You may be limited to only one direct listener object in your application if other applications or other RSX20 objects have already created a direct listener and the direct listener is using WAVE and not DirectSound.

Each object has their own Initialize function. The functions have similar prototypes:

IRSXCachedEmitter
HRESULT Initialize(RSXCACHEDEMITTERDESC* lpCachedEmitterAttr, LPUNKNOWN pUnk);
IRSXStreamingEmitter
HRESULT Initialize(RSXSTREAMINGEMITTERDESC* lpStreamingEmitterAttr, LPUNKNOWN pUnk);
IRSXDirectListener
HRESULT Initialize(RSXDIRECTLISTENERDESC* lpDirectListenerAttr, LPUNKNOWN pUnk);
IRSXStreamingListener
HRESULT Initialize(RSXSTREAMINGLISTENERDESC* lpStreamingListenerAttr, LPUNKNOWN pUnk);

The second parameter in all of the Initialize functions is a pointer to an IUnknown interface. This must always be the IUnknown pointer returned in step 1.

NOTE: The steps shown above are the PREFERRED way of creating emitters and listeners. You can however still create your emitters and listeners using the older but still supported functions: CreateCachedEmitter, CreateDirectListener, CreateStreamingEmitter, CreateStreamingListener found in the IRSX interface.


RSX 3D Contents Interfaces Data Structures Previous Next

Copyright ©1996, 1997 Intel Corporation. All rights reserved