Browse Source

Android fixes. Caret colour fix. VST host recursion check clean-up.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
981ef9313c
18 changed files with 284 additions and 234 deletions
  1. +1
    -1
      extras/JuceDemo/Builds/Android/local.properties
  2. +1
    -1
      extras/JuceDemo/Juce Demo.jucer
  3. +137
    -115
      juce_amalgamated.cpp
  4. +3
    -1
      juce_amalgamated.h
  5. +2
    -2
      src/audio/audio_sources/juce_AudioFormatReaderSource.cpp
  6. +4
    -4
      src/audio/audio_sources/juce_BufferingAudioSource.cpp
  7. +1
    -1
      src/audio/midi/juce_MidiMessage.cpp
  8. +1
    -0
      src/audio/plugin_client/VST/juce_VST_Wrapper.cpp
  9. +105
    -100
      src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp
  10. +1
    -1
      src/core/juce_StandardHeader.h
  11. +1
    -1
      src/core/juce_SystemStats.cpp
  12. +3
    -3
      src/events/juce_MessageManager.cpp
  13. +1
    -1
      src/gui/components/keyboard/juce_CaretComponent.cpp
  14. +1
    -0
      src/gui/components/layout/juce_ComponentAnimator.cpp
  15. +3
    -0
      src/memory/juce_ReferenceCountedObject.h
  16. +7
    -2
      src/native/android/juce_android_Misc.cpp
  17. +1
    -0
      src/native/mac/juce_mac_NativeIncludes.h
  18. +11
    -1
      src/native/mac/juce_mac_SystemStats.mm

+ 1
- 1
extras/JuceDemo/Builds/Android/local.properties View File

@@ -2,5 +2,5 @@
# It is automatically generated by the Jucer - DO NOT EDIT IT or your changes will be lost!.
sdk.dir=${user.home}/SDKs/android-sdk-mac_x86
ndk.dir=${user.home}/SDKs/android-ndk-r5
ndk.dir=${user.home}/SDKs/android-ndk-r5b

+ 1
- 1
extras/JuceDemo/Juce Demo.jucer View File

@@ -22,7 +22,7 @@
<VS2010 targetFolder="Builds/VisualStudio2010" vstFolder="c:\SDKs\vstsdk2.4"
rtasFolder="c:\SDKs\PT_80_SDK" libraryType="1" juceFolder="../../../juce"/>
<ANDROID targetFolder="Builds/Android" androidSDKPath="${user.home}/SDKs/android-sdk-mac_x86"
androidNDKPath="${user.home}/SDKs/android-ndk-r5" juceFolder="../../../juce"
androidNDKPath="${user.home}/SDKs/android-ndk-r5b" juceFolder="../../../juce"
androidInternetNeeded="1"/>
</EXPORTFORMATS>
<CONFIGURATIONS>


+ 137
- 115
juce_amalgamated.cpp View File

@@ -921,6 +921,7 @@ protected:
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/utsname.h>
#include <fnmatch.h>
#include <utime.h>
#include <dlfcn.h>
@@ -1716,7 +1717,7 @@ const String SystemStats::getJUCEVersion()
#undef JUCE_STRINGIFYVERSION2
}

