ReactOS  0.4.13-dev-479-gec9c8fd
main.cpp File Reference
#include "main.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

void PrintLastError (LPCSTR function)
 
BOOL generateTestSignal (double amplitude, int Channels, int SamplesPerSec, SHORT **buffer)
 
BOOL stopTestTone (void)
 
UINT findWaveDeviceID ()
 
BOOL playTestTone ()
 
BOOL CALLBACK DSEnumProc (LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext)
 
BOOL getCurrentChannelConfig ()
 
BOOL setCurrentChannelConfig ()
 
BOOL getDeviceInfo (const GUID *category, CMIDEV *pDev)
 
BOOL getDeviceInterfaceDetail (const GUID *category, CMIDEV *pDev)
 
BOOL getDriverData (CMIDEV *pDev)
 
BOOL setDriverData (CMIDEV *pDev)
 
void cleanUp ()
 
BOOL openDevice (bool handleError)
 
void updateChannelBoxes (HWND hWnd)
 
BOOL setDlgItems (HWND hWnd)
 
BOOL applySettings ()
 
BOOL initDialog (HWND hWnd)
 
BOOL changeTab (LPNMHDR lpnmhdr)
 
LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
void openURL (int control)
 
LRESULT CALLBACK TabDlgProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
void printUsage ()
 
void deleteDriverFiles ()
 
void performUninstall ()
 
bool checkToken (char *token)
 
int parseArguments (LPSTR szCmdLine)
 
void InitURLControl ()
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
 

Function Documentation

◆ applySettings()

BOOL applySettings ( )

Definition at line 633 of file main.cpp.

634 {
641 
650 
651  cmiData.formatMask = 0;
664 
666 
668 }
#define IDC_FMT_441_MULTI_PCM
Definition: resource.h:75
UInt32 invertPhaseSPDI
Definition: property.h:79
#define FMT_882_DOLBY
Definition: property.h:52
#define IDC_FMT_480_PCM
Definition: resource.h:72
UInt32 enableSPDIMonitor
Definition: property.h:69
UInt32 enableSPDI
Definition: property.h:83
#define IDC_FMT_441_PCM
Definition: resource.h:71
#define FMT_480_MULTI_PCM
Definition: property.h:47
#define IDC_FMT_882_PCM
Definition: resource.h:73
UInt32 formatMask
Definition: property.h:82
UInt32 loopSPDI
Definition: property.h:81
UInt32 invertValidBitSPDI
Definition: property.h:80
#define FMT_480_PCM
Definition: property.h:43
BOOL setDriverData(CMIDEV *pDev)
Definition: main.cpp:446
#define IDC_EN_CENTER2MIC
Definition: resource.h:45
#define CB_GETCURSEL
Definition: winuser.h:1904
#define IDC_LOOP_SPDF
Definition: resource.h:66
UInt32 enableCenter2Mic
Definition: property.h:74
#define FMT_441_PCM
Definition: property.h:42
#define IDC_FMT_480_DOLBY
Definition: resource.h:80
UInt32 enableSPDOCopyright
Definition: property.h:77
UInt32 enableCenter2Line
Definition: property.h:72
#define FMT_441_DOLBY
Definition: property.h:50
CMIDEV cmiTopologyDev
Definition: main.h:77
CMIDATA cmiData
Definition: main.h:78
UInt32 enableSPDO5V
Definition: property.h:76
#define IDC_FMT_480_MULTI_PCM
Definition: resource.h:76
#define IDC_EN_SPDO
Definition: resource.h:59
#define IDC_FMT_960_PCM
Definition: resource.h:74
#define BM_GETCHECK
Definition: winuser.h:1879
UInt32 enableSPDO
Definition: property.h:75
#define IDC_EN_SPDIMONITOR
Definition: resource.h:68
#define FMT_960_MULTI_PCM
Definition: property.h:49
#define IDC_FMT_882_MULTI_PCM
Definition: resource.h:77
BOOL setCurrentChannelConfig()
Definition: main.cpp:279
UInt32 exchangeFrontBack
Definition: property.h:70
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDCB_CHANNELCONFIG
Definition: resource.h:47
UInt32 enableRear2Line
Definition: property.h:73
#define IDC_SEL_SPDIFI
Definition: resource.h:63
#define FMT_960_PCM
Definition: property.h:45
#define IDC_FMT_960_MULTI_PCM
Definition: resource.h:78
#define IDC_FMT_882_DOLBY
Definition: resource.h:81
#define IDC_EN_CLFE2LINE
Definition: resource.h:43
UInt32 enableBass2Line
Definition: property.h:71
#define IDC_EXCH_FB
Definition: resource.h:41
#define IDC_INV_SPDIFI
Definition: resource.h:64
#define IDC_FMT_960_DOLBY
Definition: resource.h:82
#define IDC_EN_REAR2LINE
Definition: resource.h:42
#define BST_CHECKED
Definition: winuser.h:197
#define FMT_480_DOLBY
Definition: property.h:51
#define SendMessage
Definition: winuser.h:5709
#define FMT_882_MULTI_PCM
Definition: property.h:48
#define FMT_960_DOLBY
Definition: property.h:53
#define IDC_POLVALID
Definition: resource.h:65
#define FMT_882_PCM
Definition: property.h:44
#define IDC_EN_SPDO5V
Definition: resource.h:60
HWND hWndChild[NUM_TABS]
Definition: main.h:75
#define FMT_441_MULTI_PCM
Definition: property.h:46
#define IDC_EN_SPDCOPYRHT
Definition: resource.h:61
#define IDC_EN_SPDI
Definition: resource.h:67
int currentChannelCount
Definition: main.h:81
#define IDC_FMT_441_DOLBY
Definition: resource.h:79
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
UInt32 select2ndSPDI
Definition: property.h:78

Referenced by WndProc().

◆ changeTab()

BOOL changeTab ( LPNMHDR  lpnmhdr)

Definition at line 706 of file main.cpp.

707 {
708  if (lpnmhdr->code != TCN_SELCHANGE) {
709  return FALSE;
710  }
714  return TRUE;
715 }
#define TCM_GETCURSEL
Definition: commctrl.h:4034
#define SW_SHOWDEFAULT
Definition: winuser.h:774
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
UINT code
Definition: winuser.h:3112
#define TCN_SELCHANGE
Definition: commctrl.h:4104
LRESULT currentTab
Definition: main.h:76
#define SendMessage
Definition: winuser.h:5709
HWND hWndTab
Definition: main.h:74
HWND hWndChild[NUM_TABS]
Definition: main.h:75

Referenced by WndProc().

◆ checkToken()

bool checkToken ( char token)

Definition at line 834 of file main.cpp.

834  {
835  if ((strcmp(token, "?")==0) || (strcmp(token, "H")==0)) {
836  printUsage();
837  return TRUE;
838  } else
839  if (strcmp(token, "ENABLE71MODE")==0) {
841  } else
842  if (strcmp(token, "ENABLE51MODE")==0) {
844  } else
845  if ((strcmp(token, "ENABLE40MODE")==0) || (strcmp(token, "ENABLEQUADMODE")==0) || (strcmp(token, "QUAD")==0) ) {
847  } else
848  if ((strcmp(token, "ENABLE20MODE")==0) || (strcmp(token, "ENABLESTEREOMODE")==0) || (strcmp(token, "STEREO")==0) ) {
850  } else
851  if (strcmp(token, "ENABLESPDIFO")==0) {
853  } else
854  if (strcmp(token, "DISABLESPDIFO")==0) {
856  } else
857  if (strcmp(token, "ENABLESPDIFI")==0) {
859  } else
860  if (strcmp(token, "DISABLESPDIFI")==0) {
862  } else
863  if ((strcmp(token, "ENABLELOOPTHRU")==0) || (strcmp(token, "ENABLELOOPTHROUGH")==0) || (strcmp(token, "ENABLELOOP")==0) ) {
865  } else
866  if ((strcmp(token, "DISABLELOOPTHRU")==0) || (strcmp(token, "DISABLELOOPTHROUGH")==0) || (strcmp(token, "DISABLELOOP")==0) ) {
868  } else
869  if (strcmp(token, "UNINSTALL")==0) {
871  }
872  return FALSE;
873 }
#define TRUE
Definition: types.h:120
UInt32 enableSPDI
Definition: property.h:83
UInt32 loopSPDI
Definition: property.h:81
void performUninstall()
Definition: main.cpp:827
void printUsage()
Definition: main.cpp:787
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
CMIDATA cmiData
Definition: main.h:78
UInt32 enableSPDO
Definition: property.h:75
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int currentChannelCount
Definition: main.h:81

