-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIDirectSoundClassFactoryEx.cpp
executable file
·191 lines (144 loc) · 5.32 KB
/
IDirectSoundClassFactoryEx.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//////////////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2003-2007, Arne Bockholdt, [email protected]
//
// This file is part of Direct Sound Control.
//
// Direct Sound Control is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Direct Sound Control is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Direct Sound Control. If not, see <http://www.gnu.org/licenses/>.
//
//////////////////////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "DSoundTypes.h"
#include "idirectsoundex.h"
#include "idirectsoundclassfactoryex.h"
//////////////////////////////////////////////////////////////////////////////////////////////
IDirectSoundClassFactoryEx::IDirectSoundClassFactoryEx(void)
{
#ifdef ENABLE_LOG
m_cszClassName = IDIRECTSOUNDCLASSFACTORYEX_CLASS_NAME;
if( g_bLogSystem == true )
LogMessage( m_cszClassName, this, "Constructor called....");
#endif // ENABLE_LOG
}
//////////////////////////////////////////////////////////////////////////////////////////////
IDirectSoundClassFactoryEx::~IDirectSoundClassFactoryEx(void)
{
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
LogMessage( m_cszClassName, this, "Destructor called....");
#endif // ENABLE_LOG
}
//////////////////////////////////////////////////////////////////////////////////////////////
HRESULT IDirectSoundClassFactoryEx::QueryInterface( REFIID refIID, LPVOID * pVoid)
{
*pVoid = NULL;
if( refIID == IID_IClassFactory )
{
LPVOID pTemp;
HRESULT hRes = m_lpClassFactory->QueryInterface( refIID, &pTemp );
if( hRes != S_OK )
{
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
::LogMessage( m_cszClassName, this, "QueryInterface for interface IID_IClassFactory failed...");
#endif // ENABLE_LOG
return hRes;
}
m_lpClassFactory = (LPCLASSFACTORY) pTemp;
*pVoid = (LPVOID) this;
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
::LogMessage( m_cszClassName, this, "QueryInterface called,Interface=IID_IClassFactory");
#endif // ENABLE_LOG
return S_OK;
}
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
LogMessage( m_cszClassName, this, "QueryInterface called for unknown IID interface ....");
#endif // ENABLE_LOG
return m_lpClassFactory->QueryInterface( refIID, pVoid );
}
//////////////////////////////////////////////////////////////////////////////////////////////
ULONG IDirectSoundClassFactoryEx::AddRef()
{
ULONG nRefCnt = m_lpClassFactory->AddRef();
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
{
CString sLogString;
sLogString.Format("AddRef called....,nRefCnt=%u", nRefCnt );
::LogMessage( m_cszClassName, this, sLogString.GetBuffer());
}
#endif // ENABLE_LOG
return nRefCnt;
}
//////////////////////////////////////////////////////////////////////////////////////////////
ULONG IDirectSoundClassFactoryEx::Release()
{
ULONG nRefCnt = m_lpClassFactory->Release();
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
{
CString sLogString;
sLogString.Format("Release called....,nRefCnt=%u", nRefCnt );
::LogMessage( m_cszClassName, this, sLogString.GetBuffer());
}
#endif // ENABLE_LOG
if ( nRefCnt == 0 )
{
delete this;
return 0;
}
return nRefCnt;
}
//////////////////////////////////////////////////////////////////////////////////////////////
HRESULT IDirectSoundClassFactoryEx::CreateInstance( IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
{
*ppvObject = NULL;
if(( riid == IID_IDirectSound ) || ( riid == IID_IDirectSound8 ))
{
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
::LogMessage( m_cszClassName, this, "CreateInstance called for IID_IDirectSound(8) interface....");
#endif // ENABLE_LOG
IDirectSound8Ex* pDSX = new IDirectSound8Ex;
HRESULT hRes = m_lpClassFactory->CreateInstance( pUnkOuter, riid, (LPVOID*)&( pDSX->m_lpDirectSound8 ) );
if( hRes != S_OK )
{
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
::LogMessage( m_cszClassName, this, "DirectSoundCreate failed....");
#endif // ENABLE_LOG
delete pDSX;
return S_FALSE;
}
*ppvObject = (LPDIRECTSOUND) pDSX;
return S_OK;
}
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
::LogMessage( m_cszClassName, this, "CreateInstance called for unknown IID interface....");
#endif // ENABLE_LOG
return m_lpClassFactory->CreateInstance(pUnkOuter, riid, ppvObject);
}
//////////////////////////////////////////////////////////////////////////////////////////////
HRESULT IDirectSoundClassFactoryEx::LockServer( BOOL fLock )
{
#ifdef ENABLE_LOG
if( g_bLogSystem == true )
::LogMessage( m_cszClassName, this, "LockServer called....");
#endif // ENABLE_LOG
return m_lpClassFactory->LockServer(fLock);
}
//////////////////////////////////////////////////////////////////////////////////////////////