1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Updated some code to use cleaner array initialisation from constant data

This commit is contained in:
jules 2017-10-16 12:18:04 +01:00
parent 7ece1b4135
commit c2a2d5c734
11 changed files with 41 additions and 70 deletions

View file

@ -1058,7 +1058,7 @@ private:
return columnXml->getStringAttribute ("name");
}
return String();
return {};
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TableDemoComponent)
@ -1317,9 +1317,7 @@ public:
//==============================================================================
StringArray getMenuBarNames() override
{
const char* const names[] = { "Demo", "Look-and-feel", "Tabs", "Misc", nullptr };
return StringArray (names);
return { "Demo", "Look-and-feel", "Tabs", "Misc" };
}
PopupMenu getMenuForIndex (int menuIndex, const String& /*menuName*/) override

View file

@ -340,8 +340,7 @@ MenuBarModel* ProjucerApplication::getMenuModel()
StringArray ProjucerApplication::getMenuNames()
{
const char* const names[] = { "File", "Edit", "View", "Build", "Window", "GUI Editor", "Tools", nullptr };
return StringArray (names);
return { "File", "Edit", "View", "Build", "Window", "GUI Editor", "Tools" };
}
void ProjucerApplication::createMenu (PopupMenu& menu, const String& menuName)

View file

@ -206,7 +206,5 @@ inline Array<ProjectType*> ProjectType::getAllTypes()
static ProjectType_DLL dll;
static ProjectType_AudioPlugin plugin;
static ProjectType* allTypes[] = { &guiApp, &consoleApp, &staticLib, &dll, &plugin, nullptr };
return Array<ProjectType*> (allTypes);
return { &guiApp, &consoleApp, &staticLib, &dll, &plugin };
}

View file

@ -72,7 +72,7 @@ struct NewProjectWizard
virtual StringArray getDefaultModules()
{
static const char* mods[] =
return
{
"juce_core",
"juce_events",
@ -86,11 +86,8 @@ struct NewProjectWizard
"juce_audio_basics",
"juce_audio_devices",
"juce_audio_formats",
"juce_audio_processors",
nullptr
"juce_audio_processors"
};
return StringArray (mods);
}
String appTitle;

View file