Referenced by parseArguments().

◆ cleanUp()

void cleanUp ( )

Definition at line 472 of file main.cpp.

473 {
474  stopTestTone();
475  if (cmiTopologyDev.Info) {
478  }
482  }
483  if (hURLFont) {
484  DeleteObject(hURLFont); //hm?
485  hURLFont = NULL;
486  }
487 }
PSP_DEVICE_INTERFACE_DETAIL_DATA InterfaceDetailData
Definition: main.h:66
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
CMIDEV cmiTopologyDev
Definition: main.h:77
HFONT hURLFont
Definition: main.h:82
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
HDEVINFO Info
Definition: main.h:64
BOOL stopTestTone(void)
Definition: main.cpp:103

Referenced by AddRightEdges(), load_mapi_providers(), MCIAVI_OpenAudio(), WAVE_mciPlay(), WAVE_mciRecord(), WinMain(), and WndProc().

◆ deleteDriverFiles()

void deleteDriverFiles ( )

Definition at line 805 of file main.cpp.

805  {
806  TCHAR SysDir[MAX_PATH];
807  unsigned int len;
808  if (GetSystemDirectory(SysDir, sizeof(SysDir))==0) {
809  PrintLastError("GetSystemDirectory()");
810  return;
811  }
812  len = strlen(SysDir);
813 
814  strcat(SysDir, "\\cmicpl.cpl");
815  if (!DeleteFile(SysDir)) {
817  }
818  SysDir[len] = 0;
819 
820  strcat(SysDir, "\\cmicontrol.exe");
821  if (!DeleteFile(SysDir)) {
823  }
824 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define MoveFileEx
Definition: winbase.h:3692
#define DeleteFile
Definition: winbase.h:3578
smooth NULL
Definition: ftsmooth.c:416
#define MOVEFILE_DELAY_UNTIL_REBOOT
Definition: winbase.h:381
char TCHAR
Definition: xmlstorage.h:189
#define MAX_PATH
Definition: compat.h:26
GLenum GLsizei len
Definition: glext.h:6722
#define GetSystemDirectory
Definition: winbase.h:3656

Referenced by performUninstall().

◆ DSEnumProc()

BOOL CALLBACK DSEnumProc ( LPGUID  lpGUID,
LPCTSTR  lpszDesc,
LPCTSTR  lpszDrvName,
LPVOID  lpContext 
)

Definition at line 214 of file main.cpp.

215 {
216  LPGUID* pGUID = (LPGUID*)lpContext;
217 
218  if (pGUID == NULL) {
219  return FALSE;
220  }
221  if ((*pGUID) != NULL) {
222  return TRUE;
223  }
224 
225  if (lpGUID != NULL) {
226  // XP, 2k
227  if ((CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDrvName, -1, TEXT("cmipci.sys"), -1) == CSTR_EQUAL) &&
228  (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDesc, -1, TEXT("CMI8738/8768 Wave"), -1) == CSTR_EQUAL)) {
229  (*pGUID) = (LPGUID)LocalAlloc(LPTR, sizeof(GUID));
230  memcpy((*pGUID), lpGUID, sizeof(GUID));
231  return TRUE;
232  }
233  // Vista
234  if (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDesc, -1, TEXT("Speakers (CMI8738/8768 Audio Device)"), -1) == CSTR_EQUAL) {
235  (*pGUID) = (LPGUID)LocalAlloc(LPTR, sizeof(GUID));
236  memcpy((*pGUID), lpGUID, sizeof(GUID));
237  return TRUE;
238  }
239  }
240  return TRUE;
241 }
#define MAKELCID(lgid, srtid)
#define TRUE
Definition: types.h:120
#define NORM_IGNORECASE
Definition: winnls.h:173
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
smooth NULL
Definition: ftsmooth.c:416
#define CompareString
Definition: winnls.h:1171
#define SORT_DEFAULT
#define LANG_ENGLISH
Definition: nls.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CSTR_EQUAL
Definition: winnls.h:453
#define TEXT(s)
Definition: k32.h:26
#define LPTR
Definition: winbase.h:362
#define MAKELANGID(p, s)
Definition: nls.h:15
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
GUID * LPGUID
Definition: guiddef.h:76

Referenced by getCurrentChannelConfig(), and setCurrentChannelConfig().

◆ findWaveDeviceID()

UINT findWaveDeviceID ( )

Definition at line 122 of file main.cpp.

123 {
124  WAVEOUTCAPS woc;
125  UINT i, numDev;
126 
127  numDev = waveOutGetNumDevs();
128  for (i=0;i<numDev;i++) {
129  if (!waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS))) {
131  (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, woc.szPname, -1, TEXT("Speakers (CMI8738/8768 Audio De"), -1) == CSTR_EQUAL)) {
132  return i;
133  }
134  }
135  }
136  return WAVE_MAPPER;
137 }
#define MAKELCID(lgid, srtid)
#define NORM_IGNORECASE
Definition: winnls.h:173
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2140
#define CompareString
Definition: winnls.h:1171
#define WAVE_MAPPER
Definition: mmsystem.h:187
#define SORT_DEFAULT
#define LANG_ENGLISH
Definition: nls.h:52
#define CSTR_EQUAL
Definition: winnls.h:453
#define TEXT(s)
Definition: k32.h:26
#define waveOutGetDevCaps
Definition: mmsystem.h:2833
unsigned int UINT
Definition: ndis.h:50
#define MAKELANGID(p, s)
Definition: nls.h:15
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1028

Referenced by playTestTone().

◆ generateTestSignal()

BOOL generateTestSignal ( double  amplitude,
int  Channels,
int  SamplesPerSec,
SHORT **  buffer 
)

Definition at line 41 of file main.cpp.

