|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- /*
- Steinberg Audio Stream I/O API
- (c) 1996, Steinberg Soft- und Hardware GmbH
-
- asio.cpp
-
- asio functions entries which translate the
- asio interface to the asiodrvr class methods
- */
-
- #include <string.h>
- #include "asiosys.h" // platform definition
- #include "asio.h"
-
- #if MAC
- #include "asiodrvr.h"
-
- #pragma export on
-
- AsioDriver *theAsioDriver = 0;
-
- extern "C"
- {
-
- long main()
- {
- return 'ASIO';
- }
-
- #elif WINDOWS
-
- #include "windows.h"
- #include "iasiodrv.h"
- #include "asiodrivers.h"
-
- IASIO *theAsioDriver = 0;
- extern AsioDrivers *asioDrivers;
-
- #elif SGI || SUN || BEOS || LINUX
- #include "asiodrvr.h"
- static AsioDriver *theAsioDriver = 0;
- #endif
-
- //-----------------------------------------------------------------------------------------------------
- ASIOError ASIOInit(ASIODriverInfo *info)
- {
- #if MAC || SGI || SUN || BEOS || LINUX
- if(theAsioDriver)
- {
- delete theAsioDriver;
- theAsioDriver = 0;
- }
- info->driverVersion = 0;
- strcpy(info->name, "No ASIO Driver");
- theAsioDriver = getDriver();
- if(!theAsioDriver)
- {
- strcpy(info->errorMessage, "Not enough memory for the ASIO driver!");
- return ASE_NotPresent;
- }
- if(!theAsioDriver->init(info->sysRef))
- {
- theAsioDriver->getErrorMessage(info->errorMessage);
- delete theAsioDriver;
- theAsioDriver = 0;
- return ASE_NotPresent;
- }
- strcpy(info->errorMessage, "No ASIO Driver Error");
- theAsioDriver->getDriverName(info->name);
- info->driverVersion = theAsioDriver->getDriverVersion();
- return ASE_OK;
-
- #else
-
- info->driverVersion = 0;
- strcpy(info->name, "No ASIO Driver");
- if(theAsioDriver) // must be loaded!
- {
- if(!theAsioDriver->init(info->sysRef))
- {
- theAsioDriver->getErrorMessage(info->errorMessage);
- theAsioDriver = 0;
- return ASE_NotPresent;
- }
-
- strcpy(info->errorMessage, "No ASIO Driver Error");
- theAsioDriver->getDriverName(info->name);
- info->driverVersion = theAsioDriver->getDriverVersion();
- return ASE_OK;
- }
- return ASE_NotPresent;
-
- #endif // !MAC
- }
-
- ASIOError ASIOExit(void)
- {
- if(theAsioDriver)
- {
- #if WINDOWS
- asioDrivers->removeCurrentDriver();
- #else
- delete theAsioDriver;
- #endif
- }
- theAsioDriver = 0;
- return ASE_OK;
- }
-
- ASIOError ASIOStart(void)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->start();
- }
-
- ASIOError ASIOStop(void)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->stop();
- }
-
- ASIOError ASIOGetChannels(long *numInputChannels, long *numOutputChannels)
- {
- if(!theAsioDriver)
- {
- *numInputChannels = *numOutputChannels = 0;
- return ASE_NotPresent;
- }
- return theAsioDriver->getChannels(numInputChannels, numOutputChannels);
- }
-
- ASIOError ASIOGetLatencies(long *inputLatency, long *outputLatency)
- {
- if(!theAsioDriver)
- {
- *inputLatency = *outputLatency = 0;
- return ASE_NotPresent;
- }
- return theAsioDriver->getLatencies(inputLatency, outputLatency);
- }
-
- ASIOError ASIOGetBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity)
- {
- if(!theAsioDriver)
- {
- *minSize = *maxSize = *preferredSize = *granularity = 0;
- return ASE_NotPresent;
- }
- return theAsioDriver->getBufferSize(minSize, maxSize, preferredSize, granularity);
- }
-
- ASIOError ASIOCanSampleRate(ASIOSampleRate sampleRate)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->canSampleRate(sampleRate);
- }
-
- ASIOError ASIOGetSampleRate(ASIOSampleRate *currentRate)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->getSampleRate(currentRate);
- }
-
- ASIOError ASIOSetSampleRate(ASIOSampleRate sampleRate)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->setSampleRate(sampleRate);
- }
-
- ASIOError ASIOGetClockSources(ASIOClockSource *clocks, long *numSources)
- {
- if(!theAsioDriver)
- {
- *numSources = 0;
- return ASE_NotPresent;
- }
- return theAsioDriver->getClockSources(clocks, numSources);
- }
-
- ASIOError ASIOSetClockSource(long reference)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->setClockSource(reference);
- }
-
- ASIOError ASIOGetSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->getSamplePosition(sPos, tStamp);
- }
-
- ASIOError ASIOGetChannelInfo(ASIOChannelInfo *info)
- {
- if(!theAsioDriver)
- {
- info->channelGroup = -1;
- info->type = ASIOSTInt16MSB;
- strcpy(info->name, "None");
- return ASE_NotPresent;
- }
- return theAsioDriver->getChannelInfo(info);
- }
-
- ASIOError ASIOCreateBuffers(ASIOBufferInfo *bufferInfos, long numChannels,
- long bufferSize, ASIOCallbacks *callbacks)
- {
- if(!theAsioDriver)
- {
- ASIOBufferInfo *info = bufferInfos;
- for(long i = 0; i < numChannels; i++, info++)
- info->buffers[0] = info->buffers[1] = 0;
- return ASE_NotPresent;
- }
- return theAsioDriver->createBuffers(bufferInfos, numChannels, bufferSize, callbacks);
- }
-
- ASIOError ASIODisposeBuffers(void)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->disposeBuffers();
- }
-
- ASIOError ASIOControlPanel(void)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->controlPanel();
- }
-
- ASIOError ASIOFuture(long selector, void *opt)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->future(selector, opt);
- }
-
- ASIOError ASIOOutputReady(void)
- {
- if(!theAsioDriver)
- return ASE_NotPresent;
- return theAsioDriver->outputReady();
- }
-
- #if MAC
- } // extern "C"
- #pragma export off
- #endif
-
-
|