-
Notifications
You must be signed in to change notification settings - Fork 6
/
OptionSound.cpp
273 lines (235 loc) · 8.71 KB
/
OptionSound.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
// OptionSound.cpp: Implementierungsdatei
//
#include "pch.h"
#include "stdafx.h"
#include "resource.h"
#include "mmsystem.h"
#include "dsound.h"
#include "OptionSound.h"
#include "main/win_main.h"
#ifdef _DEBUG
#undef new
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Eigenschaftenseite COptionSound
IMPLEMENT_DYNCREATE(COptionSound, CPropertyPage)
COptionSound::COptionSound() :
CPropertyPage(COptionSound::IDD)
{
//{{AFX_DATA_INIT(COptionSound)
// HINWEIS: Der Klassen-Assistent fügt hier Elementinitialisierung ein
//}}AFX_DATA_INIT
}
COptionSound::~COptionSound()
{
}
void COptionSound::DoDataExchange(CDataExchange * pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COptionSound)
DDX_Control(pDX, IDC_SOUNDCARD, m_soundcard);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COptionSound, CPropertyPage)
//{{AFX_MSG_MAP(COptionSound)
ON_BN_CLICKED(IDC_SOUNDGROUP, OnSoundgroup)
ON_BN_CLICKED(IDC_ENABLE_SOUND, OnEnableSound)
ON_BN_CLICKED(IDC_SOUNDCAPABILITIES, OnSoundcapabilities)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen für Nachrichten COptionSound
void COptionSound::OnSoundgroup()
{
// TODO: Code für die Behandlungsroutine der Steuerelement-Benachrichtigung hier einfügen
SetModified(TRUE);
}
BOOL CALLBACK DSEnumCallback(
LPGUID lpGuid,
LPCSTR lpcstrDescription,
LPCSTR lpcstrModule,
LPVOID lpContext
)
{
//Currently, this is only displaying the devices, it has no active
//feature
CComboBox * cb=(CComboBox *) lpContext;
int index=cb->AddString(lpcstrDescription);
cb->SetItemData(index,(ULONG) lpGuid);
return TRUE;
}
BOOL COptionSound::OnInitDialog()
{
CPropertyPage::OnInitDialog();
if (i4_win32_startup_options.use2dsound
&&i4_win32_startup_options.use3dsound)
{
CheckRadioButton( IDC_3DSOUND,IDC_NOSOUND,IDC_3DSOUND);
}
else if(i4_win32_startup_options.use2dsound)
{
CheckRadioButton(IDC_3DSOUND,IDC_NOSOUND,IDC_2DSOUND);
}
else
{
CheckRadioButton(IDC_3DSOUND,IDC_NOSOUND,IDC_NOSOUND);
}
DirectSoundEnumerate((LPDSENUMCALLBACK) DSEnumCallback,(LPVOID) &m_soundcard);
m_soundcard.SetCurSel(0);
return TRUE;
}
void COptionSound::Apply()
{
if (!m_hWnd)
{
return;
}
int checked=GetCheckedRadioButton(IDC_3DSOUND,IDC_NOSOUND);
if (checked==IDC_3DSOUND)
{
i4_win32_startup_options.use3dsound =TRUE;
i4_win32_startup_options.use2dsound =TRUE;
}
else if (checked==IDC_2DSOUND)
{
i4_win32_startup_options.use3dsound =FALSE;
i4_win32_startup_options.use2dsound =TRUE;
}
else
{
i4_win32_startup_options.use3dsound =FALSE;
i4_win32_startup_options.use2dsound =FALSE;
}
}
//Disabled for now, doesn't work in most cases anyway.
//But enable_sound is always called uppon return from the dialog.
void COptionSound::OnEnableSound()
{
//i4_sound_man->uninit();//Restart the sound - manager
//i4_sound_man->init();
//Er... HELL, how does this work? We need to signal the clients
//that we want to kill their buffers, otherwise they pocess an
//old pointer to a directsound-buffer object but the directsound
//object itself is gone -> HUGE crash.
//li_call("enable_sound");
}
BOOL CALLBACK DSCapsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static LPDIRECTSOUND lpds=NULL;
static LPGUID lpguid;
static HWND hlist;
DSCAPS DSCaps;
UINT dwEntry=0;
HRESULT hr;
switch (message)
{
case WM_INITDIALOG:
lpguid=(LPGUID) lParam;
hlist=GetDlgItem(hDlg,IDC_DSCAPSLIST);
hr=DirectSoundCreate(lpguid,&lpds,NULL);
if (FAILED(hr))
{
MessageBox(GetParent(hDlg),"Die Eigenschaften dieses Geräts sind zur Zeit nicht verfügbar. ",
"DirectSound",MB_OK+MB_ICONSTOP);
return FALSE;
}
ZeroMemory(&DSCaps,sizeof(DSCAPS));
DSCaps.dwSize=sizeof(DSCAPS);
lpds->GetCaps(&DSCaps);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Zertifiziert"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_CERTIFIED ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Jede Samplerate möglich"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_CONTINUOUSRATE ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("DirectSound ist emuliert"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_EMULDRIVER ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("16Bit Wiedergabe möglich"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_PRIMARY16BIT ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("8Bit Wiedergabe möglich"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_PRIMARY8BIT ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Stereowiedergabe möglich"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_PRIMARYSTEREO ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("16Bit Wiedergabe mit Hardwarepuffer möglich"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_SECONDARY16BIT ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("8Bit Wiedergabe mit Hardwarepuffer möglich"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_SECONDARY8BIT ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Hardwarepuffer für Stereowiedergabe verwendbar"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFlags & DSCAPS_SECONDARYSTEREO ? TRUE : FALSE);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Minimale Samplerate für Hardwarepuffer"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwMinSecondarySampleRate);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Maximale Samplerate für Hardwarepuffer"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwMaxSecondarySampleRate);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Kanäle des Hardwaremischers"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwMaxHwMixingAllBuffers);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("3D-Kanäle auf Soundkarte"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwMaxHw3DAllBuffers);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Maximaler Durchsatz des Hardwaremischers"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwUnlockTransferRateHwBuffers);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Geschätzter CPU-Overhead für Softwaremischung"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwPlayCpuOverheadSwBuffers);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Speicherplatz auf der Soundkarte"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwTotalHwMemBytes);
dwEntry=SendMessage(hlist,LB_ADDSTRING,0,(LPARAM) TEXT("Freier Speicher auf der Soundkarte"));
SendMessage(hlist,LB_SETITEMDATA,dwEntry,(LPARAM) DSCaps.dwFreeHwMemBytes);
lpds->Release();
return TRUE;
case WM_CLOSE:
EndDialog(hDlg,TRUE);
return TRUE;
case WM_COMMAND:
DWORD wNotifycode=HIWORD(wParam);
DWORD wID=LOWORD(wParam);
char buf[256];
//HWND hwndCntl=lParam;
switch (wID)
{
case IDC_DSCAPS_CLOSE:
EndDialog(hDlg,TRUE);
return TRUE;
case IDC_DSCAPSLIST:
switch (wNotifycode)
{
case LBN_SELCHANGE:
dwEntry=SendMessage(hlist,LB_GETCURSEL,0,0);
dwEntry=SendMessage(hlist,LB_GETITEMDATA,dwEntry,0);
if (dwEntry==0)
{
strcpy(buf,TEXT("Nein/nicht vorhanden"));
}
else if (dwEntry==TRUE)
{
strcpy(buf,TEXT("Ja"));
}
else
{
wsprintf(buf,TEXT("%i"),dwEntry);
}
SendDlgItemMessage(hDlg,IDC_DSCAPS_VALUE,WM_SETTEXT,0,(LPARAM)buf);
break;
}
break;
}
break;
}
return FALSE;
}
void COptionSound::OnSoundcapabilities()
{
// TODO: Code für die Behandlungsroutine der Steuerelement-Benachrichtigung hier einfügen
//BOOL DefaultDevice ;
GUID guPreferredDevice;
LPGUID lpguTemp;
lpguTemp = (LPGUID)m_soundcard.GetItemData( m_soundcard.GetCurSel());
if( NULL != lpguTemp )
{
guPreferredDevice = *lpguTemp;
}
else
{
guPreferredDevice = GUID_NULL;
}
DialogBoxParam(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDD_SOUNDINFO),m_hWnd,(DLGPROC) DSCapsProc,
(LPARAM) (LPGUID)&guPreferredDevice);
}