42 {
43  int i, o2, o3, o4, o5;
44  bool Left,Right,BackLeft,BackRight,Center,Sub, CenterLeft, CenterRight;
45  short value;
46  double x = SPEAKER_FREQUENCY*2*3.141592654/SamplesPerSec;
47  double y = BASS_FREQUENCY*2*3.141592654/SamplesPerSec;
48 
56  CenterRight = (SendMessage(GetDlgItem(hWndChild[0], IDC_CRIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 6);
57 
58  if (!(Left || Right || BackLeft || BackRight || Center || Sub || CenterLeft || CenterRight)) {
59  return FALSE;
60  }
61 
62  if (currentChannelCount > 4) {
63  o2 = 4; o3 = 5;
64  o4 = 2; o5 = 3;
65  } else {
66  o2 = 2; o3 = 3;
67  o4 = 4; o5 = 5;
68  }
69 
70  (*buffer) = (SHORT*)LocalAlloc(LPTR, SamplesPerSec*sizeof(SHORT)*Channels);
71  ZeroMemory((*buffer), SamplesPerSec*sizeof(SHORT)*Channels);
72 
73  for (i=0;i<SamplesPerSec;i++) {
74  value = (SHORT)(cos(i*x)*amplitude*32767.0);
75  if (Left) {
76  (*buffer)[(i*Channels)+0] = value;
77  }
78  if (Right) {
79  (*buffer)[(i*Channels)+1] = value;
80  }
81  if (BackLeft) {
82  (*buffer)[(i*Channels)+o2] = value;
83  }
84  if (BackRight) {
85  (*buffer)[(i*Channels)+o3] = value;
86  }
87  if (Center) {
88  (*buffer)[(i*Channels)+o4] = value;
89  }
90  if (Sub) {
91  (*buffer)[(i*Channels)+o5] = (SHORT)(cos(i*y)*amplitude*32767.0);
92  }
93  if (CenterLeft) {
94  (*buffer)[(i*Channels)+6] = value;
95  }
96  if (CenterRight) {
97  (*buffer)[(i*Channels)+7] = value;
98  }
99  }
100  return TRUE;
101 }
#define TRUE
Definition: types.h:120
#define SPEAKER_FREQUENCY
Definition: main.h:58
#define IDC_CLEFT
Definition: resource.h:49
#define ZeroMemory
Definition: winbase.h:1635
GLuint buffer
Definition: glext.h:5915
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define IDC_RIGHT
Definition: resource.h:52
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IDC_BLEFT
Definition: resource.h:53
short SHORT
Definition: pedump.c:59
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
#define IDC_CENTER
Definition: resource.h:50
#define BM_GETCHECK
Definition: winuser.h:1879
#define IDC_LEFT
Definition: resource.h:48
#define IDC_SUB
Definition: resource.h:55
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define BASS_FREQUENCY
Definition: main.h:55
#define IDC_BRIGHT
Definition: resource.h:54
#define IDC_CRIGHT
Definition: resource.h:51
GLsizei const GLfloat * value
Definition: glext.h:6069
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define BST_CHECKED
Definition: winuser.h:197
#define SendMessage
Definition: winuser.h:5709
#define LPTR
Definition: winbase.h:362
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
HWND hWndChild[NUM_TABS]
Definition: main.h:75
int currentChannelCount
Definition: main.h:81

Referenced by playTestTone().

◆ getCurrentChannelConfig()

BOOL getCurrentChannelConfig ( )

Definition at line 243 of file main.cpp.

244 {
245  IDirectSound8* ds;
246  DWORD speakerConfig;
247  LPGUID guid = NULL;
248 
249  DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc, (VOID*)&guid);
250 
251  if (DirectSoundCreate8(guid, &ds, NULL) != S_OK) {
252  return FALSE;
253  }
254 
255  ds->Initialize(NULL);
256 
257  if (ds->GetSpeakerConfig(&speakerConfig) != S_OK) {
258  PrintLastError("GetSpeakerConfig()");
259  return FALSE;
260  }
261 
262  if (ds) {
263  ds->Release();
264  }
265  if (guid) {
266  LocalFree(guid);
267  }
268 
269  switch (DSSPEAKER_CONFIG(speakerConfig)) {
270  case DSSPEAKER_STEREO: currentChannelCount = 2; return TRUE;
271  case DSSPEAKER_QUAD: currentChannelCount = 4; return TRUE;
272  case DSSPEAKER_5POINT1: currentChannelCount = 6; return TRUE;
273  case DSSPEAKER_7POINT1: currentChannelCount = 8; return TRUE;
274  }
275 
276  return FALSE;
277 }
#define TRUE
Definition: types.h:120
HRESULT WINAPI DirectSoundCreate8(LPCGUID lpcGUID, LPDIRECTSOUND8 *ppDS, IUnknown *pUnkOuter)
Definition: directsound.c:504
#define DSSPEAKER_STEREO
Definition: dsound.h:308
#define DSSPEAKER_7POINT1
Definition: dsound.h:312
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define ds
Definition: i386-dis.c:434
const GUID * guid
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DirectSoundEnumerate
Definition: dsound.h:411
#define DSSPEAKER_CONFIG(a)
Definition: dsound.h:323
#define DSSPEAKER_5POINT1
Definition: dsound.h:310
#define S_OK
Definition: intsafe.h:59
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext)
Definition: main.cpp:214
#define DSSPEAKER_QUAD
Definition: dsound.h:307
int currentChannelCount
Definition: main.h:81

Referenced by setDlgItems().

◆ getDeviceInfo()

BOOL getDeviceInfo ( const GUID category,
CMIDEV pDev 
)

Definition at line 319 of file main.cpp.

320 {
321  TCHAR szServiceName[128];
322  int nIndex = 0;
323 
325  if (pDev->Info == INVALID_HANDLE_VALUE) {
326  PrintLastError("SetupDiGetClassDevs()");
327  return FALSE;
328  }
329 
330  pDev->InfoData.cbSize = sizeof(SP_DEVINFO_DATA);
331 
332  while (SetupDiEnumDeviceInfo(pDev->Info, nIndex, &(pDev->InfoData))) {
333  if (!SetupDiGetDeviceRegistryProperty(pDev->Info, &(pDev->InfoData), SPDRP_SERVICE, NULL, (PBYTE)szServiceName, sizeof(szServiceName), NULL)) {
334  PrintLastError("SetupDiGetDeviceRegistryProperty()");
336  pDev->Info = NULL;
337  return FALSE;
338  }
339 
341  return TRUE;
342  }
343  nIndex++;
344  }
345 
347  pDev->Info = NULL;
348  return FALSE;
349 }
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1792
#define MAKELCID(lgid, srtid)
#define TRUE
Definition: types.h:120
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2597
#define NORM_IGNORECASE
Definition: winnls.h:173
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
smooth NULL
Definition: ftsmooth.c:416
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
char TCHAR
Definition: xmlstorage.h:189
#define CompareString
Definition: winnls.h:1171
#define SORT_DEFAULT
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
#define LANG_ENGLISH
Definition: nls.h:52
#define SPDRP_SERVICE
Definition: setupapi.h:506
#define CSTR_EQUAL
Definition: winnls.h:453
#define SetupDiGetClassDevs
Definition: setupapi.h:2587
#define TEXT(s)
Definition: k32.h:26
SP_DEVINFO_DATA InfoData
Definition: main.h:65
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:174
#define MAKELANGID(p, s)
Definition: nls.h:15
HDEVINFO Info
Definition: main.h:64
BYTE * PBYTE
Definition: pedump.c:66
#define DIGCF_PRESENT
Definition: setupapi.h:171

Referenced by openDevice().

◆ getDeviceInterfaceDetail()

BOOL getDeviceInterfaceDetail ( const GUID category,
CMIDEV pDev 
)

Definition at line 351 of file main.cpp.

