1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-22 01:34:21 +00:00

Got rid of a maximum limit on the number of ASIO channels.

This commit is contained in:
jules 2012-09-13 11:54:52 +01:00
parent f4898a18ab
commit 747f898ea4

View file

@ -26,14 +26,6 @@
#undef WINDOWS
#undef log
// #define ASIO_DEBUGGING 1
#if ASIO_DEBUGGING
#define log(a) { Logger::writeToLog (a); DBG (a) }
#else
#define log(a) {}
#endif
/* The ASIO SDK *should* declare its callback functions as being __cdecl, but different versions seem
to be pretty random about whether or not they do this. If you hit an error using these functions
it'll be because you're trying to build using __stdcall, in which case you'd need to either get hold of
@ -44,7 +36,7 @@
//==============================================================================
namespace ASIODebugging
{
#if ASIO_DEBUGGING
#if ASIO_DEBUGGING
static void log (const String& context, long error)
{
const char* err = "unknown error";
@ -57,13 +49,15 @@ namespace ASIODebugging
else if (error == ASE_NoClock) err = "No Clock";
else if (error == ASE_NoMemory) err = "Out of memory";
log ("!!error: " + context + " - " + err);
log ("ASIO error: " + context + " - " + err);
}
#define log(a) { Logger::writeToLog (a); DBG (a) }
#define logError(a, b) ASIODebugging::log ((a), (b))
#else
#else
#define log(a) {}
#define logError(a, b) {}
#endif
#endif
}
//==============================================================================
@ -304,12 +298,12 @@ class ASIOAudioIODevice : public AudioIODevice,
private Timer
{
public:
ASIOAudioIODevice (const String& name_, const CLSID classId_, const int slotNumber,
const String& optionalDllForDirectLoading_)
: AudioIODevice (name_, "ASIO"),
ASIOAudioIODevice (const String& devName, const CLSID clsID, const int slotNumber,
const String& dllForDirectLoading)
: AudioIODevice (devName, "ASIO"),
asioObject (nullptr),
classId (classId_),
optionalDllForDirectLoading (optionalDllForDirectLoading_),
classId (clsID),
optionalDllForDirectLoading (dllForDirectLoading),
currentBitDepth (16),
currentSampleRate (0),
deviceIsOpen (false),
@ -319,7 +313,9 @@ public:
insideControlPanelModalLoop (false),
shouldUsePreferredSize (false)
{
name = name_;
name = devName;
inBuffers.calloc (4);
outBuffers.calloc (4);
jassert (currentASIODev [slotNumber] == nullptr);
currentASIODev [slotNumber] = this;
@ -446,8 +442,8 @@ public:
currentBlockSizeSamples = bufferSizeSamples;
currentChansOut.clear();
currentChansIn.clear();
zeromem (inBuffers, sizeof (inBuffers));
zeromem (outBuffers, sizeof (outBuffers));
inBuffers.clear (totalNumInputChans + 1);
outBuffers.clear (totalNumOutputChans + 1);
updateSampleRates();
@ -621,7 +617,7 @@ public:
Array <int> types;
currentBitDepth = 16;
for (int i = 0; i < jmin ((int) totalNumInputChans, (int) maxASIOChannels); ++i)
for (int i = 0; i < (int) totalNumInputChans; ++i)
{
if (inputChannels[i])
{
@ -643,7 +639,7 @@ public:
jassert (numActiveInputChans == n);
n = 0;
for (int i = 0; i < jmin ((int) totalNumOutputChans, (int) maxASIOChannels); ++i)
for (int i = 0; i < (int) totalNumOutputChans; ++i)
{
if (outputChannels[i])
{
@ -915,14 +911,9 @@ private:
AudioIODeviceCallback* volatile currentCallback;
CriticalSection callbackLock;
enum { maxASIOChannels = 160 };
ASIOBufferInfo bufferInfos [maxASIOChannels];
float* inBuffers [maxASIOChannels];
float* outBuffers [maxASIOChannels];
ASIOSampleFormat inputFormat [maxASIOChannels];
ASIOSampleFormat outputFormat [maxASIOChannels];
HeapBlock<ASIOBufferInfo> bufferInfos;
HeapBlock<float*> inBuffers, outBuffers;
HeapBlock<ASIOSampleFormat> inputFormat, outputFormat;
WaitableEvent event1;
HeapBlock <float> tempBuffer;
@ -1051,6 +1042,13 @@ private:
{
log (String ((int) totalNumInputChans) + " in, " + String ((int) totalNumOutputChans) + " out");
const int chansToAllocate = totalNumInputChans + totalNumOutputChans + 4;
bufferInfos.calloc (chansToAllocate);
inBuffers.calloc (chansToAllocate);
outBuffers.calloc (chansToAllocate);
inputFormat.calloc (chansToAllocate);
outputFormat.calloc (chansToAllocate);
if ((err = asioObject->getBufferSize (&minSize, &maxSize, &preferredSize, &granularity)) == 0)
{
// find a list of buffer sizes..
@ -1300,11 +1298,11 @@ private:
{
for (int i = 0; i < numActiveInputChans; ++i)
{
jassert (inBuffers[i]!= nullptr);
jassert (inBuffers[i] != nullptr);
inputFormat[i].convertToFloat (infos[i].buffers[bi], inBuffers[i], samps);
}
currentCallback->audioDeviceIOCallback ((const float**) inBuffers, numActiveInputChans,
currentCallback->audioDeviceIOCallback (const_cast <const float**> (inBuffers.getData()), numActiveInputChans,
outBuffers, numActiveOutputChans, samps);
for (int i = 0; i < numActiveOutputChans; ++i)
@ -1612,8 +1610,7 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ASIO()
return new ASIOAudioIODeviceType();
}
AudioIODevice* juce_createASIOAudioIODeviceForGUID (const String& name,
void* guid,
AudioIODevice* juce_createASIOAudioIODeviceForGUID (const String& name, void* guid,
const String& optionalDllForDirectLoading)
{
const int freeSlot = ASIOAudioIODeviceType::findFreeSlot();