Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
committed by
Michael Lutz
parent
3b4f224c0b
commit
7c8e7c6b6e
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user