352 {
353  DWORD dataSize = 0;
354  BOOL result;
355  PTSTR pnpStr = NULL;
356  HDEVINFO hDevInfoWithInterface;
357  SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
358 
359  // get the PnP string
360  SetupDiGetDeviceInstanceId(pDev->Info, &(pDev->InfoData), NULL, 0, &dataSize);
362  PrintLastError("SetupDiGetDeviceInstanceId()");
363  return FALSE;
364  }
365  pnpStr = (PTSTR)LocalAlloc(LPTR, dataSize * sizeof(TCHAR));
366  if (!pnpStr) {
367  PrintLastError("LocalAlloc()");
368  return FALSE;
369  }
370  result = SetupDiGetDeviceInstanceId(pDev->Info, &(pDev->InfoData), pnpStr, dataSize, NULL);
371  if (!result) {
372  PrintLastError("SetupDiGetDeviceInstanceId()");
373  LocalFree(pnpStr);
374  return FALSE;
375  }
376  hDevInfoWithInterface = SetupDiGetClassDevs(&KSCATEGORY_TOPOLOGY, pnpStr, NULL, DIGCF_DEVICEINTERFACE);
377  LocalFree(pnpStr);
378  if (hDevInfoWithInterface == INVALID_HANDLE_VALUE) {
379  PrintLastError("SetupDiGetClassDevs()");
380  return FALSE;
381  }
382 
383  // get the device interface data
384  DeviceInterfaceData.cbSize = sizeof(DeviceInterfaceData);
385  result = SetupDiEnumDeviceInterfaces(hDevInfoWithInterface, NULL, &KSCATEGORY_TOPOLOGY, 0, &DeviceInterfaceData);
386  if (!result) {
387  PrintLastError("SetupDiEnumDeviceInterfaces()");
388  SetupDiDestroyDeviceInfoList(hDevInfoWithInterface);
389  return FALSE;
390  }
391 
392  // get the device interface detail data
393  dataSize = 0;
394  SetupDiGetDeviceInterfaceDetail(hDevInfoWithInterface, &DeviceInterfaceData, NULL, 0, &dataSize, NULL);
396  PrintLastError("SetupDiGetDeviceInterfaceDetail()");
397  SetupDiDestroyDeviceInfoList(hDevInfoWithInterface);
398  return FALSE;
399  }
401  if (!pDev->InterfaceDetailData) {
402  PrintLastError("LocalAlloc()");
403  SetupDiDestroyDeviceInfoList(hDevInfoWithInterface);
404  return FALSE;
405  }
407  result = SetupDiGetDeviceInterfaceDetail(hDevInfoWithInterface, &DeviceInterfaceData, pDev->InterfaceDetailData, dataSize, NULL, NULL);
408  SetupDiDestroyDeviceInfoList(hDevInfoWithInterface);
409  if (!result) {
410  PrintLastError("SetupDiGetDeviceInterfaceDetail()");
412  pDev->InterfaceDetailData = NULL;
413  return FALSE;
414  }
415 
416  return TRUE;
417 
418 }
#define TRUE
Definition: types.h:120
PSP_DEVICE_INTERFACE_DETAIL_DATA InterfaceDetailData
Definition: main.h:66
SP_DEVICE_INTERFACE_DETAIL_DATA_A * PSP_DEVICE_INTERFACE_DETAIL_DATA
Definition: setupapi.h:1144
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
CHAR * PTSTR
Definition: xmlstorage.h:191
#define SetupDiGetDeviceInterfaceDetail
Definition: setupapi.h:2595
char TCHAR
Definition: xmlstorage.h:189
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetupDiGetDeviceInstanceId
Definition: setupapi.h:2594
#define SetupDiGetClassDevs
Definition: setupapi.h:2587
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
SP_DEVINFO_DATA InfoData
Definition: main.h:65
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2785
SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_DEVICE_INTERFACE_DETAIL_DATA
Definition: setupapi.h:1144
GLenum GLsizei dataSize
Definition: glext.h:11123
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:174
#define LPTR
Definition: winbase.h:362
HDEVINFO Info
Definition: main.h:64
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define KSCATEGORY_TOPOLOGY
Definition: ksmedia.h:199
GLuint64EXT * result
Definition: glext.h:11304
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by openDevice().

◆ getDriverData()

BOOL getDriverData ( CMIDEV pDev)

Definition at line 420 of file main.cpp.

421 {
422  BOOL result;
423  HANDLE hDevice;
424  KSPROPERTY KSProp;
425  DWORD dataSize;
426 
428  if (hDevice == INVALID_HANDLE_VALUE) {
429  PrintLastError("CreateFile()");
430  return FALSE;
431  }
432  KSProp.Set = KSPROPSETID_CMI;
433  KSProp.Flags = KSPROPERTY_TYPE_GET;
434  KSProp.Id = KSPROPERTY_CMI_GET;
435  result = DeviceIoControl(hDevice, IOCTL_KS_PROPERTY, &KSProp, sizeof(KSProp), &cmiData, sizeof(cmiData), &dataSize, NULL);
436  CloseHandle(hDevice);
437 
438  if (!result) {
439  PrintLastError("DeviceIoControl()");
440  return FALSE;
441  }
442 
443  return TRUE;
444 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:150
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
PSP_DEVICE_INTERFACE_DETAIL_DATA InterfaceDetailData
Definition: main.h:66
#define KSPROPERTY_CMI_GET
Definition: property.h:39
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
GUID Set
Definition: dmksctrl.h:76
#define FILE_SHARE_READ
Definition: compat.h:125
unsigned int BOOL
Definition: ntddk_ex.h:94
CMIDATA cmiData
Definition: main.h:78
smooth NULL
Definition: ftsmooth.c:416
#define KSPROPSETID_CMI
Definition: property.h:36
#define OPEN_EXISTING
Definition: compat.h:426
ULONG Id
Definition: dmksctrl.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG Flags
Definition: dmksctrl.h:78
CHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:846
#define GENERIC_READ
Definition: compat.h:124
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
GLenum GLsizei dataSize
Definition: glext.h:11123
GLuint64EXT * result
Definition: glext.h:11304

Referenced by parseArguments(), and setDlgItems().

◆ initDialog()

BOOL initDialog ( HWND  hWnd)

Definition at line 670 of file main.cpp.

671 {
672  HICON hIcon;
673  TC_ITEM tci;
674  int i;
675 
677  SendMessage(hWnd, WM_SETICON, (LPARAM) ICON_BIG, (WPARAM) hIcon);
678  hURLFont = 0;
679 
681 
682  ZeroMemory(&tci, sizeof(TC_ITEM));
683  tci.mask = TCIF_TEXT;
684  for (i=0;i<NUM_TABS;i++) {
685  tci.pszText = tabsName[i];
686  if (TabCtrl_InsertItem(hWndTab, i, &tci) == -1) {
687  PrintLastError("TabCtrl_InsertItem()");
688  return FALSE;
689  }
691  }
692 
693  hURLFont = CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH | FF_SWISS, "MS Shell Dlg");
695 
696  currentTab = 0;
698 
699  if (!openDevice(TRUE)) {
700  PrintLastError("openDevice()");
701  return FALSE;
702  }
703  return setDlgItems(hWnd);
704 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define SW_SHOWDEFAULT
Definition: winuser.h:774
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define VARIABLE_PITCH
Definition: wingdi.h:444
#define IDC_TAB
Definition: resource.h:12
#define TC_ITEM
Definition: commctrl.h:3979
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
HWND hWnd
Definition: settings.c:17
#define ZeroMemory
Definition: winbase.h:1635
UINT_PTR WPARAM
Definition: windef.h:207
LRESULT CALLBACK TabDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.cpp:756
#define TCIF_TEXT
Definition: commctrl.h:3943
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL openDevice(bool handleError)
Definition: main.cpp:489
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CreateFont
Definition: wingdi.h:4421
HFONT hURLFont
Definition: main.h:82
BOOL setDlgItems(HWND hWnd)
Definition: main.cpp:549
LONG_PTR LPARAM
Definition: windef.h:208
int tabsResource[]
Definition: resource.h:94
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_URL2
Definition: resource.h:91
LRESULT currentTab
Definition: main.h:76
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2849
char * tabsName[]
Definition: resource.h:93
#define FF_SWISS
Definition: wingdi.h:451
HINSTANCE hInst
Definition: dxdiag.c:13
HICON hIcon
Definition: msconfig.c:44
#define WM_SETFONT
Definition: winuser.h:1632
#define TabCtrl_InsertItem(hwnd, iItem, pitem)
Definition: commctrl.h:4023
#define SendMessage
Definition: winuser.h:5709
HWND hWndTab
Definition: main.h:74
#define LoadIcon
Definition: winuser.h:5679
HWND hWndChild[NUM_TABS]
Definition: main.h:75
#define NUM_TABS
Definition: resource.h:95
#define ICON_BIG
Definition: tnclass.cpp:51
#define IDI_APP_ICON
Definition: resource.h:31
#define CreateDialogParam
Definition: winuser.h:5618

Referenced by WndProc().

◆ InitURLControl()

void InitURLControl ( )

Definition at line 917 of file main.cpp.

918 {
919  WNDCLASSEX wce;
920 
921  ZeroMemory(&wce, sizeof(wce));
922  wce.cbSize = sizeof(WNDCLASSEX);
923  if (GetClassInfoEx(hInst, "Static", &wce)==0) {
924  PrintLastError("GetClassInfoEx()");
925  return;
926  }
927 
929  wce.hInstance = hInst;
930  wce.lpszClassName = "URLLink";
931  if (RegisterClassEx(&wce) == 0) {
932  PrintLastError("RegisterClassEx()");
933  }
934 
935 }
#define RegisterClassEx
Definition: winuser.h:5703
HCURSOR hCursor
Definition: winuser.h:3161
LPCSTR lpszClassName
Definition: winuser.h:3164
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hInstance
Definition: winuser.h:3159
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3154
#define IDC_HAND
Definition: winuser.h:693
#define GetClassInfoEx
Definition: winuser.h:5646
#define LoadCursor
Definition: winuser.h:5678
HINSTANCE hInst
Definition: dxdiag.c:13
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5585

Referenced by WinMain().

◆ openDevice()

BOOL openDevice ( bool  handleError)

Definition at line 489 of file main.cpp.

490 {
492  if (handleError)
493  PrintLastError("getDeviceInfo()");
494  return FALSE;
495  }
496 
498  if (handleError)
499  PrintLastError("getDeviceInterfaceDetail()");
500  return FALSE;
501  }
502 
503  return TRUE;
504 }
BOOL getDeviceInterfaceDetail(const GUID *category, CMIDEV *pDev)
Definition: main.cpp:351
#define TRUE
Definition: types.h:120
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
CMIDEV cmiTopologyDev
Definition: main.h:77
BOOL getDeviceInfo(const GUID *category, CMIDEV *pDev)
Definition: main.cpp:319
#define KSCATEGORY_TOPOLOGY
Definition: ksmedia.h:199