#if JUCE_DEBUG
#if JUCE_DEBUG && ! JUCE_ANDROID
struct JuceVersionPrinter
{
JuceVersionPrinter()
@@ -24328,8 +24329,8 @@ void AudioFormatReaderSource::getNextAudioBlock (const AudioSourceChannelInfo& i

if (looping)
{
const int newStart = start % (int) reader->lengthInSamples;
const int newEnd = (start + info.numSamples) % (int) reader->lengthInSamples;
const int newStart = (int) (start % (int) reader->lengthInSamples);
const int newEnd = (int) ((start + info.numSamples) % (int) reader->lengthInSamples);

if (newEnd > newStart)
{
@@ -24990,8 +24991,8 @@ void BufferingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info
{
for (int chan = jmin (numberOfChannels, info.buffer->getNumChannels()); --chan >= 0;)
{
const int startBufferIndex = (validStart + nextPlayPos) % buffer.getNumSamples();
const int endBufferIndex = (validEnd + nextPlayPos) % buffer.getNumSamples();
const int startBufferIndex = (int) ((validStart + nextPlayPos) % buffer.getNumSamples());
const int endBufferIndex = (int) ((validEnd + nextPlayPos) % buffer.getNumSamples());

if (startBufferIndex < endBufferIndex)
{
@@ -25094,8 +25095,8 @@ bool BufferingAudioSource::readNextBufferChunk()

if (sectionToReadStart != sectionToReadEnd)
{
const int bufferIndexStart = sectionToReadStart % buffer.getNumSamples();
const int bufferIndexEnd = sectionToReadEnd % buffer.getNumSamples();
const int bufferIndexStart = (int) (sectionToReadStart % buffer.getNumSamples());
const int bufferIndexEnd = (int) (sectionToReadEnd % buffer.getNumSamples());

if (bufferIndexStart < bufferIndexEnd)
{
@@ -29521,7 +29522,7 @@ int MidiMessage::getNoteNumber() const noexcept
void MidiMessage::setNoteNumber (const int newNoteNumber) noexcept
{
if (isNoteOnOrOff())
data[1] = newNoteNumber & 127;
data[1] = (char) (newNoteNumber & 127);
}

uint8 MidiMessage::getVelocity() const noexcept
@@ -33644,6 +33645,28 @@ static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstI
static int shellUIDToCreate = 0;
static int insideVSTCallback = 0;

class IdleCallRecursionPreventer
{
public:
IdleCallRecursionPreventer()
: isMessageThread (MessageManager::getInstance()->isThisTheMessageThread())
{
if (isMessageThread)
++insideVSTCallback;
}

~IdleCallRecursionPreventer()
{
if (isMessageThread)
--insideVSTCallback;
}

private:
const bool isMessageThread;

JUCE_DECLARE_NON_COPYABLE (IdleCallRecursionPreventer);
};

class VSTPluginWindow;

// Change this to disable logging of various VST activities
@@ -33799,7 +33822,8 @@ public:
}

_fpreset(); // (doesn't do any harm)
++insideVSTCallback;

const IdleCallRecursionPreventer icrp;
shellUIDToCreate = 0;

log ("Attempting to load VST: " + file.getFullPathName());
@@ -33809,7 +33833,6 @@ public:
if (! m->open())
m = nullptr;

--insideVSTCallback;
_fpreset(); // (doesn't do any harm)

return m.release();
@@ -33818,24 +33841,21 @@ public:
ModuleHandle (const File& file_)
: file (file_),
moduleMain (0),
#if JUCE_WINDOWS || JUCE_LINUX
#if JUCE_WINDOWS || JUCE_LINUX
hModule (0)
#elif JUCE_MAC
fragId (0),
resHandle (0),
bundleRef (0),
resFileId (0)
#endif
#elif JUCE_MAC
fragId (0), resHandle (0), bundleRef (0), resFileId (0)
#endif
{
getActiveModules().add (this);

#if JUCE_WINDOWS || JUCE_LINUX
#if JUCE_WINDOWS || JUCE_LINUX
fullParentDirectoryPathName = file_.getParentDirectory().getFullPathName();
#elif JUCE_MAC
#elif JUCE_MAC
FSRef ref;
PlatformUtilities::makeFSRefFromPath (&ref, file_.getParentDirectory().getFullPathName());
FSGetCatalogInfo (&ref, kFSCatInfoNone, 0, 0, &parentDirFSSpec, 0);
#endif
#endif
}

~ModuleHandle()
@@ -33850,7 +33870,7 @@ public:

bool open()
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
static bool timePeriodSet = false;

if (! timePeriodSet)
@@ -33858,7 +33878,7 @@ public:
timePeriodSet = true;
timeBeginPeriod (2);
}
#endif
#endif

pluginName = file.getFileNameWithoutExtension();

@@ -34009,7 +34029,7 @@ public:

void close()
{
#if JUCE_PPC
#if JUCE_PPC
if (fragId != 0)
{
if (moduleMain != 0)
@@ -34022,7 +34042,7 @@ public:
CloseResFile (resFileId);
}
else
#endif
#endif
if (bundleRef != 0)
{
CFBundleCloseBundleResourceMap (bundleRef, resFileId);
@@ -34037,7 +34057,7 @@ public:

void closeEffect (AEffect* eff)
{
#if JUCE_PPC
#if JUCE_PPC
if (fragId != 0)
{
Array<void*> thingsToDelete;
@@ -34053,13 +34073,13 @@ public:
disposeMachOFromCFM (thingsToDelete[i]);
}
else
#endif
#endif
{
eff->dispatcher (eff, effClose, 0, 0, 0, 0);
}
}

#if JUCE_PPC
#if JUCE_PPC
static void* newMachOFromCFM (void* cfmfp)
{
if (cfmfp == 0)
@@ -34094,7 +34114,7 @@ public:
eff->processReplacing = (AEffectProcessProc) newMachOFromCFM ((void*) eff->processReplacing);
}
}
#endif
#endif

#endif

@@ -34238,7 +34258,8 @@ private:
};

VSTPluginInstance::VSTPluginInstance (const ReferenceCountedObjectPtr <ModuleHandle>& module_)
: effect (0),
: effect (nullptr),
name (module_->pluginName),
wantsMidiMessages (false),
initialised (false),
isPowerOn (false),
@@ -34247,40 +34268,36 @@ VSTPluginInstance::VSTPluginInstance (const ReferenceCountedObjectPtr <ModuleHan
{
try
{
const IdleCallRecursionPreventer icrp;
_fpreset();

++insideVSTCallback;

name = module->pluginName;
log ("Creating VST instance: " + name);

#if JUCE_MAC
#if JUCE_MAC
if (module->resFileId != 0)
UseResFile (module->resFileId);

#if JUCE_PPC
#if JUCE_PPC
if (module->fragId != 0)
{
static void* audioMasterCoerced = nullptr;
if (audioMasterCoerced == 0)
if (audioMasterCoerced == nullptr)
audioMasterCoerced = NewCFMFromMachO ((void*) &audioMaster);

effect = module->moduleMain ((audioMasterCallback) audioMasterCoerced);
}
else
#endif
#endif
#endif
#endif
{
effect = module->moduleMain (&audioMaster);
}

--insideVSTCallback;

if (effect != nullptr && effect->magic == kEffectMagic)
{
#if JUCE_PPC
#if JUCE_PPC
module->coerceAEffectFunctionCalls (effect);
#endif
#endif

jassert (effect->resvd2 == 0);
jassert (effect->object != 0);
@@ -34293,25 +34310,21 @@ VSTPluginInstance::VSTPluginInstance (const ReferenceCountedObjectPtr <ModuleHan
}
}
catch (...)
{
--insideVSTCallback;
}
{}
}

VSTPluginInstance::~VSTPluginInstance()
{
const ScopedLock sl (lock);

jassert (insideVSTCallback == 0);

if (effect != nullptr && effect->magic == kEffectMagic)
{
try
{
#if JUCE_MAC
#if JUCE_MAC
if (module->resFileId != 0)
UseResFile (module->resFileId);
#endif
#endif

// Must delete any editors before deleting the plugin instance!
jassert (getActiveEditor() == 0);
@@ -34547,9 +34560,9 @@ public:

VSTPluginWindow (VSTPluginInstance& plugin_)
: AudioProcessorEditor (&plugin_),
#if ! JUCE_MAC
#if ! JUCE_MAC
ComponentMovementWatcher (this),
#endif
#endif
plugin (plugin_),
isOpen (false),
recursiveResize (false),
@@ -34600,17 +34613,17 @@ public:

recursiveResize = true;

#if JUCE_WINDOWS
#if JUCE_WINDOWS
if (pluginHWND != 0)
MoveWindow (pluginHWND, pos.getX(), pos.getY(), getWidth(), getHeight(), TRUE);
#elif JUCE_LINUX
#elif JUCE_LINUX
if (pluginWindow != 0)
{
XResizeWindow (display, pluginWindow, getWidth(), getHeight());
XMoveWindow (display, pluginWindow, pos.getX(), pos.getY());
XMapRaised (display, pluginWindow);
}
#endif
#endif

recursiveResize = false;
}
@@ -34660,7 +34673,7 @@ public:
const Point<int> pos (getScreenPosition() - peer->getScreenPosition());
peer->addMaskedRegion (pos.getX(), pos.getY(), getWidth(), getHeight());

#if JUCE_LINUX
#if JUCE_LINUX
if (pluginWindow != 0)
{
const Rectangle<int> clip (g.getClipBounds());
@@ -34676,7 +34689,7 @@ public:

sendEventToChild (&ev);
}
#endif
#endif
}
}
else
@@ -34688,14 +34701,14 @@ public:

void timerCallback()
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
if (--sizeCheckCount <= 0)
{
sizeCheckCount = 10;

checkPluginWindowSize();
}
#endif
#endif

try
{
@@ -34714,7 +34727,7 @@ public:

void mouseDown (const MouseEvent& e)
{
#if JUCE_LINUX
#if JUCE_LINUX
if (pluginWindow == 0)
return;

@@ -34735,11 +34748,11 @@ public:

sendEventToChild (&ev);

#elif JUCE_WINDOWS
#elif JUCE_WINDOWS
(void) e;

toFront (true);
#endif
#endif
}

void broughtToFront()
@@ -34747,9 +34760,9 @@ public:
activeVSTWindows.removeValue (this);
activeVSTWindows.add (this);

#if JUCE_MAC
#if JUCE_MAC
dispatch (effEditTop, 0, 0, 0, 0);
#endif
#endif
}

private:
@@ -34757,14 +34770,14 @@ private:
bool isOpen, recursiveResize;
bool pluginWantsKeys, pluginRefusesToResize, alreadyInside;

#if JUCE_WINDOWS
#if JUCE_WINDOWS
HWND pluginHWND;
void* originalWndProc;
int sizeCheckCount;
#elif JUCE_LINUX
#elif JUCE_LINUX
Window pluginWindow;
EventProcPtr pluginProc;
#endif
#endif

#if JUCE_MAC
void openPluginWindow (WindowRef parentWindow)
@@ -34829,7 +34842,7 @@ private:
// Install keyboard hooks
pluginWantsKeys = (dispatch (effKeysRequired, 0, 0, 0, 0) == 0);

#if JUCE_WINDOWS
#if JUCE_WINDOWS
originalWndProc = 0;
pluginHWND = GetWindow ((HWND) getWindowHandle(), GW_CHILD);

@@ -34884,7 +34897,7 @@ private:
}
}

#elif JUCE_LINUX
#elif JUCE_LINUX
pluginWindow = getChildWindow ((Window) getWindowHandle());

if (pluginWindow != 0)
@@ -34907,7 +34920,7 @@ private:

if (pluginWindow != 0)
XMapRaised (display, pluginWindow);
#endif
#endif

// double-check it's not too tiny
w = jmax (w, 32);
@@ -34915,9 +34928,9 @@ private:

setSize (w, h);

#if JUCE_WINDOWS
#if JUCE_WINDOWS
checkPluginWindowSize();
#endif
#endif

startTimer (18 + JUCE_NAMESPACE::Random::getSystemRandom().nextInt (5));
repaint();
@@ -34934,7 +34947,7 @@ private:

dispatch (effEditClose, 0, 0, 0, 0);

#if JUCE_WINDOWS
#if JUCE_WINDOWS
#pragma warning (push)
#pragma warning (disable: 4244)

@@ -34949,11 +34962,11 @@ private:
DestroyWindow (pluginHWND);

pluginHWND = 0;
#elif JUCE_LINUX
#elif JUCE_LINUX
stopTimer();
pluginWindow = 0;
pluginProc = 0;
#endif
#endif
}
}
#endif
@@ -35526,35 +35539,30 @@ void VSTPluginInstance::timerCallback()

int VSTPluginInstance::dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) const
{
const ScopedLock sl (lock);

++insideVSTCallback;
int result = 0;

try
if (effect != nullptr)
{
if (effect != 0)
const ScopedLock sl (lock);
const IdleCallRecursionPreventer icrp;

try
{
#if JUCE_MAC
#if JUCE_MAC
if (module->resFileId != 0)
UseResFile (module->resFileId);
#endif
#endif

result = effect->dispatcher (effect, opcode, index, value, ptr, opt);

#if JUCE_MAC
#if JUCE_MAC
module->resFileId = CurResFile();
#endif

--insideVSTCallback;
return result;
#endif
}
}
catch (...)
{
catch (...)
{}
}

--insideVSTCallback;
return result;
}

@@ -35650,19 +35658,19 @@ VstIntPtr VSTPluginInstance::handleCallback (VstInt32 opcode, VstInt32 index, Vs
case audioMasterIdle:
if (insideVSTCallback == 0 && MessageManager::getInstance()->isThisTheMessageThread())
{
++insideVSTCallback;
#if JUCE_MAC
const IdleCallRecursionPreventer icrp;

#if JUCE_MAC
if (getActiveEditor() != nullptr)
dispatch (effEditIdle, 0, 0, 0, 0);
#endif
#endif

juce_callAnyTimersSynchronously();

handleUpdateNowIfNeeded();

for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
ComponentPeer::getPeer (i)->performAnyPendingRepaintsNow();

--insideVSTCallback;
}
break;

@@ -36117,10 +36125,10 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul

try
{
#if JUCE_MAC
#if JUCE_MAC
if (instance->module->resFileId != 0)
UseResFile (instance->module->resFileId);
#endif
#endif

instance->fillInPluginDescription (desc);

@@ -36131,9 +36139,7 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul
// Normal plugin...
results.add (new PluginDescription (desc));

++insideVSTCallback;
instance->dispatch (effOpen, 0, 0, 0, 0);
--insideVSTCallback;
}
else
{
@@ -36218,11 +36224,11 @@ bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdenti
{
const File f (fileOrIdentifier);

#if JUCE_MAC
#if JUCE_MAC
if (f.isDirectory() && f.hasFileExtension (".vst"))
return true;

#if JUCE_PPC
#if JUCE_PPC
FSRef fileRef;
if (PlatformUtilities::makeFSRefFromPath (&fileRef, f.getFullPathName()))
{
@@ -36237,14 +36243,14 @@ bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdenti
return true;
}
}
#endif
#endif

return false;
#elif JUCE_WINDOWS
#elif JUCE_WINDOWS
return f.existsAsFile() && f.hasFileExtension (".dll");
#elif JUCE_LINUX
#elif JUCE_LINUX
return f.existsAsFile() && f.hasFileExtension (".so");
#endif
#endif
}

const String VSTPluginFormat::getNameOfPluginFromIdentifier (const String& fileOrIdentifier)
@@ -36291,15 +36297,15 @@ void VSTPluginFormat::recursiveFileSearch (StringArray& results, const File& dir

const FileSearchPath VSTPluginFormat::getDefaultLocationsToSearch()
{
#if JUCE_MAC
#if JUCE_MAC
return FileSearchPath ("~/Library/Audio/Plug-Ins/VST;/Library/Audio/Plug-Ins/VST");
#elif JUCE_WINDOWS
#elif JUCE_WINDOWS
const String programFiles (File::getSpecialLocation (File::globalApplicationsDirectory).getFullPathName());

return FileSearchPath (programFiles + "\\Steinberg\\VstPlugins");
#elif JUCE_LINUX
#elif JUCE_LINUX
return FileSearchPath ("/usr/lib/vst");
#endif
#endif
}

END_JUCE_NAMESPACE
@@ -39667,7 +39673,7 @@ BEGIN_JUCE_NAMESPACE

MessageManager* MessageManager::instance = nullptr;

static const int quitMessageId = 0xfffff321;
enum { quitMessageId = 0xfffff321 };

MessageManager::MessageManager() noexcept
: quitMessagePosted (false),
@@ -39733,7 +39739,7 @@ void MessageManager::deliverMessage (Message* const message)
{
callbackMessage->messageCallback();
}
else if (message->intParameter1 == quitMessageId)
else if (message->intParameter1 == (int) quitMessageId)
{
quitMessageReceived = true;
}
@@ -39756,7 +39762,7 @@ void MessageManager::runDispatchLoop()

void MessageManager::stopDispatchLoop()
{
postMessageToQueue (new Message (quitMessageId, 0, 0, nullptr));
postMessageToQueue (new Message ((int) quitMessageId, 0, 0, nullptr));
quitMessagePosted = true;
}

@@ -62219,7 +62225,7 @@ CaretComponent::~CaretComponent()

void CaretComponent::paint (Graphics& g)
{
g.fillAll (findColour (caretColourId));
g.fillAll (findColour (caretColourId, true));
}

void CaretComponent::timerCallback()
@@ -62366,6 +62372,7 @@ public:
: image (component.createComponentSnapshot (component.getLocalBounds()))
{
setBounds (component.getBounds());
setTransform (component.getTransform());
setAlpha (component.getAlpha());
setInterceptsMouseClicks (false, false);

@@ -269249,7 +269256,17 @@ SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()

const String SystemStats::getOperatingSystemName()
{
return "Mac OS X";
#if JUCE_IOS
String s ("iOS ");
#else
String s ("Mac OSX ");
#endif

struct utsname uts;
if (uname (&uts) >= 0)
s << uts.release;

return s;
}

#if ! JUCE_IOS
@@ -286772,6 +286789,8 @@ JUCE_JNI_CALLBACK (JuceAppActivity, launchApp, void, (JNIEnv* env, jobject activ
{
android.initialise (env, activity, appFile, appDataDir);

DBG (SystemStats::getJUCEVersion());

JUCEApplication::createInstance = &juce_CreateApplication;

initialiseJuce_GUI();
@@ -286793,8 +286812,11 @@ void PlatformUtilities::beep()

void Logger::outputDebugString (const String& text)
{
getEnv()->CallStaticVoidMethod (android.activityClass, android.printToConsole,
javaString (text).get());
JNIEnv* const env = getEnv();

if (env != nullptr)
env->CallStaticVoidMethod (android.activityClass, android.printToConsole,
javaString (text).get());
}

void SystemClipboard::copyTextToClipboard (const String& text)


+ 3
- 1
juce_amalgamated.h View File

@@ -73,7 +73,7 @@ namespace JuceDummyNamespace {}
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 87
#define JUCE_BUILDNUMBER 88

/** Current Juce version number.

@@ -9394,6 +9394,8 @@ template <class ReferenceCountedObjectClass>
class ReferenceCountedObjectPtr
{
public:
/** The class being referenced by this pointer. */
typedef ReferenceCountedObjectClass ReferencedType;

/** Creates a pointer to a null object. */
inline ReferenceCountedObjectPtr() noexcept


+ 2
- 2
src/audio/audio_sources/juce_AudioFormatReaderSource.cpp View File

@@ -87,8 +87,8 @@ void AudioFormatReaderSource::getNextAudioBlock (const AudioSourceChannelInfo& i
if (looping)
{
const int newStart = start % (int) reader->lengthInSamples;
const int newEnd = (start + info.numSamples) % (int) reader->lengthInSamples;
const int newStart = (int) (start % (int) reader->lengthInSamples);
const int newEnd = (int) ((start + info.numSamples) % (int) reader->lengthInSamples);
if (newEnd > newStart)
{


+ 4
- 4
src/audio/audio_sources/juce_BufferingAudioSource.cpp View File

@@ -209,8 +209,8 @@ void BufferingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info
{
for (int chan = jmin (numberOfChannels, info.buffer->getNumChannels()); --chan >= 0;)
{
const int startBufferIndex = (validStart + nextPlayPos) % buffer.getNumSamples();
const int endBufferIndex = (validEnd + nextPlayPos) % buffer.getNumSamples();
const int startBufferIndex = (int) ((validStart + nextPlayPos) % buffer.getNumSamples());
const int endBufferIndex = (int) ((validEnd + nextPlayPos) % buffer.getNumSamples());
if (startBufferIndex < endBufferIndex)
{
@@ -313,8 +313,8 @@ bool BufferingAudioSource::readNextBufferChunk()
if (sectionToReadStart != sectionToReadEnd)
{
const int bufferIndexStart = sectionToReadStart % buffer.getNumSamples();
const int bufferIndexEnd = sectionToReadEnd % buffer.getNumSamples();
const int bufferIndexStart = (int) (sectionToReadStart % buffer.getNumSamples());
const int bufferIndexEnd = (int) (sectionToReadEnd % buffer.getNumSamples());
if (bufferIndexStart < bufferIndexEnd)
{


+ 1
- 1
src/audio/midi/juce_MidiMessage.cpp View File

@@ -348,7 +348,7 @@ int MidiMessage::getNoteNumber() const noexcept
void MidiMessage::setNoteNumber (const int newNoteNumber) noexcept
{
if (isNoteOnOrOff())
data[1] = newNoteNumber & 127;
data[1] = (char) (newNoteNumber & 127);
}
uint8 MidiMessage::getVelocity() const noexcept


+ 1
- 0
src/audio/plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -87,6 +87,7 @@
typedef long VstInt32;
typedef long VstIntPtr;
enum Vst2StringConstants
{
kVstMaxNameLen = 64,


+ 105
- 100
src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp View File

@@ -222,6 +222,28 @@ static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstI
static int shellUIDToCreate = 0;
static int insideVSTCallback = 0;
class IdleCallRecursionPreventer
{
public:
IdleCallRecursionPreventer()
: isMessageThread (MessageManager::getInstance()->isThisTheMessageThread())
{
if (isMessageThread)
++insideVSTCallback;
}
~IdleCallRecursionPreventer()
{
if (isMessageThread)
--insideVSTCallback;
}
private:
const bool isMessageThread;
JUCE_DECLARE_NON_COPYABLE (IdleCallRecursionPreventer);
};
class VSTPluginWindow;
//==============================================================================
@@ -382,7 +404,8 @@ public:
}
_fpreset(); // (doesn't do any harm)
++insideVSTCallback;
const IdleCallRecursionPreventer icrp;
shellUIDToCreate = 0;
log ("Attempting to load VST: " + file.getFullPathName());
@@ -392,7 +415,6 @@ public:
if (! m->open())
m = nullptr;
--insideVSTCallback;
_fpreset(); // (doesn't do any harm)
return m.release();
@@ -402,24 +424,21 @@ public:
ModuleHandle (const File& file_)
: file (file_),
moduleMain (0),
#if JUCE_WINDOWS || JUCE_LINUX
#if JUCE_WINDOWS || JUCE_LINUX
hModule (0)
#elif JUCE_MAC
fragId (0),
resHandle (0),
bundleRef (0),
resFileId (0)
#endif
#elif JUCE_MAC
fragId (0), resHandle (0), bundleRef (0), resFileId (0)
#endif
{
getActiveModules().add (this);
#if JUCE_WINDOWS || JUCE_LINUX
#if JUCE_WINDOWS || JUCE_LINUX
fullParentDirectoryPathName = file_.getParentDirectory().getFullPathName();
#elif JUCE_MAC
#elif JUCE_MAC
FSRef ref;
PlatformUtilities::makeFSRefFromPath (&ref, file_.getParentDirectory().getFullPathName());
FSGetCatalogInfo (&ref, kFSCatInfoNone, 0, 0, &parentDirFSSpec, 0);
#endif
#endif
}
~ModuleHandle()
@@ -435,7 +454,7 @@ public:
bool open()
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
static bool timePeriodSet = false;
if (! timePeriodSet)
@@ -443,7 +462,7 @@ public:
timePeriodSet = true;
timeBeginPeriod (2);
}
#endif
#endif
pluginName = file.getFileNameWithoutExtension();
@@ -594,7 +613,7 @@ public:
void close()
{
#if JUCE_PPC
#if JUCE_PPC
if (fragId != 0)
{
if (moduleMain != 0)
@@ -607,7 +626,7 @@ public:
CloseResFile (resFileId);
}
else
#endif
#endif
if (bundleRef != 0)
{
CFBundleCloseBundleResourceMap (bundleRef, resFileId);
@@ -622,7 +641,7 @@ public:
void closeEffect (AEffect* eff)
{
#if JUCE_PPC
#if JUCE_PPC
if (fragId != 0)
{
Array<void*> thingsToDelete;
@@ -638,13 +657,13 @@ public:
disposeMachOFromCFM (thingsToDelete[i]);
}
else
#endif
#endif
{
eff->dispatcher (eff, effClose, 0, 0, 0, 0);
}
}
#if JUCE_PPC
#if JUCE_PPC
static void* newMachOFromCFM (void* cfmfp)
{
if (cfmfp == 0)
@@ -679,7 +698,7 @@ public:
eff->processReplacing = (AEffectProcessProc) newMachOFromCFM ((void*) eff->processReplacing);
}
}
#endif
#endif
#endif
@@ -832,7 +851,8 @@ private:
//==============================================================================
VSTPluginInstance::VSTPluginInstance (const ReferenceCountedObjectPtr <ModuleHandle>& module_)
: effect (0),
: effect (nullptr),
name (module_->pluginName),
wantsMidiMessages (false),
initialised (false),
isPowerOn (false),
@@ -841,40 +861,36 @@ VSTPluginInstance::VSTPluginInstance (const ReferenceCountedObjectPtr <ModuleHan
{
try
{
const IdleCallRecursionPreventer icrp;
_fpreset();
++insideVSTCallback;
name = module->pluginName;
log ("Creating VST instance: " + name);
#if JUCE_MAC
#if JUCE_MAC
if (module->resFileId != 0)
UseResFile (module->resFileId);
#if JUCE_PPC
#if JUCE_PPC
if (module->fragId != 0)
{
static void* audioMasterCoerced = nullptr;
if (audioMasterCoerced == 0)
if (audioMasterCoerced == nullptr)
audioMasterCoerced = NewCFMFromMachO ((void*) &audioMaster);
effect = module->moduleMain ((audioMasterCallback) audioMasterCoerced);
}
else
#endif
#endif
#endif
#endif
{
effect = module->moduleMain (&audioMaster);
}
--insideVSTCallback;
if (effect != nullptr && effect->magic == kEffectMagic)
{
#if JUCE_PPC
#if JUCE_PPC
module->coerceAEffectFunctionCalls (effect);
#endif
#endif
jassert (effect->resvd2 == 0);
jassert (effect->object != 0);
@@ -887,25 +903,21 @@ VSTPluginInstance::VSTPluginInstance (const ReferenceCountedObjectPtr <ModuleHan
}
}
catch (...)
{
--insideVSTCallback;
}
{}
}
VSTPluginInstance::~VSTPluginInstance()
{
const ScopedLock sl (lock);
jassert (insideVSTCallback == 0);
if (effect != nullptr && effect->magic == kEffectMagic)
{
try
{
#if JUCE_MAC
#if JUCE_MAC
if (module->resFileId != 0)
UseResFile (module->resFileId);
#endif
#endif
// Must delete any editors before deleting the plugin instance!
jassert (getActiveEditor() == 0);
@@ -1147,9 +1159,9 @@ public:
//==============================================================================
VSTPluginWindow (VSTPluginInstance& plugin_)
: AudioProcessorEditor (&plugin_),
#if ! JUCE_MAC
#if ! JUCE_MAC
ComponentMovementWatcher (this),
#endif
#endif
plugin (plugin_),
isOpen (false),
recursiveResize (false),
@@ -1201,17 +1213,17 @@ public:
recursiveResize = true;
#if JUCE_WINDOWS
#if JUCE_WINDOWS
if (pluginHWND != 0)
MoveWindow (pluginHWND, pos.getX(), pos.getY(), getWidth(), getHeight(), TRUE);
#elif JUCE_LINUX
#elif JUCE_LINUX
if (pluginWindow != 0)
{
XResizeWindow (display, pluginWindow, getWidth(), getHeight());
XMoveWindow (display, pluginWindow, pos.getX(), pos.getY());
XMapRaised (display, pluginWindow);
}
#endif
#endif
recursiveResize = false;
}
@@ -1263,7 +1275,7 @@ public:
const Point<int> pos (getScreenPosition() - peer->getScreenPosition());
peer->addMaskedRegion (pos.getX(), pos.getY(), getWidth(), getHeight());
#if JUCE_LINUX
#if JUCE_LINUX
if (pluginWindow != 0)
{
const Rectangle<int> clip (g.getClipBounds());
@@ -1279,7 +1291,7 @@ public:
sendEventToChild (&ev);
}
#endif
#endif
}
}
else
@@ -1292,14 +1304,14 @@ public:
//==============================================================================
void timerCallback()
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
if (--sizeCheckCount <= 0)
{
sizeCheckCount = 10;
checkPluginWindowSize();
}
#endif
#endif
try
{
@@ -1319,7 +1331,7 @@ public:
//==============================================================================
void mouseDown (const MouseEvent& e)
{
#if JUCE_LINUX
#if JUCE_LINUX
if (pluginWindow == 0)
return;
@@ -1340,11 +1352,11 @@ public:
sendEventToChild (&ev);
#elif JUCE_WINDOWS
#elif JUCE_WINDOWS
(void) e;
toFront (true);
#endif
#endif
}
void broughtToFront()
@@ -1352,9 +1364,9 @@ public:
activeVSTWindows.removeValue (this);
activeVSTWindows.add (this);
#if JUCE_MAC
#if JUCE_MAC
dispatch (effEditTop, 0, 0, 0, 0);
#endif
#endif
}
//==============================================================================
@@ -1363,14 +1375,14 @@ private:
bool isOpen, recursiveResize;
bool pluginWantsKeys, pluginRefusesToResize, alreadyInside;
#if JUCE_WINDOWS
#if JUCE_WINDOWS
HWND pluginHWND;
void* originalWndProc;
int sizeCheckCount;
#elif JUCE_LINUX
#elif JUCE_LINUX
Window pluginWindow;
EventProcPtr pluginProc;
#endif
#endif
//==============================================================================
#if JUCE_MAC
@@ -1436,7 +1448,7 @@ private:
// Install keyboard hooks
pluginWantsKeys = (dispatch (effKeysRequired, 0, 0, 0, 0) == 0);
#if JUCE_WINDOWS
#if JUCE_WINDOWS
originalWndProc = 0;
pluginHWND = GetWindow ((HWND) getWindowHandle(), GW_CHILD);
@@ -1491,7 +1503,7 @@ private:
}
}
#elif JUCE_LINUX
#elif JUCE_LINUX
pluginWindow = getChildWindow ((Window) getWindowHandle());
if (pluginWindow != 0)
@@ -1514,7 +1526,7 @@ private:
if (pluginWindow != 0)
XMapRaised (display, pluginWindow);
#endif
#endif
// double-check it's not too tiny
w = jmax (w, 32);
@@ -1522,9 +1534,9 @@ private:
setSize (w, h);
#if JUCE_WINDOWS
#if JUCE_WINDOWS
checkPluginWindowSize();
#endif
#endif
startTimer (18 + JUCE_NAMESPACE::Random::getSystemRandom().nextInt (5));
repaint();
@@ -1542,7 +1554,7 @@ private:
dispatch (effEditClose, 0, 0, 0, 0);
#if JUCE_WINDOWS
#if JUCE_WINDOWS
#pragma warning (push)
#pragma warning (disable: 4244)
@@ -1557,11 +1569,11 @@ private:
DestroyWindow (pluginHWND);
pluginHWND = 0;
#elif JUCE_LINUX
#elif JUCE_LINUX
stopTimer();
pluginWindow = 0;
pluginProc = 0;
#endif
#endif
}
}
#endif
@@ -2142,35 +2154,30 @@ void VSTPluginInstance::timerCallback()
int VSTPluginInstance::dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) const
{
const ScopedLock sl (lock);
++insideVSTCallback;
int result = 0;
try
if (effect != nullptr)
{
if (effect != 0)
const ScopedLock sl (lock);
const IdleCallRecursionPreventer icrp;
try
{
#if JUCE_MAC
#if JUCE_MAC
if (module->resFileId != 0)
UseResFile (module->resFileId);
#endif
#endif
result = effect->dispatcher (effect, opcode, index, value, ptr, opt);
#if JUCE_MAC
#if JUCE_MAC
module->resFileId = CurResFile();
#endif
--insideVSTCallback;
return result;
#endif
}
}
catch (...)
{
catch (...)
{}
}
--insideVSTCallback;
return result;
}
@@ -2267,19 +2274,19 @@ VstIntPtr VSTPluginInstance::handleCallback (VstInt32 opcode, VstInt32 index, Vs
case audioMasterIdle:
if (insideVSTCallback == 0 && MessageManager::getInstance()->isThisTheMessageThread())
{
++insideVSTCallback;
#if JUCE_MAC
const IdleCallRecursionPreventer icrp;
#if JUCE_MAC
if (getActiveEditor() != nullptr)
dispatch (effEditIdle, 0, 0, 0, 0);
#endif
#endif
juce_callAnyTimersSynchronously();
handleUpdateNowIfNeeded();
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
ComponentPeer::getPeer (i)->performAnyPendingRepaintsNow();
--insideVSTCallback;
}
break;
@@ -2742,10 +2749,10 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul
try
{
#if JUCE_MAC
#if JUCE_MAC
if (instance->module->resFileId != 0)
UseResFile (instance->module->resFileId);
#endif
#endif
instance->fillInPluginDescription (desc);
@@ -2756,9 +2763,7 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul
// Normal plugin...
results.add (new PluginDescription (desc));
++insideVSTCallback;
instance->dispatch (effOpen, 0, 0, 0, 0);
--insideVSTCallback;
}
else
{
@@ -2843,11 +2848,11 @@ bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdenti
{
const File f (fileOrIdentifier);
#if JUCE_MAC
#if JUCE_MAC
if (f.isDirectory() && f.hasFileExtension (".vst"))
return true;
#if JUCE_PPC
#if JUCE_PPC
FSRef fileRef;
if (PlatformUtilities::makeFSRefFromPath (&fileRef, f.getFullPathName()))
{
@@ -2862,14 +2867,14 @@ bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdenti
return true;
}
}
#endif
#endif
return false;
#elif JUCE_WINDOWS
#elif JUCE_WINDOWS
return f.existsAsFile() && f.hasFileExtension (".dll");
#elif JUCE_LINUX
#elif JUCE_LINUX
return f.existsAsFile() && f.hasFileExtension (".so");
#endif
#endif
}
const String VSTPluginFormat::getNameOfPluginFromIdentifier (const String& fileOrIdentifier)
@@ -2916,15 +2921,15 @@ void VSTPluginFormat::recursiveFileSearch (StringArray& results, const File& dir
const FileSearchPath VSTPluginFormat::getDefaultLocationsToSearch()
{
#if JUCE_MAC
#if JUCE_MAC
return FileSearchPath ("~/Library/Audio/Plug-Ins/VST;/Library/Audio/Plug-Ins/VST");
#elif JUCE_WINDOWS
#elif JUCE_WINDOWS
const String programFiles (File::getSpecialLocation (File::globalApplicationsDirectory).getFullPathName());
return FileSearchPath (programFiles + "\\Steinberg\\VstPlugins");
#elif JUCE_LINUX
#elif JUCE_LINUX
return FileSearchPath ("/usr/lib/vst");
#endif
#endif
}


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 87
#define JUCE_BUILDNUMBER 88
/** Current Juce version number.


+ 1
- 1
src/core/juce_SystemStats.cpp View File

@@ -66,7 +66,7 @@ const String SystemStats::getJUCEVersion()
#undef JUCE_STRINGIFYVERSION2
}
#if JUCE_DEBUG
#if JUCE_DEBUG && ! JUCE_ANDROID
struct JuceVersionPrinter
{
JuceVersionPrinter()


+ 3
- 3
src/events/juce_MessageManager.cpp View File

@@ -37,7 +37,7 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
MessageManager* MessageManager::instance = nullptr;
static const int quitMessageId = 0xfffff321;
enum { quitMessageId = 0xfffff321 };
MessageManager::MessageManager() noexcept
: quitMessagePosted (false),
@@ -105,7 +105,7 @@ void MessageManager::deliverMessage (Message* const message)
{
callbackMessage->messageCallback();
}
else if (message->intParameter1 == quitMessageId)
else if (message->intParameter1 == (int) quitMessageId)
{
quitMessageReceived = true;
}
@@ -129,7 +129,7 @@ void MessageManager::runDispatchLoop()
void MessageManager::stopDispatchLoop()
{
postMessageToQueue (new Message (quitMessageId, 0, 0, nullptr));
postMessageToQueue (new Message ((int) quitMessageId, 0, 0, nullptr));
quitMessagePosted = true;
}


+ 1
- 1
src/gui/components/keyboard/juce_CaretComponent.cpp View File

@@ -44,7 +44,7 @@ CaretComponent::~CaretComponent()
void CaretComponent::paint (Graphics& g)
{
g.fillAll (findColour (caretColourId));
g.fillAll (findColour (caretColourId, true));
}
void CaretComponent::timerCallback()


+ 1
- 0
src/gui/components/layout/juce_ComponentAnimator.cpp View File

@@ -152,6 +152,7 @@ public:
: image (component.createComponentSnapshot (component.getLocalBounds()))
{
setBounds (component.getBounds());
setTransform (component.getTransform());
setAlpha (component.getAlpha());
setInterceptsMouseClicks (false, false);


+ 3
- 0
src/memory/juce_ReferenceCountedObject.h View File

@@ -130,6 +130,9 @@ template <class ReferenceCountedObjectClass>
class ReferenceCountedObjectPtr
{
public:
/** The class being referenced by this pointer. */
typedef ReferenceCountedObjectClass ReferencedType;
//==============================================================================
/** Creates a pointer to a null object. */
inline ReferenceCountedObjectPtr() noexcept


+ 7
- 2
src/native/android/juce_android_Misc.cpp View File

@@ -37,6 +37,8 @@ JUCE_JNI_CALLBACK (JuceAppActivity, launchApp, void, (JNIEnv* env, jobject activ
{
android.initialise (env, activity, appFile, appDataDir);
DBG (SystemStats::getJUCEVersion());
JUCEApplication::createInstance = &juce_CreateApplication;
initialiseJuce_GUI();
@@ -60,8 +62,11 @@ void PlatformUtilities::beep()
//==============================================================================
void Logger::outputDebugString (const String& text)
{
getEnv()->CallStaticVoidMethod (android.activityClass, android.printToConsole,
javaString (text).get());
JNIEnv* const env = getEnv();
if (env != nullptr)
env->CallStaticVoidMethod (android.activityClass, android.printToConsole,
javaString (text).get());
}
//==============================================================================


+ 1
- 0
src/native/mac/juce_mac_NativeIncludes.h View File

@@ -69,6 +69,7 @@
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/utsname.h>
#include <fnmatch.h>
#include <utime.h>
#include <dlfcn.h>


+ 11
- 1
src/native/mac/juce_mac_SystemStats.mm View File

@@ -99,7 +99,17 @@ SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
const String SystemStats::getOperatingSystemName()
{
return "Mac OS X";
#if JUCE_IOS
String s ("iOS ");
#else
String s ("Mac OSX ");
#endif
struct utsname uts;
if (uname (&uts) >= 0)
s << uts.release;
return s;
}
#if ! JUCE_IOS


Loading…
Cancel
Save