Browse Source

64-bit VST tweaks. Removed leak warnings for messages.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
f73d602b45
13 changed files with 158 additions and 149 deletions
  1. +27
    -19
      extras/Introjucer/Source/Project/jucer_ResourceFile.cpp
  2. +7
    -1
      extras/Introjucer/Source/Project/jucer_ResourceFile.h
  3. +10
    -0
      extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp
  4. +1
    -0
      extras/Introjucer/Source/Utility/jucer_CodeHelpers.h
  5. +2
    -0
      extras/audio plugins/wrapper/RTAS/juce_RTAS_MacUtilities.mm
  6. +47
    -11
      extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm
  7. +25
    -56
      juce_amalgamated.cpp
  8. +7
    -3
      juce_amalgamated.h
  9. +5
    -5
      src/containers/juce_Variant.cpp
  10. +1
    -1
      src/core/juce_StandardHeader.h
  11. +20
    -51
      src/core/juce_Time.cpp
  12. +3
    -1
      src/events/juce_CallbackMessage.h
  13. +3
    -1
      src/events/juce_Message.h

+ 27
- 19
extras/Introjucer/Source/Project/jucer_ResourceFile.cpp View File

@@ -87,7 +87,28 @@ void ResourceFile::setClassName (const String& className_)
void ResourceFile::addFile (const File& file)
{
files.add (new File (file));
files.add (file);
const String variableNameRoot (CodeHelpers::makeBinaryDataIdentifierName (file));
String variableName (variableNameRoot);
int suffix = 2;
while (variableNames.contains (variableName))
variableName = variableNameRoot + String (suffix++);
variableNames.add (variableName);
}
const String ResourceFile::getDataVariableFor (const File& file) const
{
jassert (files.indexOf (file) >= 0);
return variableNames [files.indexOf (file)];
}
const String ResourceFile::getSizeVariableFor (const File& file) const
{
jassert (files.indexOf (file) >= 0);
return variableNames [files.indexOf (file)] + "Size";
}
int64 ResourceFile::getTotalDataSize() const
@@ -95,7 +116,7 @@ int64 ResourceFile::getTotalDataSize() const
int64 total = 0;
for (int i = 0; i < files.size(); ++i)
total += files.getUnchecked(i)->getSize();
total += files.getReference(i).getSize();
return total;
}
@@ -118,25 +139,12 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream&
header << CodeHelpers::createIncludeStatement (juceHeader, cppFile) << newLine;
const String namespaceName (className);
StringArray variableNames, returnCodes;
StringArray returnCodes;
int i;
for (i = 0; i < files.size(); ++i)
{
String variableNameRoot (CodeHelpers::makeValidIdentifier (files.getUnchecked(i)->getFileName()
.replaceCharacters (" .", "__")
.retainCharacters ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"),
false, true, false));
String variableName (variableNameRoot);
int suffix = 2;
while (variableNames.contains (variableName))
variableName = variableNameRoot + String (suffix++);
variableNames.add (variableName);
returnCodes.add ("numBytes = " + namespaceName + "::" + variableName + "Size; return "
+ namespaceName + "::" + variableName + ";");
}
returnCodes.add ("numBytes = " + namespaceName + "::" + variableNames[i] + "Size; return "
+ namespaceName + "::" + variableNames[i] + ";");
cpp << CodeHelpers::createIncludeStatement (cppFile.withFileExtension (".h"), cppFile) << newLine
<< newLine
@@ -155,7 +163,7 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream&
for (i = 0; i < files.size(); ++i)
{
const File file (*files.getUnchecked(i));
const File& file = files.getReference(i);
const int64 dataSize = file.getSize();
ScopedPointer <InputStream> fileStream (file.createInputStream());


+ 7
- 1
extras/Introjucer/Source/Project/jucer_ResourceFile.h View File

@@ -43,8 +43,13 @@ public:
//==============================================================================
void setJuceHeaderToInclude (const File& header);
void setClassName (const String& className);
const String getClassName() const { return className; }
void addFile (const File& file);
const String getDataVariableFor (const File& file) const;
const String getSizeVariableFor (const File& file) const;
int getNumFiles() const { return files.size(); }
int64 getTotalDataSize() const;
@@ -54,7 +59,8 @@ public:
//==============================================================================
private:
OwnedArray <File> files;
Array<File> files;
StringArray variableNames;
Project& project;
File juceHeader;
String className;


+ 10
- 0
extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp View File

@@ -186,6 +186,14 @@ namespace CodeHelpers
+ "_" + String::toHexString (file.hashCode()).toUpperCase() + "__";
}
const String makeBinaryDataIdentifierName (const File& file)
{
return makeValidIdentifier (file.getFileName()
.replaceCharacters (" .", "__")
.retainCharacters ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"),
false, true, false);
}
const String stringLiteral (const String& text)
{
if (text.isEmpty())
@@ -344,6 +352,8 @@ namespace CodeHelpers
s << ", Font::bold";
else if (font.isItalic())
s << ", Font::italic";
else if (name != Font::getDefaultSansSerifFontName()) // need this param if we're using the typeface name constructor
s << ", Font::plain";
return s + ")";
}