Referenced by initDialog(), and parseArguments().

◆ openURL()

void openURL ( int  control)

Definition at line 749 of file main.cpp.

750 {
751  char buffer[127];
752  GetWindowText(GetDlgItem(hWndChild[3], control), buffer, sizeof(buffer));
754 }
GLuint buffer
Definition: glext.h:5915
#define GetWindowText
Definition: winuser.h:5664
#define ShellExecute
Definition: shellapi.h:689
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND hWndMain
Definition: welcome.c:60
#define SW_SHOWNORMAL
Definition: winuser.h:764
HWND hWndChild[NUM_TABS]
Definition: main.h:75

Referenced by TabDlgProc().

◆ parseArguments()

int parseArguments ( LPSTR  szCmdLine)

Definition at line 875 of file main.cpp.

875  {
876  BOOL inToken = false, result;
877  int i = 0, j=0;
878  char token[MAX_TOKEN_SIZE];
879 
880  if (openDevice(FALSE)) {
882  currentChannelCount = -1;
883  }
884 
885  while (szCmdLine[i]) {
886  if (inToken) {
887  if (szCmdLine[i] == ' ') {
888  inToken = false;
889  token[j] = 0;
890  if (checkToken(token)) {
891  return TRUE;
892  }
893  } else {
894  token[j] = (char)toupper(szCmdLine[i]);
895  if (j < MAX_TOKEN_SIZE-1) {
896  j++;
897  }
898  }
899  } else {
900  if ((szCmdLine[i] == '-') || (szCmdLine[i] == '/')) {
901  j = 0;
902  inToken = true;
903  }
904  }
905 
906  i++;
907  }
908  token[j] = 0;
909  checkToken(token);
910 
912  if (currentChannelCount != -1)
914  return result;
915 }
bool checkToken(char *token)
Definition: main.cpp:834
#define TRUE
Definition: types.h:120
BOOL setDriverData(CMIDEV *pDev)
Definition: main.cpp:446
BOOL openDevice(bool handleError)
Definition: main.cpp:489
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
CMIDEV cmiTopologyDev
Definition: main.h:77
unsigned char
Definition: typeof.h:29
#define MAX_TOKEN_SIZE
Definition: main.h:61
BOOL getDriverData(CMIDEV *pDev)
Definition: main.cpp:420
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
int toupper(int c)
Definition: utclib.c:881
BOOL setCurrentChannelConfig()
Definition: main.cpp:279
GLuint64EXT * result
Definition: glext.h:11304
int currentChannelCount
Definition: main.h:81

Referenced by WinMain().

◆ performUninstall()

void performUninstall ( )

Definition at line 827 of file main.cpp.

827  {
829  RegDeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\CMIDriver");
830  MessageBox(NULL, "The CMI driver applications have been successfully removed from your computer!", "CMIDriver", MB_ICONINFORMATION);
831  ExitProcess(0);
832 }
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
smooth NULL
Definition: ftsmooth.c:416
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define MessageBox
Definition: winuser.h:5688
void deleteDriverFiles()
Definition: main.cpp:805
#define RegDeleteKey
Definition: winreg.h:502
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by checkToken().

◆ playTestTone()

BOOL playTestTone ( )

Definition at line 139 of file main.cpp.

140 {
141  SHORT* buffer;
142  BOOL isChannelChecked;
143 #if 1
145 
146  ZeroMemory(&wfx, sizeof(WAVEFORMATEXTENSIBLE));
150  wfx.Format.wBitsPerSample = 16;
151  wfx.Format.nBlockAlign = (wfx.Format.wBitsPerSample >> 3) * wfx.Format.nChannels;
153  wfx.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
156 #else
157  WAVEFORMATEX wfx;
159  wfx.wBitsPerSample = 16;
162  wfx.nAvgBytesPerSec = SAMPLE_RATE * (wfx.wBitsPerSample >> 3) * wfx.nChannels;
163  wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels;
164  wfx.cbSize = 0;
165 #endif
166 
167  isChannelChecked = (SendMessage(GetDlgItem(hWndChild[0], IDC_LEFT), BM_GETCHECK, 0, 0) == BST_CHECKED);
168  isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_RIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED);
169  isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_BLEFT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 2);
170  isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_BRIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 2);
171  isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_CENTER), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 4);
172  isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_SUB), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 4);
173  isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_CLEFT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 6);
174  isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_CRIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 6);
175 
176  if (!isChannelChecked)
177  return FALSE;
178 
180  PrintLastError("waveOutOpen()");
181  return FALSE;
182  }
183 
185  return FALSE;
186  }
187 
188  ZeroMemory(&pwh, sizeof(pwh));
189  pwh.lpData = (LPSTR)buffer;
192  pwh.dwLoops = 0xFFFFFFFF;
193  if (waveOutPrepareHeader(hWave, &pwh, sizeof(pwh)) != MMSYSERR_NOERROR) {
194  LocalFree(buffer);
195  PrintLastError("waveOutPrepareHeader()");
196  return FALSE;
197  }
198 
200  LocalFree(buffer);
201  PrintLastError("waveOutReset()");
202  return FALSE;
203  }
204  if (waveOutWrite(hWave, &pwh, sizeof(WAVEHDR)) != MMSYSERR_NOERROR) {
205  LocalFree(buffer);
206  PrintLastError("waveOutWrite()");
207  return FALSE;
208  }
209 
210  return TRUE;
211 }
#define TRUE
Definition: types.h:120
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:921
#define WHDR_BEGINLOOP
Definition: mmsystem.h:195
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define WHDR_ENDLOOP
Definition: mmsystem.h:196
#define IDC_CLEFT
Definition: resource.h:49
#define ZeroMemory
Definition: winbase.h:1635
GLuint buffer
Definition: glext.h:5915
LPSTR lpData
Definition: mmsystem.h:1014
char * LPSTR
Definition: xmlstorage.h:182
#define IDC_RIGHT
Definition: resource.h:52
UINT WINAPI waveOutPrepareHeader(HWAVEOUT hWaveOut, WAVEHDR *lpWaveOutHdr, UINT uSize)
Definition: winmm.c:2280
DWORD dwLoops
Definition: mmsystem.h:1019
#define SAMPLE_RATE
Definition: main.h:53
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define IDC_BLEFT
Definition: resource.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
short SHORT
Definition: pedump.c:59
DWORD dwFlags
Definition: mmsystem.h:1018
WORD wBitsPerSample
Definition: audioclient.idl:45
HWAVEOUT hWave
Definition: main.h:79
#define IDC_CENTER
Definition: resource.h:50
#define BM_GETCHECK
Definition: winuser.h:1879
DWORD nSamplesPerSec
Definition: audioclient.idl:42
#define SPEAKER_AMPLITUDE
Definition: main.h:59
#define IDC_LEFT
Definition: resource.h:48
#define IDC_SUB
Definition: resource.h:55
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
WAVEFORMATEX Format
Definition: ksmedia.h:538
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDC_BRIGHT
Definition: resource.h:54
UINT WINAPI waveOutWrite(HWAVEOUT hWaveOut, LPWAVEHDR lpWaveOutHdr, UINT uSize)
Definition: winmm.c:2344
DWORD dwBufferLength
Definition: mmsystem.h:1015
UINT findWaveDeviceID()
Definition: main.cpp:122
#define IDC_CRIGHT
Definition: resource.h:51
WAVEHDR pwh
Definition: main.h:80
WORD wValidBitsPerSample
Definition: ksmedia.h:541
#define CALLBACK_NULL
Definition: mmsystem.h:147
MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID, LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags)
Definition: winmm.c:2249
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
#define BST_CHECKED
Definition: winuser.h:197
#define SendMessage
Definition: winuser.h:5709
BOOL generateTestSignal(double amplitude, int Channels, int SamplesPerSec, SHORT **buffer)
Definition: main.cpp:41
HWND hWndChild[NUM_TABS]
Definition: main.h:75
union WAVEFORMATEXTENSIBLE::@2895 Samples
UINT WINAPI waveOutReset(HWAVEOUT hWaveOut)
Definition: winmm.c:2388
#define WAVE_FORMAT_EXTENSIBLE
Definition: ksmedia.h:551
int currentChannelCount
Definition: main.h:81

Referenced by TabDlgProc().

◆ PrintLastError()

void PrintLastError ( LPCSTR  function)

Definition at line 31 of file main.cpp.

32 {
33  LPVOID lpMsgBuf;
34  DWORD errorid = GetLastError();
35 
37  MessageBox(NULL, (LPCSTR)lpMsgBuf, function, MB_ICONEXCLAMATION | MB_OK);
38  LocalFree(lpMsgBuf);
39 }
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FormatMessage
Definition: winbase.h:3609
#define MessageBox
Definition: winuser.h:5688
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define MB_OK
Definition: winuser.h:784
#define MAKELANGID(p, s)
Definition: nls.h:15

Referenced by deleteDriverFiles(), getCurrentChannelConfig(), getDeviceInfo(), getDeviceInterfaceDetail(), getDriverData(), initDialog(), InitURLControl(), openDevice(), playTestTone(), setCurrentChannelConfig(), setDlgItems(), setDriverData(), stopTestTone(), and WinMain().

◆ printUsage()

static void printUsage ( )

Definition at line 787 of file main.cpp.

788 {
789  unsigned char usage[] = "/h - print this help message\r\n" \
790  "/enable71Mode - change channel configuration to 7.1\r\n" \
791  "/enable51Mode - change channel configuration to 5.1\r\n" \
792  "/enable40Mode - change channel configuration to 4.0 (Quad)\r\n" \
793  "/enable20Mode - change channel configuration to 2.0 (Stereo)\r\n" \
794  "/enableSPDIFo - enable SPDIF-out\r\n" \
795  "/disableSPDIFo - disable SPDIF-out\r\n"\
796  "/enableSPDIFi - enable SPDIF-in recording\r\n" \
797  "/disableSPDIFi - disable SPDIF-in recording\r\n" \
798  "/enableLoopThru - enable loop-through from SPDIF-in to SPDIF-out\r\n" \
799  "/disableLoopThru - disable loop-through from SPDIF-in to SPDIF-out\r\n";
800 
801  MessageBox(NULL, (LPCSTR)usage, TEXT("Usage Help"), MB_ICONINFORMATION | MB_OK);
802  return;
803 }
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define MB_ICONINFORMATION
Definition: winuser.h:796
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define MessageBox
Definition: winuser.h:5688
#define TEXT(s)
Definition: k32.h:26
#define MB_OK
Definition: winuser.h:784

Referenced by checkToken().

◆ setCurrentChannelConfig()

BOOL setCurrentChannelConfig ( )

Definition at line 279 of file main.cpp.

280 {
281  IDirectSound8* ds;
282  DWORD speakerConfig;
283  LPGUID guid = NULL;
284 
285  DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc, (VOID*)&guid);
286 
287  if (DirectSoundCreate8(guid, &ds, NULL) != S_OK) {
288  PrintLastError("DirectSoundCreate8()");
289  return FALSE;
290  }
291 
292 
293  ds->Initialize(NULL);
294 
295  switch (currentChannelCount) {
296  case 2: speakerConfig = DSSPEAKER_STEREO; break;
297  case 4: speakerConfig = DSSPEAKER_QUAD; break;
298  case 6: speakerConfig = DSSPEAKER_5POINT1; break;
299  case 8: speakerConfig = DSSPEAKER_7POINT1; break;
300  default: speakerConfig = DSSPEAKER_STEREO; break;
301  }
302 
303  if (ds->SetSpeakerConfig(speakerConfig) != S_OK) {
304  PrintLastError("SetSpeakerConfig()");
305  return FALSE;
306  }
307 
308  if (ds) {
309  ds->Release();
310  }
311  if (guid) {
312  LocalFree(guid);
313  }
314 
315 
316  return FALSE;
317 }
HRESULT WINAPI DirectSoundCreate8(LPCGUID lpcGUID, LPDIRECTSOUND8 *ppDS, IUnknown *pUnkOuter)
Definition: directsound.c:504
#define DSSPEAKER_STEREO
Definition: dsound.h:308
#define DSSPEAKER_7POINT1
Definition: dsound.h:312
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define ds
Definition: i386-dis.c:434
const GUID * guid
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DirectSoundEnumerate
Definition: dsound.h:411
#define DSSPEAKER_5POINT1
Definition: dsound.h:310
#define S_OK
Definition: intsafe.h:59
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext)
Definition: main.cpp:214
#define DSSPEAKER_QUAD
Definition: dsound.h:307
int currentChannelCount
Definition: main.h:81

Referenced by applySettings(), and parseArguments().

◆ setDlgItems()

BOOL setDlgItems ( HWND  hWnd)

Definition at line 549 of file main.cpp.

