Fix minor compile warnings generated by clang:

- mostly change pointer -> 0 to use 'nullptr'
 - some commenting and formatting fixes
This commit is contained in:
Stephen Anthony 2018-05-11 21:01:40 -02:30
parent d624140829
commit 741515a520
11 changed files with 63 additions and 58 deletions

View File

@ -93,7 +93,7 @@ Int16* AudioQueue::enqueue(Int16* fragment)
if (!myFirstFragmentForEnqueue) throw runtime_error("enqueue called empty");
newFragment = myFirstFragmentForEnqueue;
myFirstFragmentForEnqueue = 0;
myFirstFragmentForEnqueue = nullptr;
return newFragment;
}
@ -115,13 +115,13 @@ Int16* AudioQueue::dequeue(Int16* fragment)
{
lock_guard<mutex> guard(myMutex);
if (mySize == 0) return 0;
if (mySize == 0) return nullptr;
if (!fragment) {
if (!myFirstFragmentForDequeue) throw runtime_error("dequeue called empty");
fragment = myFirstFragmentForDequeue;
myFirstFragmentForDequeue = 0;
myFirstFragmentForDequeue = nullptr;
}
Int16* nextFragment = myFragmentQueue.at(myNextFragment);

View File

@ -41,7 +41,7 @@ class AudioQueue
Create a new AudioQueue.
@param fragmentSize The size (in stereo / mono samples) of each fragment
@param capacaity The number of fragments that can be queued before wrapping.
@param capacity The number of fragments that can be queued before wrapping.
@param isStereo Whether samples are stereo or mono.
@param sampleRate The sample rate. This is not used, but can be queried.
*/
@ -83,7 +83,7 @@ class AudioQueue
@param fragment The returned fragment. This must be empty on the first call (when
there is nothing to return)
*/
Int16* enqueue(Int16* fragment = 0);
Int16* enqueue(Int16* fragment = nullptr);
/**
Dequeue a fragment for playback and return the played fragment. This may
@ -93,7 +93,7 @@ class AudioQueue
@param fragment The returned fragment. This must be empty on the first call (when
there is nothing to return).
*/
Int16* dequeue(Int16* fragment = 0);
Int16* dequeue(Int16* fragment = nullptr);
/**
Return the currently playing fragment without drawing a new one. This is called

View File

@ -39,8 +39,7 @@ SoundSDL2::SoundSDL2(OSystem& osystem)
myIsInitializedFlag(false),
myVolume(100),
myVolumeFactor(0xffff),
myAudioQueue(0),
myCurrentFragment(0)
myCurrentFragment(nullptr)
{
myOSystem.logMessage("SoundSDL2::SoundSDL2 started ...", 2);
@ -103,9 +102,10 @@ void SoundSDL2::setEnabled(bool state)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue, EmulationTiming* emulationTiming)
void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
EmulationTiming* emulationTiming)
{
this->emulationTiming = emulationTiming;
myEmulationTiming = emulationTiming;
myOSystem.logMessage("SoundSDL2::open started ...", 2);
mute(true);
@ -118,7 +118,7 @@ void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue, EmulationTiming* emulati
myAudioQueue = audioQueue;
myUnderrun = true;
myCurrentFragment = 0;
myCurrentFragment = nullptr;
// Adjust volume to that defined in settings
setVolume(myOSystem.settings().getInt("volume"));
@ -149,8 +149,8 @@ void SoundSDL2::close()
mute(true);
if (myAudioQueue) myAudioQueue->closeSink(myCurrentFragment);
myAudioQueue = 0;
myCurrentFragment = 0;
myAudioQueue.reset();
myCurrentFragment = nullptr;
myOSystem.logMessage("SoundSDL2::close", 2);
@ -167,7 +167,8 @@ void SoundSDL2::mute(bool state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::reset()
{}
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::setVolume(Int32 percent)
@ -233,14 +234,15 @@ void SoundSDL2::processFragment(float* stream, uInt32 length)
void SoundSDL2::initResampler()
{
Resampler::NextFragmentCallback nextFragmentCallback = [this] () -> Int16* {
Int16* nextFragment = 0;
Int16* nextFragment = nullptr;
if (myUnderrun)
nextFragment = myAudioQueue->size() > emulationTiming->prebufferFragmentCount() ? myAudioQueue->dequeue(myCurrentFragment) : 0;
nextFragment = myAudioQueue->size() > myEmulationTiming->prebufferFragmentCount() ?
myAudioQueue->dequeue(myCurrentFragment) : nullptr;
else
nextFragment = myAudioQueue->dequeue(myCurrentFragment);
myUnderrun = nextFragment == 0;
myUnderrun = nextFragment == nullptr;
if (nextFragment) myCurrentFragment = nextFragment;
return nextFragment;

View File

@ -33,7 +33,7 @@ class EmulationTiming;
/**
This class implements the sound API for SDL.
@author Stephen Anthony and Bradford W. Mott
@author Stephen Anthony and Christian Speckner (DirtyHairy)
*/
class SoundSDL2 : public Sound
{
@ -130,7 +130,7 @@ class SoundSDL2 : public Sound
shared_ptr<AudioQueue> myAudioQueue;
EmulationTiming* emulationTiming;
EmulationTiming* myEmulationTiming;
Int16* myCurrentFragment;
bool myUnderrun;

View File

@ -75,10 +75,10 @@ LanczosResampler::LanczosResampler(
myKernelSize(2 * kernelParameter),
myCurrentKernelIndex(0),
myKernelParameter(kernelParameter),
myBuffer(0),
myBufferL(0),
myBufferR(0),
myCurrentFragment(0),
myBuffer(nullptr),
myBufferL(nullptr),
myBufferR(nullptr),
myCurrentFragment(nullptr),
myFragmentIndex(0),
myIsUnderrun(true),
myTimeIndex(0)

View File

@ -22,7 +22,8 @@
#include "Resampler.hxx"
#include "ConvolutionBuffer.hxx"
class LanczosResampler : public Resampler {
class LanczosResampler : public Resampler
{
public:
LanczosResampler(
Resampler::Format formatFrom,

View File

@ -30,10 +30,10 @@ class Resampler {
class Format {
public:
Format(uInt32 sampleRate, uInt32 fragmentSize, bool stereo) :
sampleRate(sampleRate),
fragmentSize(fragmentSize),
stereo(stereo)
Format(uInt32 f_sampleRate, uInt32 f_fragmentSize, bool f_stereo) :
sampleRate(f_sampleRate),
fragmentSize(f_fragmentSize),
stereo(f_stereo)
{}
public:

View File

@ -22,13 +22,13 @@ SimpleResampler::SimpleResampler(
Resampler::Format formatFrom,
Resampler::Format formatTo,
Resampler::NextFragmentCallback nextFragmentCallback)
:
Resampler(formatFrom, formatTo, nextFragmentCallback),
myCurrentFragment(0),
: Resampler(formatFrom, formatTo, nextFragmentCallback),
myCurrentFragment(nullptr),
myTimeIndex(0),
myFragmentIndex(0),
myIsUnderrun(true)
{}
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SimpleResampler::fillFragment(float* fragment, uInt32 length)

View File

@ -21,7 +21,8 @@
#include "bspf.hxx"
#include "Resampler.hxx"
class SimpleResampler : public Resampler {
class SimpleResampler : public Resampler
{
public:
SimpleResampler(
Resampler::Format formatFrom,

View File

@ -110,7 +110,7 @@ class M6502 : public Serializable
is executed, someone stops execution, or an error occurs. Answers
true iff execution stops normally.
@param number Indicates the number of cycles to execute. Not that the actual
@param cycles Indicates the number of cycles to execute. Not that the actual
granularity of the CPU is instructions, so this is only accurate up to
a couple of cycles
@return true iff execution stops normally

View File

@ -35,8 +35,8 @@ namespace {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Audio::Audio()
: myAudioQueue(0),
myCurrentFragment(0)
: myAudioQueue(nullptr),
myCurrentFragment(nullptr)
{
for (uInt8 i = 0; i <= 0x1e; i++) myMixingTableSum[i] = mixingTableEntry(i, 0x1e);
for (uInt8 i = 0; i <= 0x0f; i++) myMixingTableIndividual[i] = mixingTableEntry(i, 0x0f);
@ -65,7 +65,8 @@ void Audio::setAudioQueue(shared_ptr<AudioQueue> queue)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Audio::tick()
{ switch (myCounter) {
{
switch (myCounter) {
case 9:
case 81:
myChannel0.phase0();