+ 1
- 0
extras/Introjucer/Source/Utility/jucer_CodeHelpers.h View File

@@ -35,6 +35,7 @@ namespace CodeHelpers
const String addEscapeChars (const String& text);
const String createIncludeStatement (const File& includeFile, const File& targetFile);
const String makeHeaderGuardName (const File& file);
const String makeBinaryDataIdentifierName (const File& file);
const String stringLiteral (const String& text);
const String stringLiteralIfNotEmpty (const String& text); // if the string's empty, this returns an empty string


+ 2
- 0
extras/audio plugins/wrapper/RTAS/juce_RTAS_MacUtilities.mm View File

@@ -45,7 +45,9 @@
//==============================================================================
void initialiseMacRTAS()
{
#if ! JUCE_64BIT
NSApplicationLoad();
#endif
}
void* attachSubWindow (void* hostWindowRef, Component* comp)


+ 47
- 11
extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm View File

@@ -34,7 +34,9 @@
#include "../juce_PluginHeaders.h"
#include "../juce_PluginHostType.h"
#define ADD_CARBON_BODGE 1 // see note below..
#if ! (JUCE_64BIT || defined (ADD_CARBON_BODGE))
#define ADD_CARBON_BODGE 1 // see note below..
#endif
//==============================================================================
BEGIN_JUCE_NAMESPACE
@@ -93,13 +95,27 @@ static pascal OSStatus viewBoundsChangedEvent (EventHandlerCallRef, EventRef, vo
//==============================================================================
void initialiseMac()
{
#if ! JUCE_64BIT
NSApplicationLoad();
#endif
}
void* attachComponentToWindowRef (Component* comp, void* windowRef)
{
JUCE_AUTORELEASEPOOL
#if JUCE_64BIT
NSView* parentView = (NSView*) windowRef;
#if JucePlugin_EditorRequiresKeyboardFocus
comp->addToDesktop (0, parentView);
#else
comp->addToDesktop (ComponentPeer::windowIgnoresKeyPresses, parentView);
#endif
[[parentView window] setAcceptsMouseMovedEvents: YES];
return parentView;
#else
NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef];
[hostWindow retain];
[hostWindow setCanHide: YES];
@@ -141,11 +157,11 @@ void* attachComponentToWindowRef (Component* comp, void* windowRef)
updateComponentPos (comp);
#if ! JucePlugin_EditorRequiresKeyboardFocus
#if ! JucePlugin_EditorRequiresKeyboardFocus
comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses);
#else
#else
comp->addToDesktop (ComponentPeer::windowIsTemporary);
#endif
#endif
comp->setVisible (true);
comp->toFront (false);
@@ -160,7 +176,7 @@ void* attachComponentToWindowRef (Component* comp, void* windowRef)
[hostWindow orderFront: nil];
[pluginWindow orderFront: nil];
#if ADD_CARBON_BODGE
#if ADD_CARBON_BODGE
{
// Adds a callback bodge to work around some problems with wrapped
// carbon windows..
@@ -176,14 +192,17 @@ void* attachComponentToWindowRef (Component* comp, void* windowRef)
(void*) hostWindow, &ref);
comp->getProperties().set ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref));
}
#endif
#endif
return hostWindow;
#endif
}
void detachComponentFromWindowRef (Component* comp, void* nsWindow)
{
#if JUCE_64BIT
comp->removeFromDesktop();
#else
{
JUCE_AUTORELEASEPOOL
@@ -191,11 +210,11 @@ void detachComponentFromWindowRef (Component* comp, void* nsWindow)
comp->getProperties() ["boundsEventRef"].toString().getHexValue64();
RemoveEventHandler (ref);
#if ADD_CARBON_BODGE
#if ADD_CARBON_BODGE
ref = (EventHandlerRef) (void*) (pointer_sized_int)
comp->getProperties() ["carbonEventRef"].toString().getHexValue64();
RemoveEventHandler (ref);
#endif
#endif
HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int)
comp->getProperties() ["dummyViewRef"].toString().getHexValue64();
@@ -220,15 +239,25 @@ void detachComponentFromWindowRef (Component* comp, void* nsWindow)
// how many messages will be dispatched, which seems to be vital in Reaper)
for (int i = 20; --i >= 0;)
MessageManager::getInstance()->runDispatchLoopUntil (1);
#endif
}
void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, const PluginHostType& host)
{
JUCE_AUTORELEASEPOOL
#if JUCE_64BIT
NSView* hostView = (NSView*) nsWindow;
if (hostView != 0)
{
// xxx is this necessary, or do the hosts detect a change in the child view and do this automatically?
[hostView setSize: NSMakeSize ([hostView size].width + (newWidth - component->getWidth()),
[hostView size].height + (newHeight - component->getHeight()))];
}
#else
NSWindow* hostWindow = (NSWindow*) nsWindow;
if (hostWindow != 0)
{
JUCE_AUTORELEASEPOOL
// Can't use the cocoa NSWindow resizing code, or it messes up in Live.
Rect r;
GetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r);
@@ -239,19 +268,26 @@ void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth
r.left = r.top = 0;
InvalWindowRect ((WindowRef) [hostWindow windowRef], &r);
}
#endif
}
void checkWindowVisibility (void* nsWindow, Component* comp)
{
#if JUCE_64BIT
NSView* hostWindow = (NSView*) nsWindow;
#else
NSWindow* hostWindow = (NSWindow*) nsWindow;
#endif
comp->setVisible ([hostWindow isVisible]);
}
void forwardCurrentKeyEventToHost (Component* comp)
{
#if ! JUCE_64BIT
NSWindow* win = [(NSView*) comp->getWindowHandle() window];
[[win parentWindow] makeKeyWindow];
[NSApp postEvent: [NSApp currentEvent] atStart: YES];
#endif
}