550 {
551  HWND hWndItem;
552  char buffer[127];
553 
554  if (!getDriverData(&cmiTopologyDev)) {
555  PrintLastError("getDriverData()");
556  return FALSE;
557  }
558 
559  // 'About' tab
565  wsprintf(buffer, "%04X", cmiData.IOBase);
567  wsprintf(buffer, "%04X", cmiData.MPUBase);
569 
570  // channel config combobox
571  hWndItem = GetDlgItem(hWndChild[0], IDCB_CHANNELCONFIG);
572  SendMessage(hWndItem, CB_RESETCONTENT, 0, 0);
573  if (cmiData.maxChannels >= 2) {
574  SendMessage(hWndItem, CB_ADDSTRING, 0, (LPARAM)"Stereo (2.0)");
575  }
576  if (cmiData.maxChannels >= 4) {
577  SendMessage(hWndItem, CB_ADDSTRING, 0, (LPARAM)"Quadrophonic (4.0)");
578  }
579  if (cmiData.maxChannels >= 6) {
580  SendMessage(hWndItem, CB_ADDSTRING, 0, (LPARAM)"5.1 Surround");
581  }
582  if (cmiData.maxChannels >= 8) {
583  SendMessage(hWndItem, CB_ADDSTRING, 0, (LPARAM)"7.1 Surround");
584  }
585  if (getCurrentChannelConfig()) {
588  SendMessage(hWndItem, CB_SETCURSEL, (currentChannelCount/2)-1, 0);
590  } else {
593  }
594 
595  // checkboxes
598 
607 
620 
621  // radioboxes
625 
628 
629 
630  return TRUE;
631 }
#define IDC_FMT_441_MULTI_PCM
Definition: resource.h:75
UInt32 invertPhaseSPDI
Definition: property.h:79
UInt32 maxChannels
Definition: property.h:68
#define IDC_MAXCHAN
Definition: resource.h:87
#define FMT_882_DOLBY
Definition: property.h:52
#define IDC_FMT_480_PCM
Definition: resource.h:72
UInt32 enableSPDIMonitor
Definition: property.h:69
#define TRUE
Definition: types.h:120
UInt32 enableSPDI
Definition: property.h:83
#define IDC_NOROUTE_LINE
Definition: resource.h:44
int hardwareRevision
Definition: property.h:65
#define IDC_FMT_441_PCM
Definition: resource.h:71
#define FMT_480_MULTI_PCM
Definition: property.h:47
#define IDC_HWREV
Definition: resource.h:86
#define IDC_FMT_882_PCM
Definition: resource.h:73
UInt32 formatMask
Definition: property.h:82
#define IDC_NOROUTE_MIC
Definition: resource.h:46
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
HWND hWnd
Definition: settings.c:17
GLuint buffer
Definition: glext.h:5915
UInt32 loopSPDI
Definition: property.h:81
UInt32 invertValidBitSPDI
Definition: property.h:80
#define FMT_480_PCM
Definition: property.h:43
char driverVersion[32]
Definition: property.h:64
#define IDC_EN_CENTER2MIC
Definition: resource.h:45
#define IDB_STARTSTOP
Definition: resource.h:56
#define IDC_LOOP_SPDF
Definition: resource.h:66
UInt32 enableCenter2Mic
Definition: property.h:74
#define FMT_441_PCM
Definition: property.h:42
#define IDC_FMT_480_DOLBY
Definition: resource.h:80
UInt32 enableSPDOCopyright
Definition: property.h:77
UInt32 enableCenter2Line
Definition: property.h:72
#define IDC_BASEADR
Definition: resource.h:88
UInt16 MPUBase
Definition: property.h:67
#define FMT_441_DOLBY
Definition: property.h:50
CMIDEV cmiTopologyDev
Definition: main.h:77
CMIDATA cmiData
Definition: main.h:78
UInt32 enableSPDO5V
Definition: property.h:76
#define CB_ADDSTRING
Definition: winuser.h:1897
#define IDC_FMT_480_MULTI_PCM
Definition: resource.h:76
#define IDC_EN_SPDO
Definition: resource.h:59
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_FMT_960_PCM
Definition: resource.h:74
BOOL getDriverData(CMIDEV *pDev)
Definition: main.cpp:420
#define CB_RESETCONTENT
Definition: winuser.h:1920
#define IDC_MPUADR
Definition: resource.h:89
UInt32 enableSPDO
Definition: property.h:75
#define IDC_EN_SPDIMONITOR
Definition: resource.h:68
#define FMT_960_MULTI_PCM
Definition: property.h:49
#define IDC_VERSION
Definition: resource.h:291
#define IDC_FMT_882_MULTI_PCM
Definition: resource.h:77
#define BM_SETCHECK
Definition: winuser.h:1882
UInt32 exchangeFrontBack
Definition: property.h:70
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDCB_CHANNELCONFIG
Definition: resource.h:47
UInt32 enableRear2Line
Definition: property.h:73
#define IDC_SEL_SPDIFI
Definition: resource.h:63
#define FMT_960_PCM
Definition: property.h:45
#define IDC_FMT_960_MULTI_PCM
Definition: resource.h:78
#define IDC_FMT_882_DOLBY
Definition: resource.h:81
UInt16 IOBase
Definition: property.h:66
#define IDC_EN_CLFE2LINE
Definition: resource.h:43
UInt32 enableBass2Line
Definition: property.h:71
#define IDC_EXCH_FB
Definition: resource.h:41
#define CB_SETCURSEL
Definition: winuser.h:1922
#define BST_UNCHECKED
Definition: winuser.h:199
#define IDC_INV_SPDIFI
Definition: resource.h:64
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define IDC_FMT_960_DOLBY
Definition: resource.h:82
#define IDC_EN_REAR2LINE
Definition: resource.h:42
#define SetWindowText
Definition: winuser.h:5723
#define BST_CHECKED
Definition: winuser.h:197
#define FMT_480_DOLBY
Definition: property.h:51
void updateChannelBoxes(HWND hWnd)
Definition: main.cpp:506
#define SendMessage
Definition: winuser.h:5709
#define FMT_882_MULTI_PCM
Definition: property.h:48
#define FMT_960_DOLBY
Definition: property.h:53
#define IDC_POLVALID
Definition: resource.h:65
#define FMT_882_PCM
Definition: property.h:44
BOOL getCurrentChannelConfig()
Definition: main.cpp:243
#define IDC_EN_SPDO5V
Definition: resource.h:60
#define wsprintf
Definition: winuser.h:5731
HWND hWndChild[NUM_TABS]
Definition: main.h:75
#define FMT_441_MULTI_PCM
Definition: property.h:46
#define NUM_TABS
Definition: resource.h:95
#define IDC_EN_SPDCOPYRHT
Definition: resource.h:61
#define IDC_EN_SPDI
Definition: resource.h:67
int currentChannelCount
Definition: main.h:81
#define IDC_FMT_441_DOLBY
Definition: resource.h:79
UInt32 select2ndSPDI
Definition: property.h:78

Referenced by initDialog(), and WndProc().

◆ setDriverData()

BOOL setDriverData ( CMIDEV pDev)

Definition at line 446 of file main.cpp.

447 {
448  BOOL result;
449  HANDLE hDevice;
450  KSPROPERTY KSProp;
451  DWORD dataSize;
452 
454  if (hDevice == INVALID_HANDLE_VALUE) {
455  PrintLastError("CreateFile()");
456  return FALSE;
457  }
458  KSProp.Set = KSPROPSETID_CMI;
459  KSProp.Flags = KSPROPERTY_TYPE_SET;
460  KSProp.Id = KSPROPERTY_CMI_SET;
461  result = DeviceIoControl(hDevice, IOCTL_KS_PROPERTY, &KSProp, sizeof(KSProp), &cmiData, sizeof(cmiData), &dataSize, NULL);
462  CloseHandle(hDevice);
463 
464  if (!result) {
465  PrintLastError("DeviceIoControl()");
466  return FALSE;
467  }
468 
469  return TRUE;
470 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:150
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
PSP_DEVICE_INTERFACE_DETAIL_DATA InterfaceDetailData
Definition: main.h:66
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
GUID Set
Definition: dmksctrl.h:76
#define FILE_SHARE_READ
Definition: compat.h:125
unsigned int BOOL
Definition: ntddk_ex.h:94
CMIDATA cmiData
Definition: main.h:78
smooth NULL
Definition: ftsmooth.c:416
#define KSPROPSETID_CMI
Definition: property.h:36
#define OPEN_EXISTING
Definition: compat.h:426
#define KSPROPERTY_CMI_SET
Definition: property.h:40
ULONG Id
Definition: dmksctrl.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG Flags
Definition: dmksctrl.h:78
CHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:846
#define GENERIC_READ
Definition: compat.h:124
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
GLenum GLsizei dataSize
Definition: glext.h:11123
GLuint64EXT * result
Definition: glext.h:11304
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43

Referenced by applySettings(), and parseArguments().

◆ stopTestTone()

BOOL stopTestTone ( void  )

Definition at line 103 of file main.cpp.

104 {
105  if (hWave == NULL) {
106  return FALSE;
107  }
108 
110  PrintLastError("waveOutReset()");
111  return FALSE;
112  }
114  PrintLastError("waveOutClose()");
115  return FALSE;
116  }
117  hWave = NULL;
119  return TRUE;
120 }
#define TRUE
Definition: types.h:120
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
LPSTR lpData
Definition: mmsystem.h:1014
smooth NULL
Definition: ftsmooth.c:416
HWAVEOUT hWave
Definition: main.h:79
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
WAVEHDR pwh
Definition: main.h:80
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
UINT WINAPI waveOutClose(HWAVEOUT hWaveOut)
Definition: winmm.c:2260
UINT WINAPI waveOutReset(HWAVEOUT hWaveOut)
Definition: winmm.c:2388

Referenced by cleanUp(), and TabDlgProc().

◆ TabDlgProc()

LRESULT CALLBACK TabDlgProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 756 of file main.cpp.

