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

Fix for mono files in QuicktimeAudioFormat. Avoided some floating-point comparison warnings. Added some iOS options in the new jucer plist. Fix for audio host startup. Changes to allow backslashes in unix filenames.

This commit is contained in:
Julian Storer 2011-02-17 10:22:36 +00:00
parent 2a86002b31
commit 3fe85fd17a
24 changed files with 150 additions and 85 deletions

View file

@ -98,6 +98,14 @@ public:
props.add (new TextPropertyComponent (getSetting ("documentExtensions"), "Document file extensions", 128, false));
props.getLast()->setTooltip ("A comma-separated list of file extensions for documents that your app can open.");
}
else if (iPhone)
{
props.add (new BooleanPropertyComponent (getSetting ("UIFileSharingEnabled"), "File Sharing Enabled", "Enabled"));
props.getLast()->setTooltip ("Enable this to expose your app's files to iTunes.");
props.add (new BooleanPropertyComponent (getSetting ("UIStatusBarHidden"), "Status Bar Hidden", "Enabled"));
props.getLast()->setTooltip ("Enable this to disable the status bar in your app.");
}
}
void launchProject()
@ -326,6 +334,9 @@ private:
XmlElement plist ("plist");
XmlElement* dict = plist.createNewChildElement ("dict");
if (iPhone)
addPlistDictionaryKeyBool (dict, "LSRequiresIPhoneOS", true);
addPlistDictionaryKey (dict, "CFBundleExecutable", "${EXECUTABLE_NAME}");
addPlistDictionaryKey (dict, "CFBundleIconFile", iconFile.exists() ? iconFile.getFileName() : String::empty);
addPlistDictionaryKey (dict, "CFBundleIdentifier", project.getBundleIdentifier().toString());
@ -370,6 +381,12 @@ private:
}
}
if (getSetting ("UIFileSharingEnabled").getValue())
addPlistDictionaryKeyBool (dict, "UIFileSharingEnabled", true);
if (getSetting ("UIStatusBarHidden").getValue())
addPlistDictionaryKeyBool (dict, "UIStatusBarHidden", true);
MemoryOutputStream mo;
plist.writeToStream (mo, "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
@ -730,6 +747,12 @@ private:
xml->createNewChildElement ("string")->addTextElement (value);
}
static void addPlistDictionaryKeyBool (XmlElement* xml, const String& key, const bool value)
{
xml->createNewChildElement ("key")->addTextElement (key);
xml->createNewChildElement (value ? "true" : "false");
}
const String addBuildFile (const RelativePath& path, const String& fileRefID, bool addToSourceBuildPhase, bool inhibitWarnings)
{
String fileID (createID (path.toUnixStyle() + "buildref"));

View file

@ -48,7 +48,7 @@ public:
{
}
void initialise (const String& /*commandLine*/)
void initialise (const String& commandLine)
{
// initialise our settings file..
ApplicationProperties::getInstance()

View file

@ -83,6 +83,8 @@ public:
void addPluginsToMenu (PopupMenu& m) const;
const PluginDescription* getChosenType (const int menuID) const;
GraphDocumentComponent* getGraphEditor() const;
private:
//==============================================================================
AudioDeviceManager deviceManager;
@ -92,7 +94,6 @@ private:
KnownPluginList::SortMethod pluginSortMethod;
void showAudioSettings();
GraphDocumentComponent* getGraphEditor() const;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainHostWindow);
};

View file