+ 25
- 56
juce_amalgamated.cpp View File

@@ -1884,20 +1884,20 @@ int64 Time::currentTimeMillis() throw()
{
// get the time once using normal library calls, and store the difference needed to
// turn the millisecond counter into a real time.
#if JUCE_WINDOWS
#if JUCE_WINDOWS
struct _timeb t;
#ifdef USE_NEW_SECURE_TIME_FNS
#ifdef USE_NEW_SECURE_TIME_FNS
_ftime_s (&t);
#else
#else
_ftime (&t);
#endif
#endif
correction = (((int64) t.time) * 1000 + t.millitm) - now;
#else
#else
struct timeval tv;
struct timezone tz;
gettimeofday (&tv, &tz);
correction = (((int64) tv.tv_sec) * 1000 + tv.tv_usec / 1000) - now;
#endif
#endif
}
}

@@ -2027,30 +2027,14 @@ const String Time::formatted (const String& format) const
return CharPointer_UTF32 (buffer.getData());
}

int Time::getYear() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_year + 1900;
}

int Time::getMonth() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mon;
}

int Time::getDayOfMonth() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mday;
}

int Time::getDayOfWeek() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_wday;
}

int Time::getHours() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_hour;
}
int Time::getYear() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_year + 1900; }
int Time::getMonth() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mon; }
int Time::getDayOfMonth() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mday; }
int Time::getDayOfWeek() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_wday; }
int Time::getHours() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_hour; }
int Time::getMinutes() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_min; }
int Time::getSeconds() const throw() { return TimeHelpers::extendedModulo (millisSinceEpoch / 1000, 60); }
int Time::getMilliseconds() const throw() { return TimeHelpers::extendedModulo (millisSinceEpoch, 1000); }

