@@ -204,7 +204,8 @@ private: | |||||
const float* s = buffer.getSampleData (0, 0); | const float* s = buffer.getSampleData (0, 0); | ||||
const int spikeDriftAllowed = 5; | const int spikeDriftAllowed = 5; | ||||
Array <int> spikesFound (100); | |||||
Array <int> spikesFound; | |||||
spikesFound.ensureStorageAllocated (100); | |||||
double runningAverage = 0; | double runningAverage = 0; | ||||
int lastSpike = 0; | int lastSpike = 0; | ||||
@@ -38,8 +38,7 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
ApplicationCommandManager::ApplicationCommandManager() | ApplicationCommandManager::ApplicationCommandManager() | ||||
: listeners (8), | |||||
firstTarget (0) | |||||
: firstTarget (0) | |||||
{ | { | ||||
keyMappings = new KeyPressMappingSet (this); | keyMappings = new KeyPressMappingSet (this); | ||||
@@ -166,7 +165,7 @@ const StringArray ApplicationCommandManager::getCommandCategories() const throw( | |||||
const Array <CommandID> ApplicationCommandManager::getCommandsInCategory (const String& categoryName) const throw() | const Array <CommandID> ApplicationCommandManager::getCommandsInCategory (const String& categoryName) const throw() | ||||
{ | { | ||||
Array <CommandID> results (4); | |||||
Array <CommandID> results; | |||||
for (int i = 0; i < commands.size(); ++i) | for (int i = 0; i < commands.size(); ++i) | ||||
if (commands.getUnchecked(i)->categoryName == categoryName) | if (commands.getUnchecked(i)->categoryName == categoryName) | ||||
@@ -37,8 +37,7 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
AudioFormatManager::AudioFormatManager() | AudioFormatManager::AudioFormatManager() | ||||
: knownFormats (4), | |||||
defaultFormatIndex (0) | |||||
: defaultFormatIndex (0) | |||||
{ | { | ||||
} | } | ||||
@@ -42,8 +42,7 @@ class SharedBufferingAudioSourceThread : public DeletedAtShutdown, | |||||
{ | { | ||||
public: | public: | ||||
SharedBufferingAudioSourceThread() | SharedBufferingAudioSourceThread() | ||||
: Thread ("Audio Buffer"), | |||||
sources (8) | |||||
: Thread ("Audio Buffer") | |||||
{ | { | ||||
} | } | ||||
@@ -64,9 +64,6 @@ AudioDeviceManager::AudioDeviceManager() | |||||
inputLevelMeasurementEnabledCount (0), | inputLevelMeasurementEnabledCount (0), | ||||
inputLevel (0), | inputLevel (0), | ||||
tempBuffer (2, 2), | tempBuffer (2, 2), | ||||
enabledMidiInputs (4), | |||||
midiCallbacks (4), | |||||
midiCallbackDevices (4), | |||||
defaultMidiOutput (0), | defaultMidiOutput (0), | ||||
cpuUsageMs (0), | cpuUsageMs (0), | ||||
timeToCpuScale (0) | timeToCpuScale (0) | ||||
@@ -32,24 +32,20 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
MidiBuffer::MidiBuffer() throw() | MidiBuffer::MidiBuffer() throw() | ||||
: data (32), | |||||
bytesUsed (0) | |||||
: bytesUsed (0) | |||||
{ | { | ||||
} | } | ||||
MidiBuffer::MidiBuffer (const MidiMessage& message) throw() | MidiBuffer::MidiBuffer (const MidiMessage& message) throw() | ||||
: data (32), | |||||
bytesUsed (0) | |||||
: bytesUsed (0) | |||||
{ | { | ||||
addEvent (message, 0); | addEvent (message, 0); | ||||
} | } | ||||
MidiBuffer::MidiBuffer (const MidiBuffer& other) throw() | MidiBuffer::MidiBuffer (const MidiBuffer& other) throw() | ||||
: data (32), | |||||
bytesUsed (other.bytesUsed) | |||||
: bytesUsed (other.bytesUsed), | |||||
data (other.data) | |||||
{ | { | ||||
data.ensureAllocatedSize (bytesUsed); | |||||
memcpy (data.elements, other.data.elements, bytesUsed); | |||||
} | } | ||||
const MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw() | const MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw() | ||||
@@ -57,10 +53,7 @@ const MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw() | |||||
if (this != &other) | if (this != &other) | ||||
{ | { | ||||
bytesUsed = other.bytesUsed; | bytesUsed = other.bytesUsed; | ||||
data.ensureAllocatedSize (bytesUsed); | |||||
if (bytesUsed > 0) | |||||
memcpy (data.elements, other.data.elements, bytesUsed); | |||||
data = other.data; | |||||
} | } | ||||
return *this; | return *this; | ||||
@@ -68,8 +61,7 @@ const MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw() | |||||
void MidiBuffer::swap (MidiBuffer& other) | void MidiBuffer::swap (MidiBuffer& other) | ||||
{ | { | ||||
swapVariables <uint8*> (data.elements, other.data.elements); | |||||
swapVariables <int> (data.numAllocated, other.data.numAllocated); | |||||
data.swapWith (other.data); | |||||
swapVariables <int> (bytesUsed, other.bytesUsed); | swapVariables <int> (bytesUsed, other.bytesUsed); | ||||
} | } | ||||
@@ -85,12 +77,12 @@ void MidiBuffer::clear() throw() | |||||
void MidiBuffer::clear (const int startSample, | void MidiBuffer::clear (const int startSample, | ||||
const int numSamples) throw() | const int numSamples) throw() | ||||
{ | { | ||||
uint8* const start = findEventAfter (data.elements, startSample - 1); | |||||
uint8* const start = findEventAfter (data, startSample - 1); | |||||
uint8* const end = findEventAfter (start, startSample + numSamples - 1); | uint8* const end = findEventAfter (start, startSample + numSamples - 1); | ||||
if (end > start) | if (end > start) | ||||
{ | { | ||||
const size_t bytesToMove = (size_t) (bytesUsed - (end - data.elements)); | |||||
const size_t bytesToMove = (size_t) (bytesUsed - (end - (uint8*) data.getData())); | |||||
if (bytesToMove > 0) | if (bytesToMove > 0) | ||||
memmove (start, end, bytesToMove); | memmove (start, end, bytesToMove); | ||||
@@ -144,10 +136,11 @@ void MidiBuffer::addEvent (const uint8* const newData, | |||||
if (numBytes > 0) | if (numBytes > 0) | ||||
{ | { | ||||
data.ensureAllocatedSize (bytesUsed + numBytes + 6); | |||||
int spaceNeeded = bytesUsed + numBytes + 6; | |||||
data.ensureSize ((spaceNeeded + spaceNeeded / 2 + 8) & ~7); | |||||
uint8* d = findEventAfter (data.elements, sampleNumber); | |||||
const size_t bytesToMove = (size_t) (bytesUsed - (d - data.elements)); | |||||
uint8* d = findEventAfter ((uint8*) data.getData(), sampleNumber); | |||||
const size_t bytesToMove = (size_t) (bytesUsed - (d - (uint8*) data.getData())); | |||||
if (bytesToMove > 0) | if (bytesToMove > 0) | ||||
memmove (d + numBytes + 6, | memmove (d + numBytes + 6, | ||||
@@ -173,13 +166,13 @@ void MidiBuffer::addEvents (const MidiBuffer& otherBuffer, | |||||
Iterator i (otherBuffer); | Iterator i (otherBuffer); | ||||
i.setNextSamplePosition (startSample); | i.setNextSamplePosition (startSample); | ||||
const uint8* data; | |||||
int size, position; | |||||
const uint8* eventData; | |||||
int eventSize, position; | |||||
while (i.getNextEvent (data, size, position) | |||||
while (i.getNextEvent (eventData, eventSize, position) | |||||
&& (position < startSample + numSamples || numSamples < 0)) | && (position < startSample + numSamples || numSamples < 0)) | ||||
{ | { | ||||
addEvent (data, size, position + sampleDeltaToAdd); | |||||
addEvent (eventData, eventSize, position + sampleDeltaToAdd); | |||||
} | } | ||||
} | } | ||||
@@ -191,8 +184,8 @@ bool MidiBuffer::isEmpty() const throw() | |||||
int MidiBuffer::getNumEvents() const throw() | int MidiBuffer::getNumEvents() const throw() | ||||
{ | { | ||||
int n = 0; | int n = 0; | ||||
const uint8* d = data.elements; | |||||
const uint8* const end = data.elements + bytesUsed; | |||||
const uint8* d = (uint8*) data.getData(); | |||||
const uint8* const end = d + bytesUsed; | |||||
while (d < end) | while (d < end) | ||||
{ | { | ||||
@@ -206,7 +199,7 @@ int MidiBuffer::getNumEvents() const throw() | |||||
int MidiBuffer::getFirstEventTime() const throw() | int MidiBuffer::getFirstEventTime() const throw() | ||||
{ | { | ||||
return (bytesUsed > 0) ? *(const int*) data.elements : 0; | |||||
return (bytesUsed > 0) ? *(const int*) data.getData() : 0; | |||||
} | } | ||||
int MidiBuffer::getLastEventTime() const throw() | int MidiBuffer::getLastEventTime() const throw() | ||||
@@ -214,7 +207,7 @@ int MidiBuffer::getLastEventTime() const throw() | |||||
if (bytesUsed == 0) | if (bytesUsed == 0) | ||||
return 0; | return 0; | ||||
const uint8* d = data.elements; | |||||
const uint8* d = (uint8*) data.getData(); | |||||
const uint8* const endData = d + bytesUsed; | const uint8* const endData = d + bytesUsed; | ||||
for (;;) | for (;;) | ||||
@@ -230,7 +223,7 @@ int MidiBuffer::getLastEventTime() const throw() | |||||
uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const throw() | uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const throw() | ||||
{ | { | ||||
const uint8* const endData = data.elements + bytesUsed; | |||||
const uint8* const endData = ((uint8*) data.getData()) + bytesUsed; | |||||
while (d < endData && *(int*) d <= samplePosition) | while (d < endData && *(int*) d <= samplePosition) | ||||
{ | { | ||||
@@ -244,7 +237,7 @@ uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const thr | |||||
//============================================================================== | //============================================================================== | ||||
MidiBuffer::Iterator::Iterator (const MidiBuffer& buffer_) throw() | MidiBuffer::Iterator::Iterator (const MidiBuffer& buffer_) throw() | ||||
: buffer (buffer_), | : buffer (buffer_), | ||||
data (buffer_.data.elements) | |||||
data ((uint8*) buffer_.data.getData()) | |||||
{ | { | ||||
} | } | ||||
@@ -255,8 +248,8 @@ MidiBuffer::Iterator::~Iterator() throw() | |||||
//============================================================================== | //============================================================================== | ||||
void MidiBuffer::Iterator::setNextSamplePosition (const int samplePosition) throw() | void MidiBuffer::Iterator::setNextSamplePosition (const int samplePosition) throw() | ||||
{ | { | ||||
data = buffer.data.elements; | |||||
const uint8* dataEnd = buffer.data.elements + buffer.bytesUsed; | |||||
data = buffer.data; | |||||
const uint8* dataEnd = ((uint8*) buffer.data.getData()) + buffer.bytesUsed; | |||||
while (data < dataEnd && *(int*) data < samplePosition) | while (data < dataEnd && *(int*) data < samplePosition) | ||||
{ | { | ||||
@@ -269,7 +262,7 @@ bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, | |||||
int& numBytes, | int& numBytes, | ||||
int& samplePosition) throw() | int& samplePosition) throw() | ||||
{ | { | ||||
if (data >= buffer.data.elements + buffer.bytesUsed) | |||||
if (data >= ((uint8*) buffer.data.getData()) + buffer.bytesUsed) | |||||
return false; | return false; | ||||
samplePosition = *(int*) data; | samplePosition = *(int*) data; | ||||
@@ -285,7 +278,7 @@ bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, | |||||
bool MidiBuffer::Iterator::getNextEvent (MidiMessage& result, | bool MidiBuffer::Iterator::getNextEvent (MidiMessage& result, | ||||
int& samplePosition) throw() | int& samplePosition) throw() | ||||
{ | { | ||||
if (data >= buffer.data.elements + buffer.bytesUsed) | |||||
if (data >= ((uint8*) buffer.data.getData()) + buffer.bytesUsed) | |||||
return false; | return false; | ||||
samplePosition = *(int*) data; | samplePosition = *(int*) data; | ||||
@@ -26,7 +26,7 @@ | |||||
#ifndef __JUCE_MIDIBUFFER_JUCEHEADER__ | #ifndef __JUCE_MIDIBUFFER_JUCEHEADER__ | ||||
#define __JUCE_MIDIBUFFER_JUCEHEADER__ | #define __JUCE_MIDIBUFFER_JUCEHEADER__ | ||||
#include "../../containers/juce_ArrayAllocationBase.h" | |||||
#include "../../containers/juce_MemoryBlock.h" | |||||
#include "juce_MidiMessage.h" | #include "juce_MidiMessage.h" | ||||
@@ -226,7 +226,7 @@ public: | |||||
private: | private: | ||||
friend class MidiBuffer::Iterator; | friend class MidiBuffer::Iterator; | ||||
ArrayAllocationBase <uint8> data; | |||||
MemoryBlock data; | |||||
int bytesUsed; | int bytesUsed; | ||||
uint8* findEventAfter (uint8* d, const int samplePosition) const throw(); | uint8* findEventAfter (uint8* d, const int samplePosition) const throw(); | ||||
@@ -33,7 +33,6 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
MidiKeyboardState::MidiKeyboardState() | MidiKeyboardState::MidiKeyboardState() | ||||
: listeners (2) | |||||
{ | { | ||||
zeromem (noteStates, sizeof (noteStates)); | zeromem (noteStates, sizeof (noteStates)); | ||||
} | } | ||||
@@ -298,7 +298,8 @@ void MidiMessageSequence::createControllerUpdatesForTime (const int channelNumbe | |||||
{ | { | ||||
bool doneProg = false; | bool doneProg = false; | ||||
bool donePitchWheel = false; | bool donePitchWheel = false; | ||||
Array <int> doneControllers (32); | |||||
Array <int> doneControllers; | |||||
doneControllers.ensureStorageAllocated (32); | |||||
for (int i = list.size(); --i >= 0;) | for (int i = list.size(); --i >= 0;) | ||||
{ | { | ||||
@@ -72,9 +72,7 @@ void SynthesiserVoice::clearCurrentNote() | |||||
//============================================================================== | //============================================================================== | ||||
Synthesiser::Synthesiser() | Synthesiser::Synthesiser() | ||||
: voices (2), | |||||
sounds (2), | |||||
sampleRate (0), | |||||
: sampleRate (0), | |||||
lastNoteOnCounter (0), | lastNoteOnCounter (0), | ||||
shouldStealNotes (true) | shouldStealNotes (true) | ||||
{ | { | ||||
@@ -56,15 +56,9 @@ class Array | |||||
{ | { | ||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
/** Creates an empty array. | |||||
@param granularity this is the size of increment by which the internal storage | |||||
used by the array will grow. Only change it from the default if you know the | |||||
array is going to be very big and needs to be able to grow efficiently. | |||||
*/ | |||||
Array (const int granularity = juceDefaultArrayGranularity) throw() | |||||
: data (granularity), | |||||
numUsed (0) | |||||
/** Creates an empty array. */ | |||||
Array() throw() | |||||
: numUsed (0) | |||||
{ | { | ||||
} | } | ||||
@@ -72,7 +66,6 @@ public: | |||||
@param other the array to copy | @param other the array to copy | ||||
*/ | */ | ||||
Array (const Array<ElementType, TypeOfCriticalSectionToUse>& other) throw() | Array (const Array<ElementType, TypeOfCriticalSectionToUse>& other) throw() | ||||
: data (other.data.granularity) | |||||
{ | { | ||||
other.lockArray(); | other.lockArray(); | ||||
numUsed = other.numUsed; | numUsed = other.numUsed; | ||||
@@ -86,8 +79,7 @@ public: | |||||
@param values the array to copy from | @param values the array to copy from | ||||
*/ | */ | ||||
Array (const ElementType* values) throw() | Array (const ElementType* values) throw() | ||||
: data (juceDefaultArrayGranularity), | |||||
numUsed (0) | |||||
: numUsed (0) | |||||
{ | { | ||||
while (*values != 0) | while (*values != 0) | ||||
add (*values++); | add (*values++); | ||||
@@ -99,8 +91,7 @@ public: | |||||
@param numValues the number of values in the array | @param numValues the number of values in the array | ||||
*/ | */ | ||||
Array (const ElementType* values, int numValues) throw() | Array (const ElementType* values, int numValues) throw() | ||||
: data (juceDefaultArrayGranularity), | |||||
numUsed (numValues) | |||||
: numUsed (numValues) | |||||
{ | { | ||||
data.setAllocatedSize (numValues); | data.setAllocatedSize (numValues); | ||||
memcpy (data.elements, values, numValues * sizeof (ElementType)); | memcpy (data.elements, values, numValues * sizeof (ElementType)); | ||||
@@ -121,7 +112,6 @@ public: | |||||
other.lockArray(); | other.lockArray(); | ||||
lock.enter(); | lock.enter(); | ||||
data.granularity = other.data.granularity; | |||||
data.ensureAllocatedSize (other.size()); | data.ensureAllocatedSize (other.size()); | ||||
numUsed = other.numUsed; | numUsed = other.numUsed; | ||||
memcpy (data.elements, other.data.elements, numUsed * sizeof (ElementType)); | memcpy (data.elements, other.data.elements, numUsed * sizeof (ElementType)); | ||||
@@ -977,19 +967,7 @@ public: | |||||
void minimiseStorageOverheads() throw() | void minimiseStorageOverheads() throw() | ||||
{ | { | ||||
lock.enter(); | lock.enter(); | ||||
if (numUsed == 0) | |||||
{ | |||||
data.setAllocatedSize (0); | |||||
} | |||||
else | |||||
{ | |||||
const int newAllocation = data.granularity * (numUsed / data.granularity + 1); | |||||
if (newAllocation < data.numAllocated) | |||||
data.setAllocatedSize (newAllocation); | |||||
} | |||||
data.shrinkToNoMoreThan (numUsed); | |||||
lock.exit(); | lock.exit(); | ||||
} | } | ||||
@@ -1001,7 +979,9 @@ public: | |||||
*/ | */ | ||||
void ensureStorageAllocated (const int minNumElements) throw() | void ensureStorageAllocated (const int minNumElements) throw() | ||||
{ | { | ||||
lock.enter(); | |||||
data.ensureAllocatedSize (minNumElements); | data.ensureAllocatedSize (minNumElements); | ||||
lock.exit(); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -27,14 +27,6 @@ | |||||
#define __JUCE_ARRAYALLOCATIONBASE_JUCEHEADER__ | #define __JUCE_ARRAYALLOCATIONBASE_JUCEHEADER__ | ||||
//============================================================================== | |||||
/** The default size of chunk in which arrays increase their storage. | |||||
Used by ArrayAllocationBase and its subclasses. | |||||
*/ | |||||
const int juceDefaultArrayGranularity = 8; | |||||
//============================================================================== | //============================================================================== | ||||
/** | /** | ||||
Implements some basic array storage allocation functions. | Implements some basic array storage allocation functions. | ||||
@@ -49,17 +41,11 @@ class ArrayAllocationBase | |||||
{ | { | ||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
/** Creates an empty array. | |||||
@param granularity_ this is the size of increment by which the internal storage | |||||
will be increased. | |||||
*/ | |||||
ArrayAllocationBase (const int granularity_) throw() | |||||
/** Creates an empty array. */ | |||||
ArrayAllocationBase() throw() | |||||
: elements (0), | : elements (0), | ||||
numAllocated (0), | |||||
granularity (granularity_) | |||||
numAllocated (0) | |||||
{ | { | ||||
jassert (granularity > 0); | |||||
} | } | ||||
/** Destructor. */ | /** Destructor. */ | ||||
@@ -114,25 +100,21 @@ public: | |||||
void ensureAllocatedSize (int minNumElements) throw() | void ensureAllocatedSize (int minNumElements) throw() | ||||
{ | { | ||||
if (minNumElements > numAllocated) | if (minNumElements > numAllocated) | ||||
{ | |||||
// for arrays with small granularity that get big, start | |||||
// increasing the size in bigger jumps | |||||
if (minNumElements > (granularity << 6)) | |||||
{ | |||||
minNumElements += (minNumElements / granularity); | |||||
if (minNumElements > (granularity << 8)) | |||||
minNumElements += granularity << 6; | |||||
else | |||||
minNumElements += granularity << 5; | |||||
} | |||||
setAllocatedSize ((minNumElements + minNumElements / 2 + 8) & ~7); | |||||
} | |||||
setAllocatedSize (granularity * (minNumElements / granularity + 1)); | |||||
} | |||||
/** Minimises the amount of storage allocated so that it's no more than | |||||
the given number of elements. | |||||
*/ | |||||
void shrinkToNoMoreThan (int maxNumElements) throw() | |||||
{ | |||||
if (maxNumElements < numAllocated) | |||||
setAllocatedSize (maxNumElements); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
ElementType* elements; | ElementType* elements; | ||||
int numAllocated, granularity; | |||||
int numAllocated; | |||||
private: | private: | ||||
ArrayAllocationBase (const ArrayAllocationBase&); | ArrayAllocationBase (const ArrayAllocationBase&); | ||||
@@ -145,6 +145,12 @@ void MemoryBlock::ensureSize (const int minimumSize, | |||||
setSize (minimumSize, initialiseToZero); | setSize (minimumSize, initialiseToZero); | ||||
} | } | ||||
void MemoryBlock::swapWith (MemoryBlock& other) throw() | |||||
{ | |||||
swapVariables (size, other.size); | |||||
data.swapWith (other.data); | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
void MemoryBlock::fillWith (const uint8 value) throw() | void MemoryBlock::fillWith (const uint8 value) throw() | ||||
{ | { | ||||
@@ -151,6 +151,11 @@ public: | |||||
void append (const void* const data, | void append (const void* const data, | ||||
const int numBytes) throw(); | const int numBytes) throw(); | ||||
/** Exchanges the contents of this and another memory block. | |||||
No actual copying is required for this, so it's very fast. | |||||
*/ | |||||
void swapWith (MemoryBlock& other) throw(); | |||||
//============================================================================== | //============================================================================== | ||||
/** Copies data into this MemoryBlock from a memory address. | /** Copies data into this MemoryBlock from a memory address. | ||||
@@ -58,15 +58,9 @@ class OwnedArray | |||||
{ | { | ||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
/** Creates an empty array. | |||||
@param granularity this is the size of increment by which the internal storage | |||||
used by the array will grow. Only change it from the default if you know the | |||||
array is going to be very big and needs to be able to grow efficiently. | |||||
*/ | |||||
OwnedArray (const int granularity = juceDefaultArrayGranularity) throw() | |||||
: data (granularity), | |||||
numUsed (0) | |||||
/** Creates an empty array. */ | |||||
OwnedArray() throw() | |||||
: numUsed (0) | |||||
{ | { | ||||
} | } | ||||
@@ -674,19 +668,7 @@ public: | |||||
void minimiseStorageOverheads() throw() | void minimiseStorageOverheads() throw() | ||||
{ | { | ||||
lock.enter(); | lock.enter(); | ||||
if (numUsed == 0) | |||||
{ | |||||
data.setAllocatedSize (0); | |||||
} | |||||
else | |||||
{ | |||||
const int newAllocation = data.granularity * (numUsed / data.granularity + 1); | |||||
if (newAllocation < data.numAllocated) | |||||
data.setAllocatedSize (newAllocation); | |||||
} | |||||
data.shrinkToNoMoreThan (numUsed); | |||||
lock.exit(); | lock.exit(); | ||||
} | } | ||||
@@ -698,7 +680,9 @@ public: | |||||
*/ | */ | ||||
void ensureStorageAllocated (const int minNumElements) throw() | void ensureStorageAllocated (const int minNumElements) throw() | ||||
{ | { | ||||
lock.enter(); | |||||
data.ensureAllocatedSize (minNumElements); | data.ensureAllocatedSize (minNumElements); | ||||
lock.exit(); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -51,22 +51,15 @@ class ReferenceCountedArray | |||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
/** Creates an empty array. | /** Creates an empty array. | ||||
@param granularity this is the size of increment by which the internal storage | |||||
used by the array will grow. Only change it from the default if you know the | |||||
array is going to be very big and needs to be able to grow efficiently. | |||||
@see ReferenceCountedObject, Array, OwnedArray | @see ReferenceCountedObject, Array, OwnedArray | ||||
*/ | */ | ||||
ReferenceCountedArray (const int granularity = juceDefaultArrayGranularity) throw() | |||||
: data (granularity), | |||||
numUsed (0) | |||||
ReferenceCountedArray() throw() | |||||
: numUsed (0) | |||||
{ | { | ||||
} | } | ||||
/** Creates a copy of another array */ | /** Creates a copy of another array */ | ||||
ReferenceCountedArray (const ReferenceCountedArray<ObjectClass, TypeOfCriticalSectionToUse>& other) throw() | ReferenceCountedArray (const ReferenceCountedArray<ObjectClass, TypeOfCriticalSectionToUse>& other) throw() | ||||
: data (other.data.granularity) | |||||
{ | { | ||||
other.lockArray(); | other.lockArray(); | ||||
numUsed = other.numUsed; | numUsed = other.numUsed; | ||||
@@ -93,7 +86,6 @@ public: | |||||
clear(); | clear(); | ||||
data.granularity = other.granularity; | |||||
data.ensureAllocatedSize (other.numUsed); | data.ensureAllocatedSize (other.numUsed); | ||||
numUsed = other.numUsed; | numUsed = other.numUsed; | ||||
memcpy (data.elements, other.data.elements, numUsed * sizeof (ObjectClass*)); | memcpy (data.elements, other.data.elements, numUsed * sizeof (ObjectClass*)); | ||||
@@ -738,19 +730,7 @@ public: | |||||
void minimiseStorageOverheads() throw() | void minimiseStorageOverheads() throw() | ||||
{ | { | ||||
lock.enter(); | lock.enter(); | ||||
if (numUsed == 0) | |||||
{ | |||||
data.setAllocatedSize (0); | |||||
} | |||||
else | |||||
{ | |||||
const int newAllocation = data.granularity * (numUsed / data.granularity + 1); | |||||
if (newAllocation < data.numAllocated) | |||||
data.setAllocatedSize (newAllocation); | |||||
} | |||||
data.shrinkToNoMoreThan (numUsed); | |||||
lock.exit(); | lock.exit(); | ||||
} | } | ||||
@@ -62,15 +62,9 @@ class SortedSet | |||||
{ | { | ||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
/** Creates an empty set. | |||||
@param granularity this is the size of increment by which the internal storage | |||||
used by the array will grow. Only change it from the default if you know the | |||||
array is going to be very big and needs to be able to grow efficiently. | |||||
*/ | |||||
SortedSet (const int granularity = juceDefaultArrayGranularity) throw() | |||||
: data (granularity), | |||||
numUsed (0) | |||||
/** Creates an empty set. */ | |||||
SortedSet() throw() | |||||
: numUsed (0) | |||||
{ | { | ||||
} | } | ||||
@@ -78,7 +72,6 @@ public: | |||||
@param other the set to copy | @param other the set to copy | ||||
*/ | */ | ||||
SortedSet (const SortedSet<ElementType, TypeOfCriticalSectionToUse>& other) throw() | SortedSet (const SortedSet<ElementType, TypeOfCriticalSectionToUse>& other) throw() | ||||
: data (other.data.granularity) | |||||
{ | { | ||||
other.lockSet(); | other.lockSet(); | ||||
numUsed = other.numUsed; | numUsed = other.numUsed; | ||||
@@ -102,7 +95,6 @@ public: | |||||
other.lockSet(); | other.lockSet(); | ||||
lock.enter(); | lock.enter(); | ||||
data.granularity = other.data.granularity; | |||||
data.ensureAllocatedSize (other.size()); | data.ensureAllocatedSize (other.size()); | ||||
numUsed = other.numUsed; | numUsed = other.numUsed; | ||||
memcpy (data.elements, other.data.elements, numUsed * sizeof (ElementType)); | memcpy (data.elements, other.data.elements, numUsed * sizeof (ElementType)); | ||||
@@ -572,19 +564,7 @@ public: | |||||
void minimiseStorageOverheads() throw() | void minimiseStorageOverheads() throw() | ||||
{ | { | ||||
lock.enter(); | lock.enter(); | ||||
if (numUsed == 0) | |||||
{ | |||||
data.setAllocatedSize (0); | |||||
} | |||||
else | |||||
{ | |||||
const int newAllocation = data.granularity * (numUsed / data.granularity + 1); | |||||
if (newAllocation < data.numAllocated) | |||||
data.setAllocatedSize (newAllocation); | |||||
} | |||||
data.shrinkToNoMoreThan (numUsed); | |||||
lock.exit(); | lock.exit(); | ||||
} | } | ||||
@@ -145,6 +145,11 @@ void Value::setValue (const var& newValue) | |||||
value->setValue (newValue); | value->setValue (newValue); | ||||
} | } | ||||
const String Value::toString() const | |||||
{ | |||||
return value->getValue().toString(); | |||||
} | |||||
const Value& Value::operator= (const var& newValue) | const Value& Value::operator= (const var& newValue) | ||||
{ | { | ||||
value->setValue (newValue); | value->setValue (newValue); | ||||
@@ -76,6 +76,12 @@ public: | |||||
/** Returns the current value. */ | /** Returns the current value. */ | ||||
operator const var() const; | operator const var() const; | ||||
/** Returns the value as a string. | |||||
This is alternative to writing things like "myValue.getValue().toString()". | |||||
*/ | |||||
const String toString() const; | |||||
/** Sets the current value. | /** Sets the current value. | ||||
You can also use operator= to set the value. | You can also use operator= to set the value. | ||||
@@ -193,7 +193,7 @@ inline void swapVariables (Type& variable1, Type& variable2) | |||||
variable2 = tempVal; | variable2 = tempVal; | ||||
} | } | ||||
/** Handy macro for getting the number of elements in a simple const C array. | |||||
/** Handy function for getting the number of elements in a simple const C array. | |||||
E.g. | E.g. | ||||
@code | @code | ||||
@@ -202,7 +202,8 @@ inline void swapVariables (Type& variable1, Type& variable2) | |||||
int numElements = numElementsInArray (myArray) // returns 3 | int numElements = numElementsInArray (myArray) // returns 3 | ||||
@endcode | @endcode | ||||
*/ | */ | ||||
#define numElementsInArray(a) ((int) (sizeof (a) / sizeof ((a)[0]))) | |||||
template <typename Type> | |||||
inline int numElementsInArray (Type& array) { return (int) (sizeof (array) / sizeof (array[0])); } | |||||
//============================================================================== | //============================================================================== | ||||
// Some useful maths functions that aren't always present with all compilers and build settings. | // Some useful maths functions that aren't always present with all compilers and build settings. | ||||
@@ -200,15 +200,17 @@ | |||||
//============================================================================== | //============================================================================== | ||||
/** Clears a block of memory. */ | /** Clears a block of memory. */ | ||||
#define zeromem(memory, numBytes) memset (memory, 0, numBytes) | |||||
inline void zeromem (void* memory, int numBytes) { memset (memory, 0, numBytes); } | |||||
/** Clears a reference to a local structure. */ | /** Clears a reference to a local structure. */ | ||||
#define zerostruct(structure) memset (&structure, 0, sizeof (structure)) | |||||
template <typename Type> | |||||
inline void zerostruct (Type& structure) { memset (&structure, 0, sizeof (structure)); } | |||||
/** A handy macro that calls delete on a pointer if it's non-zero, and | |||||
then sets the pointer to null. | |||||
/** A handy function that calls delete on a pointer if it's non-zero, and then sets | |||||
the pointer to null. | |||||
*/ | */ | ||||
#define deleteAndZero(pointer) { delete (pointer); (pointer) = 0; } | |||||
template <typename Type> | |||||
inline void deleteAndZero (Type& pointer) { delete pointer; pointer = 0; } | |||||
@@ -203,20 +203,12 @@ | |||||
forcedinline void myfunction (int x) | forcedinline void myfunction (int x) | ||||
@endcode | @endcode | ||||
*/ | */ | ||||
#ifdef JUCE_DEBUG | |||||
#ifndef JUCE_DEBUG | |||||
#define forcedinline __forceinline | #define forcedinline __forceinline | ||||
#else | #else | ||||
#define forcedinline inline | #define forcedinline inline | ||||
#endif | #endif | ||||
/** A platform-independent way of stopping the compiler inlining a function. | |||||
Use the syntax: @code | |||||
juce_noinline void myfunction (int x) | |||||
@endcode | |||||
*/ | |||||
#define juce_noinline | |||||
#else | #else | ||||
/** A platform-independent way of forcing an inline function. | /** A platform-independent way of forcing an inline function. | ||||
@@ -230,14 +222,6 @@ | |||||
#define forcedinline inline | #define forcedinline inline | ||||
#endif | #endif | ||||
/** A platform-independent way of stopping the compiler inlining a function. | |||||
Use the syntax: @code | |||||
juce_noinline void myfunction (int x) | |||||
@endcode | |||||
*/ | |||||
#define juce_noinline __attribute__((noinline)) | |||||
#endif | #endif | ||||
#endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ | #endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ |
@@ -60,6 +60,11 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI() | |||||
#ifdef JUCE_DEBUG | #ifdef JUCE_DEBUG | ||||
{ | { | ||||
char a1[7]; | |||||
jassert (numElementsInArray(a1) == 7); | |||||
int a2[3]; | |||||
jassert (numElementsInArray(a2) == 3); | |||||
// Some simple test code to keep an eye on things and make sure these functions | // Some simple test code to keep an eye on things and make sure these functions | ||||
// work ok on all platforms. Let me know if any of these assertions fail! | // work ok on all platforms. Let me know if any of these assertions fail! | ||||
int n = 1; | int n = 1; | ||||
@@ -70,10 +70,10 @@ | |||||
#ifdef _DEBUG | #ifdef _DEBUG | ||||
#define JUCE_DEBUG 1 | #define JUCE_DEBUG 1 | ||||
#endif | #endif | ||||
#ifdef __MINGW32__ | |||||
#define JUCE_MINGW 1 | |||||
#endif | |||||
#ifdef __MINGW32__ | |||||
#define JUCE_MINGW 1 | |||||
#endif | |||||
/** If defined, this indicates that the processor is little-endian. */ | /** If defined, this indicates that the processor is little-endian. */ | ||||
#define JUCE_LITTLE_ENDIAN 1 | #define JUCE_LITTLE_ENDIAN 1 | ||||
@@ -36,10 +36,8 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
Button::Button (const String& name) | Button::Button (const String& name) | ||||
: Component (name), | : Component (name), | ||||
shortcuts (2), | |||||
keySource (0), | keySource (0), | ||||
text (name), | text (name), | ||||
buttonListeners (2), | |||||
buttonPressTime (0), | buttonPressTime (0), | ||||
lastTimeCallbackTime (0), | lastTimeCallbackTime (0), | ||||
commandManagerToUse (0), | commandManagerToUse (0), | ||||
@@ -38,7 +38,6 @@ Label::Label (const String& componentName, | |||||
text (labelText), | text (labelText), | ||||
font (15.0f), | font (15.0f), | ||||
justification (Justification::centredLeft), | justification (Justification::centredLeft), | ||||
listeners (2), | |||||
ownerComponent (0), | ownerComponent (0), | ||||
horizontalBorderSize (3), | horizontalBorderSize (3), | ||||
verticalBorderSize (1), | verticalBorderSize (1), | ||||
@@ -91,7 +91,6 @@ private: | |||||
//============================================================================== | //============================================================================== | ||||
Slider::Slider (const String& name) | Slider::Slider (const String& name) | ||||
: Component (name), | : Component (name), | ||||
listeners (2), | |||||
lastCurrentValue (0), | lastCurrentValue (0), | ||||
lastValueMin (0), | lastValueMin (0), | ||||
lastValueMax (0), | lastValueMax (0), | ||||
@@ -64,8 +64,7 @@ private: | |||||
//============================================================================== | //============================================================================== | ||||
TableHeaderComponent::TableHeaderComponent() | TableHeaderComponent::TableHeaderComponent() | ||||
: listeners (2), | |||||
columnsChanged (false), | |||||
: columnsChanged (false), | |||||
columnsResized (false), | columnsResized (false), | ||||
sortChanged (false), | sortChanged (false), | ||||
menuActive (true), | menuActive (true), | ||||
@@ -79,17 +79,17 @@ public: | |||||
const Colour& colour_, | const Colour& colour_, | ||||
const tchar passwordCharacter) | const tchar passwordCharacter) | ||||
: font (font_), | : font (font_), | ||||
colour (colour_), | |||||
atoms (64) | |||||
colour (colour_) | |||||
{ | { | ||||
initialiseAtoms (text, passwordCharacter); | initialiseAtoms (text, passwordCharacter); | ||||
} | } | ||||
UniformTextSection (const UniformTextSection& other) | UniformTextSection (const UniformTextSection& other) | ||||
: font (other.font), | : font (other.font), | ||||
colour (other.colour), | |||||
atoms (64) | |||||
colour (other.colour) | |||||
{ | { | ||||
atoms.ensureStorageAllocated (other.atoms.size()); | |||||
for (int i = 0; i < other.atoms.size(); ++i) | for (int i = 0; i < other.atoms.size(); ++i) | ||||
atoms.add (new TextAtom (*(const TextAtom*) other.atoms.getUnchecked(i))); | atoms.add (new TextAtom (*(const TextAtom*) other.atoms.getUnchecked(i))); | ||||
} | } | ||||
@@ -141,6 +141,8 @@ public: | |||||
} | } | ||||
} | } | ||||
atoms.ensureStorageAllocated (atoms.size() + other.atoms.size() - i); | |||||
while (i < other.atoms.size()) | while (i < other.atoms.size()) | ||||
{ | { | ||||
atoms.add (other.getAtom(i)); | atoms.add (other.getAtom(i)); | ||||
@@ -990,10 +992,8 @@ TextEditor::TextEditor (const String& name, | |||||
currentFont (14.0f), | currentFont (14.0f), | ||||
totalNumChars (0), | totalNumChars (0), | ||||
caretPosition (0), | caretPosition (0), | ||||
sections (8), | |||||
passwordCharacter (passwordCharacter_), | passwordCharacter (passwordCharacter_), | ||||
dragType (notDragging), | |||||
listeners (2) | |||||
dragType (notDragging) | |||||
{ | { | ||||
setOpaque (true); | setOpaque (true); | ||||
@@ -1086,7 +1086,6 @@ enum TreeViewOpenness | |||||
TreeViewItem::TreeViewItem() | TreeViewItem::TreeViewItem() | ||||
: ownerView (0), | : ownerView (0), | ||||
parentItem (0), | parentItem (0), | ||||
subItems (8), | |||||
y (0), | y (0), | ||||
itemHeight (0), | itemHeight (0), | ||||
totalHeight (0), | totalHeight (0), | ||||
@@ -33,8 +33,7 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
DirectoryContentsDisplayComponent::DirectoryContentsDisplayComponent (DirectoryContentsList& listToShow) | DirectoryContentsDisplayComponent::DirectoryContentsDisplayComponent (DirectoryContentsList& listToShow) | ||||
: fileList (listToShow), | |||||
listeners (2) | |||||
: fileList (listToShow) | |||||
{ | { | ||||
} | } | ||||
@@ -44,7 +44,6 @@ FileBrowserComponent::FileBrowserComponent (int flags_, | |||||
: FileFilter (String::empty), | : FileFilter (String::empty), | ||||
fileFilter (fileFilter_), | fileFilter (fileFilter_), | ||||
flags (flags_), | flags (flags_), | ||||
listeners (2), | |||||
previewComp (previewComp_), | previewComp (previewComp_), | ||||
thread ("Juce FileBrowser") | thread ("Juce FileBrowser") | ||||
{ | { | ||||
@@ -46,8 +46,8 @@ BEGIN_JUCE_NAMESPACE | |||||
Component* Component::componentUnderMouse = 0; | Component* Component::componentUnderMouse = 0; | ||||
Component* Component::currentlyFocusedComponent = 0; | Component* Component::currentlyFocusedComponent = 0; | ||||
static Array <Component*> modalComponentStack (4), modalComponentReturnValueKeys (4); | |||||
static Array <int> modalReturnValues (4); | |||||
static Array <Component*> modalComponentStack, modalComponentReturnValueKeys; | |||||
static Array <int> modalReturnValues; | |||||
static const int customCommandMessage = 0x7fff0001; | static const int customCommandMessage = 0x7fff0001; | ||||
static const int exitModalStateMessage = 0x7fff0002; | static const int exitModalStateMessage = 0x7fff0002; | ||||
@@ -108,7 +108,6 @@ Component::Component() throw() | |||||
: parentComponent_ (0), | : parentComponent_ (0), | ||||
componentUID (++nextComponentUID), | componentUID (++nextComponentUID), | ||||
numDeepMouseListeners (0), | numDeepMouseListeners (0), | ||||
childComponentList_ (16), | |||||
lookAndFeel_ (0), | lookAndFeel_ (0), | ||||
effect_ (0), | effect_ (0), | ||||
bufferedImage_ (0), | bufferedImage_ (0), | ||||
@@ -125,7 +124,6 @@ Component::Component (const String& name) throw() | |||||
parentComponent_ (0), | parentComponent_ (0), | ||||
componentUID (++nextComponentUID), | componentUID (++nextComponentUID), | ||||
numDeepMouseListeners (0), | numDeepMouseListeners (0), | ||||
childComponentList_ (16), | |||||
lookAndFeel_ (0), | lookAndFeel_ (0), | ||||
effect_ (0), | effect_ (0), | ||||
bufferedImage_ (0), | bufferedImage_ (0), | ||||
@@ -2163,7 +2161,7 @@ void Component::parentSizeChanged() | |||||
void Component::addComponentListener (ComponentListener* const newListener) throw() | void Component::addComponentListener (ComponentListener* const newListener) throw() | ||||
{ | { | ||||
if (componentListeners_ == 0) | if (componentListeners_ == 0) | ||||
componentListeners_ = new VoidArray (4); | |||||
componentListeners_ = new VoidArray(); | |||||
componentListeners_->addIfNotAlreadyThere (newListener); | componentListeners_->addIfNotAlreadyThere (newListener); | ||||
} | } | ||||
@@ -2243,7 +2241,7 @@ void Component::addMouseListener (MouseListener* const newListener, | |||||
checkMessageManagerIsLocked | checkMessageManagerIsLocked | ||||
if (mouseListeners_ == 0) | if (mouseListeners_ == 0) | ||||
mouseListeners_ = new VoidArray (4); | |||||
mouseListeners_ = new VoidArray(); | |||||
if (! mouseListeners_->contains (newListener)) | if (! mouseListeners_->contains (newListener)) | ||||
{ | { | ||||
@@ -3509,7 +3507,7 @@ const Rectangle Component::getParentMonitorArea() const throw() | |||||
void Component::addKeyListener (KeyListener* const newListener) throw() | void Component::addKeyListener (KeyListener* const newListener) throw() | ||||
{ | { | ||||
if (keyListeners_ == 0) | if (keyListeners_ == 0) | ||||
keyListeners_ = new VoidArray (4); | |||||
keyListeners_ = new VoidArray(); | |||||
keyListeners_->addIfNotAlreadyThere (newListener); | keyListeners_->addIfNotAlreadyThere (newListener); | ||||
} | } | ||||
@@ -40,11 +40,7 @@ extern void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords, | |||||
static Desktop* juce_desktopInstance = 0; | static Desktop* juce_desktopInstance = 0; | ||||
Desktop::Desktop() throw() | Desktop::Desktop() throw() | ||||
: mouseListeners (2), | |||||
desktopComponents (4), | |||||
monitorCoordsClipped (2), | |||||
monitorCoordsUnclipped (2), | |||||
lastMouseX (0), | |||||
: lastMouseX (0), | |||||
lastMouseY (0), | lastMouseY (0), | ||||
kioskModeComponent (0) | kioskModeComponent (0) | ||||
{ | { | ||||
@@ -34,7 +34,6 @@ BEGIN_JUCE_NAMESPACE | |||||
ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_) | ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_) | ||||
: component (component_), | : component (component_), | ||||
lastPeer (0), | lastPeer (0), | ||||
registeredParentComps (4), | |||||
reentrant (false) | reentrant (false) | ||||
{ | { | ||||
jassert (component != 0); // can't use this with a null pointer.. | jassert (component != 0); // can't use this with a null pointer.. | ||||
@@ -98,8 +98,7 @@ ScrollBar::ScrollBar (const bool vertical_, | |||||
isDraggingThumb (false), | isDraggingThumb (false), | ||||
alwaysVisible (false), | alwaysVisible (false), | ||||
upButton (0), | upButton (0), | ||||
downButton (0), | |||||
listeners (2) | |||||
downButton (0) | |||||
{ | { | ||||
setButtonVisibility (buttonsAreVisible); | setButtonVisibility (buttonsAreVisible); | ||||
@@ -1281,15 +1281,13 @@ private: | |||||
//============================================================================== | //============================================================================== | ||||
PopupMenu::PopupMenu() | PopupMenu::PopupMenu() | ||||
: items (8), | |||||
lookAndFeel (0), | |||||
: lookAndFeel (0), | |||||
separatorPending (false) | separatorPending (false) | ||||
{ | { | ||||
} | } | ||||
PopupMenu::PopupMenu (const PopupMenu& other) | PopupMenu::PopupMenu (const PopupMenu& other) | ||||
: items (8), | |||||
lookAndFeel (other.lookAndFeel), | |||||
: lookAndFeel (other.lookAndFeel), | |||||
separatorPending (false) | separatorPending (false) | ||||
{ | { | ||||
items.ensureStorageAllocated (other.items.size()); | items.ensureStorageAllocated (other.items.size()); | ||||
@@ -40,7 +40,7 @@ void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) th | |||||
//============================================================================== | //============================================================================== | ||||
static CriticalSection activeCursorListLock; | static CriticalSection activeCursorListLock; | ||||
static VoidArray activeCursors (2); | |||||
static VoidArray activeCursors; | |||||
//============================================================================== | //============================================================================== | ||||
class SharedMouseCursorInternal : public ReferenceCountedObject | class SharedMouseCursorInternal : public ReferenceCountedObject | ||||
@@ -674,6 +674,7 @@ private: | |||||
return y; | return y; | ||||
} | } | ||||
public: | |||||
//============================================================================== | //============================================================================== | ||||
class ChannelSelectorListBox : public ListBox, | class ChannelSelectorListBox : public ListBox, | ||||
public ListBoxModel | public ListBoxModel | ||||
@@ -930,6 +931,7 @@ private: | |||||
const ChannelSelectorListBox& operator= (const ChannelSelectorListBox&); | const ChannelSelectorListBox& operator= (const ChannelSelectorListBox&); | ||||
}; | }; | ||||
private: | |||||
ChannelSelectorListBox* inputChanList; | ChannelSelectorListBox* inputChanList; | ||||
ChannelSelectorListBox* outputChanList; | ChannelSelectorListBox* outputChanList; | ||||
@@ -95,8 +95,6 @@ MidiKeyboardComponent::MidiKeyboardComponent (MidiKeyboardState& state_, | |||||
canScroll (true), | canScroll (true), | ||||
mouseDragging (false), | mouseDragging (false), | ||||
useMousePositionForVelocity (true), | useMousePositionForVelocity (true), | ||||
keyPresses (4), | |||||
keyPressNotes (16), | |||||
keyMappingOctave (6), | keyMappingOctave (6), | ||||
octaveNumForMiddleC (3) | octaveNumForMiddleC (3) | ||||
{ | { | ||||
@@ -53,7 +53,7 @@ extern bool juce_MouseHasMovedSignificantlySincePressed; | |||||
static const int fakeMouseMoveMessage = 0x7fff00ff; | static const int fakeMouseMoveMessage = 0x7fff00ff; | ||||
static VoidArray heavyweightPeers (4); | |||||
static VoidArray heavyweightPeers; | |||||
//============================================================================== | //============================================================================== | ||||
@@ -45,8 +45,7 @@ class TopLevelWindowManager : public Timer, | |||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
TopLevelWindowManager() | TopLevelWindowManager() | ||||
: windows (8), | |||||
currentActive (0) | |||||
: currentActive (0) | |||||
{ | { | ||||
} | } | ||||
@@ -32,7 +32,6 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
ColourGradient::ColourGradient() throw() | ColourGradient::ColourGradient() throw() | ||||
: colours (4) | |||||
{ | { | ||||
#ifdef JUCE_DEBUG | #ifdef JUCE_DEBUG | ||||
x1 = 987654.0f; | x1 = 987654.0f; | ||||
@@ -50,8 +49,7 @@ ColourGradient::ColourGradient (const Colour& colour1, | |||||
y1 (y1_), | y1 (y1_), | ||||
x2 (x2_), | x2 (x2_), | ||||
y2 (y2_), | y2 (y2_), | ||||
isRadial (isRadial_), | |||||
colours (4) | |||||
isRadial (isRadial_) | |||||
{ | { | ||||
colours.add (0); | colours.add (0); | ||||
colours.add (colour1.getARGB()); | colours.add (colour1.getARGB()); | ||||
@@ -35,20 +35,16 @@ BEGIN_JUCE_NAMESPACE | |||||
static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamplingQuality; | static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamplingQuality; | ||||
//============================================================================== | //============================================================================== | ||||
#define MINIMUM_COORD -0x3fffffff | |||||
#define MAXIMUM_COORD 0x3fffffff | |||||
#undef ASSERT_COORDS_ARE_SENSIBLE_NUMBERS | |||||
#define ASSERT_COORDS_ARE_SENSIBLE_NUMBERS(x, y, w, h) \ | |||||
jassert ((int) x >= MINIMUM_COORD \ | |||||
&& (int) x <= MAXIMUM_COORD \ | |||||
&& (int) y >= MINIMUM_COORD \ | |||||
&& (int) y <= MAXIMUM_COORD \ | |||||
&& (int) w >= MINIMUM_COORD \ | |||||
&& (int) w <= MAXIMUM_COORD \ | |||||
&& (int) h >= MINIMUM_COORD \ | |||||
&& (int) h <= MAXIMUM_COORD); | |||||
template <typename Type> | |||||
static bool areCoordsSensibleNumbers (Type x, Type y, Type w, Type h) | |||||
{ | |||||
const int maxVal = 0x3fffffff; | |||||
return (int) x >= -maxVal && (int) x <= maxVal | |||||
&& (int) y >= -maxVal && (int) y <= maxVal | |||||
&& (int) w >= -maxVal && (int) w <= maxVal | |||||
&& (int) h >= -maxVal && (int) h <= maxVal; | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
LowLevelGraphicsContext::LowLevelGraphicsContext() | LowLevelGraphicsContext::LowLevelGraphicsContext() | ||||
@@ -62,7 +58,7 @@ LowLevelGraphicsContext::~LowLevelGraphicsContext() | |||||
//============================================================================== | //============================================================================== | ||||
Graphics::Graphics (Image& imageToDrawOnto) throw() | Graphics::Graphics (Image& imageToDrawOnto) throw() | ||||
: context (imageToDrawOnto.createLowLevelContext()), | : context (imageToDrawOnto.createLowLevelContext()), | ||||
ownsContext (true), | |||||
contextToDelete (context), | |||||
saveStatePending (false) | saveStatePending (false) | ||||
{ | { | ||||
resetToDefaultState(); | resetToDefaultState(); | ||||
@@ -70,7 +66,6 @@ Graphics::Graphics (Image& imageToDrawOnto) throw() | |||||
Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw() | Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw() | ||||
: context (internalContext), | : context (internalContext), | ||||
ownsContext (false), | |||||
saveStatePending (false) | saveStatePending (false) | ||||
{ | { | ||||
resetToDefaultState(); | resetToDefaultState(); | ||||
@@ -78,8 +73,6 @@ Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw() | |||||
Graphics::~Graphics() throw() | Graphics::~Graphics() throw() | ||||
{ | { | ||||
if (ownsContext) | |||||
delete context; | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -325,7 +318,7 @@ void Graphics::fillRect (int x, | |||||
int height) const throw() | int height) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
context->fillRect (Rectangle (x, y, width, height), false); | context->fillRect (Rectangle (x, y, width, height), false); | ||||
} | } | ||||
@@ -341,7 +334,7 @@ void Graphics::fillRect (const float x, | |||||
const float height) const throw() | const float height) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
Path p; | Path p; | ||||
p.addRectangle (x, y, width, height); | p.addRectangle (x, y, width, height); | ||||
@@ -397,7 +390,7 @@ void Graphics::drawRect (const int x, | |||||
const int lineThickness) const throw() | const int lineThickness) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
context->fillRect (Rectangle (x, y, width, lineThickness), false); | context->fillRect (Rectangle (x, y, width, lineThickness), false); | ||||
context->fillRect (Rectangle (x, y + lineThickness, lineThickness, height - lineThickness * 2), false); | context->fillRect (Rectangle (x, y + lineThickness, lineThickness, height - lineThickness * 2), false); | ||||
@@ -412,7 +405,7 @@ void Graphics::drawRect (const float x, | |||||
const float lineThickness) const throw() | const float lineThickness) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
Path p; | Path p; | ||||
p.addRectangle (x, y, width, lineThickness); | p.addRectangle (x, y, width, lineThickness); | ||||
@@ -441,7 +434,7 @@ void Graphics::drawBevel (const int x, | |||||
const bool sharpEdgeOnOutside) const throw() | const bool sharpEdgeOnOutside) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
if (clipRegionIntersects (x, y, width, height)) | if (clipRegionIntersects (x, y, width, height)) | ||||
{ | { | ||||
@@ -476,7 +469,7 @@ void Graphics::fillEllipse (const float x, | |||||
const float height) const throw() | const float height) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
Path p; | Path p; | ||||
p.addEllipse (x, y, width, height); | p.addEllipse (x, y, width, height); | ||||
@@ -490,7 +483,7 @@ void Graphics::drawEllipse (const float x, | |||||
const float lineThickness) const throw() | const float lineThickness) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
Path p; | Path p; | ||||
p.addEllipse (x, y, width, height); | p.addEllipse (x, y, width, height); | ||||
@@ -504,7 +497,7 @@ void Graphics::fillRoundedRectangle (const float x, | |||||
const float cornerSize) const throw() | const float cornerSize) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
Path p; | Path p; | ||||
p.addRoundedRectangle (x, y, width, height, cornerSize); | p.addRoundedRectangle (x, y, width, height, cornerSize); | ||||
@@ -529,7 +522,7 @@ void Graphics::drawRoundedRectangle (const float x, | |||||
const float lineThickness) const throw() | const float lineThickness) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height); | |||||
jassert (areCoordsSensibleNumbers (x, y, width, height)); | |||||
Path p; | Path p; | ||||
p.addRoundedRectangle (x, y, width, height, cornerSize); | p.addRoundedRectangle (x, y, width, height, cornerSize); | ||||
@@ -723,7 +716,7 @@ void Graphics::drawImageWithin (const Image* const imageToDraw, | |||||
const bool fillAlphaChannelWithCurrentBrush) const throw() | const bool fillAlphaChannelWithCurrentBrush) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (destX, destY, destW, destH); | |||||
jassert (areCoordsSensibleNumbers (destX, destY, destW, destH)); | |||||
if (imageToDraw != 0) | if (imageToDraw != 0) | ||||
{ | { | ||||
@@ -757,8 +750,8 @@ void Graphics::drawImage (const Image* const imageToDraw, | |||||
const bool fillAlphaChannelWithCurrentBrush) const throw() | const bool fillAlphaChannelWithCurrentBrush) const throw() | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (dx, dy, dw, dh); | |||||
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (sx, sy, sw, sh); | |||||
jassert (areCoordsSensibleNumbers (dx, dy, dw, dh)); | |||||
jassert (areCoordsSensibleNumbers (sx, sy, sw, sh)); | |||||
if (context->clipRegionIntersects (Rectangle (dx, dy, dw, dh))) | if (context->clipRegionIntersects (Rectangle (dx, dy, dw, dh))) | ||||
{ | { | ||||
@@ -717,7 +717,7 @@ public: | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
LowLevelGraphicsContext* const context; | LowLevelGraphicsContext* const context; | ||||
const bool ownsContext; | |||||
ScopedPointer <LowLevelGraphicsContext> contextToDelete; | |||||
bool saveStatePending; | bool saveStatePending; | ||||
void saveStateIfPending() throw(); | void saveStateIfPending() throw(); | ||||
@@ -443,10 +443,9 @@ void LowLevelGraphicsPostScriptRenderer::writeImage (const Image& im, | |||||
pixel = Colours::transparentWhite; | pixel = Colours::transparentWhite; | ||||
} | } | ||||
char colourString [16]; | |||||
sprintf (colourString, "%x%x%x", pixel.getRed(), pixel.getGreen(), pixel.getBlue()); | |||||
const uint8 pixelValues[3] = { pixel.getRed(), pixel.getGreen(), pixel.getBlue() }; | |||||
out << (const char*) colourString; | |||||
out << String::toHexString (pixelValues, 3, 0); | |||||
charsOnLine += 3; | charsOnLine += 3; | ||||
if (charsOnLine > 100) | if (charsOnLine > 100) | ||||
@@ -1341,10 +1341,10 @@ private: | |||||
//============================================================================== | //============================================================================== | ||||
LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (Image& image_) | LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (Image& image_) | ||||
: image (image_), | |||||
stateStack (20) | |||||
: image (image_) | |||||
{ | { | ||||
currentState = new LLGCSavedState (image_.getBounds(), 0, 0, Font(), FillType(), Graphics::mediumResamplingQuality); | |||||
currentState = new LLGCSavedState (image_.getBounds(), 0, 0, Font(), | |||||
FillType(), Graphics::mediumResamplingQuality); | |||||
} | } | ||||
LowLevelGraphicsSoftwareRenderer::~LowLevelGraphicsSoftwareRenderer() | LowLevelGraphicsSoftwareRenderer::~LowLevelGraphicsSoftwareRenderer() | ||||
@@ -341,8 +341,7 @@ class TypefaceCache : public DeletedAtShutdown | |||||
{ | { | ||||
public: | public: | ||||
TypefaceCache (int numToCache = 10) throw() | TypefaceCache (int numToCache = 10) throw() | ||||
: counter (1), | |||||
faces (2) | |||||
: counter (1) | |||||
{ | { | ||||
while (--numToCache >= 0) | while (--numToCache >= 0) | ||||
faces.add (new CachedFace()); | faces.add (new CachedFace()); | ||||
@@ -109,8 +109,8 @@ void PositionedGlyph::moveBy (const float deltaX, | |||||
//============================================================================== | //============================================================================== | ||||
GlyphArrangement::GlyphArrangement() | GlyphArrangement::GlyphArrangement() | ||||
: glyphs (128) | |||||
{ | { | ||||
glyphs.ensureStorageAllocated (128); | |||||
} | } | ||||
GlyphArrangement::GlyphArrangement (const GlyphArrangement& other) | GlyphArrangement::GlyphArrangement (const GlyphArrangement& other) | ||||
@@ -93,22 +93,21 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
TextLayout::TextLayout() throw() | TextLayout::TextLayout() throw() | ||||
: tokens (64), | |||||
totalLines (0) | |||||
: totalLines (0) | |||||
{ | { | ||||
tokens.ensureStorageAllocated (64); | |||||
} | } | ||||
TextLayout::TextLayout (const String& text, | TextLayout::TextLayout (const String& text, | ||||
const Font& font) throw() | const Font& font) throw() | ||||
: tokens (64), | |||||
totalLines (0) | |||||
: totalLines (0) | |||||
{ | { | ||||
tokens.ensureStorageAllocated (64); | |||||
appendText (text, font); | appendText (text, font); | ||||
} | } | ||||
TextLayout::TextLayout (const TextLayout& other) throw() | TextLayout::TextLayout (const TextLayout& other) throw() | ||||
: tokens (64), | |||||
totalLines (0) | |||||
: totalLines (0) | |||||
{ | { | ||||
*this = other; | *this = other; | ||||
} | } | ||||
@@ -49,8 +49,7 @@ static const int defaultGranularity = 32; | |||||
//============================================================================== | //============================================================================== | ||||
Path::Path() throw() | Path::Path() throw() | ||||
: data (defaultGranularity), | |||||
numElements (0), | |||||
: numElements (0), | |||||
pathXMin (0), | pathXMin (0), | ||||
pathXMax (0), | pathXMax (0), | ||||
pathYMin (0), | pathYMin (0), | ||||
@@ -64,8 +63,7 @@ Path::~Path() throw() | |||||
} | } | ||||
Path::Path (const Path& other) throw() | Path::Path (const Path& other) throw() | ||||
: data (defaultGranularity), | |||||
numElements (other.numElements), | |||||
: numElements (other.numElements), | |||||
pathXMin (other.pathXMin), | pathXMin (other.pathXMin), | ||||
pathXMax (other.pathXMax), | pathXMax (other.pathXMax), | ||||
pathYMin (other.pathYMin), | pathYMin (other.pathYMin), | ||||
@@ -32,9 +32,9 @@ | |||||
namespace jpeglibNamespace | namespace jpeglibNamespace | ||||
{ | { | ||||
#if JUCE_INCLUDE_JPEGLIB_CODE | #if JUCE_INCLUDE_JPEGLIB_CODE | ||||
#if JUCE_MINGW | |||||
typedef unsigned char boolean; | |||||
#endif | |||||
#if JUCE_MINGW | |||||
typedef unsigned char boolean; | |||||
#endif | |||||
extern "C" | extern "C" | ||||
{ | { | ||||
#define JPEG_INTERNALS | #define JPEG_INTERNALS | ||||
@@ -49,7 +49,6 @@ static int cacheTimeout = 5000; | |||||
ImageCache::ImageCache() | ImageCache::ImageCache() | ||||
: images (4) | |||||
{ | { | ||||
} | } | ||||
@@ -985,17 +985,6 @@ bool File::appendText (const String& text, | |||||
return false; | return false; | ||||
} | } | ||||
bool File::printf (const tchar* pf, ...) const | |||||
{ | |||||
va_list list; | |||||
va_start (list, pf); | |||||
String text; | |||||
text.vprintf (pf, list); | |||||
return appendData ((const char*) text, text.length()); | |||||
} | |||||
bool File::replaceWithText (const String& textToWrite, | bool File::replaceWithText (const String& textToWrite, | ||||
const bool asUnicode, | const bool asUnicode, | ||||
const bool writeUnicodeHeaderBytes) const | const bool writeUnicodeHeaderBytes) const | ||||
@@ -575,7 +575,7 @@ public: | |||||
@returns a stream that will write to this file (initially positioned at the | @returns a stream that will write to this file (initially positioned at the | ||||
end of the file), or 0 if the file can't be opened for some reason | end of the file), or 0 if the file can't be opened for some reason | ||||
@see createInputStream, printf, appendData, appendText | |||||
@see createInputStream, appendData, appendText | |||||
*/ | */ | ||||
FileOutputStream* createOutputStream (const int bufferSize = 0x8000) const; | FileOutputStream* createOutputStream (const int bufferSize = 0x8000) const; | ||||
@@ -602,14 +602,6 @@ public: | |||||
const String loadFileAsString() const; | const String loadFileAsString() const; | ||||
//============================================================================== | //============================================================================== | ||||
/** Writes text to the end of the file. | |||||
This will try to do a printf to the file. | |||||
@returns false if it can't write to the file for some reason | |||||
*/ | |||||
bool printf (const tchar* format, ...) const; | |||||
/** Appends a block of binary data to the end of the file. | /** Appends a block of binary data to the end of the file. | ||||
This will try to write the given buffer to the end of the file. | This will try to write the given buffer to the end of the file. | ||||
@@ -416,12 +416,6 @@ const String juce_getOutputFromCommand (const String& command) | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_64BIT | |||||
#define filedesc ((long long) internal) | |||||
#else | |||||
#define filedesc ((int) internal) | |||||
#endif | |||||
InterProcessLock::InterProcessLock (const String& name_) | InterProcessLock::InterProcessLock (const String& name_) | ||||
: internal (0), | : internal (0), | ||||
name (name_), | name (name_), | ||||
@@ -436,7 +430,7 @@ InterProcessLock::InterProcessLock (const String& name_) | |||||
temp.create(); | temp.create(); | ||||
internal = (void*) open (temp.getFullPathName().toUTF8(), O_RDWR); | |||||
internal = open (temp.getFullPathName().toUTF8(), O_RDWR); | |||||
} | } | ||||
InterProcessLock::~InterProcessLock() | InterProcessLock::~InterProcessLock() | ||||
@@ -444,7 +438,7 @@ InterProcessLock::~InterProcessLock() | |||||
while (reentrancyLevel > 0) | while (reentrancyLevel > 0) | ||||
this->exit(); | this->exit(); | ||||
close (filedesc); | |||||
close (internal); | |||||
} | } | ||||
bool InterProcessLock::enter (const int timeOutMillisecs) | bool InterProcessLock::enter (const int timeOutMillisecs) | ||||
@@ -464,7 +458,7 @@ bool InterProcessLock::enter (const int timeOutMillisecs) | |||||
for (;;) | for (;;) | ||||
{ | { | ||||
const int result = fcntl (filedesc, F_SETLK, &fl); | |||||
const int result = fcntl (internal, F_SETLK, &fl); | |||||
if (result >= 0) | if (result >= 0) | ||||
{ | { | ||||
@@ -498,7 +492,7 @@ void InterProcessLock::exit() | |||||
for (;;) | for (;;) | ||||
{ | { | ||||
const int result = fcntl (filedesc, F_SETLKW, &fl); | |||||
const int result = fcntl (internal, F_SETLKW, &fl); | |||||
if (result >= 0 || errno != EINTR) | if (result >= 0 || errno != EINTR) | ||||
break; | break; | ||||
@@ -504,7 +504,7 @@ private: | |||||
{ | { | ||||
NSString* route = (NSString*) audioRoute; | NSString* route = (NSString*) audioRoute; | ||||
//printf ("audio route: %s\n", [route cString]); | |||||
//DBG ("audio route: " + nsStringToJuce (route)); | |||||
if ([route hasPrefix: @"Receiver"]) | if ([route hasPrefix: @"Receiver"]) | ||||
{ | { | ||||
@@ -406,7 +406,7 @@ void* juce_findFileStart (const String& directory, const String& wildCard, Strin | |||||
if (e != 0) | if (e != 0) | ||||
{ | { | ||||
FindFileStruct* ff = new FindFileStruct(); | |||||
ScopedPointer <FindFileStruct> ff (new FindFileStruct()); | |||||
ff->enumerator = [e retain]; | ff->enumerator = [e retain]; | ||||
ff->parentDir = directory; | ff->parentDir = directory; | ||||
ff->wildCard = wildCard; | ff->wildCard = wildCard; | ||||
@@ -415,10 +415,9 @@ void* juce_findFileStart (const String& directory, const String& wildCard, Strin | |||||
ff->parentDir += File::separator; | ff->parentDir += File::separator; | ||||
if (juce_findFileNext (ff, firstResultFile, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly)) | if (juce_findFileNext (ff, firstResultFile, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly)) | ||||
return ff; | |||||
return ff.release(); | |||||
[e release]; | [e release]; | ||||
delete ff; | |||||
} | } | ||||
return 0; | return 0; | ||||
@@ -426,9 +425,8 @@ void* juce_findFileStart (const String& directory, const String& wildCard, Strin | |||||
void juce_findFileClose (void* handle) | void juce_findFileClose (void* handle) | ||||
{ | { | ||||
FindFileStruct* ff = (FindFileStruct*) handle; | |||||
ScopedPointer <FindFileStruct> ff ((FindFileStruct*) handle); | |||||
[ff->enumerator release]; | [ff->enumerator release]; | ||||
delete ff; | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -178,7 +178,7 @@ public: | |||||
{ | { | ||||
makeInactive(); | makeInactive(); | ||||
[renderContext clearDrawable]; | [renderContext clearDrawable]; | ||||
delete viewHolder; | |||||
viewHolder = 0; | |||||
} | } | ||||
bool makeActive() const throw() | bool makeActive() const throw() | ||||
@@ -250,7 +250,7 @@ public: | |||||
private: | private: | ||||
OpenGLPixelFormat pixelFormat; | OpenGLPixelFormat pixelFormat; | ||||
NSViewComponentInternal* viewHolder; | |||||
ScopedPointer <NSViewComponentInternal> viewHolder; | |||||
//============================================================================== | //============================================================================== | ||||
WindowedGLContext (const WindowedGLContext&); | WindowedGLContext (const WindowedGLContext&); | ||||
@@ -1723,7 +1723,6 @@ class ASIOAudioIODeviceType : public AudioIODeviceType | |||||
public: | public: | ||||
ASIOAudioIODeviceType() | ASIOAudioIODeviceType() | ||||
: AudioIODeviceType (T("ASIO")), | : AudioIODeviceType (T("ASIO")), | ||||
classIds (2), | |||||
hasScanned (false) | hasScanned (false) | ||||
{ | { | ||||
CoInitialize (0); | CoInitialize (0); | ||||
@@ -171,7 +171,7 @@ public: | |||||
HRESULT __stdcall GetWindowContext (LPOLEINPLACEFRAME* lplpFrame, LPOLEINPLACEUIWINDOW* lplpDoc, LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO lpFrameInfo) | HRESULT __stdcall GetWindowContext (LPOLEINPLACEFRAME* lplpFrame, LPOLEINPLACEUIWINDOW* lplpDoc, LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO lpFrameInfo) | ||||
{ | { | ||||
frame->AddRef(); | |||||
// frame->AddRef(); // MS docs are unclear about whether this is needed, but it seems to lead to a memory leak.. | |||||
*lplpFrame = frame; | *lplpFrame = frame; | ||||
*lplpDoc = 0; | *lplpDoc = 0; | ||||
lpFrameInfo->fMDIApp = FALSE; | lpFrameInfo->fMDIApp = FALSE; | ||||
@@ -960,8 +960,6 @@ public: | |||||
isStarted (false), | isStarted (false), | ||||
outputDeviceIndex (outputDeviceIndex_), | outputDeviceIndex (outputDeviceIndex_), | ||||
inputDeviceIndex (inputDeviceIndex_), | inputDeviceIndex (inputDeviceIndex_), | ||||
inChans (4), | |||||
outChans (4), | |||||
numInputBuffers (0), | numInputBuffers (0), | ||||
numOutputBuffers (0), | numOutputBuffers (0), | ||||
totalSamplesOut (0), | totalSamplesOut (0), | ||||
@@ -32,16 +32,16 @@ | |||||
static const unsigned int specialId = WM_APP + 0x4400; | static const unsigned int specialId = WM_APP + 0x4400; | ||||
static const unsigned int broadcastId = WM_APP + 0x4403; | static const unsigned int broadcastId = WM_APP + 0x4403; | ||||
static const unsigned int specialCallbackId = WM_APP + 0x4402; | static const unsigned int specialCallbackId = WM_APP + 0x4402; | ||||
static const TCHAR* const messageWindowName = _T("JUCEWindow"); | static const TCHAR* const messageWindowName = _T("JUCEWindow"); | ||||
HWND juce_messageWindowHandle = 0; | HWND juce_messageWindowHandle = 0; | ||||
extern long improbableWindowNumber; // defined in windowing.cpp | extern long improbableWindowNumber; // defined in windowing.cpp | ||||
#ifndef WM_APPCOMMAND | |||||
#define WM_APPCOMMAND 0x0319 | |||||
#endif | |||||
#ifndef WM_APPCOMMAND | |||||
#define WM_APPCOMMAND 0x0319 | |||||
#endif | |||||
//============================================================================== | //============================================================================== | ||||
@@ -415,7 +415,7 @@ struct MidiOutHandle | |||||
juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
}; | }; | ||||
static VoidArray handles (4); | |||||
static Array <MidiOutHandle*> midiOutputHandles; | |||||
//============================================================================== | //============================================================================== | ||||
const StringArray MidiOutput::getDevices() | const StringArray MidiOutput::getDevices() | ||||
@@ -485,9 +485,9 @@ MidiOutput* MidiOutput::openDevice (int index) | |||||
} | } | ||||
} | } | ||||
for (i = handles.size(); --i >= 0;) | |||||
for (i = midiOutputHandles.size(); --i >= 0;) | |||||
{ | { | ||||
MidiOutHandle* const han = (MidiOutHandle*) handles.getUnchecked(i); | |||||
MidiOutHandle* const han = midiOutputHandles.getUnchecked(i); | |||||
if (han != 0 && han->deviceId == deviceId) | if (han != 0 && han->deviceId == deviceId) | ||||
{ | { | ||||
@@ -510,7 +510,7 @@ MidiOutput* MidiOutput::openDevice (int index) | |||||
han->deviceId = deviceId; | han->deviceId = deviceId; | ||||
han->refCount = 1; | han->refCount = 1; | ||||
han->handle = h; | han->handle = h; | ||||
handles.add (han); | |||||
midiOutputHandles.add (han); | |||||
MidiOutput* const out = new MidiOutput(); | MidiOutput* const out = new MidiOutput(); | ||||
out->internal = (void*) han; | out->internal = (void*) han; | ||||
@@ -533,10 +533,10 @@ MidiOutput::~MidiOutput() | |||||
{ | { | ||||
MidiOutHandle* const h = (MidiOutHandle*) internal; | MidiOutHandle* const h = (MidiOutHandle*) internal; | ||||
if (handles.contains ((void*) h) && --(h->refCount) == 0) | |||||
if (midiOutputHandles.contains (h) && --(h->refCount) == 0) | |||||
{ | { | ||||
midiOutClose (h->handle); | midiOutClose (h->handle); | ||||
handles.removeValue ((void*) h); | |||||
midiOutputHandles.removeValue (h); | |||||
delete h; | delete h; | ||||
} | } | ||||
} | } | ||||
@@ -72,7 +72,7 @@ static HKEY findKeyForPath (String name, | |||||
const String PlatformUtilities::getRegistryValue (const String& regValuePath, | const String PlatformUtilities::getRegistryValue (const String& regValuePath, | ||||
const String& defaultValue) | const String& defaultValue) | ||||
{ | { | ||||
String valueName, s; | |||||
String valueName, result (defaultValue); | |||||
HKEY k = findKeyForPath (regValuePath, false, valueName); | HKEY k = findKeyForPath (regValuePath, false, valueName); | ||||
if (k != 0) | if (k != 0) | ||||
@@ -82,14 +82,17 @@ const String PlatformUtilities::getRegistryValue (const String& regValuePath, | |||||
DWORD type = REG_SZ; | DWORD type = REG_SZ; | ||||
if (RegQueryValueEx (k, valueName, 0, &type, (LPBYTE) buffer, &bufferSize) == ERROR_SUCCESS) | if (RegQueryValueEx (k, valueName, 0, &type, (LPBYTE) buffer, &bufferSize) == ERROR_SUCCESS) | ||||
s = buffer; | |||||
else | |||||
s = defaultValue; | |||||
{ | |||||
if (type == REG_SZ) | |||||
result = buffer; | |||||
else if (type == REG_DWORD) | |||||
result = String ((int) *(DWORD*) buffer); | |||||
} | |||||
RegCloseKey (k); | RegCloseKey (k); | ||||
} | } | ||||
return s; | |||||
return result; | |||||
} | } | ||||
void PlatformUtilities::setRegistryValue (const String& regValuePath, | void PlatformUtilities::setRegistryValue (const String& regValuePath, | ||||
@@ -715,10 +715,7 @@ void XmlElement::setAttribute (const tchar* const attributeName, | |||||
void XmlElement::setAttribute (const tchar* const attributeName, | void XmlElement::setAttribute (const tchar* const attributeName, | ||||
const double number) throw() | const double number) throw() | ||||
{ | { | ||||
tchar buffer [40]; | |||||
CharacterFunctions::printf (buffer, numElementsInArray (buffer), T("%.9g"), number); | |||||
setAttribute (attributeName, buffer); | |||||
setAttribute (attributeName, String (number)); | |||||
} | } | ||||
void XmlElement::removeAttribute (const tchar* const attributeName) throw() | void XmlElement::removeAttribute (const tchar* const attributeName) throw() | ||||
@@ -73,7 +73,14 @@ public: | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_WINDOWS | |||||
void* internal; | void* internal; | ||||
#elif JUCE_64BIT | |||||
long long internal; | |||||
#else | |||||
int internal; | |||||
#endif | |||||
String name; | String name; | ||||
int reentrancyLevel; | int reentrancyLevel; | ||||
@@ -43,7 +43,7 @@ void juce_CloseThreadHandle (void* handle); | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
static VoidArray runningThreads (4); | |||||
static VoidArray runningThreads; | |||||
static CriticalSection runningThreadsLock; | static CriticalSection runningThreadsLock; | ||||
//============================================================================== | //============================================================================== | ||||
@@ -34,7 +34,7 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
static VoidArray objectsToDelete (16); | |||||
static VoidArray objectsToDelete; | |||||
static CriticalSection lock; | static CriticalSection lock; | ||||
//============================================================================== | //============================================================================== | ||||