mirror of https://github.com/stella-emu/stella.git
Fix minor compile warnings generated by clang:
- mostly change pointer -> 0 to use 'nullptr' - some commenting and formatting fixes
This commit is contained in:
parent
d624140829
commit
741515a520
|
@ -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);
|
||||
|
|
|
@ -23,16 +23,16 @@
|
|||
#include "bspf.hxx"
|
||||
|
||||
/**
|
||||
This class implements a an audio queue that acts both like a ring buffer
|
||||
and a pool of audio fragments. The TIA emulation core fills a fragment
|
||||
with samples and then returns it to the queue, receiving a new fragment
|
||||
in return. The sound driver removes fragments for playback from the
|
||||
queue and returns the used fragment in this process.
|
||||
This class implements a an audio queue that acts both like a ring buffer
|
||||
and a pool of audio fragments. The TIA emulation core fills a fragment
|
||||
with samples and then returns it to the queue, receiving a new fragment
|
||||
in return. The sound driver removes fragments for playback from the
|
||||
queue and returns the used fragment in this process.
|
||||
|
||||
The queue needs to be threadsafe as the (SDL) audio driver runs on a
|
||||
separate thread. Samples are stored as signed 16 bit integers
|
||||
(platform endian).
|
||||
*/
|
||||
The queue needs to be threadsafe as the (SDL) audio driver runs on a
|
||||
separate thread. Samples are stored as signed 16 bit integers
|
||||
(platform endian).
|
||||
*/
|
||||
class AudioQueue
|
||||
{
|
||||
public:
|
||||
|
@ -40,10 +40,10 @@ 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 isStereo Whether samples are stereo or mono.
|
||||
@param sampleRate The sample rate. This is not used, but can be queried.
|
||||
@param fragmentSize The size (in stereo / mono samples) of each fragment
|
||||
@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.
|
||||
*/
|
||||
AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo, uInt16 sampleRate);
|
||||
|
||||
|
@ -83,17 +83,17 @@ 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
|
||||
return 0 if there is no queued fragment to return (in this case, the returned
|
||||
fragment is not enqueued and must be passed in the next invocation).
|
||||
Dequeue a fragment for playback and return the played fragment. This may
|
||||
return 0 if there is no queued fragment to return (in this case, the returned
|
||||
fragment is not enqueued and must be passed in the next invocation).
|
||||
|
||||
@param fragment The returned fragment. This must be empty on the first call (when
|
||||
there is nothing to return).
|
||||
@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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -99,13 +98,14 @@ void SoundSDL2::setEnabled(bool state)
|
|||
myOSystem.settings().setValue("sound", state);
|
||||
|
||||
myOSystem.logMessage(state ? "SoundSDL2::setEnabled(true)" :
|
||||
"SoundSDL2::setEnabled(false)", 2);
|
||||
"SoundSDL2::setEnabled(false)", 2);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#include "Resampler.hxx"
|
||||
#include "ConvolutionBuffer.hxx"
|
||||
|
||||
class LanczosResampler : public Resampler {
|
||||
class LanczosResampler : public Resampler
|
||||
{
|
||||
public:
|
||||
LanczosResampler(
|
||||
Resampler::Format formatFrom,
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -22,13 +22,13 @@ SimpleResampler::SimpleResampler(
|
|||
Resampler::Format formatFrom,
|
||||
Resampler::Format formatTo,
|
||||
Resampler::NextFragmentCallback nextFragmentCallback)
|
||||
:
|
||||
Resampler(formatFrom, formatTo, nextFragmentCallback),
|
||||
myCurrentFragment(0),
|
||||
myTimeIndex(0),
|
||||
myFragmentIndex(0),
|
||||
myIsUnderrun(true)
|
||||
{}
|
||||
: Resampler(formatFrom, formatTo, nextFragmentCallback),
|
||||
myCurrentFragment(nullptr),
|
||||
myTimeIndex(0),
|
||||
myFragmentIndex(0),
|
||||
myIsUnderrun(true)
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SimpleResampler::fillFragment(float* fragment, uInt32 length)
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
#include "bspf.hxx"
|
||||
#include "Resampler.hxx"
|
||||
|
||||
class SimpleResampler : public Resampler {
|
||||
class SimpleResampler : public Resampler
|
||||
{
|
||||
public:
|
||||
SimpleResampler(
|
||||
Resampler::Format formatFrom,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue