summaryrefslogtreecommitdiff
path: root/src/sound
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/sound
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/sound')
-rw-r--r--src/sound/allegro_s.cpp16
-rw-r--r--src/sound/cocoa_s.cpp16
-rw-r--r--src/sound/null_s.h2
-rw-r--r--src/sound/sdl_s.cpp2
-rw-r--r--src/sound/win32_s.cpp12
-rw-r--r--src/sound/xaudio2_s.cpp8
6 files changed, 28 insertions, 28 deletions
diff --git a/src/sound/allegro_s.cpp b/src/sound/allegro_s.cpp
index 88a723ff8..f6bb96306 100644
--- a/src/sound/allegro_s.cpp
+++ b/src/sound/allegro_s.cpp
@@ -22,18 +22,18 @@
static FSoundDriver_Allegro iFSoundDriver_Allegro;
/** The stream we are writing too */
-static AUDIOSTREAM *_stream = NULL;
+static AUDIOSTREAM *_stream = nullptr;
/** The number of samples in the buffer */
static int _buffer_size;
void SoundDriver_Allegro::MainLoop()
{
/* We haven't opened a stream yet */
- if (_stream == NULL) return;
+ if (_stream == nullptr) return;
void *data = get_audio_stream_buffer(_stream);
/* We don't have to fill the stream yet */
- if (data == NULL) return;
+ if (data == nullptr) return;
/* Mix the samples */
MxMixSamples(data, _buffer_size);
@@ -54,14 +54,14 @@ extern int _allegro_instance_count;
const char *SoundDriver_Allegro::Start(const char * const *parm)
{
- if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) {
+ if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
return "Failed to set up Allegro";
}
_allegro_instance_count++;
/* Initialise the sound */
- if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) {
+ if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, nullptr) != 0) {
DEBUG(driver, 0, "allegro: install_sound failed '%s'", allegro_error);
return "Failed to set up Allegro sound";
}
@@ -76,14 +76,14 @@ const char *SoundDriver_Allegro::Start(const char * const *parm)
_buffer_size = GetDriverParamInt(parm, "samples", 1024) * hz / 11025;
_stream = play_audio_stream(_buffer_size, 16, true, hz, 255, 128);
MxInitialize(hz);
- return NULL;
+ return nullptr;
}
void SoundDriver_Allegro::Stop()
{
- if (_stream != NULL) {
+ if (_stream != nullptr) {
stop_audio_stream(_stream);
- _stream = NULL;
+ _stream = nullptr;
}
remove_sound();
diff --git a/src/sound/cocoa_s.cpp b/src/sound/cocoa_s.cpp
index 8133bf62f..13fe176f5 100644
--- a/src/sound/cocoa_s.cpp
+++ b/src/sound/cocoa_s.cpp
@@ -80,9 +80,9 @@ const char *SoundDriver_Cocoa::Start(const char * const *parm)
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
- AudioComponent comp = AudioComponentFindNext (NULL, &desc);
- if (comp == NULL) {
- return "cocoa_s: Failed to start CoreAudio: AudioComponentFindNext returned NULL";
+ AudioComponent comp = AudioComponentFindNext (nullptr, &desc);
+ if (comp == nullptr) {
+ return "cocoa_s: Failed to start CoreAudio: AudioComponentFindNext returned nullptr";
}
/* Open & initialize the default output audio unit */
@@ -101,9 +101,9 @@ const char *SoundDriver_Cocoa::Start(const char * const *parm)
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
- Component comp = FindNextComponent (NULL, &desc);
- if (comp == NULL) {
- return "cocoa_s: Failed to start CoreAudio: FindNextComponent returned NULL";
+ Component comp = FindNextComponent (nullptr, &desc);
+ if (comp == nullptr) {
+ return "cocoa_s: Failed to start CoreAudio: FindNextComponent returned nullptr";
}
/* Open & initialize the default output audio unit */
@@ -126,7 +126,7 @@ const char *SoundDriver_Cocoa::Start(const char * const *parm)
/* Set the audio callback */
callback.inputProc = audioCallback;
- callback.inputProcRefCon = NULL;
+ callback.inputProcRefCon = nullptr;
if (AudioUnitSetProperty(_outputAudioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)) != noErr) {
return "cocoa_s: Failed to start CoreAudio: AudioUnitSetProperty (kAudioUnitProperty_SetRenderCallback)";
}
@@ -137,7 +137,7 @@ const char *SoundDriver_Cocoa::Start(const char * const *parm)
}
/* We're running! */
- return NULL;
+ return nullptr;
}
diff --git a/src/sound/null_s.h b/src/sound/null_s.h
index ca9adb546..e1e2ad460 100644
--- a/src/sound/null_s.h
+++ b/src/sound/null_s.h
@@ -17,7 +17,7 @@
/** Implementation of the null sound driver. */
class SoundDriver_Null : public SoundDriver {
public:
- const char *Start(const char * const *param) override { return NULL; }
+ const char *Start(const char * const *param) override { return nullptr; }
void Stop() override { }
const char *GetName() const override { return "null"; }
diff --git a/src/sound/sdl_s.cpp b/src/sound/sdl_s.cpp
index b37016c24..f8041aa84 100644
--- a/src/sound/sdl_s.cpp
+++ b/src/sound/sdl_s.cpp
@@ -54,7 +54,7 @@ const char *SoundDriver_SDL::Start(const char * const *parm)
MxInitialize(spec.freq);
SDL_OpenAudio(&spec, &spec);
SDL_PauseAudio(0);
- return NULL;
+ return nullptr;
}
void SoundDriver_SDL::Stop()
diff --git a/src/sound/win32_s.cpp b/src/sound/win32_s.cpp
index 493ed7fc1..d16e5be2d 100644
--- a/src/sound/win32_s.cpp
+++ b/src/sound/win32_s.cpp
@@ -50,12 +50,12 @@ static DWORD WINAPI SoundThread(LPVOID arg)
if ((hdr->dwFlags & WHDR_INQUEUE) != 0) continue;
MxMixSamples(hdr->lpData, hdr->dwBufferLength / 4);
if (waveOutWrite(_waveout, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR) {
- MessageBox(NULL, _T("Sounds are disabled until restart."), _T("waveOutWrite failed"), MB_ICONINFORMATION);
+ MessageBox(nullptr, _T("Sounds are disabled until restart."), _T("waveOutWrite failed"), MB_ICONINFORMATION);
return 0;
}
}
WaitForSingleObject(_event, INFINITE);
- } while (_waveout != NULL);
+ } while (_waveout != nullptr);
return 0;
}
@@ -75,7 +75,7 @@ const char *SoundDriver_Win32::Start(const char * const *parm)
_bufsize = min(_bufsize, UINT16_MAX);
try {
- if (NULL == (_event = CreateEvent(NULL, FALSE, FALSE, NULL))) throw "Failed to create event";
+ if (nullptr == (_event = CreateEvent(nullptr, FALSE, FALSE, nullptr))) throw "Failed to create event";
if (waveOutOpen(&_waveout, WAVE_MAPPER, &wfex, (DWORD_PTR)_event, 0, CALLBACK_EVENT) != MMSYSERR_NOERROR) throw "waveOutOpen failed";
@@ -84,13 +84,13 @@ const char *SoundDriver_Win32::Start(const char * const *parm)
PrepareHeader(&_wave_hdr[0]);
PrepareHeader(&_wave_hdr[1]);
- if (NULL == (_thread = CreateThread(NULL, 8192, SoundThread, 0, 0, &_threadId))) throw "Failed to create thread";
+ if (nullptr == (_thread = CreateThread(nullptr, 8192, SoundThread, 0, 0, &_threadId))) throw "Failed to create thread";
} catch (const char *error) {
this->Stop();
return error;
}
- return NULL;
+ return nullptr;
}
void SoundDriver_Win32::Stop()
@@ -98,7 +98,7 @@ void SoundDriver_Win32::Stop()
HWAVEOUT waveout = _waveout;
/* Stop the sound thread. */
- _waveout = NULL;
+ _waveout = nullptr;
SetEvent(_event);
WaitForSingleObject(_thread, INFINITE);
diff --git a/src/sound/xaudio2_s.cpp b/src/sound/xaudio2_s.cpp
index 60311ced2..2acfd20a3 100644
--- a/src/sound/xaudio2_s.cpp
+++ b/src/sound/xaudio2_s.cpp
@@ -125,7 +125,7 @@ static StreamingVoiceContext* _voice_context = nullptr;
* Initialises the XAudio2 driver.
*
* @param parm Driver parameters.
-* @return An error message if unsuccessful, or NULL otherwise.
+* @return An error message if unsuccessful, or nullptr otherwise.
*
*/
const char *SoundDriver_XAudio2::Start(const char * const *parm)
@@ -140,7 +140,7 @@ const char *SoundDriver_XAudio2::Start(const char * const *parm)
_xaudio_dll_handle = LoadLibraryA(XAUDIO2_DLL_A);
- if (_xaudio_dll_handle == NULL)
+ if (_xaudio_dll_handle == nullptr)
{
CoUninitialize();
@@ -150,7 +150,7 @@ const char *SoundDriver_XAudio2::Start(const char * const *parm)
API_XAudio2Create xAudio2Create = (API_XAudio2Create) GetProcAddress(_xaudio_dll_handle, "XAudio2Create");
- if (xAudio2Create == NULL)
+ if (xAudio2Create == nullptr)
{
FreeLibrary(_xaudio_dll_handle);
CoUninitialize();
@@ -248,7 +248,7 @@ const char *SoundDriver_XAudio2::Start(const char * const *parm)
return "Failed to submit the first audio buffer";
}
- return NULL;
+ return nullptr;
}
/**