Browse Source

Minor clean-ups.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
7c77e101fc
8 changed files with 58 additions and 68 deletions
  1. +0
    -2
      extras/Introjucer/Source/Project/jucer_AudioPluginModule.h
  2. +1
    -3
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  3. +1
    -4
      modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp
  4. +8
    -0
      modules/juce_core/memory/juce_ReferenceCountedObject.h
  5. +26
    -31
      modules/juce_events/timers/juce_Timer.cpp
  6. +7
    -3
      modules/juce_events/timers/juce_Timer.h
  7. +12
    -24
      modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp
  8. +3
    -1
      modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h

+ 0
- 2
extras/Introjucer/Source/Project/jucer_AudioPluginModule.h View File

@@ -378,8 +378,6 @@ namespace AUHelpers
JUCE_AU_PUBLIC "OtherBases/AUEffectBase.h",
JUCE_AU_PUBLIC "Utility/AUBuffer.cpp",
JUCE_AU_PUBLIC "Utility/AUBuffer.h",
JUCE_AU_PUBLIC "Utility/AUDebugDispatcher.cpp",
JUCE_AU_PUBLIC "Utility/AUDebugDispatcher.h",
JUCE_AU_PUBLIC "Utility/AUInputFormatConverter.h",
JUCE_AU_PUBLIC "Utility/AUSilentTimeout.h",
JUCE_AU_PUBLIC "Utility/AUTimestampGenerator.h", 0 };


+ 1
- 3
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -96,8 +96,6 @@ static bool recursionCheck = false;
static juce::uint32 lastMasterIdleCall = 0;
BEGIN_JUCE_NAMESPACE
extern void JUCE_API juce_callAnyTimersSynchronously();
#if JUCE_MAC
extern void initialiseMac();
extern void* attachComponentToWindowRef (Component* component, void* windowRef);
@@ -947,7 +945,7 @@ public:
recursionCheck = true;
JUCE_AUTORELEASEPOOL
juce_callAnyTimersSynchronously();
Timer::callPendingTimersSynchronously();
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
ComponentPeer::getPeer (i)->performAnyPendingRepaintsNow();


+ 1
- 4
modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp View File

@@ -79,9 +79,6 @@ BEGIN_JUCE_NAMESPACE
static void _clearfp() {}
#endif
extern void JUCE_API juce_callAnyTimersSynchronously();
//==============================================================================
const int fxbVersionNum = 1;
@@ -2247,7 +2244,7 @@ VstIntPtr VSTPluginInstance::handleCallback (VstInt32 opcode, VstInt32 index, Vs
dispatch (effEditIdle, 0, 0, 0, 0);
#endif
juce_callAnyTimersSynchronously();
Timer::callPendingTimersSynchronously();
handleUpdateNowIfNeeded();


+ 8
- 0
modules/juce_core/memory/juce_ReferenceCountedObject.h View File

@@ -105,6 +105,14 @@ protected:
jassert (getReferenceCount() == 0);
}
/** Resets the reference count to zero without deleting the object.
You should probably never need to use this!
*/
void resetReferenceCount() noexcept
{
refCount = 0;
}
private:
//==============================================================================
Atomic <int> refCount;


+ 26
- 31
modules/juce_events/timers/juce_Timer.cpp View File