@ -7567,7 +7567,13 @@ const String File::parseAbsolutePath (const String& p)
}
#else
// Mac or Linux..
String path (p.replaceCharacter ('\\', '/'));
// Yes, I know it's legal for a unix pathname to contain a backslash, but this assertion is here
// to catch anyone who's trying to run code that was written on Windows with hard-coded path names.
// If that's why you've ended up here, use File::getChildFile() to build your paths instead.
jassert ((! p.containsChar ('\\')) || (p.indexOfChar ('/') >= 0 && p.indexOfChar ('/') < p.indexOfChar ('\\')));
String path (p);
if (path.startsWithChar ('~'))
{
@ -7808,11 +7814,11 @@ bool File::isAChildOf (const File& potentialParent) const
bool File::isAbsolutePath (const String& path)
{
return path.startsWithChar ('/') || path.startsWithChar ('\\')
#if JUCE_WINDOWS
#if JUCE_WINDOWS
|| (path.isNotEmpty() && path[1] == ':');
#else
#else
|| path.startsWithChar ('~');
#endif
#endif
}
const File File::getChildFile (String relativePath) const
@ -7829,11 +7835,12 @@ const File File::getChildFile (String relativePath) const
if (relativePath[0] == '.')
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
relativePath = relativePath.replaceCharacter ('/', '\\').trimStart();
#else
relativePath = relativePath.replaceCharacter ('\\', '/').trimStart();
#endif
#else
relativePath = relativePath.trimStart();
#endif
while (relativePath[0] == '.')
{
if (relativePath[1] == '.')
@ -20657,7 +20664,7 @@ AudioFormatReader* AiffAudioFormat::createReaderFor (InputStream* sourceStream,
{
ScopedPointer <AiffAudioFormatReader> w (new AiffAudioFormatReader (sourceStream));
if (w->sampleRate != 0)
if (w->sampleRate > 0)
return w.release();
if (! deleteStreamIfOpeningFails)
@ -22618,10 +22625,13 @@ public:
{
if (destSamples[j] != 0)
{
const short* const src = ((const short*) bufferList->mBuffers[0].mData) + j;
const short* src = ((const short*) bufferList->mBuffers[0].mData) + j;
for (int i = 0; i < samplesReceived; ++i)
destSamples[j][startOffsetInDestBuffer + i] = src [i << 1] << 16;
{
destSamples[j][startOffsetInDestBuffer + i] = (*src << 16);
src += numChannels;
}
}
}
@ -23398,7 +23408,7 @@ AudioFormatReader* WavAudioFormat::createReaderFor (InputStream* sourceStream,
{
ScopedPointer <WavAudioFormatReader> r (new WavAudioFormatReader (sourceStream));
if (r->sampleRate != 0)
if (r->sampleRate > 0)
return r.release();
if (! deleteStreamIfOpeningFails)
@ -23870,7 +23880,7 @@ void AudioTransportSource::setSource (PositionableAudioSource* const newSource,
newPositionableSource->setNextReadPosition (0);
if (sourceSampleRateToCorrectFor != 0)
if (sourceSampleRateToCorrectFor > 0)
newMasterSource = newResamplerSource
= new ResamplingAudioSource (newPositionableSource, false, maxNumChannels);
else
@ -24013,7 +24023,7 @@ void AudioTransportSource::prepareToPlay (int samplesPerBlockExpected,
if (masterSource != 0)
masterSource->prepareToPlay (samplesPerBlockExpected, sampleRate);
if (resamplerSource != 0 && sourceSampleRate != 0)
if (resamplerSource != 0 && sourceSampleRate > 0)
resamplerSource->setResamplingRatio (sourceSampleRate / sampleRate);
isPrepared = true;
@ -24668,7 +24678,7 @@ void MixerAudioSource::addInputSource (AudioSource* input, const bool deleteWhen
localBufferSize = bufferSizeExpected;
}
if (localRate != 0.0)
if (localRate > 0.0)
input->prepareToPlay (localBufferSize, localRate);
const ScopedLock sl (lock);
@ -25516,7 +25526,7 @@ double AudioDeviceManager::chooseBestSampleRate (double rate) const
{
const double sr = currentAudioDevice->getSampleRate (i);
if (sr >= 44100.0 && (lowestAbove44 == 0 || sr < lowestAbove44))
if (sr >= 44100.0 && (lowestAbove44 < 1.0 || sr < lowestAbove44))
lowestAbove44 = sr;
}
@ -28043,7 +28053,6 @@ namespace MidiFileHelpers
break;
}
}
}
return correctedTempoTime + (time - tempoTime) * secsPerTick;
@ -28062,19 +28071,16 @@ namespace MidiFileHelpers
{
const double diff = (first->message.getTimeStamp() - second->message.getTimeStamp());
if (diff == 0)
{
if (first->message.isNoteOff() && second->message.isNoteOn())
return -1;
else if (first->message.isNoteOn() && second->message.isNoteOff())
return 1;
else
return 0;
}
else
{
return (diff > 0) ? 1 : -1;
}
if (diff > 0)
return 1;
else if (diff < 0)
return -1;
else if (first->message.isNoteOff() && second->message.isNoteOn())
return -1;
else if (first->message.isNoteOn() && second->message.isNoteOff())
return 1;
return 0;
}
};
}
@ -62983,7 +62989,7 @@ void ResizableEdgeComponent::paint (Graphics& g)
isMouseOver(), isMouseButtonDown());
}
void ResizableEdgeComponent::mouseDown (const MouseEvent& e)
void ResizableEdgeComponent::mouseDown (const MouseEvent&)
{
if (component == 0)
{
@ -81073,7 +81079,7 @@ void Colour::getHSB (float& h, float& s, float& v) const throw()
{
s = (hi - lo) / (float) hi;
if (s != 0)
if (s > 0)
{
const float invDiff = 1.0f / (hi - lo);
@ -81451,6 +81457,16 @@ bool ColourGradient::isInvisible() const throw()
return true;
}
bool ColourGradient::ColourPoint::operator== (const ColourPoint& other) const throw()
{
return position == other.position && colour == other.colour;
}
bool ColourGradient::ColourPoint::operator!= (const ColourPoint& other) const throw()
{
return position != other.position || colour != other.colour;
}
END_JUCE_NAMESPACE
/*** End of inlined file: juce_ColourGradient.cpp ***/
@ -86641,7 +86657,7 @@ public:
owner.repaint();
}
void applyNewBounds (const Rectangle<int>& newBounds)
void applyNewBounds (const Rectangle<int>&)
{
jassertfalse; // drawables can't be resized directly!
}
@ -87701,7 +87717,7 @@ public:
owner.applyRelativePath (*owner.relativePath, &scope);
}
void applyNewBounds (const Rectangle<int>& newBounds)
void applyNewBounds (const Rectangle<int>&)
{
jassertfalse; // drawables can't be resized directly!
}
@ -93782,6 +93798,12 @@ PathFlatteningIterator::~PathFlatteningIterator()
{
}
bool PathFlatteningIterator::isLastInSubpath() const throw()
{
return stackPos == stackBase.getData()
&& (index >= path.numElements || points [index] == Path::moveMarker);
}
bool PathFlatteningIterator::next()
{
x1 = x2;
@ -129170,7 +129192,7 @@ AudioFormatReader* FlacAudioFormat::createReaderFor (InputStream* in,
{
ScopedPointer<FlacReader> r (new FlacReader (in));
if (r->sampleRate != 0)
if (r->sampleRate > 0)
return r.release();
if (! deleteStreamIfOpeningFails)
@ -188176,7 +188198,7 @@ AudioFormatReader* OggVorbisAudioFormat::createReaderFor (InputStream* in,
{
ScopedPointer <OggReader> r (new OggReader (in));
if (r->sampleRate != 0)
if (r->sampleRate > 0)
return r.release();
if (! deleteStreamIfOpeningFails)

View file

@ -24103,7 +24103,7 @@ public:
const Point<ValueType> delta (end - start);
const double length = juce_hypot ((double) delta.getX(),
(double) delta.getY());
if (length == 0)
if (length <= 0)
return start;
return Point<ValueType> (start.getX() + (ValueType) ((delta.getX() * distanceFromStart - delta.getY() * perpendicularDistance) / length),
@ -27692,8 +27692,8 @@ private:
: position (position_), colour (colour_)
{}
bool operator== (const ColourPoint& other) const throw() { return position == other.position && colour == other.colour; }
bool operator!= (const ColourPoint& other) const throw() { return position != other.position || colour != other.colour; }
bool operator== (const ColourPoint& other) const throw();
bool operator!= (const ColourPoint& other) const throw();
double position;
Colour colour;
@ -65679,8 +65679,7 @@ public:
int subPathIndex;
/** Returns true if the current segment is the last in the current sub-path. */
bool isLastInSubpath() const throw() { return stackPos == stackBase.getData()
&& (index >= path.numElements || points [index] == Path::moveMarker); }
bool isLastInSubpath() const throw();
/** This is the default value that should be used for the tolerance value (see the constructor parameters). */
static const float defaultTolerance;

View file

@ -404,7 +404,7 @@ AudioFormatReader* AiffAudioFormat::createReaderFor (InputStream* sourceStream,
{
ScopedPointer <AiffAudioFormatReader> w (new AiffAudioFormatReader (sourceStream));
if (w->sampleRate != 0)
if (w->sampleRate > 0)
return w.release();
if (! deleteStreamIfOpeningFails)

View file

@ -507,7 +507,7 @@ AudioFormatReader* FlacAudioFormat::createReaderFor (InputStream* in,
{
ScopedPointer<FlacReader> r (new FlacReader (in));
if (r->sampleRate != 0)
if (r->sampleRate > 0)
return r.release();
if (! deleteStreamIfOpeningFails)

View file

@ -426,7 +426,7 @@ AudioFormatReader* OggVorbisAudioFormat::createReaderFor (InputStream* in,
{
ScopedPointer <OggReader> r (new OggReader (in));
if (r->sampleRate != 0)
if (r->sampleRate > 0)
return r.release();
if (! deleteStreamIfOpeningFails)

View file

@ -280,10 +280,13 @@ public:
{
if (destSamples[j] != 0)
{
const short* const src = ((const short*) bufferList->mBuffers[0].mData) + j;
const short* src = ((const short*) bufferList->mBuffers[0].mData) + j;
for (int i = 0; i < samplesReceived; ++i)
destSamples[j][startOffsetInDestBuffer + i] = src [i << 1] << 16;
{
destSamples[j][startOffsetInDestBuffer + i] = (*src << 16);
src += numChannels;
}
}
}

View file

@ -718,7 +718,7 @@ AudioFormatReader* WavAudioFormat::createReaderFor (InputStream* sourceStream,
{
ScopedPointer <WavAudioFormatReader> r (new WavAudioFormatReader (sourceStream));
if (r->sampleRate != 0)
if (r->sampleRate > 0)
return r.release();
if (! deleteStreamIfOpeningFails)

View file

@ -94,7 +94,7 @@ void AudioTransportSource::setSource (PositionableAudioSource* const newSource,
newPositionableSource->setNextReadPosition (0);
if (sourceSampleRateToCorrectFor != 0)
if (sourceSampleRateToCorrectFor > 0)
newMasterSource = newResamplerSource
= new ResamplingAudioSource (newPositionableSource, false, maxNumChannels);
else
@ -237,7 +237,7 @@ void AudioTransportSource::prepareToPlay (int samplesPerBlockExpected,
if (masterSource != 0)
masterSource->prepareToPlay (samplesPerBlockExpected, sampleRate);
if (resamplerSource != 0 && sourceSampleRate != 0)
if (resamplerSource != 0 && sourceSampleRate > 0)
resamplerSource->setResamplingRatio (sourceSampleRate / sampleRate);
isPrepared = true;

View file

@ -59,7 +59,7 @@ void MixerAudioSource::addInputSource (AudioSource* input, const bool deleteWhen
localBufferSize = bufferSizeExpected;
}
if (localRate != 0.0)
if (localRate > 0.0)
input->prepareToPlay (localBufferSize, localRate);
const ScopedLock sl (lock);

View file

@ -468,7 +468,7 @@ double AudioDeviceManager::chooseBestSampleRate (double rate) const
{
const double sr = currentAudioDevice->getSampleRate (i);
if (sr >= 44100.0 && (lowestAbove44 == 0 || sr < lowestAbove44))
if (sr >= 44100.0 && (lowestAbove44 < 1.0 || sr < lowestAbove44))
lowestAbove44 = sr;
}

View file

@ -150,7 +150,6 @@ namespace MidiFileHelpers
break;
}
}
}
return correctedTempoTime + (time - tempoTime) * secsPerTick;
@ -169,19 +168,16 @@ namespace MidiFileHelpers
{
const double diff = (first->message.getTimeStamp() - second->message.getTimeStamp());
if (diff == 0)
{
if (first->message.isNoteOff() && second->message.isNoteOn())
return -1;
else if (first->message.isNoteOn() && second->message.isNoteOff())
return 1;
else
return 0;
}
else
{
return (diff > 0) ? 1 : -1;
}
if (diff > 0)
return 1;
else if (diff < 0)
return -1;
else if (first->message.isNoteOff() && second->message.isNoteOn())
return -1;
else if (first->message.isNoteOn() && second->message.isNoteOff())
return 1;
return 0;
}
};
}

View file

@ -60,7 +60,7 @@ void ResizableEdgeComponent::paint (Graphics& g)
isMouseOver(), isMouseButtonDown());
}
void ResizableEdgeComponent::mouseDown (const MouseEvent& e)
void ResizableEdgeComponent::mouseDown (const MouseEvent&)
{
if (component == 0)
{

View file

@ -339,7 +339,7 @@ void Colour::getHSB (float& h, float& s, float& v) const throw()
{
s = (hi - lo) / (float) hi;
if (s != 0)
if (s > 0)
{
const float invDiff = 1.0f / (hi - lo);

View file

@ -219,5 +219,15 @@ bool ColourGradient::isInvisible() const throw()
return true;
}
bool ColourGradient::ColourPoint::operator== (const ColourPoint& other) const throw()
{
return position == other.position && colour == other.colour;
}
bool ColourGradient::ColourPoint::operator!= (const ColourPoint& other) const throw()
{
return position != other.position || colour != other.colour;
}
END_JUCE_NAMESPACE

View file

@ -163,8 +163,8 @@ private:
: position (position_), colour (colour_)
{}
bool operator== (const ColourPoint& other) const throw() { return position == other.position && colour == other.colour; }
bool operator!= (const ColourPoint& other) const throw() { return position != other.position || colour != other.colour; }
bool operator== (const ColourPoint& other) const throw();
bool operator!= (const ColourPoint& other) const throw();
double position;
Colour colour;

View file

@ -123,7 +123,7 @@ public:
owner.applyRelativePath (*owner.relativePath, &scope);
}
void applyNewBounds (const Rectangle<int>& newBounds)
void applyNewBounds (const Rectangle<int>&)
{
jassertfalse; // drawables can't be resized directly!
}

View file

@ -77,7 +77,7 @@ public:
owner.repaint();
}
void applyNewBounds (const Rectangle<int>& newBounds)
void applyNewBounds (const Rectangle<int>&)
{
jassertfalse; // drawables can't be resized directly!
}

View file

@ -211,7 +211,7 @@ public:
const Point<ValueType> delta (end - start);
const double length = juce_hypot ((double) delta.getX(),
(double) delta.getY());
if (length == 0)
if (length <= 0)
return start;
return Point<ValueType> (start.getX() + (ValueType) ((delta.getX() * distanceFromStart - delta.getY() * perpendicularDistance) / length),

View file

@ -63,6 +63,12 @@ PathFlatteningIterator::~PathFlatteningIterator()
{
}
bool PathFlatteningIterator::isLastInSubpath() const throw()
{
return stackPos == stackBase.getData()
&& (index >= path.numElements || points [index] == Path::moveMarker);
}
bool PathFlatteningIterator::next()
{
x1 = x2;

View file

@ -91,9 +91,7 @@ public:
int subPathIndex;
/** Returns true if the current segment is the last in the current sub-path. */
bool isLastInSubpath() const throw() { return stackPos == stackBase.getData()
&& (index >= path.numElements || points [index] == Path::moveMarker); }
bool isLastInSubpath() const throw();
/** This is the default value that should be used for the tolerance value (see the constructor parameters). */
static const float defaultTolerance;

View file

@ -118,7 +118,13 @@ const String File::parseAbsolutePath (const String& p)
}
#else
// Mac or Linux..
String path (p.replaceCharacter ('\\', '/'));
// Yes, I know it's legal for a unix pathname to contain a backslash, but this assertion is here
// to catch anyone who's trying to run code that was written on Windows with hard-coded path names.
// If that's why you've ended up here, use File::getChildFile() to build your paths instead.
jassert ((! p.containsChar ('\\')) || (p.indexOfChar ('/') >= 0 && p.indexOfChar ('/') < p.indexOfChar ('\\')));
String path (p);
if (path.startsWithChar ('~'))
{
@ -364,11 +370,11 @@ bool File::isAChildOf (const File& potentialParent) const
bool File::isAbsolutePath (const String& path)
{
return path.startsWithChar ('/') || path.startsWithChar ('\\')
#if JUCE_WINDOWS
#if JUCE_WINDOWS
|| (path.isNotEmpty() && path[1] == ':');
#else
#else
|| path.startsWithChar ('~');
#endif
#endif
}
const File File::getChildFile (String relativePath) const
@ -385,11 +391,12 @@ const File File::getChildFile (String relativePath) const
if (relativePath[0] == '.')
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
relativePath = relativePath.replaceCharacter ('/', '\\').trimStart();
#else
relativePath = relativePath.replaceCharacter ('\\', '/').trimStart();
#endif
#else
relativePath = relativePath.trimStart();
#endif
while (relativePath[0] == '.')
{
if (relativePath[1] == '.')