3131#pragma warning(pop)
3232
3333#ifdef _EDITOR
34- log_fn_ptr_type* pLog = NULL ;
34+ log_fn_ptr_type* pLog = nullptr ;
3535#endif
3636
3737void __cdecl al_log (char * msg) { Log (msg); }
3838ALDeviceList::ALDeviceList ()
3939{
4040 pLog = al_log;
41- snd_device_id = u32 (- 1 ) ;
41+ snd_device_id = ( u32 )- 1 ;
4242 Enumerate ();
4343}
4444
@@ -48,18 +48,17 @@ ALDeviceList::ALDeviceList()
4848ALDeviceList::~ALDeviceList ()
4949{
5050 for (int i = 0 ; snd_devices_token[i].name ; i++)
51- {
5251 xr_free (snd_devices_token[i].name );
53- }
52+
5453 xr_free (snd_devices_token);
55- snd_devices_token = NULL ;
54+ snd_devices_token = nullptr ;
5655}
5756
5857void ALDeviceList::Enumerate ()
5958{
60- char * devices;
59+ pstr devices;
6160 int major, minor, index;
62- LPCSTR actualDeviceName;
61+ pcstr actualDeviceName;
6362
6463 Msg (" SOUND: OpenAL: enumerate devices..." );
6564 // have a set of vectors storing the device list, selection status, spec version #, and XRAM support status
@@ -68,13 +67,13 @@ void ALDeviceList::Enumerate()
6867
6968 CoUninitialize ();
7069 // grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices
71- if (alcIsExtensionPresent (NULL , " ALC_ENUMERATION_EXT" ))
70+ if (alcIsExtensionPresent (nullptr , " ALC_ENUMERATION_EXT" ))
7271 {
7372 Msg (" SOUND: OpenAL: EnumerationExtension Present" );
7473
75- devices = (char * )alcGetString (NULL , ALC_DEVICE_SPECIFIER);
74+ devices = (pstr )alcGetString (nullptr , ALC_DEVICE_SPECIFIER);
7675 Msg (" devices %s" , devices);
77- xr_strcpy (m_defaultDeviceName, (char * )alcGetString (NULL , ALC_DEFAULT_DEVICE_SPECIFIER));
76+ xr_strcpy (m_defaultDeviceName, (pstr )alcGetString (nullptr , ALC_DEFAULT_DEVICE_SPECIFIER));
7877 Msg (" SOUND: OpenAL: system default SndDevice name is %s" , m_defaultDeviceName);
7978
8079 // ManowaR
@@ -99,14 +98,14 @@ void ALDeviceList::Enumerate()
9998 ALCdevice* device = alcOpenDevice (devices);
10099 if (device)
101100 {
102- ALCcontext* context = alcCreateContext (device, NULL );
101+ ALCcontext* context = alcCreateContext (device, nullptr );
103102 if (context)
104103 {
105104 alcMakeContextCurrent (context);
106105 // if new actual device name isn't already in the list, then add it...
107106 actualDeviceName = alcGetString (device, ALC_DEVICE_SPECIFIER);
108107
109- if (( actualDeviceName != NULL ) && xr_strlen (actualDeviceName) > 0 )
108+ if (actualDeviceName != nullptr && xr_strlen (actualDeviceName) > 0 )
110109 {
111110 alcGetIntegerv (device, ALC_MAJOR_VERSION, sizeof (int ), &major);
112111 alcGetIntegerv (device, ALC_MINOR_VERSION, sizeof (int ), &minor);
@@ -121,26 +120,22 @@ void ALDeviceList::Enumerate()
121120 if (alIsExtensionPresent (" EAX5.0" ))
122121 m_devices.back ().props .eax = 5 ;
123122
124- m_devices.back ().props .efx = ( alIsExtensionPresent (" ALC_EXT_EFX" ) == TRUE ) ;
125- m_devices.back ().props .xram = ( alIsExtensionPresent (" EAX_RAM" ) == TRUE ) ;
123+ m_devices.back ().props .efx = alIsExtensionPresent (" ALC_EXT_EFX" ) == true ;
124+ m_devices.back ().props .xram = alIsExtensionPresent (" EAX_RAM" ) == true ;
126125
127126 m_devices.back ().props .eax_unwanted =
128- (( 0 == xr_strcmp (actualDeviceName, AL_GENERIC_HARDWARE) ) ||
129- ( 0 == xr_strcmp (actualDeviceName, AL_GENERIC_SOFTWARE)) );
127+ 0 == xr_strcmp (actualDeviceName, AL_GENERIC_HARDWARE) ||
128+ 0 == xr_strcmp (actualDeviceName, AL_GENERIC_SOFTWARE);
130129 ++index;
131130 }
132131 alcDestroyContext (context);
133132 }
134133 else
135- {
136134 Msg (" SOUND: OpenAL: cant create context for %s" , device);
137- }
138135 alcCloseDevice (device);
139136 }
140137 else
141- {
142138 Msg (" SOUND: OpenAL: cant open device %s" , devices);
143- }
144139
145140 devices += xr_strlen (devices) + 1 ;
146141 }
@@ -152,7 +147,7 @@ void ALDeviceList::Enumerate()
152147 u32 _cnt = GetNumDevices ();
153148 snd_devices_token = xr_alloc<xr_token>(_cnt + 1 );
154149 snd_devices_token[_cnt].id = -1 ;
155- snd_devices_token[_cnt].name = NULL ;
150+ snd_devices_token[_cnt].name = nullptr ;
156151 for (u32 i = 0 ; i < _cnt; ++i)
157152 {
158153 snd_devices_token[i].id = i;
@@ -169,23 +164,23 @@ void ALDeviceList::Enumerate()
169164 {
170165 GetDeviceVersion (j, &majorVersion, &minorVersion);
171166 Msg (" %d. %s, Spec Version %d.%d %s eax[%d] efx[%s] xram[%s]" , j + 1 , GetDeviceName (j), majorVersion,
172- minorVersion, ( _stricmp (GetDeviceName (j), m_defaultDeviceName) == 0 ) ? " (default)" : " " ,
167+ minorVersion, _stricmp (GetDeviceName (j), m_defaultDeviceName) == 0 ? " (default)" : " " ,
173168 GetDeviceDesc (j).props .eax , GetDeviceDesc (j).props .efx ? " yes" : " no" ,
174169 GetDeviceDesc (j).props .xram ? " yes" : " no" );
175170 }
176171 if (!strstr (GetCommandLine (), " -editor" ))
177- CoInitializeEx (NULL , COINIT_MULTITHREADED);
172+ CoInitializeEx (nullptr , COINIT_MULTITHREADED);
178173}
179174
180- LPCSTR ALDeviceList::GetDeviceName (u32 index) { return snd_devices_token[index].name ; }
175+ pcstr ALDeviceList::GetDeviceName (u32 index) const { return snd_devices_token[index].name ; }
181176void ALDeviceList::SelectBestDevice ()
182177{
183178 int best_majorVersion = -1 ;
184179 int best_minorVersion = -1 ;
185180 int majorVersion;
186181 int minorVersion;
187182
188- if (snd_device_id == u32 (- 1 ) )
183+ if (snd_device_id == ( u32 )- 1 )
189184 {
190185 // select best
191186 u32 new_device_id = snd_device_id;
@@ -195,19 +190,19 @@ void ALDeviceList::SelectBestDevice()
195190 continue ;
196191
197192 GetDeviceVersion (i, &majorVersion, &minorVersion);
198- if (( majorVersion > best_majorVersion) ||
199- ( majorVersion == best_majorVersion && minorVersion > best_minorVersion) )
193+ if (majorVersion > best_majorVersion ||
194+ majorVersion == best_majorVersion && minorVersion > best_minorVersion)
200195 {
201196 best_majorVersion = majorVersion;
202197 best_minorVersion = minorVersion;
203198 new_device_id = i;
204199 }
205200 }
206- if (new_device_id == u32 (- 1 ) )
201+ if (new_device_id == ( u32 )- 1 )
207202 {
208203 R_ASSERT (GetNumDevices () != 0 );
209204 new_device_id = 0 ; // first
210- };
205+ }
211206 snd_device_id = new_device_id;
212207 }
213208 if (GetNumDevices () == 0 )
@@ -223,5 +218,4 @@ void ALDeviceList::GetDeviceVersion(u32 index, int* major, int* minor)
223218{
224219 *major = m_devices[index].major_ver ;
225220 *minor = m_devices[index].minor_ver ;
226- return ;
227221}
0 commit comments