mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
A handful of small fixes and whitespace clean-ups. Added a parameter to the DatagramSocket::read to specify whether the operation should block.
This commit is contained in:
parent
0b1b03a324
commit
787a4e6de9
17 changed files with 1490 additions and 1469 deletions
|
|
@ -55,7 +55,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../../../src/juce_core/io/files/juce_FileOutputStream.h"
|
||||
#include "../../../src/juce_core/basics/juce_SystemStats.h"
|
||||
#include "../../../src/juce_core/basics/juce_Time.h"
|
||||
#include "../../../src/juce_core/basics/juce_Random.h"
|
||||
#include "../../../src/juce_core/basics/juce_Random.h"
|
||||
#include "../../../src/juce_core/io/network/juce_URL.h"
|
||||
#include "../../../src/juce_core/io/files/juce_NamedPipe.h"
|
||||
#include "../../../src/juce_core/threads/juce_InterProcessLock.h"
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ public:
|
|||
virtual NSRect constrainRect (NSRect r);
|
||||
|
||||
static void showArrowCursorIfNeeded();
|
||||
|
||||
|
||||
//==============================================================================
|
||||
virtual void viewFocusGain();
|
||||
virtual void viewFocusLoss();
|
||||
|
|
@ -636,7 +636,9 @@ static int getKeyCodeFromEvent (NSEvent* ev)
|
|||
int keyCode = unmodified[0];
|
||||
|
||||
if (keyCode == 0x19) // (backwards-tab)
|
||||
keyCode = 9;
|
||||
keyCode = '\t';
|
||||
else if (keyCode == 0x03) // (enter)
|
||||
keyCode = '\r';
|
||||
|
||||
return keyCode;
|
||||
}
|
||||
|
|
@ -1296,7 +1298,7 @@ void NSViewComponentPeer::showArrowCursorIfNeeded()
|
|||
{
|
||||
int mx, my;
|
||||
Desktop::getInstance().getMousePosition (mx, my);
|
||||
|
||||
|
||||
if (Desktop::getInstance().findComponentAt (mx, my) == 0)
|
||||
[[NSCursor arrowCursor] set];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,7 +203,6 @@ public:
|
|||
: Thread (T("http connection")),
|
||||
owner (owner_)
|
||||
{
|
||||
startThread();
|
||||
}
|
||||
|
||||
~JuceURLConnectionMessageThread()
|
||||
|
|
@ -241,6 +240,7 @@ public:
|
|||
hasFinished = false;
|
||||
|
||||
runLoopThread = new JuceURLConnectionMessageThread (self);
|
||||
runLoopThread->startThread();
|
||||
|
||||
while (runLoopThread->isThreadRunning() && ! initialised)
|
||||
{
|
||||
|
|
@ -268,7 +268,7 @@ public:
|
|||
- (void) createConnection
|
||||
{
|
||||
connection = [[NSURLConnection alloc] initWithRequest: request
|
||||
delegate: self];
|
||||
delegate: [self retain]];
|
||||
|
||||
if (connection == nil)
|
||||
runLoopThread->signalThreadShouldExit();
|
||||
|
|
|
|||
|
|
@ -402,9 +402,9 @@ const String juce_getOutputFromCommand (const String& command)
|
|||
// slight bodge here, as we just pipe the output into a temp file and read it...
|
||||
const File tempFile (File::getSpecialLocation (File::tempDirectory)
|
||||
.getNonexistentChildFile (String::toHexString (Random::getSystemRandom().nextInt()), ".tmp", false));
|
||||
|
||||
|
||||
juce_runSystemCommand (command + " > " + tempFile.getFullPathName());
|
||||
|
||||
|
||||
String result (tempFile.loadFileAsString());
|
||||
tempFile.deleteFile();
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ static void* callFunctionIfNotLocked (MessageCallbackFunction* callback, void* u
|
|||
if (MessageManager::getInstance()->currentThreadHasLockedMessageManager())
|
||||
return callback (userData);
|
||||
else
|
||||
MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData);
|
||||
return MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -990,7 +990,7 @@ public:
|
|||
// must check this as often as possible, because this is
|
||||
// how we know if the user's pressed 'cancel'
|
||||
if (threadShouldExit())
|
||||
break;
|
||||
return;
|
||||
|
||||
// this will update the progress bar on the dialog box
|
||||
setProgress (i / (double) thingsToDo);
|
||||
|
|
@ -1002,7 +1002,7 @@ public:
|
|||
|
||||
setProgress (-1.0); // setting a value beyond the range 0 -> 1 will show a spinning bar..
|
||||
setStatusMessage (T("Finishing off the last few bits and pieces!"));
|
||||
wait (3000);
|
||||
wait (2000);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -164,7 +164,7 @@ const AudioSampleBuffer& AudioSampleBuffer::operator= (const AudioSampleBuffer&
|
|||
AudioSampleBuffer::~AudioSampleBuffer() throw()
|
||||
{
|
||||
juce_free (allocatedData);
|
||||
|
||||
|
||||
if (channels != (float**) preallocatedChannelSpace)
|
||||
juce_free (channels);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,13 @@ public:
|
|||
float* getSampleData (const int channelNumber,
|
||||
const int sampleOffset = 0) const throw();
|
||||
|
||||
/** Returns an array of pointers to the channels in the buffer.
|
||||
|
||||
Don't modify any of the pointers that are returned, and bear in mind that
|
||||
these will become invalid if the buffer is resized.
|
||||
*/
|
||||
float** getArrayOfChannels() const throw() { return channels; }
|
||||
|
||||
//==============================================================================
|
||||
/** Chages the buffer's size or number of channels.
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ bool InterprocessConnection::readNextMessageInt()
|
|||
const int maximumMessageSize = 1024 * 1024 * 10; // sanity check
|
||||
|
||||
uint32 messageHeader[2];
|
||||
const int bytes = (socket != 0) ? socket->read (messageHeader, sizeof (messageHeader))
|
||||
const int bytes = (socket != 0) ? socket->read (messageHeader, sizeof (messageHeader), true)
|
||||
: pipe->read (messageHeader, sizeof (messageHeader), pipeReceiveMessageTimeout);
|
||||
|
||||
if (bytes == sizeof (messageHeader)
|
||||
|
|
@ -308,7 +308,7 @@ bool InterprocessConnection::readNextMessageInt()
|
|||
return false;
|
||||
|
||||
const int numThisTime = jmin (bytesInMessage, 65536);
|
||||
const int bytesIn = (socket != 0) ? socket->read (((char*) messageData.getData()) + bytesRead, numThisTime)
|
||||
const int bytesIn = (socket != 0) ? socket->read (((char*) messageData.getData()) + bytesRead, numThisTime, true)
|
||||
: pipe->read (((char*) messageData.getData()) + bytesRead, numThisTime,
|
||||
pipeReceiveMessageTimeout);
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ void ProgressBar::timerCallback()
|
|||
const int timeSinceLastCallback = (int) (now - lastCallbackTime);
|
||||
lastCallbackTime = now;
|
||||
|
||||
newProgress = jmin (currentValue + 0.00018 * timeSinceLastCallback,
|
||||
newProgress = jmin (currentValue + 0.00018 * timeSinceLastCallback,
|
||||
newProgress);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ public:
|
|||
|
||||
if (item != 0)
|
||||
return item->getTooltip();
|
||||
|
||||
|
||||
return owner->getTooltip();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ bool ComponentPeer::handleKeyPress (const int keyCode,
|
|||
keyWasUsed = (currentlyFocused != Component::getCurrentlyFocusedComponent());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
target = target->parentComponent_;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ ThreadWithProgressWindow::ThreadWithProgressWindow (const String& title,
|
|||
timeOutMsWhenCancelling (timeOutMsWhenCancelling_)
|
||||
{
|
||||
alertWindow = LookAndFeel::getDefaultLookAndFeel()
|
||||
.createAlertWindow (title, String::empty, cancelButtonText,
|
||||
.createAlertWindow (title, String::empty, cancelButtonText,
|
||||
String::empty, String::empty,
|
||||
AlertWindow::NoIcon, hasCancelButton ? 1 : 0, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ void TooltipWindow::showFor (Component* const c, const String& tip)
|
|||
{
|
||||
jassert (tip.isNotEmpty());
|
||||
tipShowing = tip;
|
||||
|
||||
|
||||
int mx, my;
|
||||
Desktop::getMousePosition (mx, my);
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ void TooltipWindow::timerCallback()
|
|||
if (isVisible() || now < lastHideTime + 500)
|
||||
{
|
||||
// if a tip is currently visible (or has just disappeared), update to a new one
|
||||
// immediately if needed..
|
||||
// immediately if needed..
|
||||
if (newComp == 0 || mouseWasClicked || newTip.isEmpty())
|
||||
{
|
||||
if (isVisible())
|
||||
|
|
@ -174,7 +174,7 @@ void TooltipWindow::timerCallback()
|
|||
}
|
||||
else
|
||||
{
|
||||
// if there isn't currently a tip, but one is needed, only let it
|
||||
// if there isn't currently a tip, but one is needed, only let it
|
||||
// appear after a timeout..
|
||||
if (newTip.isNotEmpty()
|
||||
&& newTip != tipShowing
|
||||
|
|
|
|||
|
|
@ -118,7 +118,8 @@ static bool bindSocketToPort (const int handle, const int port) throw()
|
|||
|
||||
static int readSocket (const int handle,
|
||||
void* const destBuffer, const int maxBytesToRead,
|
||||
bool volatile& connected) throw()
|
||||
bool volatile& connected,
|
||||
const bool blockUntilSpecifiedAmountHasArrived) throw()
|
||||
{
|
||||
int bytesRead = 0;
|
||||
|
||||
|
|
@ -145,6 +146,9 @@ static int readSocket (const int handle,
|
|||
}
|
||||
|
||||
bytesRead += bytesThisTime;
|
||||
|
||||
if (! blockUntilSpecifiedAmountHasArrived)
|
||||
break;
|
||||
}
|
||||
|
||||
return bytesRead;
|
||||
|
|
@ -335,9 +339,9 @@ StreamingSocket::~StreamingSocket()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
int StreamingSocket::read (void* destBuffer, const int maxBytesToRead)
|
||||
int StreamingSocket::read (void* destBuffer, const int maxBytesToRead, const bool blockUntilSpecifiedAmountHasArrived)
|
||||
{
|
||||
return (connected && ! isListener) ? readSocket (handle, destBuffer, maxBytesToRead, connected)
|
||||
return (connected && ! isListener) ? readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
|
||||
: -1;
|
||||
}
|
||||
|
||||
|
|
@ -611,9 +615,9 @@ int DatagramSocket::waitUntilReady (const bool readyForReading,
|
|||
: -1;
|
||||
}
|
||||
|
||||
int DatagramSocket::read (void* destBuffer, const int maxBytesToRead)
|
||||
int DatagramSocket::read (void* destBuffer, const int maxBytesToRead, const bool blockUntilSpecifiedAmountHasArrived)
|
||||
{
|
||||
return connected ? readSocket (handle, destBuffer, maxBytesToRead, connected)
|
||||
return connected ? readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
|
||||
: -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,14 +112,18 @@ public:
|
|||
int waitUntilReady (const bool readyForReading,
|
||||
const int timeoutMsecs) const;
|
||||
|
||||
/** Reads bytes from the socket (blocking).
|
||||
/** Reads bytes from the socket.
|
||||
|
||||
Note that this method will block unless you have checked the socket is ready
|
||||
for reading before calling it (see the waitUntilReady() method).
|
||||
If blockUntilSpecifiedAmountHasArrived is true, the method will block until
|
||||
maxBytesToRead bytes have been read, (or until an error occurs). If this
|
||||
flag is false, the method will return as much data as is currently available
|
||||
without blocking.
|
||||
|
||||
@returns the number of bytes read, or -1 if there was an error.
|
||||
@see waitUntilReady
|
||||
*/
|
||||
int read (void* destBuffer, const int maxBytesToRead);
|
||||
int read (void* destBuffer, const int maxBytesToRead,
|
||||
const bool blockUntilSpecifiedAmountHasArrived);
|
||||
|
||||
/** Writes bytes to the socket from a buffer.
|
||||
|
||||
|
|
@ -249,14 +253,18 @@ public:
|
|||
int waitUntilReady (const bool readyForReading,
|
||||
const int timeoutMsecs) const;
|
||||
|
||||
/** Reads bytes from the socket (blocking).
|
||||
/** Reads bytes from the socket.
|
||||
|
||||
Note that this method will block unless you have checked the socket is ready
|
||||
for reading before calling it (see the waitUntilReady() method).
|
||||
If blockUntilSpecifiedAmountHasArrived is true, the method will block until
|
||||
maxBytesToRead bytes have been read, (or until an error occurs). If this
|
||||
flag is false, the method will return as much data as is currently available
|
||||
without blocking.
|
||||
|
||||
@returns the number of bytes read, or -1 if there was an error.
|
||||
@see waitUntilReady
|
||||
*/
|
||||
int read (void* destBuffer, const int maxBytesToRead);
|
||||
int read (void* destBuffer, const int maxBytesToRead,
|
||||
const bool blockUntilSpecifiedAmountHasArrived);
|
||||
|
||||
/** Writes bytes to the socket from a buffer.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue