| @@ -323,10 +323,12 @@ public: | |||
| optionalDllForDirectLoading (dllForDirectLoading), | |||
| currentBitDepth (16), | |||
| currentSampleRate (0), | |||
| currentCallback (nullptr), | |||
| deviceIsOpen (false), | |||
| isStarted (false), | |||
| buffersCreated (false), | |||
| postOutput (true), | |||
| needToReset (false), | |||
| insideControlPanelModalLoop (false), | |||
| shouldUsePreferredSize (false) | |||
| { | |||
| @@ -336,8 +338,6 @@ public: | |||
| jassert (currentASIODev [slotNumber] == nullptr); | |||
| currentASIODev [slotNumber] = this; | |||
| openDevice(); | |||
| } | |||
| ~ASIOAudioIODevice() | |||
| @@ -355,32 +355,37 @@ public: | |||
| { | |||
| // find a list of sample rates.. | |||
| const int possibleSampleRates[] = { 44100, 48000, 88200, 96000, 176400, 192000 }; | |||
| sampleRates.clear(); | |||
| Array<int> newRates; | |||
| if (asioObject != nullptr) | |||
| { | |||
| for (int index = 0; index < numElementsInArray (possibleSampleRates); ++index) | |||
| { | |||
| const long err = asioObject->canSampleRate ((double) possibleSampleRates[index]); | |||
| JUCE_ASIO_LOG_ERROR ("canSampleRate " + String (possibleSampleRates[index]), err); | |||
| if (asioObject->canSampleRate ((double) possibleSampleRates[index]) == 0) | |||
| newRates.add (possibleSampleRates[index]); | |||
| } | |||
| if (err == 0) | |||
| { | |||
| sampleRates.add (possibleSampleRates[index]); | |||
| JUCE_ASIO_LOG ("rate: " + String (possibleSampleRates[index])); | |||
| } | |||
| } | |||
| if (newRates.size() == 0) | |||
| { | |||
| double cr = 0; | |||
| const long err = asioObject->getSampleRate (&cr); | |||
| JUCE_ASIO_LOG ("No sample rates supported - current rate: " + String ((int) cr)); | |||
| JUCE_ASIO_LOG_ERROR ("getSampleRate", err); | |||
| if (sampleRates.size() == 0) | |||
| { | |||
| double cr = 0; | |||
| const long err = asioObject->getSampleRate (&cr); | |||
| JUCE_ASIO_LOG ("No sample rates supported - current rate: " + String ((int) cr)); | |||
| JUCE_ASIO_LOG_ERROR ("getSampleRate", err); | |||
| if (err == 0) | |||
| newRates.add ((int) cr); | |||
| } | |||
| if (err == 0) | |||
| sampleRates.add ((int) cr); | |||
| } | |||
| if (sampleRates != newRates) | |||
| { | |||
| sampleRates.swapWithArray (newRates); | |||
| #if JUCE_ASIO_DEBUGGING | |||
| StringArray s; | |||
| for (int i = 0; i < sampleRates.size(); ++i) | |||
| s.add (String (sampleRates.getUnchecked(i))); | |||
| JUCE_ASIO_LOG ("Rates: " + s.joinIntoString (" ")); | |||
| #endif | |||
| } | |||
| } | |||
| @@ -400,7 +405,7 @@ public: | |||
| int bufferSizeSamples) | |||
| { | |||
| close(); | |||
| currentCallback = nullptr; | |||
| jassert (currentCallback == nullptr); | |||
| if (bufferSizeSamples <= 0) | |||
| shouldUsePreferredSize = true; | |||
| @@ -813,7 +818,6 @@ public: | |||
| { | |||
| stopTimer(); | |||
| // used to cause a reset | |||
| JUCE_ASIO_LOG ("restart request!"); | |||
| AudioIODeviceCallback* const oldCallback = currentCallback; | |||
| @@ -1090,7 +1094,7 @@ private: | |||
| if ((err = asioObject->getBufferSize (&minSize, &maxSize, &preferredSize, &granularity)) == 0) | |||
| { | |||
| // find a list of buffer sizes.. | |||
| JUCE_ASIO_LOG (String ((int) minSize) + " " + String ((int) maxSize) + " " + String ((int) preferredSize) + " " + String ((int) granularity)); | |||
| JUCE_ASIO_LOG (String ((int) minSize) + "->" + String ((int) maxSize) + ", " + String ((int) preferredSize) + ", " + String ((int) granularity)); | |||
| if (granularity >= 0) | |||
| { | |||
| @@ -1216,7 +1220,7 @@ private: | |||
| // ignore an error here, as it might start later after setting other stuff up | |||
| JUCE_ASIO_LOG_ERROR ("start", err); | |||
| Thread::sleep (100); | |||
| Thread::sleep (80); | |||
| asioObject->stop(); | |||
| } | |||
| else | |||
| @@ -1250,6 +1254,7 @@ private: | |||
| deviceIsOpen = false; | |||
| needToReset = false; | |||
| stopTimer(); | |||
| return error; | |||
| } | |||
| @@ -1365,27 +1370,16 @@ private: | |||
| switch (selector) | |||
| { | |||
| case kAsioSelectorSupported: | |||
| if (value == kAsioResetRequest | |||
| || value == kAsioEngineVersion | |||
| || value == kAsioResyncRequest | |||
| || value == kAsioLatenciesChanged | |||
| || value == kAsioSupportsInputMonitor) | |||
| if (value == kAsioResetRequest || value == kAsioEngineVersion || value == kAsioResyncRequest | |||
| || value == kAsioLatenciesChanged || value == kAsioSupportsInputMonitor) | |||
| return 1; | |||
| break; | |||
| case kAsioBufferSizeChange: | |||
| case kAsioResetRequest: | |||
| case kAsioResyncRequest: | |||
| if (currentASIODev[deviceIndex] != nullptr) | |||
| currentASIODev[deviceIndex]->resetRequest(); | |||
| return 1; | |||
| case kAsioLatenciesChanged: | |||
| return 1; | |||
| case kAsioEngineVersion: | |||
| return 2; | |||
| case kAsioBufferSizeChange: JUCE_ASIO_LOG ("kAsioBufferSizeChange"); return sendResetRequest (deviceIndex); | |||
| case kAsioResetRequest: JUCE_ASIO_LOG ("kAsioResetRequest"); return sendResetRequest (deviceIndex); | |||
| case kAsioResyncRequest: JUCE_ASIO_LOG ("kAsioResyncRequest"); return sendResetRequest (deviceIndex); | |||
| case kAsioLatenciesChanged: JUCE_ASIO_LOG ("kAsioLatenciesChanged"); return 1; | |||
| case kAsioEngineVersion: return 2; | |||
| case kAsioSupportsTimeInfo: | |||
| case kAsioSupportsTimeCode: | |||
| @@ -1395,6 +1389,14 @@ private: | |||
| return 0; | |||
| } | |||
| static long sendResetRequest (int deviceIndex) | |||
| { | |||
| if (currentASIODev[deviceIndex] != nullptr) | |||
| currentASIODev[deviceIndex]->resetRequest(); | |||
| return 1; | |||
| } | |||
| static void JUCE_ASIOCALLBACK sampleRateChangedCallback (ASIOSampleRate) | |||
| { | |||
| } | |||