int Time::getHoursInAmPmFormat() const throw()
{
@@ -2069,21 +2053,6 @@ bool Time::isAfternoon() const throw()
return getHours() >= 12;
}

int Time::getMinutes() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_min;
}

int Time::getSeconds() const throw()
{
return TimeHelpers::extendedModulo (millisSinceEpoch / 1000, 60);
}

int Time::getMilliseconds() const throw()
{
return TimeHelpers::extendedModulo (millisSinceEpoch, 1000);
}

bool Time::isDaylightSavingTime() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_isdst != 0;
@@ -2093,10 +2062,10 @@ const String Time::getTimeZone() const throw()
{
String zone[2];

#if JUCE_WINDOWS
#if JUCE_WINDOWS
_tzset();

#ifdef USE_NEW_SECURE_TIME_FNS
#ifdef USE_NEW_SECURE_TIME_FNS
for (int i = 0; i < 2; ++i)
{
char name[128] = { 0 };
@@ -2104,17 +2073,17 @@ const String Time::getTimeZone() const throw()
_get_tzname (&length, name, 127, i);
zone[i] = name;
}
#else
#else
const char** const zonePtr = (const char**) _tzname;
zone[0] = zonePtr[0];
zone[1] = zonePtr[1];
#endif
#else
#endif
#else
tzset();
const char** const zonePtr = (const char**) tzname;
zone[0] = zonePtr[0];
zone[1] = zonePtr[1];
#endif
#endif

if (isDaylightSavingTime())
{
@@ -4193,12 +4162,12 @@ BEGIN_JUCE_NAMESPACE

enum VariantStreamMarkers
{
varMarker_Int = 1,
varMarker_BoolTrue = 2,
varMarker_Int = 1,
varMarker_BoolTrue = 2,
varMarker_BoolFalse = 3,
varMarker_Double = 4,
varMarker_String = 5,
varMarker_Int64 = 6
varMarker_Double = 4,
varMarker_String = 5,
varMarker_Int64 = 6
};

class var::VariantType


+ 7
- 3
juce_amalgamated.h View File

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

/** Current Juce version number.

@@ -15630,7 +15630,9 @@ private:
friend class MessageManager;
MessageListener* messageRecipient;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Message);
// Avoid the leak-detector because for plugins, the host can unload our DLL with undelivered
// messages still in the system event queue. These aren't harmful, but can cause annoying assertions.
JUCE_DECLARE_NON_COPYABLE (Message);
};

#endif // __JUCE_MESSAGE_JUCEHEADER__
@@ -15681,7 +15683,9 @@ public:

private:

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CallbackMessage);
// Avoid the leak-detector because for plugins, the host can unload our DLL with undelivered
// messages still in the system event queue. These aren't harmful, but can cause annoying assertions.
JUCE_DECLARE_NON_COPYABLE (CallbackMessage);
};

#endif // __JUCE_CALLBACKMESSAGE_JUCEHEADER__


+ 5
- 5
src/containers/juce_Variant.cpp View File

@@ -33,12 +33,12 @@ BEGIN_JUCE_NAMESPACE
enum VariantStreamMarkers
{
varMarker_Int = 1,
varMarker_BoolTrue = 2,
varMarker_Int = 1,
varMarker_BoolTrue = 2,
varMarker_BoolFalse = 3,
varMarker_Double = 4,
varMarker_String = 5,
varMarker_Int64 = 6
varMarker_Double = 4,
varMarker_String = 5,
varMarker_Int64 = 6
};
//==============================================================================


+ 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 66
#define JUCE_BUILDNUMBER 67
/** Current Juce version number.


+ 20
- 51
src/core/juce_Time.cpp View File

@@ -229,20 +229,20 @@ int64 Time::currentTimeMillis() throw()
{
// get the time once using normal library calls, and store the difference needed to
// turn the millisecond counter into a real time.
#if JUCE_WINDOWS
#if JUCE_WINDOWS
struct _timeb t;
#ifdef USE_NEW_SECURE_TIME_FNS
#ifdef USE_NEW_SECURE_TIME_FNS
_ftime_s (&t);
#else
#else
_ftime (&t);
#endif
#endif
correction = (((int64) t.time) * 1000 + t.millitm) - now;
#else
#else
struct timeval tv;
struct timezone tz;
gettimeofday (&tv, &tz);
correction = (((int64) tv.tv_sec) * 1000 + tv.tv_usec / 1000) - now;
#endif
#endif
}
}
@@ -378,30 +378,14 @@ const String Time::formatted (const String& format) const
}
//==============================================================================
int Time::getYear() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_year + 1900;
}
int Time::getMonth() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mon;
}
int Time::getDayOfMonth() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mday;
}
int Time::getDayOfWeek() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_wday;
}
int Time::getHours() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_hour;
}
int Time::getYear() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_year + 1900; }
int Time::getMonth() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mon; }
int Time::getDayOfMonth() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mday; }
int Time::getDayOfWeek() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_wday; }
int Time::getHours() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_hour; }
int Time::getMinutes() const throw() { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_min; }
int Time::getSeconds() const throw() { return TimeHelpers::extendedModulo (millisSinceEpoch / 1000, 60); }
int Time::getMilliseconds() const throw() { return TimeHelpers::extendedModulo (millisSinceEpoch, 1000); }
int Time::getHoursInAmPmFormat() const throw()
{
@@ -420,21 +404,6 @@ bool Time::isAfternoon() const throw()
return getHours() >= 12;
}
int Time::getMinutes() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_min;
}
int Time::getSeconds() const throw()
{
return TimeHelpers::extendedModulo (millisSinceEpoch / 1000, 60);
}
int Time::getMilliseconds() const throw()
{
return TimeHelpers::extendedModulo (millisSinceEpoch, 1000);
}
bool Time::isDaylightSavingTime() const throw()
{
return TimeHelpers::millisToLocal (millisSinceEpoch).tm_isdst != 0;
@@ -444,10 +413,10 @@ const String Time::getTimeZone() const throw()
{
String zone[2];
#if JUCE_WINDOWS
#if JUCE_WINDOWS
_tzset();
#ifdef USE_NEW_SECURE_TIME_FNS
#ifdef USE_NEW_SECURE_TIME_FNS
for (int i = 0; i < 2; ++i)
{
char name[128] = { 0 };
@@ -455,17 +424,17 @@ const String Time::getTimeZone() const throw()
_get_tzname (&length, name, 127, i);
zone[i] = name;
}
#else
#else
const char** const zonePtr = (const char**) _tzname;
zone[0] = zonePtr[0];
zone[1] = zonePtr[1];
#endif
#else
#endif
#else
tzset();
const char** const zonePtr = (const char**) tzname;
zone[0] = zonePtr[0];
zone[1] = zonePtr[1];
#endif
#endif
if (isDaylightSavingTime())
{


+ 3
- 1
src/events/juce_CallbackMessage.h View File

@@ -76,7 +76,9 @@ public:
private:
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CallbackMessage);
// Avoid the leak-detector because for plugins, the host can unload our DLL with undelivered
// messages still in the system event queue. These aren't harmful, but can cause annoying assertions.
JUCE_DECLARE_NON_COPYABLE (CallbackMessage);
};


+ 3
- 1
src/events/juce_Message.h View File

@@ -81,7 +81,9 @@ private:
friend class MessageManager;
MessageListener* messageRecipient;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Message);
// Avoid the leak-detector because for plugins, the host can unload our DLL with undelivered
// messages still in the system event queue. These aren't harmful, but can cause annoying assertions.
JUCE_DECLARE_NON_COPYABLE (Message);
};


Loading…
Cancel
Save