@ -402,7 +402,7 @@ public:
return true;
}
auto currentPlayTime = Time::getHighResolutionTicks ();
auto currentPlayTime = Time::getHighResolutionTicks();
if (! firstPlayTime)
{
auto expectedBuffers = (currentPlayTime - lastPlayTime) / ticksPerBuffer;
@ -534,9 +534,8 @@ struct DSoundInternalInChannel
public:
DSoundInternalInChannel (const String& name_, const GUID& guid_, int rate,
int bufferSize, float* left, float* right)
: bitDepth (16), name (name_), guid (guid_), sampleRate (rate),
bufferSizeSamples (bufferSize), leftBuffer (left), rightBuffer (right),
pDirectSound (nullptr), pDirectSoundCapture (nullptr), pInputBuffer (nullptr)
: name (name_), guid (guid_), sampleRate (rate),
bufferSizeSamples (bufferSize), leftBuffer (left), rightBuffer (right)
{
}
@ -647,6 +646,7 @@ public:
return true;
int bytesFilled = (int) (readPos - readOffset);
if (bytesFilled < 0)
bytesFilled += totalBytesPerBuffer;
@ -715,7 +715,7 @@ public:
unsigned int readOffset;
int bytesPerBuffer, totalBytesPerBuffer;
int bitDepth;
int bitDepth = 16;
bool doneFlag;
private:
@ -725,9 +725,9 @@ private:
float* leftBuffer;
float* rightBuffer;
IDirectSound* pDirectSound;
IDirectSoundCapture* pDirectSoundCapture;
IDirectSoundCaptureBuffer* pInputBuffer;
IDirectSound* pDirectSound = nullptr;
IDirectSoundCapture* pDirectSoundCapture = nullptr;
IDirectSoundCaptureBuffer* pInputBuffer = nullptr;
JUCE_DECLARE_NON_COPYABLE (DSoundInternalInChannel)
};
@ -743,12 +743,7 @@ public:
: AudioIODevice (deviceName, "DirectSound"),
Thread ("Juce DSound"),
outputDeviceIndex (outputDeviceIndex_),
inputDeviceIndex (inputDeviceIndex_),
isOpen_ (false),
isStarted (false),
bufferSizeSamples (0),
sampleRate (0.0),
callback (nullptr)
inputDeviceIndex (inputDeviceIndex_)
{
if (outputDeviceIndex_ >= 0)
{
@ -801,8 +796,7 @@ public:
Array<double> getAvailableSampleRates() override
{
static const double rates[] = { 44100.0, 48000.0, 88200.0, 96000.0 };
return Array<double> (rates, numElementsInArray (rates));
return { 44100.0, 48000.0, 88200.0, 96000.0 };
}
Array<int> getAvailableBufferSizes() override
@ -862,7 +856,7 @@ public:
{
if (isStarted)
{
AudioIODeviceCallback* const callbackLocal = callback;
auto* callbackLocal = callback;
{
const ScopedLock sl (startStopLock);
@ -877,9 +871,9 @@ public:
bool isPlaying() override { return isStarted && isOpen_ && isThreadRunning(); }
String getLastError() override { return lastError; }
int getXRunCount () const noexcept override
int getXRunCount() const noexcept override
{
return (outChans[0] != nullptr ? outChans[0]->xruns : -1);
return outChans[0] != nullptr ? outChans[0]->xruns : -1;
}
//==============================================================================
@ -887,20 +881,20 @@ public:
int outputDeviceIndex, inputDeviceIndex;
private:
bool isOpen_;
bool isStarted;
bool isOpen_ = false;
bool isStarted = false;
String lastError;
OwnedArray<DSoundInternalInChannel> inChans;
OwnedArray<DSoundInternalOutChannel> outChans;
WaitableEvent startEvent;
int bufferSizeSamples;
double sampleRate;
int bufferSizeSamples = 0;
double sampleRate = 0;
BigInteger enabledInputs, enabledOutputs;
AudioSampleBuffer inputBuffers, outputBuffers;
AudioIODeviceCallback* callback;
AudioIODeviceCallback* callback = nullptr;
CriticalSection startStopLock;
String openDevice (const BigInteger& inputChannels,
@ -1218,8 +1212,7 @@ class DSoundAudioIODeviceType : public AudioIODeviceType,
public:
DSoundAudioIODeviceType()
: AudioIODeviceType ("DirectSound"),
DeviceChangeDetector (L"DirectSound"),
hasScanned (false)
DeviceChangeDetector (L"DirectSound")
{
initialiseDSoundFunctions();
}
@ -1275,7 +1268,7 @@ public:
private:
DSoundDeviceList deviceList;
bool hasScanned;
bool hasScanned = false;
void systemDeviceChanged() override
{

View file

@ -933,14 +933,12 @@ AiffAudioFormat::~AiffAudioFormat() {}
Array<int> AiffAudioFormat::getPossibleSampleRates()
{
const int rates[] = { 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 0 };
return Array<int> (rates);
return { 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000 };
}
Array<int> AiffAudioFormat::getPossibleBitDepths()
{
const int depths[] = { 8, 16, 24, 0 };
return Array<int> (depths);
return { 8, 16, 24 };
}
bool AiffAudioFormat::canDoStereo() { return true; }

View file

@ -545,17 +545,13 @@ FlacAudioFormat::~FlacAudioFormat() {}
Array<int> FlacAudioFormat::getPossibleSampleRates()
{
const int rates[] = { 8000, 11025, 12000, 16000, 22050, 32000, 44100, 48000,
88200, 96000, 176400, 192000, 352800, 384000 };
return Array<int> (rates, numElementsInArray (rates));
return { 8000, 11025, 12000, 16000, 22050, 32000, 44100, 48000,
88200, 96000, 176400, 192000, 352800, 384000 };
}
Array<int> FlacAudioFormat::getPossibleBitDepths()
{
const int depths[] = { 16, 24 };
return Array<int> (depths, numElementsInArray (depths));
return { 16, 24 };
}
bool FlacAudioFormat::canDoStereo() { return true; }
@ -595,8 +591,7 @@ AudioFormatWriter* FlacAudioFormat::createWriterFor (OutputStream* out,
StringArray FlacAudioFormat::getQualityOptions()
{
static const char* options[] = { "0 (Fastest)", "1", "2", "3", "4", "5 (Default)","6", "7", "8 (Highest quality)", 0 };
return StringArray (options);
return { "0 (Fastest)", "1", "2", "3", "4", "5 (Default)","6", "7", "8 (Highest quality)" };
}
#endif

View file

@ -168,14 +168,12 @@ bool LAMEEncoderAudioFormat::canHandleFile (const File&)
Array<int> LAMEEncoderAudioFormat::getPossibleSampleRates()
{
const int rates[] = { 32000, 44100, 48000, 0 };
return Array<int> (rates);
return { 32000, 44100, 48000 };
}
Array<int> LAMEEncoderAudioFormat::getPossibleBitDepths()
{
const int depths[] = { 16, 0 };
return Array<int> (depths);
return Array<int> (16);
}
bool LAMEEncoderAudioFormat::canDoStereo() { return true; }

View file

@ -433,17 +433,13 @@ OggVorbisAudioFormat::~OggVorbisAudioFormat()
Array<int> OggVorbisAudioFormat::getPossibleSampleRates()
{
const int rates[] = { 8000, 11025, 12000, 16000, 22050, 32000,
44100, 48000, 88200, 96000, 176400, 192000 };
return Array<int> (rates, numElementsInArray (rates));
return { 8000, 11025, 12000, 16000, 22050, 32000,
44100, 48000, 88200, 96000, 176400, 192000 };
}
Array<int> OggVorbisAudioFormat::getPossibleBitDepths()
{
const int depths[] = { 32 };
return Array<int> (depths, numElementsInArray (depths));
return Array<int> (32);
}
bool OggVorbisAudioFormat::canDoStereo() { return true; }
@ -482,9 +478,8 @@ AudioFormatWriter* OggVorbisAudioFormat::createWriterFor (OutputStream* out,
StringArray OggVorbisAudioFormat::getQualityOptions()
{
static const char* options[] = { "64 kbps", "80 kbps", "96 kbps", "112 kbps", "128 kbps", "160 kbps",
"192 kbps", "224 kbps", "256 kbps", "320 kbps", "500 kbps", 0 };
return StringArray (options);
return { "64 kbps", "80 kbps", "96 kbps", "112 kbps", "128 kbps", "160 kbps",
"192 kbps", "224 kbps", "256 kbps", "320 kbps", "500 kbps" };
}
int OggVorbisAudioFormat::estimateOggFileQuality (const File& source)

View file

@ -78,7 +78,7 @@ int AudioCDReader::getLastIndex() const
Array<int> AudioCDReader::findIndexesInTrack (const int)
{
return Array<int>();
return {};
}
} // namespace juce

View file

@ -51,7 +51,7 @@ Array<KeyPress> KeyPressMappingSet::getKeyPressesAssignedToCommand (const Comman
if (mappings.getUnchecked(i)->commandID == commandID)
return mappings.getUnchecked (i)->keypresses;
return Array<KeyPress>();
return {};
}
void KeyPressMappingSet::addKeyPress (const CommandID commandID, const KeyPress& newKeyPress, int insertIndex)