Browse Source

Cherry-pick a commit from juce upstream

tags/2018-04-16
falkTX 6 years ago
parent
commit
7963c05742
10 changed files with 42 additions and 24 deletions
  1. +12
    -8
      libs/juce/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp
  2. +1
    -1
      libs/juce/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h
  3. +1
    -1
      libs/juce/source/modules/juce_core/threads/juce_SpinLock.h
  4. +4
    -4
      libs/juce/source/modules/juce_events/messages/juce_MessageManager.cpp
  5. +2
    -2
      libs/juce/source/modules/juce_events/messages/juce_MessageManager.h
  6. +3
    -3
      libs/juce/source/modules/juce_events/native/juce_ios_MessageManager.mm
  7. +3
    -3
      libs/juce/source/modules/juce_events/native/juce_mac_MessageManager.mm
  8. +7
    -0
      libs/juce/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp
  9. +1
    -1
      libs/juce/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h
  10. +8
    -1
      libs/juce/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp

+ 12
- 8
libs/juce/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp View File

@@ -928,6 +928,8 @@ AudioDeviceManager::LevelMeter::LevelMeter() noexcept : level() {}
void AudioDeviceManager::LevelMeter::updateLevel (const float* const* channelData, int numChannels, int numSamples) noexcept
{
auto localLevel = level.get();
if (enabled.get() != 0 && numChannels > 0)
{
for (int j = 0; j < numSamples; ++j)
@@ -939,20 +941,22 @@ void AudioDeviceManager::LevelMeter::updateLevel (const float* const* channelDat
s /= (float) numChannels;
const double decayFactor = 0.99992;
const float decayFactor = 0.99992f;
if (s > level)
level = s;
else if (level > 0.001f)
level *= decayFactor;
if (s > localLevel)
localLevel = s;
else if (localLevel > 0.001f)
localLevel *= decayFactor;
else
level = 0;
localLevel = 0;
}
}
else
{
level = 0;
localLevel = 0;
}
level = localLevel;
}
void AudioDeviceManager::LevelMeter::setEnabled (bool shouldBeEnabled) noexcept
@@ -964,7 +968,7 @@ void AudioDeviceManager::LevelMeter::setEnabled (bool shouldBeEnabled) noexcept
double AudioDeviceManager::LevelMeter::getCurrentLevel() const noexcept
{
jassert (enabled.get() != 0); // you need to call setEnabled (true) before using this!
return level;
return level.get();
}
void AudioDeviceManager::playTestSound()


+ 1
- 1
libs/juce/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h View File

@@ -488,7 +488,7 @@ private:
double getCurrentLevel() const noexcept;
Atomic<int> enabled;
double level;
Atomic<float> level;
};
LevelMeter inputLevelMeter, outputLevelMeter;


+ 1
- 1
libs/juce/source/modules/juce_core/threads/juce_SpinLock.h View File

@@ -62,7 +62,7 @@ public:
/** Releases the lock. */
inline void exit() const noexcept
{
jassert (lock.value == 1); // Agh! Releasing a lock that isn't currently held!
jassert (lock.get() == 1); // Agh! Releasing a lock that isn't currently held!
lock = 0;
}


+ 4
- 4
libs/juce/source/modules/juce_events/messages/juce_MessageManager.cpp View File

@@ -68,7 +68,7 @@ bool MessageManager::MessageBase::post()
{
auto* mm = MessageManager::instance;
if (mm == nullptr || mm->quitMessagePosted || ! postMessageToSystemQueue (this))
if (mm == nullptr || mm->quitMessagePosted.get() != 0 || ! postMessageToSystemQueue (this))
{
Ptr deleter (this); // (this will delete messages that were just created with a 0 ref count)
return false;
@@ -85,7 +85,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
const int64 endTime = Time::currentTimeMillis() + millisecondsToRunFor;
while (! quitMessageReceived)
while (quitMessageReceived.get() == 0)
{
JUCE_TRY
{
@@ -98,7 +98,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
break;
}
return ! quitMessageReceived;
return quitMessageReceived.get() == 0;
}
#endif
@@ -121,7 +121,7 @@ void MessageManager::runDispatchLoop()
{
jassert (isThisTheMessageThread()); // must only be called by the message thread
while (! quitMessageReceived)
while (quitMessageReceived.get() == 0)
{
JUCE_TRY
{


+ 2
- 2
libs/juce/source/modules/juce_events/messages/juce_MessageManager.h View File

@@ -80,7 +80,7 @@ public:
/** Returns true if the stopDispatchLoop() method has been called.
*/
bool hasStopMessageBeenSent() const noexcept { return quitMessagePosted; }
bool hasStopMessageBeenSent() const noexcept { return quitMessagePosted.get() != 0; }
#if JUCE_MODAL_LOOPS_PERMITTED || DOXYGEN
/** Synchronously dispatches messages until a given time has elapsed.
@@ -205,7 +205,7 @@ private:
friend class MessageManagerLock;
ScopedPointer<ActionBroadcaster> broadcaster;
bool quitMessagePosted = false, quitMessageReceived = false;
Atomic<int> quitMessagePosted { 0 }, quitMessageReceived { 0 };
Thread::ThreadID messageThreadId;
Thread::ThreadID volatile threadWithLock = {};
CriticalSection lockingLock;


+ 3
- 3
libs/juce/source/modules/juce_events/native/juce_ios_MessageManager.mm View File

@@ -27,7 +27,7 @@ void MessageManager::runDispatchLoop()
{
jassert (isThisTheMessageThread()); // must only be called by the message thread
while (! quitMessagePosted)
while (quitMessagePosted.get() == 0)
{
JUCE_AUTORELEASEPOOL
{
@@ -55,7 +55,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
uint32 startTime = Time::getMillisecondCounter();
NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001];
while (! quitMessagePosted)
while (quitMessagePosted.get() == 0)
{
JUCE_AUTORELEASEPOOL
{
@@ -68,7 +68,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
}
}
return ! quitMessagePosted;
return quitMessagePosted.get() == 0;
}
}
#endif


+ 3
- 3
libs/juce/source/modules/juce_events/native/juce_mac_MessageManager.mm View File

@@ -222,7 +222,7 @@ private:
//==============================================================================
void MessageManager::runDispatchLoop()
{
if (! quitMessagePosted) // check that the quit message wasn't already posted..
if (quitMessagePosted.get() == 0) // check that the quit message wasn't already posted..
{
JUCE_AUTORELEASEPOOL
{
@@ -292,7 +292,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
uint32 endTime = Time::getMillisecondCounter() + (uint32) millisecondsToRunFor;
while (! quitMessagePosted)
while (quitMessagePosted.get() == 0)
{
JUCE_AUTORELEASEPOOL
{
@@ -311,7 +311,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
}
}
return ! quitMessagePosted;
return quitMessagePosted.get() == 0;
}
#endif


+ 7
- 0
libs/juce/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp View File

@@ -120,6 +120,13 @@ void DirectoryContentsList::setFileFilter (const FileFilter* newFileFilter)
}
//==============================================================================
int DirectoryContentsList::getNumFiles() const noexcept
{
const ScopedLock sl (fileListLock);
return files.size();
}
bool DirectoryContentsList::getFileInfo (const int index, FileInfo& result) const
{
const ScopedLock sl (fileListLock);


+ 1
- 1
libs/juce/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h View File

@@ -163,7 +163,7 @@ public:
@see getFileInfo, getFile
*/
int getNumFiles() const noexcept { return files.size(); }
int getNumFiles() const noexcept;
/** Returns the cached information about one of the files in the list.


+ 8
- 1
libs/juce/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp View File

@@ -177,6 +177,8 @@ public:
void paintItem (Graphics& g, int width, int height) override
{
ScopedLock lock (iconUpdate);
if (file != File())
{
updateIcon (true);
@@ -229,6 +231,7 @@ private:
OptionalScopedPointer<DirectoryContentsList> subContentsList;
bool isDirectory;
TimeSliceThread& thread;
CriticalSection iconUpdate;
Image icon;
String fileSize, modTime;
@@ -249,7 +252,11 @@ private:
if (im.isValid())
{
icon = im;
{
ScopedLock lock (iconUpdate);
icon = im;
}
triggerAsyncUpdate();
}
}


Loading…
Cancel
Save