757 {
758  switch(msg) {
759  case WM_COMMAND:
760  switch (LOWORD(wParam)) {
761  case IDB_STARTSTOP:
762  if (stopTestTone()) {
763  SetDlgItemText(hWndChild[0], IDB_STARTSTOP, "&Play test tone");
764  return TRUE;
765  }
766  if (playTestTone()) {
767  SetDlgItemText(hWndChild[0], IDB_STARTSTOP, "&Stop");
768  return TRUE;
769  }
770  break;
771  case IDC_URL1:
772  case IDC_URL2:
774  break;
775  }
776  case WM_CTLCOLORSTATIC:
778  SetTextColor((HDC)wParam, 0xFF0000);
781  }
782  }
783 
784  return 0;
785 }
#define TRUE
Definition: types.h:120
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1748
static HDC
Definition: imagelist.c:92
#define IDC_URL1
Definition: resource.h:90
WPARAM wParam
Definition: combotst.c:138
#define IDB_STARTSTOP
Definition: resource.h:56
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
BOOL playTestTone()
Definition: main.cpp:139
#define TRANSPARENT
Definition: wingdi.h:949
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SetDlgItemText
Definition: winuser.h:5715
#define IDC_URL2
Definition: resource.h:91
#define COLOR_BTNFACE
Definition: winuser.h:918
void openURL(int control)
Definition: main.cpp:749
#define WM_COMMAND
Definition: winuser.h:1716
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
#define msg(x)
Definition: auth_time.c:54
LONG_PTR LRESULT
Definition: windef.h:209
HWND hWndChild[NUM_TABS]
Definition: main.h:75
HBRUSH WINAPI GetSysColorBrush(_In_ int)
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
BOOL stopTestTone(void)
Definition: main.cpp:103

Referenced by initDialog().

◆ updateChannelBoxes()

void updateChannelBoxes ( HWND  hWnd)

Definition at line 506 of file main.cpp.

507 {
509  case 0: // stereo
517  break;
518  case 1: // quad
526  break;
527  case 2: // 5.1
534  SetDlgItemText(hWnd, IDT_SWAPJACKS, "BL/BR and C/LFE jacks are swapped!");
535  break;
536  case 3: // 7.1
543  SetDlgItemText(hWnd, IDT_SWAPJACKS, "BL/BR and C/LFE jacks are swapped!");
544  break;
545  }
546 }
#define SW_HIDE
Definition: winuser.h:762
HWND hWnd
Definition: settings.c:17
#define IDC_CLEFT
Definition: resource.h:49
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CB_GETCURSEL
Definition: winuser.h:1904
#define IDC_BLEFT
Definition: resource.h:53
#define IDC_CENTER
Definition: resource.h:50
#define SW_SHOW
Definition: winuser.h:769
#define IDC_SUB
Definition: resource.h:55
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDCB_CHANNELCONFIG
Definition: resource.h:47
#define SetDlgItemText
Definition: winuser.h:5715
#define IDC_BRIGHT
Definition: resource.h:54
#define IDC_CRIGHT
Definition: resource.h:51
#define SendMessage
Definition: winuser.h:5709
#define IDT_SWAPJACKS
Definition: resource.h:38
HWND hWndChild[NUM_TABS]
Definition: main.h:75

Referenced by setDlgItems().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
PSTR  szCmdLine,
int  iCmdShow 
)

Definition at line 937 of file main.cpp.

938 {
939  WNDCLASSEX wce;
940  MSG msg;
941 
942  ZeroMemory(&cmiData, sizeof(CMIDATA));
943  ZeroMemory(&cmiTopologyDev, sizeof(CMIDEV));
944  hWave = NULL;
945 
946  if (szCmdLine && szCmdLine[0] != 0) {
947  int result = parseArguments(szCmdLine);
948  cleanUp();
949  return result;
950  }
951 
952  if ((hWndMain = FindWindow("cmiControlPanel", NULL))) {
954  return FALSE;
955  }
956 
957  hInst = hInstance;
960 
961  ZeroMemory(&wce, sizeof(WNDCLASSEX));
962  wce.cbSize = sizeof(WNDCLASSEX);
963  wce.lpfnWndProc = DefDlgProc;
964  wce.style = 0;
966  wce.hInstance = hInstance;
968  wce.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
969  wce.lpszClassName = "cmiControlPanel";
970  wce.lpszMenuName = NULL;
973  if(!RegisterClassEx(&wce)) {
974  PrintLastError("RegisterClassEx()");
975  return -1;
976  }
977  InitURLControl();
978 
980  if (!hWndMain) {
981  PrintLastError("CreateDialogParam()");
982  return -1;
983  }
984 
985  while (GetMessage(&msg, (HWND) NULL, 0, 0)) {
988  }
989  return 0;
990 }
UINT style
Definition: winuser.h:3155
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LPCSTR lpszMenuName
Definition: winuser.h:3163
#define RegisterClassEx
Definition: winuser.h:5703
#define FindWindow
Definition: winuser.h:5643
HCURSOR hCursor
Definition: winuser.h:3161
WNDPROC lpfnWndProc
Definition: winuser.h:3156
LPCSTR lpszClassName
Definition: winuser.h:3164
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define ZeroMemory
Definition: winbase.h:1635
HICON hIconSm
Definition: winuser.h:3165
#define COLOR_WINDOW
Definition: winuser.h:908
#define IDD_MAIN
Definition: resource.h:106
HINSTANCE hInstance
Definition: charmap.c:20
HINSTANCE hInstance
Definition: winuser.h:3159
CMIDEV cmiTopologyDev
Definition: main.h:77
CMIDATA cmiData
Definition: main.h:78
smooth NULL
Definition: ftsmooth.c:416
HWAVEOUT hWave
Definition: main.h:79
UINT cbSize
Definition: winuser.h:3154
void InitURLControl()
Definition: main.cpp:917
HBRUSH hbrBackground
Definition: winuser.h:3162
int cbWndExtra
Definition: winuser.h:3158
HICON hIcon
Definition: winuser.h:3160
#define DLGWINDOWEXTRA
Definition: winuser.h:2519
HWND hWndMain
Definition: welcome.c:60
#define LoadCursor
Definition: winuser.h:5678
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2849
#define DefDlgProc
Definition: ros2win.h:34
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.cpp:717
Definition: main.h:63
#define GetMessage
Definition: winuser.h:5656
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI SetForegroundWindow(_In_ HWND)
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5585
#define LoadIcon
Definition: winuser.h:5679
void cleanUp()
Definition: main.cpp:472
GLuint64EXT * result
Definition: glext.h:11304
int parseArguments(LPSTR szCmdLine)
Definition: main.cpp:875
#define IDI_APP_ICON
Definition: resource.h:31
#define CreateDialogParam
Definition: winuser.h:5618

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 717 of file main.cpp.

718 {
719  switch(msg) {
720  case WM_INITDIALOG:
721  if (!initDialog(hWnd)) {
722  PostQuitMessage(0);
723  }
724  return TRUE;
725  case WM_CLOSE:
727  return TRUE;
728  case WM_NOTIFY:
729  return changeTab((LPNMHDR)lParam);
730  case WM_DESTROY:
731  cleanUp();
732  PostQuitMessage(0);
733  return TRUE;
734  case WM_COMMAND:
735  if (LOWORD(wParam) == IDB_CLOSE) {
736  PostQuitMessage(0);
737  return TRUE;
738  }
739  if (LOWORD(wParam) == IDB_APPLY) {
740  applySettings();
741  setDlgItems(hWnd);
742  return TRUE;
743  }
744  break;
745  }
746  return 0;
747 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
#define IDB_APPLY
Definition: resource.h:36
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
BOOL applySettings()
Definition: main.cpp:633
BOOL setDlgItems(HWND hWnd)
Definition: main.cpp:549
#define WM_DESTROY
Definition: winuser.h:1591
BOOL initDialog(HWND hWnd)
Definition: main.cpp:670
#define WM_CLOSE
Definition: winuser.h:1603
#define WM_COMMAND
Definition: winuser.h:1716
BOOL changeTab(LPNMHDR lpnmhdr)
Definition: main.cpp:706
#define msg(x)
Definition: auth_time.c:54
void cleanUp()
Definition: main.cpp:472
#define IDB_CLOSE
Definition: resource.h:35
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by WinMain().