@@ -26,15 +26,15 @@
BEGIN_JUCE_NAMESPACE
//==============================================================================
class InternalTimerThread : private Thread,
private MessageListener,
private DeletedAtShutdown,
private AsyncUpdater
class Timer::TimerThread : private Thread,
private MessageListener,
private DeletedAtShutdown,
private AsyncUpdater
{
public:
typedef CriticalSection LockType; // (mysteriously, using a SpinLock here causes problems on some XP machines..)
InternalTimerThread()
TimerThread()
: Thread ("Juce Timer"),
firstTimer (nullptr),
callbackNeeded (0)
@@ -42,7 +42,7 @@ public:
triggerAsyncUpdate();
}
~InternalTimerThread() noexcept
~TimerThread() noexcept
{
stopThread (4000);
@@ -158,16 +158,10 @@ public:
callTimers();
}
static void callAnyTimersSynchronously()
{
if (InternalTimerThread::instance != nullptr)
InternalTimerThread::instance->callTimersSynchronously();
}
static inline void add (Timer* const tim) noexcept
{
if (instance == nullptr)
instance = new InternalTimerThread();
instance = new TimerThread();
instance->addTimer (tim);
}
@@ -194,10 +188,10 @@ public:
}
}
private:
friend class Timer;
static InternalTimerThread* instance;
static TimerThread* instance;
static LockType lock;
private:
Timer* volatile firstTimer;
Atomic <int> callbackNeeded;
@@ -302,16 +296,11 @@ private:
startThread (7);
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InternalTimerThread);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimerThread);
};
InternalTimerThread* InternalTimerThread::instance = nullptr;
InternalTimerThread::LockType InternalTimerThread::lock;
void JUCE_API juce_callAnyTimersSynchronously()
{
InternalTimerThread::callAnyTimersSynchronously();
}
Timer::TimerThread* Timer::TimerThread::instance = nullptr;
Timer::TimerThread::LockType Timer::TimerThread::lock;
//==============================================================================
#if JUCE_DEBUG
@@ -325,7 +314,7 @@ Timer::Timer() noexcept
next (nullptr)
{
#if JUCE_DEBUG
const InternalTimerThread::LockType::ScopedLockType sl (InternalTimerThread::lock);
const TimerThread::LockType::ScopedLockType sl (TimerThread::lock);
activeTimers.add (this);
#endif
}
@@ -337,7 +326,7 @@ Timer::Timer (const Timer&) noexcept
next (nullptr)
{
#if JUCE_DEBUG
const InternalTimerThread::LockType::ScopedLockType sl (InternalTimerThread::lock);
const TimerThread::LockType::ScopedLockType sl (TimerThread::lock);
activeTimers.add (this);
#endif
}
@@ -353,7 +342,7 @@ Timer::~Timer()
void Timer::startTimer (const int interval) noexcept
{
const InternalTimerThread::LockType::ScopedLockType sl (InternalTimerThread::lock);
const TimerThread::LockType::ScopedLockType sl (TimerThread::lock);
#if JUCE_DEBUG
// this isn't a valid object! Your timer might be a dangling pointer or something..
@@ -364,17 +353,17 @@ void Timer::startTimer (const int interval) noexcept
{
countdownMs = interval;
periodMs = jmax (1, interval);
InternalTimerThread::add (this);
TimerThread::add (this);
}
else
{
InternalTimerThread::resetCounter (this, interval);
TimerThread::resetCounter (this, interval);
}
}
void Timer::stopTimer() noexcept
{
const InternalTimerThread::LockType::ScopedLockType sl (InternalTimerThread::lock);
const TimerThread::LockType::ScopedLockType sl (TimerThread::lock);
#if JUCE_DEBUG
// this isn't a valid object! Your timer might be a dangling pointer or something..
@@ -383,9 +372,15 @@ void Timer::stopTimer() noexcept
if (periodMs > 0)
{
InternalTimerThread::remove (this);
TimerThread::remove (this);
periodMs = 0;
}
}
void JUCE_CALLTYPE Timer::callPendingTimersSynchronously()
{
if (TimerThread::instance != nullptr)
TimerThread::instance->callTimersSynchronously();
}
END_JUCE_NAMESPACE

+ 7
- 3
modules/juce_events/timers/juce_Timer.h View File

@@ -26,8 +26,6 @@
#ifndef __JUCE_TIMER_JUCEHEADER__
#define __JUCE_TIMER_JUCEHEADER__
class InternalTimerThread;
//==============================================================================
/**
@@ -119,8 +117,14 @@ public:
//==============================================================================
/** For internal use only: invokes any timers that need callbacks.
Don't call this unless you really know what you're doing!
*/
static void JUCE_CALLTYPE callPendingTimersSynchronously();
private:
friend class InternalTimerThread;
class TimerThread;
friend class TimerThread;
int countdownMs, periodMs;
Timer* previous;
Timer* next;


+ 12
- 24
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp View File

@@ -164,8 +164,7 @@ public:
glTexParameterf (textureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf (textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
textureType, textureID, 0);
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, textureType, textureID, 0);
if (wantsDepthBuffer || wantsStencilBuffer)
{
@@ -222,25 +221,6 @@ public:
bool bind() { return bind (frameBufferHandle); }
bool unbind() { return bind (0); }
/*Image createImage()
{
Image im;
if (ok)
{
bind();
im = Image (Image::ARGB, width, height, true);
Image::BitmapData data (im, Image::BitmapData::writeOnly);
glReadPixels (0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data.data);
unbind();
}
return im;
}*/
const int width, height;
GLuint textureID, frameBufferHandle, depthOrStencilBuffer;
bool hasDepthBuffer, hasStencilBuffer, ok;
@@ -298,10 +278,9 @@ int OpenGLFrameBuffer::getWidth() const noexcept { return pimpl != nu
int OpenGLFrameBuffer::getHeight() const noexcept { return pimpl != nullptr ? pimpl->height : 0; }
GLuint OpenGLFrameBuffer::getTextureID() const noexcept { return pimpl != nullptr ? pimpl->textureID : 0; }
void OpenGLFrameBuffer::makeCurrentTarget()
bool OpenGLFrameBuffer::makeCurrentTarget()
{
if (pimpl != nullptr)
pimpl->bind();
return pimpl != nullptr && pimpl->bind();
}
void OpenGLFrameBuffer::releaseCurrentTarget()
@@ -310,4 +289,13 @@ void OpenGLFrameBuffer::releaseCurrentTarget()
pimpl->unbind();
}
void OpenGLFrameBuffer::clear (const Colour& colour)
{
if (makeCurrentTarget())
{
OpenGLHelpers::clear (colour);
releaseCurrentTarget();
}
}
END_JUCE_NAMESPACE

+ 3
- 1
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h View File

@@ -66,11 +66,13 @@ public:
//==============================================================================
/** Selects this buffer as the current OpenGL rendering target. */
void makeCurrentTarget();
bool makeCurrentTarget();
/** Deselects this buffer as the current OpenGL rendering target. */
void releaseCurrentTarget();
void clear (const Colour& colour);
private:
class Pimpl;
friend class ScopedPointer<Pimpl>;


Loading…
Cancel
Save