sl@0
|
1 |
//------------------------------------------------------------------------------
|
sl@0
|
2 |
#include "IdwApi.h"
|
sl@0
|
3 |
#include <windows.h>
|
sl@2
|
4 |
|
sl@0
|
5 |
//------------------------------------------------------------------------------
|
sl@0
|
6 |
IdwApi::IdwApi(HINSTANCE hInstance)
|
sl@0
|
7 |
: m_hInstance(hInstance)
|
sl@0
|
8 |
, m_pIdwThread(NULL)
|
sl@0
|
9 |
, m_nInitCount(0)
|
sl@0
|
10 |
{
|
sl@0
|
11 |
}
|
sl@0
|
12 |
//------------------------------------------------------------------------------
|
sl@0
|
13 |
IdwApi::~IdwApi()
|
sl@0
|
14 |
{
|
sl@0
|
15 |
}
|
sl@0
|
16 |
//------------------------------------------------------------------------------
|
sl@0
|
17 |
DSPResult IdwApi::Init(IDW_INITRESULT* pInitResult)
|
sl@0
|
18 |
{
|
sl@0
|
19 |
m_mutex.Request();
|
sl@0
|
20 |
if (m_nInitCount == 0)
|
sl@0
|
21 |
{
|
sl@0
|
22 |
m_pIdwThread = new IdwThread(m_hInstance);
|
sl@0
|
23 |
m_pIdwThread->Start();
|
sl@0
|
24 |
}
|
sl@0
|
25 |
++m_nInitCount;
|
sl@0
|
26 |
DSPResult ret = m_pIdwThread->Init(pInitResult);
|
sl@0
|
27 |
m_mutex.Release();
|
sl@0
|
28 |
return ret;
|
sl@0
|
29 |
}
|
sl@0
|
30 |
//------------------------------------------------------------------------------
|
sl@0
|
31 |
DSPResult IdwApi::Uninit()
|
sl@0
|
32 |
{
|
sl@0
|
33 |
m_mutex.Request();
|
sl@0
|
34 |
if (m_nInitCount == 0)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
m_mutex.Release();
|
sl@0
|
37 |
return DSP_E_NOT_INITED;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
DSPResult ret = m_pIdwThread->Uninit();
|
sl@0
|
40 |
if (ret == DSP_SUCCEEDED)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
--m_nInitCount;
|
sl@0
|
43 |
if (m_nInitCount == 0)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
m_pIdwThread->Interrupt();
|
sl@0
|
46 |
m_pIdwThread->Join();
|
sl@0
|
47 |
delete m_pIdwThread;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
}
|
sl@0
|
50 |
m_mutex.Release();
|
sl@0
|
51 |
return ret;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
//------------------------------------------------------------------------------
|
sl@2
|
54 |
DSPResult IdwApi::IsInitialized()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
m_mutex.Request();
|
sl@0
|
57 |
if (m_nInitCount == 0)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
m_mutex.Release();
|
sl@0
|
60 |
return DSP_S_NOT_INITED;
|
sl@0
|
61 |
}
|
sl@3
|
62 |
DSPResult ret = m_pIdwThread->IsInitialized();
|
sl@0
|
63 |
m_mutex.Release();
|
sl@0
|
64 |
return ret;
|
sl@0
|
65 |
}
|
sl@0
|
66 |
//------------------------------------------------------------------------------
|
sl@0
|
67 |
DSPResult IdwApi::IsPluginModeEnabled()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
m_mutex.Request();
|
sl@0
|
70 |
if (m_nInitCount == 0)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
m_mutex.Release();
|
sl@0
|
73 |
return DSP_S_NOT_IN_PLUGIN_MODE;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
DSPResult ret = m_pIdwThread->IsPluginModeEnabled();
|
sl@0
|
76 |
m_mutex.Release();
|
sl@0
|
77 |
return ret;
|
sl@0
|
78 |
}
|
sl@2
|
79 |
|
sl@2
|
80 |
/**
|
sl@2
|
81 |
Fetch our current status.
|
sl@2
|
82 |
It's actually just the last notification from iMON.
|
sl@2
|
83 |
*/
|
sl@2
|
84 |
DSPResult IdwApi::GetStatus(IDW_STATUS* aStatus)
|
sl@2
|
85 |
{
|
sl@2
|
86 |
m_mutex.Request();
|
sl@2
|
87 |
if (m_nInitCount == 0)
|
sl@2
|
88 |
{
|
sl@2
|
89 |
m_mutex.Release();
|
sl@2
|
90 |
return DSP_E_NOT_INITED;
|
sl@2
|
91 |
}
|
sl@2
|
92 |
|
sl@2
|
93 |
DSPResult ret = m_pIdwThread->GetStatus(aStatus);
|
sl@2
|
94 |
m_mutex.Release();
|
sl@2
|
95 |
return ret;
|
sl@2
|
96 |
}
|
sl@2
|
97 |
|
sl@0
|
98 |
//------------------------------------------------------------------------------
|
sl@0
|
99 |
DSPResult IdwApi::SetVfdText(LPCWSTR lpszLine1, LPCWSTR lpszLine2)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
m_mutex.Request();
|
sl@0
|
102 |
if (m_nInitCount == 0)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
m_mutex.Release();
|
sl@0
|
105 |
return DSP_E_NOT_INITED;
|
sl@0
|
106 |
}
|
sl@0
|
107 |
DSPResult ret = m_pIdwThread->SetVfdText(lpszLine1, lpszLine2);
|
sl@0
|
108 |
m_mutex.Release();
|
sl@0
|
109 |
return ret;
|
sl@0
|
110 |
}
|
sl@0
|
111 |
//------------------------------------------------------------------------------
|
sl@0
|
112 |
DSPResult IdwApi::SetVfdEqData(PDSPEQDATA pEqData)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
m_mutex.Request();
|
sl@0
|
115 |
if (m_nInitCount == 0)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
m_mutex.Release();
|
sl@0
|
118 |
return DSP_E_NOT_INITED;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
DSPResult ret = m_pIdwThread->SetVfdEqData(pEqData);
|
sl@0
|
121 |
m_mutex.Release();
|
sl@0
|
122 |
return ret;
|
sl@0
|
123 |
}
|
sl@0
|
124 |
//------------------------------------------------------------------------------
|
sl@0
|
125 |
DSPResult IdwApi::SetLcdText(LPCWSTR lpszLine1)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
m_mutex.Request();
|
sl@0
|
128 |
if (m_nInitCount == 0)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
m_mutex.Release();
|
sl@0
|
131 |
return DSP_E_NOT_INITED;
|
sl@0
|
132 |
}
|
sl@0
|
133 |
DSPResult ret = m_pIdwThread->SetLcdText(lpszLine1);
|
sl@0
|
134 |
m_mutex.Release();
|
sl@0
|
135 |
return ret;
|
sl@0
|
136 |
}
|
sl@0
|
137 |
//------------------------------------------------------------------------------
|
sl@0
|
138 |
DSPResult IdwApi::SetLcdEqData(PDSPEQDATA pEqDataL, PDSPEQDATA pEqDataR)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
m_mutex.Request();
|
sl@0
|
141 |
if (m_nInitCount == 0)
|
sl@0
|
142 |
{
|
sl@0
|
143 |
m_mutex.Release();
|
sl@0
|
144 |
return DSP_E_NOT_INITED;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
DSPResult ret = m_pIdwThread->SetLcdEqData(pEqDataL, pEqDataR);
|
sl@0
|
147 |
m_mutex.Release();
|
sl@0
|
148 |
return ret;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
//------------------------------------------------------------------------------
|
sl@0
|
151 |
DSPResult IdwApi::SetLcdAllIcons(BOOL bOn)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
m_mutex.Request();
|
sl@0
|
154 |
if (m_nInitCount == 0)
|
sl@0
|
155 |
{
|
sl@0
|
156 |
m_mutex.Release();
|
sl@0
|
157 |
return DSP_E_NOT_INITED;
|
sl@0
|
158 |
}
|
sl@0
|
159 |
DSPResult ret = m_pIdwThread->SetLcdAllIcons(bOn);
|
sl@0
|
160 |
m_mutex.Release();
|
sl@0
|
161 |
return ret;
|
sl@0
|
162 |
}
|
sl@0
|
163 |
//------------------------------------------------------------------------------
|
sl@0
|
164 |
DSPResult IdwApi::SetLcdOrangeIcon(BYTE btIconData1, BYTE btIconData2)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
m_mutex.Request();
|
sl@0
|
167 |
if (m_nInitCount == 0)
|
sl@0
|
168 |
{
|
sl@0
|
169 |
m_mutex.Release();
|
sl@0
|
170 |
return DSP_E_NOT_INITED;
|
sl@0
|
171 |
}
|
sl@0
|
172 |
DSPResult ret = m_pIdwThread->SetLcdOrangeIcon(btIconData1, btIconData2);
|
sl@0
|
173 |
m_mutex.Release();
|
sl@0
|
174 |
return ret;
|
sl@0
|
175 |
}
|
sl@0
|
176 |
//------------------------------------------------------------------------------
|
sl@0
|
177 |
DSPResult IdwApi::SetLcdMediaTypeIcon(BYTE btIconData)
|
sl@0
|
178 |
{
|
sl@0
|
179 |
m_mutex.Request();
|
sl@0
|
180 |
if (m_nInitCount == 0)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
m_mutex.Release();
|
sl@0
|
183 |
return DSP_E_NOT_INITED;
|
sl@0
|
184 |
}
|
sl@0
|
185 |
DSPResult ret = m_pIdwThread->SetLcdMediaTypeIcon(btIconData);
|
sl@0
|
186 |
m_mutex.Release();
|
sl@0
|
187 |
return ret;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
//------------------------------------------------------------------------------
|
sl@0
|
190 |
DSPResult IdwApi::SetLcdSpeakerIcon(BYTE btIconData1, BYTE btIconData2)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
m_mutex.Request();
|
sl@0
|
193 |
if (m_nInitCount == 0)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
m_mutex.Release();
|
sl@0
|
196 |
return DSP_E_NOT_INITED;
|
sl@0
|
197 |
}
|
sl@0
|
198 |
DSPResult ret = m_pIdwThread->SetLcdSpeakerIcon(btIconData1, btIconData2);
|
sl@0
|
199 |
m_mutex.Release();
|
sl@0
|
200 |
return ret;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
//------------------------------------------------------------------------------
|
sl@0
|
203 |
DSPResult IdwApi::SetLcdVideoCodecIcon(BYTE btIconData)
|
sl@0
|
204 |
{
|
sl@0
|
205 |
m_mutex.Request();
|
sl@0
|
206 |
if (m_nInitCount == 0)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
m_mutex.Release();
|
sl@0
|
209 |
return DSP_E_NOT_INITED;
|
sl@0
|
210 |
}
|
sl@0
|
211 |
DSPResult ret = m_pIdwThread->SetLcdVideoCodecIcon(btIconData);
|
sl@0
|
212 |
m_mutex.Release();
|
sl@0
|
213 |
return ret;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
//------------------------------------------------------------------------------
|
sl@0
|
216 |
DSPResult IdwApi::SetLcdAudioCodecIcon(BYTE btIconData)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
m_mutex.Request();
|
sl@0
|
219 |
if (m_nInitCount == 0)
|
sl@0
|
220 |
{
|
sl@0
|
221 |
m_mutex.Release();
|
sl@0
|
222 |
return DSP_E_NOT_INITED;
|
sl@0
|
223 |
}
|
sl@0
|
224 |
DSPResult ret = m_pIdwThread->SetLcdAudioCodecIcon(btIconData);
|
sl@0
|
225 |
m_mutex.Release();
|
sl@0
|
226 |
return ret;
|
sl@0
|
227 |
}
|
sl@0
|
228 |
//------------------------------------------------------------------------------
|
sl@0
|
229 |
DSPResult IdwApi::SetLcdAspectRatioIcon(BYTE btIconData)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
m_mutex.Request();
|
sl@0
|
232 |
if (m_nInitCount == 0)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
m_mutex.Release();
|
sl@0
|
235 |
return DSP_E_NOT_INITED;
|
sl@0
|
236 |
}
|
sl@0
|
237 |
DSPResult ret = m_pIdwThread->SetLcdAspectRatioIcon(btIconData);
|
sl@0
|
238 |
m_mutex.Release();
|
sl@0
|
239 |
return ret;
|
sl@0
|
240 |
}
|
sl@0
|
241 |
//------------------------------------------------------------------------------
|
sl@0
|
242 |
DSPResult IdwApi::SetLcdEtcIcon(BYTE btIconData)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
m_mutex.Request();
|
sl@0
|
245 |
if (m_nInitCount == 0)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
m_mutex.Release();
|
sl@0
|
248 |
return DSP_E_NOT_INITED;
|
sl@0
|
249 |
}
|
sl@0
|
250 |
DSPResult ret = m_pIdwThread->SetLcdEtcIcon(btIconData);
|
sl@0
|
251 |
m_mutex.Release();
|
sl@0
|
252 |
return ret;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
//------------------------------------------------------------------------------
|
sl@0
|
255 |
DSPResult IdwApi::SetLcdProgress(int nCurPos, int nTotal)
|
sl@0
|
256 |
{
|
sl@0
|
257 |
m_mutex.Request();
|
sl@0
|
258 |
if (m_nInitCount == 0)
|
sl@0
|
259 |
{
|
sl@0
|
260 |
m_mutex.Release();
|
sl@0
|
261 |
return DSP_E_NOT_INITED;
|
sl@0
|
262 |
}
|
sl@0
|
263 |
DSPResult ret = m_pIdwThread->SetLcdProgress(nCurPos, nTotal);
|
sl@0
|
264 |
m_mutex.Release();
|
sl@0
|
265 |
return ret;
|
sl@0
|
266 |
}
|
sl@0
|
267 |
//------------------------------------------------------------------------------ |