📄 idscx5530.cpp
字号:
//////////////////////////////////////////////////////////////////////////////
/*****************************************************************************
Copyright (c) 1999 Microsoft Corporation
Module Name:
IDsCX5530.cpp
Abstract:
Provides the DllEntry point for the the IDsCX5530 dll.
This Dll serves out IDsPlaybackDriver and IDsPlaybackDriverBuffer
COM objects which will talk to your audio hardware.
Software Layers:
=============== ===============
| Application | | Application | Module(s)
=============== ===============
----------- DSOUND.H --------- Interface
=============== ===============
| DSOUNDC.DLL | | DSOUNDC.DLL | Module (dsoundc.dll)
=============== ===============
------- DSoundSIOCTLs.H ----- Interface
------ DeviceIoControl() ----- PSL API
==================================
| DSound server | Module (dsounds.dll)
==================================
-- IDsPlaybackDriver, IDsPlaybackDriverBuffer - Interface
==================================
| IDsCX5530.DLL | Module (IDsCX5530.dll)
==================================
==================================
| HARDWARE |
==================================
Revision History:
mmaguire 08/19/99
*****************************************************************************/
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// BEGIN INCLUDES
//
// standard includes:
//
//
// where we can find declaration for main class in this file:
//
//
//
// where we can find declarations needed in this file:
//
#define INITGUID // Instantiate the guids from this file - don't do this in two places
#define INSTANTIATE_DEBUG
#include "includes.h"
#include "DsPlaybackDriver.h"
#include "DsCaptureDriver.h"
//
//
//
// END INCLUDES
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
/*****************************************************************************
globals
*****************************************************************************/
//////////////////////////////////////////////////////////////////////////////
//HANDLE g_hInstance;
//////////////////////////////////////////////////////////////////////////////
/*****************************************************************************
IDsCX5530.DLL entry point.
*****************************************************************************/
//////////////////////////////////////////////////////////////////////////////
extern "C" BOOL
DllEntry(
HANDLE hinstDll, /*@parm Instance pointer. */
DWORD dwReason, /*@parm Reason routine is called. */
PULONG lpReserved /*@parm system parameter. */
)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
FUNCMSG("IDsCX5530 DLL_PROCESS_ATTACH");
// this creates the singleton CCX5530Audio object
// and initializes the audio hardware.
if (!CCX5530Audio::GetCX5530AudioObject())
{
ERRMSG("Can't initialize audio! DLL unloading");
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
FUNCMSG("+IDsCX5530 DLL_PROCESS_DETACH");
CCX5530Audio::DeleteObject(); // this cleans up the single CCX5530Audio object
break;
/*
case DLL_THREAD_ATTACH:
FUNCMSG1("+IDsCX5530 DLL_THREAD_ATTACH: 0x%8.8x", GetCurrentThreadId());
break;
case DLL_THREAD_DETACH:
FUNCMSG("+IDsCX5530 DLL_THREAD_DETACH");
break;
case DLL_PROCESS_EXITING:
FUNCMSG("+IDsCX5530 DLL_PROCESS_EXITING");
break;
case DLL_SYSTEM_STARTED:
FUNCMSG("+IDsCX5530 DLL_SYSTEM_STARTED");
break;
case DLL_MEMORY_LOW:
FUNCMSG("+IDsCX5530 DLL_MEMORY_LOW");
break;
*/
}
return TRUE;
}
// This is the CLSID that we will register in the appropriate DirectSound
// registry setting. DirectSound will look in that (to be determined) regsitry
// key, see the name of the dll we have provided, and then create the IDsPlaybackDriver
// object by calling DllGetClassObject, passing in the CLSID we've registered.
// {9636C711-40EA-489b-AE3D-D510F7A9A0AA}
DEFINE_GUID(CLSID_CX5530IDsPlaybackDriver,
0x9636c711, 0x40ea, 0x489b, 0xae, 0x3d, 0xd5, 0x10, 0xf7, 0xa9, 0xa0, 0xaa);
// {A9AA6676-6B8C-47d0-98BB-737ABD6B0A79}
DEFINE_GUID(CLSID_CX5530IDsCaptureDriver,
0xa9aa6676, 0x6b8c, 0x47d0, 0x98, 0xbb, 0x73, 0x7a, 0xbd, 0x6b, 0xa, 0x79);
//////////////////////////////////////////////////////////////////////////////
/*****************************************************************************
*****************************************************************************/
//////////////////////////////////////////////////////////////////////////////
HRESULT WINAPI DllGetClassObject(
REFCLSID rclsid //CLSID for the class object
, REFIID riid //Reference to the identifier of the interface
// that communicates with the class object
, LPVOID * ppv //Address of output variable that receives the
// interface pointer requested in riid
)
{
FUNCMSG1("+IDsCX5530Audio DllGetClassObject: %x", rclsid.Data1);
HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
IUnknown * pUnknown = NULL;
#if 0
CCX5530Audio::GetCX5530AudioObject()->Test();
#endif
if( IsEqualGUID( rclsid, CLSID_CX5530IDsPlaybackDriver) )
{
INFMSG("Getting CLSID_CX5530IDsPlaybackDriver");
pUnknown = (IUnknown *) new DsPlaybackDriver( hr );
}
// If we supported creating any other objects from this driver,
// for example a capture driver object (IDsCaptureDriver) then
// we could check for that here.
else if( IsEqualGUID( rclsid, CLSID_CX5530IDsCaptureDriver ) )
{
INFMSG("Getting CLSID_CX5530IDsCaptureDriver");
pUnknown = (IUnknown *) new DsCaptureDriver( hr );
}
if( FAILED(hr) || ! pUnknown )
{
ERRMSG("IDsCX5530 DllGetClassObject -- unknown class");
if( pUnknown )
{
delete pUnknown;
}
*ppv = NULL;
return CLASS_E_CLASSNOTAVAILABLE;
}
// Now call on the object we've created and see if it supports the
// requested interface (i.e. see if it inherits from the
// requested abstract C++ base class).
hr = pUnknown->QueryInterface( riid, ppv );
// Need to make sure RefCount on the object is correct -- whether we
// succeeded above or failed, it is 1 higher than it should be.
// If we succeeded above, it is now 2, not 1 and if we failed it is 1 not 0.
// This is because both constructor and QueryInterface increased RefCount.
pUnknown->Release();
if( FAILED(hr) || ! *ppv )
{
ERRMSG("IDsCX5530 DllGetClassObject -- QueryInterface failed");
if( *ppv )
{
((IUnknown *) *ppv)->Release();
*ppv = NULL;
}
// ISSUE: Actually interface not supported.
return CLASS_E_CLASSNOTAVAILABLE;
}
// If we got to this point, we are good to go.
return DS_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -