From 7fc53bff3025da994486b6fcbfd9ea7c87fd6bc0 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 31 Mar 2009 10:09:29 +0000 Subject: [PATCH] Fix for a linux build error; CoreAudio fix for mac; added some notes to the plugin framework docs --- .../juce_linux_Files.cpp | 1 + .../juce_mac_CoreAudio.cpp | 22 ++++++++++-------- .../How to use this framework.txt | 7 ++++++ juce_amalgamated.cpp | 23 +++++++++++-------- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/build/linux/platform_specific_code/juce_linux_Files.cpp b/build/linux/platform_specific_code/juce_linux_Files.cpp index 1d763ceabd..9c58f7deb9 100644 --- a/build/linux/platform_specific_code/juce_linux_Files.cpp +++ b/build/linux/platform_specific_code/juce_linux_Files.cpp @@ -55,6 +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/io/network/juce_URL.h" #include "../../../src/juce_core/io/files/juce_NamedPipe.h" #include "../../../src/juce_core/threads/juce_InterProcessLock.h" diff --git a/build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp b/build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp index 2863a2f8e6..9bdc5af5cc 100644 --- a/build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp +++ b/build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp @@ -124,22 +124,21 @@ public: delete inputDevice; } - void setTempBufferSize (const int numChannels, const int numSamples) + void allocateTempBuffers() { + const int tempBufSize = bufferSize + 4; juce_free (audioBuffer); - - audioBuffer = (float*) juce_calloc (32 + numChannels * numSamples * sizeof (float)); + audioBuffer = (float*) juce_calloc ((numInputChans + numOutputChans) * tempBufSize * sizeof (float)); zeromem (tempInputBuffers, sizeof (tempInputBuffers)); zeromem (tempOutputBuffers, sizeof (tempOutputBuffers)); - int count = 0; - int i; + int i, count = 0; for (i = 0; i < numInputChans; ++i) - tempInputBuffers[i] = audioBuffer + count++ * numSamples; + tempInputBuffers[i] = audioBuffer + count++ * tempBufSize; for (i = 0; i < numOutputChans; ++i) - tempOutputBuffers[i] = audioBuffer + count++ * numSamples; + tempOutputBuffers[i] = audioBuffer + count++ * tempBufSize; } // returns the number of actual available channels @@ -218,9 +217,7 @@ public: if (OK (AudioDeviceGetProperty (deviceID, 0, false, kAudioDevicePropertyBufferFrameSize, &size, &framesPerBuf))) { bufferSize = framesPerBuf; - - if (bufferSize > 0) - setTempBufferSize (numInputChans + numOutputChans, bufferSize); + allocateTempBuffers(); } bufferSizes.clear(); @@ -611,6 +608,11 @@ public: { jassert (inputDevice->bufferSize == bufferSize); + // Sometimes the two linked devices seem to get their callbacks in + // parallel, so we need to lock both devices to stop the input data being + // changed while inside our callback.. + const ScopedLock sl (inputDevice->callbackLock); + callback->audioDeviceIOCallback ((const float**) inputDevice->tempInputBuffers, inputDevice->numInputChans, tempOutputBuffers, diff --git a/extras/audio plugins/How to use this framework.txt b/extras/audio plugins/How to use this framework.txt index 142da6aca7..9989c9eb15 100644 --- a/extras/audio plugins/How to use this framework.txt +++ b/extras/audio plugins/How to use this framework.txt @@ -116,9 +116,16 @@ make it easier to update to the latest code. DAE.lib, DigiExt.lib, DSI.lib, PlugInLib.lib. - In XCode: After installing the Digidesign SDK, make sure you've run the config_SDK_for_Mac command in the SDK's root directory. This sets up some of the tools that it needs. +- In XCode: If you're using the Digi files CommonDebugSettings.xcconfig and CommonReleaseSettings.xcconfig, + then you'll probably have to remove the "-x c++" option from their OTHER_CFLAGS setting, because + that prevents it compiling obj-C. Also, you might need to comment-out the GCC_PREFIX_HEADER setting, + unless you can persuade precompiled headers to work (I've never managed to get them working myself..) + You'll also probably want to add a "MacBag" setting to these files, rather than putting it into + your project - e.g. "MacBag = /Users/jules/SDKs/PT_80_SDK/MacBag" ----------------------------------------------------------------------------------------------------- + Choosing the formats to build ============================= diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 705efabe78..cb9dad64bf 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -267204,6 +267204,7 @@ NSRect NSViewComponentPeer::constrainRect (NSRect r) current.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - current.origin.y - current.size.height; r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.origin.y - r.size.height; + int x = (int) r.origin.x; int y = (int) r.origin.y; int w = (int) r.size.width; @@ -270883,22 +270884,21 @@ public: delete inputDevice; } - void setTempBufferSize (const int numChannels, const int numSamples) + void allocateTempBuffers() { + const int tempBufSize = bufferSize + 4; juce_free (audioBuffer); - - audioBuffer = (float*) juce_calloc (32 + numChannels * numSamples * sizeof (float)); + audioBuffer = (float*) juce_calloc ((numInputChans + numOutputChans) * tempBufSize * sizeof (float)); zeromem (tempInputBuffers, sizeof (tempInputBuffers)); zeromem (tempOutputBuffers, sizeof (tempOutputBuffers)); - int count = 0; - int i; + int i, count = 0; for (i = 0; i < numInputChans; ++i) - tempInputBuffers[i] = audioBuffer + count++ * numSamples; + tempInputBuffers[i] = audioBuffer + count++ * tempBufSize; for (i = 0; i < numOutputChans; ++i) - tempOutputBuffers[i] = audioBuffer + count++ * numSamples; + tempOutputBuffers[i] = audioBuffer + count++ * tempBufSize; } // returns the number of actual available channels @@ -270977,9 +270977,7 @@ public: if (OK (AudioDeviceGetProperty (deviceID, 0, false, kAudioDevicePropertyBufferFrameSize, &size, &framesPerBuf))) { bufferSize = framesPerBuf; - - if (bufferSize > 0) - setTempBufferSize (numInputChans + numOutputChans, bufferSize); + allocateTempBuffers(); } bufferSizes.clear(); @@ -271368,6 +271366,11 @@ public: { jassert (inputDevice->bufferSize == bufferSize); + // Sometimes the two linked devices seem to get their callbacks in + // parallel, so we need to lock both devices to stop the input data being + // changed while inside our callback.. + const ScopedLock sl (inputDevice->callbackLock); + callback->audioDeviceIOCallback ((const float**) inputDevice->tempInputBuffers, inputDevice->numInputChans, tempOutputBuffers,