Version 3.0.3
authorGary Scavone <gary@music.mcgill.ca>
Wed, 9 Oct 2013 21:50:06 +0000 (23:50 +0200)
committerStephen Sinclair <sinclair@music.mcgill.ca>
Wed, 9 Oct 2013 23:16:30 +0000 (01:16 +0200)
30 files changed:
RtAudio.cpp
RtAudio.h
asio/asio.cpp [new file with mode: 0644]
asio/asio.h
asio/asiodrivers.cpp [new file with mode: 0644]
asio/asiodrvr.h [new file with mode: 0644]
asio/asiolist.cpp [new file with mode: 0644]
asio/iasiodrv.h [new file with mode: 0644]
asio/iasiothiscallresolver.cpp [new file with mode: 0644]
asio/iasiothiscallresolver.h [new file with mode: 0644]
doc/doxygen/tutorial.txt
doc/release.txt
tests/Windows/asio.cpp [deleted file]
tests/Windows/asio.h [deleted file]
tests/Windows/asiodrivers.cpp [deleted file]
tests/Windows/asiodrivers.h [deleted file]
tests/Windows/asiodrvr.h [deleted file]
tests/Windows/asiolist.cpp [deleted file]
tests/Windows/asiolist.h [deleted file]
tests/Windows/asiosys.h [deleted file]
tests/Windows/call_inout.dsp
tests/Windows/call_saw.dsp
tests/Windows/ginclude.h [deleted file]
tests/Windows/iasiodrv.h [deleted file]
tests/Windows/in_out.dsp
tests/Windows/info.dsp
tests/Windows/play_raw.dsp
tests/Windows/play_saw.dsp
tests/Windows/record_raw.dsp
tests/Windows/twostreams.dsp

index 1f6a597d4ee1c082aaec6e74ff0824fc834e7330..f7c918de7b8dbea0f11f12d0ac1b293344cd3cbf 100644 (file)
 */
 /************************************************************************/
 
-// RtAudio: Version 3.0.2 (14 October 2005)
-
-// Modified by Robin Davies, 1 October 2005
-// - Improvements to DirectX pointer chasing. 
-// - Backdoor RtDsStatistics hook provides DirectX performance information.
-// - Bug fix for non-power-of-two Asio granularity used by Edirol PCR-A30.
-// - Auto-call CoInitialize for DSOUND and ASIO platforms.
+// RtAudio: Version 3.0.3 (18 November 2005)
 
 #include "RtAudio.h"
 #include <iostream>
@@ -2742,11 +2736,35 @@ void RtApiJack :: initialize(void)
   if ( (client = jack_client_new( "RtApiJack" )) == 0)
     return;
 
-  RtApiDevice device;
-  // Determine the name of the device.
-  device.name = "Jack Server";
-  devices_.push_back(device);
-  nDevices_++;
+  /*
+    RtApiDevice device;
+    // Determine the name of the device.
+    device.name = "Jack Server";
+    devices_.push_back(device);
+    nDevices_++;
+  */
+  const char **ports;
+  std::string port, prevPort;
+  unsigned int nChannels = 0;
+  ports = jack_get_ports( client, NULL, NULL, 0 );
+  if ( ports ) {
+    port = (char *) ports[ nChannels ];
+    unsigned int colonPos = 0;
+    do {
+      port = (char *) ports[ nChannels ];
+      if ( (colonPos = port.find(":")) != std::string::npos ) {
+        port = port.substr( 0, colonPos+1 );
+        if ( port != prevPort ) {
+          RtApiDevice device;
+          device.name = port;
+          devices_.push_back( device );
+          nDevices_++;
+          prevPort = port;
+        }
+      }
+    } while ( ports[++nChannels] );
+    free( ports );
+  }
 
   jack_client_close(client);
 }
@@ -2755,7 +2773,7 @@ void RtApiJack :: probeDeviceInfo(RtApiDevice *info)
 {
   // Look for jack server and try to become a client.
   jack_client_t *client;
-  if ( (client = jack_client_new( "RtApiJack" )) == 0) {
+  if ( (client = jack_client_new( "RtApiJack_Probe" )) == 0) {
     sprintf(message_, "RtApiJack: error connecting to Linux Jack server in probeDeviceInfo() (jack: %s)!",
             jackmsg.c_str());
     error(RtError::WARNING);
@@ -2771,7 +2789,7 @@ void RtApiJack :: probeDeviceInfo(RtApiDevice *info)
   const char **ports;
   char *port;
   unsigned int nChannels = 0;
-  ports = jack_get_ports( client, NULL, NULL, JackPortIsInput );
+  ports = jack_get_ports( client, info->name.c_str(), NULL, JackPortIsInput );
   if ( ports ) {
     port = (char *) ports[nChannels];
     while ( port )
@@ -2783,7 +2801,7 @@ void RtApiJack :: probeDeviceInfo(RtApiDevice *info)
 
   // Jack "output ports" equal RtAudio input channels.
   nChannels = 0;
-  ports = jack_get_ports( client, NULL, NULL, JackPortIsOutput );
+  ports = jack_get_ports( client, info->name.c_str(), NULL, JackPortIsOutput );
   if ( ports ) {
     port = (char *) ports[nChannels];
     while ( port )
@@ -3178,7 +3196,7 @@ void RtApiJack :: startStream()
   int result;
   // Get the list of available ports.
   if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
-    ports = jack_get_ports(handle->client, NULL, NULL, JackPortIsPhysical|JackPortIsInput);
+    ports = jack_get_ports(handle->client, devices_[stream_.device[0]].name.c_str(), NULL, JackPortIsInput);
     if ( ports == NULL) {
       sprintf(message_, "RtApiJack: error determining available jack input ports!");
       error(RtError::SYSTEM_ERROR);
@@ -3201,7 +3219,7 @@ void RtApiJack :: startStream()
   }
 
   if ( stream_.mode == INPUT || stream_.mode == DUPLEX ) {
-    ports = jack_get_ports( handle->client, NULL, NULL, JackPortIsPhysical|JackPortIsOutput );
+    ports = jack_get_ports( handle->client, devices_[stream_.device[1]].name.c_str(), NULL, JackPortIsOutput );
     if ( ports == NULL) {
       sprintf(message_, "RtApiJack: error determining available jack output ports!");
       error(RtError::SYSTEM_ERROR);
@@ -4209,6 +4227,72 @@ void RtApiAlsa :: closeStream()
   stream_.mode = UNINITIALIZED;
 }
 
+// Pump a bunch of zeros into the output buffer.  This is needed only when we
+// are doing duplex operations.
+bool RtApiAlsa :: primeOutputBuffer()
+{
+  int err;
+  char *buffer;
+  int channels;
+  snd_pcm_t **handle;
+  RtAudioFormat format;
+  AlsaHandle *apiInfo = (AlsaHandle *) stream_.apiHandle;
+  handle = (snd_pcm_t **) apiInfo->handles;
+  
+  if (stream_.mode == DUPLEX) {
+
+    // Setup parameters and do buffer conversion if necessary.
+    if ( stream_.doConvertBuffer[0] ) {
+      convertBuffer( stream_.deviceBuffer, apiInfo->tempBuffer, stream_.convertInfo[0] );
+      channels = stream_.nDeviceChannels[0];
+      format = stream_.deviceFormat[0];
+    }
+    else {
+      channels = stream_.nUserChannels[0];
+      format = stream_.userFormat;
+    }
+
+    buffer = new char[stream_.bufferSize * formatBytes(format) * channels];
+    bzero(buffer, stream_.bufferSize * formatBytes(format) * channels);
+    
+    for (int i=0; i<stream_.nBuffers; i++) {
+      // Write samples to device in interleaved/non-interleaved format.
+      if (stream_.deInterleave[0]) {
+        void *bufs[channels];
+        size_t offset = stream_.bufferSize * formatBytes(format);
+        for (int i=0; i<channels; i++)
+          bufs[i] = (void *) (buffer + (i * offset));
+        err = snd_pcm_writen(handle[0], bufs, stream_.bufferSize);
+      }
+      else
+        err = snd_pcm_writei(handle[0], buffer, stream_.bufferSize);
+  
+      if (err < stream_.bufferSize) {
+        // Either an error or underrun occured.
+        if (err == -EPIPE) {
+          snd_pcm_state_t state = snd_pcm_state(handle[0]);
+          if (state == SND_PCM_STATE_XRUN) {
+            sprintf(message_, "RtApiAlsa: underrun detected while priming output buffer.");
+            return false;
+          }
+          else {
+            sprintf(message_, "RtApiAlsa: primeOutputBuffer() error, current state is %s.",
+                    snd_pcm_state_name(state));
+            return false;
+          }
+        }
+        else {
+          sprintf(message_, "RtApiAlsa: audio write error for device (%s): %s.",
+                  devices_[stream_.device[0]].name.c_str(), snd_strerror(err));
+          return false;
+        }
+      }
+    }
+  }
+
+  return true;
+}
+
 void RtApiAlsa :: startStream()
 {
   // This method calls snd_pcm_prepare if the device isn't already in that state.
@@ -4232,6 +4316,11 @@ void RtApiAlsa :: startStream()
         MUTEX_UNLOCK(&stream_.mutex);
         error(RtError::DRIVER_ERROR);
       }
+      // Reprime output buffer if needed
+      if ( (stream_.mode == DUPLEX) && ( !primeOutputBuffer() ) ) {
+        MUTEX_UNLOCK(&stream_.mutex);
+        error(RtError::DRIVER_ERROR);
+      }
     }
   }
 
@@ -4247,6 +4336,11 @@ void RtApiAlsa :: startStream()
       }
     }
   }
+
+  if ( (stream_.mode == DUPLEX) && ( !primeOutputBuffer() ) ) {
+    MUTEX_UNLOCK(&stream_.mutex);
+    error(RtError::DRIVER_ERROR);
+  }
   stream_.state = STREAM_RUNNING;
 
   MUTEX_UNLOCK(&stream_.mutex);
@@ -4441,6 +4535,11 @@ void RtApiAlsa :: tickStream()
             MUTEX_UNLOCK(&stream_.mutex);
             error(RtError::DRIVER_ERROR);
           }
+          // Reprime output buffer if needed.
+          if ( (stream_.mode == DUPLEX) && ( !primeOutputBuffer() ) ) {
+            MUTEX_UNLOCK(&stream_.mutex);
+            error(RtError::DRIVER_ERROR);
+          }
         }
         else {
           sprintf(message_, "RtApiAlsa: tickStream() error, current state is %s.",
@@ -4639,6 +4738,7 @@ extern "C" void *alsaCallbackHandler(void *ptr)
 
 #include "asio/asiosys.h"
 #include "asio/asio.h"
+#include "asio/iasiothiscallresolver.h"
 #include "asio/asiodrivers.h"
 #include <math.h>
 
@@ -4656,7 +4756,7 @@ struct AsioHandle {
     :stopStream(false), bufferInfos(0) {}
 };
 
-static const char*GetAsioErrorString(ASIOError result)
+static const char* GetAsioErrorString( ASIOError result )
 {
   struct Messages 
   {
@@ -4674,10 +4774,9 @@ static const char*GetAsioErrorString(ASIOError result)
     {   ASE_NoMemory,           "Not enough memory to complete the request." }
   };
 
-  for (int i = 0; i < sizeof(m)/sizeof(m[0]); ++i)
-  {
+  for (unsigned int i = 0; i < sizeof(m)/sizeof(m[0]); ++i)
     if (m[i].value == result) return m[i].message;
-  }
+
   return "Unknown error.";
 }
 
@@ -4695,11 +4794,9 @@ RtApiAsio :: RtApiAsio()
 RtApiAsio :: ~RtApiAsio()
 {
   if ( stream_.mode != UNINITIALIZED ) closeStream();
+
   if ( coInitialized )
-  {
     CoUninitialize();
-  }
-
 }
 
 void RtApiAsio :: initialize(void)
@@ -4709,8 +4806,7 @@ void RtApiAsio :: initialize(void)
   // for appartment threading (in which case, CoInitilialize will return S_FALSE here).
   coInitialized = false;
   HRESULT hr = CoInitialize(NULL); 
-  if (FAILED(hr))
-  {
+  if ( FAILED(hr) ) {
     sprintf(message_,"RtApiAsio: ASIO requires a single-threaded appartment. Call CoInitializeEx(0,COINIT_APARTMENTTHREADED)");
   }
   coInitialized = true;
@@ -5573,29 +5669,24 @@ void RtApiAsio :: callbackEvent(long bufferIndex)
 static inline DWORD dsPointerDifference(DWORD laterPointer,DWORD earlierPointer,DWORD bufferSize)
 {
   if (laterPointer > earlierPointer)
-  {
     return laterPointer-earlierPointer;
-  } else
-  {
+  else
     return laterPointer-earlierPointer+bufferSize;
-  }
 }
 
 static inline DWORD dsPointerBetween(DWORD pointer, DWORD laterPointer,DWORD earlierPointer, DWORD bufferSize)
 {
   if (pointer > bufferSize) pointer -= bufferSize;
+
   if (laterPointer < earlierPointer)
-  {
     laterPointer += bufferSize;
-  }
+
   if (pointer < earlierPointer)
-  {
     pointer += bufferSize;
-  }
+
   return pointer >= earlierPointer && pointer < laterPointer;
 }
 
-
 #undef GENERATE_DEBUG_LOG // Define this to generate a debug timing log file in c:/rtaudiolog.txt"
 #ifdef GENERATE_DEBUG_LOG
 
@@ -5637,38 +5728,34 @@ RtApiDs::RtDsStatistics RtApiDs::getDsStatistics()
   
 
   if (s.inputFrameSize != 0)
-  {
     s.latency += s.readDeviceSafeLeadBytes*1.0/s.inputFrameSize / s.sampleRate;
-  }
+
   if (s.outputFrameSize != 0)
-  {
-    s.latency += 
-      (s.writeDeviceSafeLeadBytes+ s.writeDeviceBufferLeadBytes)*1.0/s.outputFrameSize / s.sampleRate;
-  }
+    s.latency += (s.writeDeviceSafeLeadBytes+ s.writeDeviceBufferLeadBytes)*1.0/s.outputFrameSize / s.sampleRate;
+
   return s;
 }
 
-
 // Declarations for utility functions, callbacks, and structures
 // specific to the DirectSound implementation.
 static bool CALLBACK deviceCountCallback(LPGUID lpguid,
-                                         LPCSTR lpcstrDescription,
-                                         LPCSTR lpcstrModule,
+                                         LPCTSTR description,
+                                         LPCTSTR module,
                                          LPVOID lpContext);
 
 static bool CALLBACK deviceInfoCallback(LPGUID lpguid,
-                                        LPCSTR lpcstrDescription,
-                                        LPCSTR lpcstrModule,
+                                        LPCTSTR description,
+                                        LPCTSTR module,
                                         LPVOID lpContext);
 
 static bool CALLBACK defaultDeviceCallback(LPGUID lpguid,
-                                           LPCSTR lpcstrDescription,
-                                           LPCSTR lpcstrModule,
+                                           LPCTSTR description,
+                                           LPCTSTR module,
                                            LPVOID lpContext);
 
 static bool CALLBACK deviceIdCallback(LPGUID lpguid,
-                                      LPCSTR lpcstrDescription,
-                                      LPCSTR lpcstrModule,
+                                      LPCTSTR description,
+                                      LPCTSTR module,
                                       LPVOID lpContext);
 
 static char* getErrorString(int code);
@@ -5676,7 +5763,7 @@ static char* getErrorString(int code);
 extern "C" unsigned __stdcall callbackHandler(void *ptr);
 
 struct enum_info {
-  char name[64];
+  std::string name;
   LPGUID id;
   bool isInput;
   bool isValid;
@@ -5684,13 +5771,12 @@ struct enum_info {
 
 RtApiDs :: RtApiDs()
 {
-  // Dsound will run both-threaded. If CoInitialize fails, then just accept whatever the mainline 
-  // chose for a threading model.
+  // Dsound will run both-threaded. If CoInitialize fails, then just
+  // accept whatever the mainline chose for a threading model.
   coInitialized = false;
   HRESULT hr = CoInitialize(NULL);
-  if (!FAILED(hr)) {
+  if ( !FAILED(hr) )
     coInitialized = true;
-  }
 
   this->initialize();
 
@@ -5703,16 +5789,14 @@ RtApiDs :: RtApiDs()
 RtApiDs :: ~RtApiDs()
 {
   if (coInitialized)
-  {
     CoUninitialize(); // balanced call.
-  }
+
   if ( stream_.mode != UNINITIALIZED ) closeStream();
 }
 
 int RtApiDs :: getDefaultInputDevice(void)
 {
   enum_info info;
-  info.name[0] = '\0';
 
   // Enumerate through devices to find the default output.
   HRESULT result = DirectSoundCaptureEnumerate((LPDSENUMCALLBACK)defaultDeviceCallback, &info);
@@ -5724,10 +5808,9 @@ int RtApiDs :: getDefaultInputDevice(void)
   }
 
   for ( int i=0; i<nDevices_; i++ ) {
-    if ( strncmp( info.name, devices_[i].name.c_str(), 64 ) == 0 ) return i;
+    if ( info.name == devices_[i].name ) return i;
   }
 
-
   return 0;
 }
 
@@ -5746,7 +5829,7 @@ int RtApiDs :: getDefaultOutputDevice(void)
   }
 
   for ( int i=0; i<nDevices_; i++ )
-    if ( strncmp( info.name, devices_[i].name.c_str(), 64 ) == 0 ) return i;
+    if ( info.name == devices_[i].name ) return i;
 
   return 0;
 }
@@ -5778,7 +5861,6 @@ void RtApiDs :: initialize(void)
 
   std::vector<enum_info> info(count);
   for (i=0; i<count; i++) {
-    info[i].name[0] = '\0';
     if (i < outs) info[i].isInput = false;
     else info[i].isInput = true;
   }
@@ -5804,11 +5886,10 @@ void RtApiDs :: initialize(void)
   // opened, they report < 1 supported channels, or they report no
   // supported data (capture only).
   RtApiDevice device;
-  int index = 0;
   for (i=0; i<count; i++) {
     if ( info[i].isValid ) {
       device.name.erase();
-      device.name.append( (const char *)info[i].name, strlen(info[i].name)+1);
+      device.name = info[i].name;
       devices_.push_back(device);
     }
   }
@@ -5820,7 +5901,7 @@ void RtApiDs :: initialize(void)
 void RtApiDs :: probeDeviceInfo(RtApiDevice *info)
 {
   enum_info dsinfo;
-  strncpy( dsinfo.name, info->name.c_str(), 64 );
+  dsinfo.name = info->name;
   dsinfo.isValid = false;
 
   // Enumerate through input devices to find the id (if it exists).
@@ -6073,32 +6154,25 @@ bool RtApiDs :: probeDeviceOpen( int device, StreamMode mode, int channels,
   waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSample / 8;
   waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
 
-  // Determine the device buffer size. By default, 32k, 
-  // but we will grow it to make allowances for very large softare buffer sizes.
+  // Determine the device buffer size. By default, 32k, but we will
+  // grow it to make allowances for very large software buffer sizes.
   DWORD dsBufferSize = 0;
   DWORD dsPointerLeadTime = 0;
 
   buffer_size = MINIMUM_DEVICE_BUFFER_SIZE; // sound cards will always *knock wood* support this
 
-
-  // poisonously large buffer lead time? Then increase the device buffer size accordingly.
-  while (dsPointerLeadTime *2U > (DWORD)buffer_size)
-  {
-    buffer_size *= 2;
-  }
-
-
-
   enum_info dsinfo;
   void *ohandle = 0, *bhandle = 0;
-  strncpy( dsinfo.name, devices_[device].name.c_str(), 64 );
+  //  strncpy( dsinfo.name, devices_[device].name.c_str(), 64 );
+  dsinfo.name = devices_[device].name;
   dsinfo.isValid = false;
   if ( mode == OUTPUT ) {
-    dsPointerLeadTime = (numberOfBuffers) * 
-      (*bufferSize) * 
-      (waveFormat.wBitsPerSample / 8)
-      *channels;
 
+    dsPointerLeadTime = numberOfBuffers * (*bufferSize) * (waveFormat.wBitsPerSample / 8) * channels;
+
+    // If the user wants an even bigger buffer, increase the device buffer size accordingly.
+    while ( dsPointerLeadTime * 2U > (DWORD)buffer_size )
+      buffer_size *= 2;
 
     if ( devices_[device].maxOutputChannels < channels ) {
       sprintf(message_, "RtApiDs: requested channels (%d) > than supported (%d) by device (%s).",
@@ -6595,18 +6669,16 @@ void RtApiDs :: startStream()
   verifyStream();
   if (stream_.state == STREAM_RUNNING) return;
 
-
-  // increase scheduler frequency on lesser windows (a side-effect of increasing timer accuracy.
-  // on greater windows (Win2K or later), this is already in effect.
+  // Increase scheduler frequency on lesser windows (a side-effect of
+  // increasing timer accuracy).  On greater windows (Win2K or later),
+  // this is already in effect.
 
   MUTEX_LOCK(&stream_.mutex);
-
   
   DsHandle *handles = (DsHandle *) stream_.apiHandle;
 
   timeBeginPeriod(1); 
 
-
   memset(&statistics,0,sizeof(statistics));
   statistics.sampleRate = stream_.sampleRate;
   statistics.writeDeviceBufferLeadBytes = handles[0].dsPointerLeadTime ;
@@ -6614,8 +6686,7 @@ void RtApiDs :: startStream()
   buffersRolling = false;
   duplexPrerollBytes = 0;
 
-  if (stream_.mode == DUPLEX)
-  {
+  if (stream_.mode == DUPLEX) {
     // 0.5 seconds of silence in DUPLEX mode while the devices spin up and synchronize.
     duplexPrerollBytes = (int)(0.5*stream_.sampleRate*formatBytes( stream_.deviceFormat[1])*stream_.nDeviceChannels[1]);
   }
@@ -6629,9 +6700,8 @@ void RtApiDs :: startStream()
       statistics.outputFrameSize = formatBytes( stream_.deviceFormat[0])
                                   *stream_.nDeviceChannels[0];
 
-
     LPDIRECTSOUNDBUFFER buffer = (LPDIRECTSOUNDBUFFER) handles[0].buffer;
-    result = buffer->Play(0, 0, DSBPLAY_LOOPING );
+    result = buffer->Play( 0, 0, DSBPLAY_LOOPING );
     if ( FAILED(result) ) {
       sprintf(message_, "RtApiDs: Unable to start buffer (%s): %s.",
               devices_[stream_.device[0]].name.c_str(), getErrorString(result));
@@ -6661,34 +6731,30 @@ void RtApiDs :: stopStream()
   verifyStream();
   if (stream_.state == STREAM_STOPPED) return;
 
-
   // Change the state before the lock to improve shutdown response
   // when using a callback.
   stream_.state = STREAM_STOPPED;
   MUTEX_LOCK(&stream_.mutex);
 
-
   timeEndPeriod(1); // revert to normal scheduler frequency on lesser windows.
 
 #ifdef GENERATE_DEBUG_LOG
-  // write the timing log to a .TSV file for analysis in Excel.
+  // Write the timing log to a .TSV file for analysis in Excel.
   unlink("c:/rtaudiolog.txt");
   std::ofstream os("c:/rtaudiolog.txt");
   os << "writeTime\treadDelay\tnextWritePointer\tnextReadPointer\tcurrentWritePointer\tsafeWritePointer\tcurrentReadPointer\tsafeReadPointer" << std::endl;
-  for (int i = 0; i < currentDebugLogEntry ; ++i)
-  {
+  for (int i = 0; i < currentDebugLogEntry ; ++i) {
     TTickRecord &r = debugLog[i];
-    os 
-      << r.writeTime-debugLog[0].writeTime << "\t" << (r.readTime-r.writeTime) << "\t"
-      << r.nextWritePointer % BUFFER_SIZE << "\t" << r.nextReadPointer % BUFFER_SIZE 
-      << "\t" << r.currentWritePointer % BUFFER_SIZE << "\t" << r.safeWritePointer % BUFFER_SIZE 
-      << "\t" << r.currentReadPointer % BUFFER_SIZE << "\t" << r.safeReadPointer % BUFFER_SIZE << std::endl;
+    os << r.writeTime-debugLog[0].writeTime << "\t" << (r.readTime-r.writeTime) << "\t"
+       << r.nextWritePointer % BUFFER_SIZE << "\t" << r.nextReadPointer % BUFFER_SIZE 
+       << "\t" << r.currentWritePointer % BUFFER_SIZE << "\t" << r.safeWritePointer % BUFFER_SIZE 
+       << "\t" << r.currentReadPointer % BUFFER_SIZE << "\t" << r.safeReadPointer % BUFFER_SIZE << std::endl;
   }
 #endif
 
   // There is no specific DirectSound API call to "drain" a buffer
-  // before stopping.  We can hack this for playback by writing zeroes
-  // for another bufferSize * nBuffers frames.  For capture, the
+  // before stopping.  We can hack this for playback by writing
+  // buffers of zeroes over the entire buffer.  For capture, the
   // concept is less clear so we'll repeat what we do in the
   // abortStream() case.
   HRESULT result;
@@ -6701,27 +6767,26 @@ void RtApiDs :: stopStream()
   if (stream_.mode == OUTPUT || stream_.mode == DUPLEX) {
 
     DWORD currentPos, safePos;
-    long buffer_bytes = stream_.bufferSize * stream_.nDeviceChannels[0]
-                      * formatBytes(stream_.deviceFormat[0]);
-
+    long buffer_bytes = stream_.bufferSize * stream_.nDeviceChannels[0] * formatBytes(stream_.deviceFormat[0]);
 
     LPDIRECTSOUNDBUFFER dsBuffer = (LPDIRECTSOUNDBUFFER) handles[0].buffer;
-    long nextWritePos = handles[0].bufferPointer;
+    DWORD nextWritePos = handles[0].bufferPointer;
     dsBufferSize = handles[0].dsBufferSize;
+    DWORD dsBytesWritten = 0;
 
-    // Write zeroes for nBuffer counts.
-    for (int i=0; i<stream_.nBuffers; i++) {
+    // Write zeroes for at least dsBufferSize bytes. 
+    while ( dsBytesWritten < dsBufferSize ) {
 
       // Find out where the read and "safe write" pointers are.
-      result = dsBuffer->GetCurrentPosition(&currentPos, &safePos);
+      result = dsBuffer->GetCurrentPosition( &currentPos, &safePos );
       if ( FAILED(result) ) {
         sprintf(message_, "RtApiDs: Unable to get current position (%s): %s.",
                 devices_[stream_.device[0]].name.c_str(), getErrorString(result));
         error(RtError::DRIVER_ERROR);
       }
-      // Chase nextWritePos.
 
-      if ( currentPos < (DWORD)nextWritePos ) currentPos += dsBufferSize; // unwrap offset
+      // Chase nextWritePosition.
+      if ( currentPos < nextWritePos ) currentPos += dsBufferSize; // unwrap offset
       DWORD endWrite = nextWritePos + buffer_bytes;
 
       // Check whether the entire write region is behind the play pointer.
@@ -6738,11 +6803,12 @@ void RtApiDs :: stopStream()
                   devices_[stream_.device[0]].name.c_str(), getErrorString(result));
           error(RtError::DRIVER_ERROR);
         }
+
         if ( currentPos < (DWORD)nextWritePos ) currentPos += dsBufferSize; // unwrap offset
       }
 
       // Lock free space in the buffer
-      result = dsBuffer->Lock (nextWritePos, buffer_bytes, &buffer1,
+      result = dsBuffer->LocknextWritePos, buffer_bytes, &buffer1,
                                &bufferSize1, &buffer2, &bufferSize2, 0);
       if ( FAILED(result) ) {
         sprintf(message_, "RtApiDs: Unable to lock buffer during playback (%s): %s.",
@@ -6751,11 +6817,11 @@ void RtApiDs :: stopStream()
       }
 
       // Zero the free space
-      ZeroMemory(buffer1, bufferSize1);
-      if (buffer2 != NULL) ZeroMemory(buffer2, bufferSize2);
+      ZeroMemory( buffer1, bufferSize1 );
+      if (buffer2 != NULL) ZeroMemory( buffer2, bufferSize2 );
 
       // Update our buffer offset and unlock sound buffer
-      dsBuffer->Unlock (buffer1, bufferSize1, buffer2, bufferSize2);
+      dsBuffer->Unlock( buffer1, bufferSize1, buffer2, bufferSize2 );
       if ( FAILED(result) ) {
         sprintf(message_, "RtApiDs: Unable to unlock buffer during playback (%s): %s.",
                 devices_[stream_.device[0]].name.c_str(), getErrorString(result));
@@ -6763,6 +6829,15 @@ void RtApiDs :: stopStream()
       }
       nextWritePos = (nextWritePos + bufferSize1 + bufferSize2) % dsBufferSize;
       handles[0].bufferPointer = nextWritePos;
+      dsBytesWritten += buffer_bytes;
+    }
+
+    // OK, now stop the buffer.
+    result = dsBuffer->Stop();
+    if ( FAILED(result) ) {
+      sprintf(message_, "RtApiDs: Unable to stop buffer (%s): %s",
+              devices_[stream_.device[0]].name.c_str(), getErrorString(result));
+      error(RtError::DRIVER_ERROR);
     }
 
     // If we play again, start at the beginning of the buffer.
@@ -6821,6 +6896,8 @@ void RtApiDs :: abortStream()
   stream_.state = STREAM_STOPPED;
   MUTEX_LOCK(&stream_.mutex);
 
+  timeEndPeriod(1); // revert to normal scheduler frequency on lesser windows.
+
   HRESULT result;
   long dsBufferSize;
   LPVOID audioPtr;
@@ -7001,6 +7078,7 @@ void RtApiDs :: tickStream()
 #ifdef GENERATE_DEBUG_LOG
   DWORD writeTime, readTime;
 #endif
+
   LPVOID buffer1 = NULL;
   LPVOID buffer2 = NULL;
   DWORD bufferSize1 = 0;
@@ -7010,29 +7088,29 @@ void RtApiDs :: tickStream()
   long buffer_bytes;
   DsHandle *handles = (DsHandle *) stream_.apiHandle;
 
-  if (stream_.mode == DUPLEX && !buffersRolling)
-  {
+  if (stream_.mode == DUPLEX && !buffersRolling) {
     assert(handles[0].dsBufferSize == handles[1].dsBufferSize);
 
-    // it takes a while for the devices to get rolling. As a result, there's 
-    // no guarantee that the capture and write device pointers will move in lockstep.
-    // Wait here for both devices to start rolling, and then set our buffer pointers accordingly.
-    // e.g. Crystal Drivers: the capture buffer starts up 5700 to 9600 bytes later than the write
-    // buffer.
+    // It takes a while for the devices to get rolling. As a result,
+    // there's no guarantee that the capture and write device pointers
+    // will move in lockstep.  Wait here for both devices to start
+    // rolling, and then set our buffer pointers accordingly.
+    // e.g. Crystal Drivers: the capture buffer starts up 5700 to 9600
+    // bytes later than the write buffer.
 
-    // Stub: a serious risk of having a pre-emptive scheduling round take place between 
-    // the two GetCurrentPosition calls... but I'm really not sure how to solve the problem.
-    // Temporarily boost to Realtime priority, maybe; but I'm not sure what priority the 
-    // directsound service threads run at. We *should* be roughly within a ms or so of correct.
+    // Stub: a serious risk of having a pre-emptive scheduling round
+    // take place between the two GetCurrentPosition calls... but I'm
+    // really not sure how to solve the problem.  Temporarily boost to
+    // Realtime priority, maybe; but I'm not sure what priority the
+    // directsound service threads run at. We *should* be roughly
+    // within a ms or so of correct.
 
     LPDIRECTSOUNDBUFFER dsWriteBuffer = (LPDIRECTSOUNDBUFFER) handles[0].buffer;
     LPDIRECTSOUNDCAPTUREBUFFER dsCaptureBuffer = (LPDIRECTSOUNDCAPTUREBUFFER) handles[1].buffer;
 
-
     DWORD initialWritePos, initialSafeWritePos;
     DWORD initialReadPos, initialSafeReadPos;;
 
-
     result = dsWriteBuffer->GetCurrentPosition(&initialWritePos, &initialSafeWritePos);
     if ( FAILED(result) ) {
       sprintf(message_, "RtApiDs: Unable to get current position (%s): %s.",
@@ -7045,8 +7123,7 @@ void RtApiDs :: tickStream()
               devices_[stream_.device[1]].name.c_str(), getErrorString(result));
       error(RtError::DRIVER_ERROR);
     }
-    while (true)
-    {
+    while (true) {
       result = dsWriteBuffer->GetCurrentPosition(&currentWritePos, &safeWritePos);
       if ( FAILED(result) ) {
         sprintf(message_, "RtApiDs: Unable to get current position (%s): %s.",
@@ -7059,16 +7136,14 @@ void RtApiDs :: tickStream()
                 devices_[stream_.device[1]].name.c_str(), getErrorString(result));
         error(RtError::DRIVER_ERROR);
       }
-      if (safeWritePos != initialSafeWritePos && safeReadPos != initialSafeReadPos)
-      {
+      if (safeWritePos != initialSafeWritePos && safeReadPos != initialSafeReadPos) {
         break;
       }
       Sleep(1);
     }
 
-    assert(handles[0].dsBufferSize == handles[1].dsBufferSize);
+    assert( handles[0].dsBufferSize == handles[1].dsBufferSize );
 
-    UINT writeBufferLead = (safeWritePos-safeReadPos + handles[0].dsBufferSize) % handles[0].dsBufferSize;
     buffersRolling = true;
     handles[0].bufferPointer = (safeWritePos + handles[0].dsPointerLeadTime);
     handles[1].bufferPointer = safeReadPos;
@@ -7104,8 +7179,7 @@ void RtApiDs :: tickStream()
          nextWritePos = handles[0].bufferPointer;
 
     DWORD endWrite;
-    while (true)
-    {
+    while ( true ) {
       // Find out where the read and "safe write" pointers are.
       result = dsBuffer->GetCurrentPosition(&currentWritePos, &safeWritePos);
       if ( FAILED(result) ) {
@@ -7115,16 +7189,11 @@ void RtApiDs :: tickStream()
       }
 
       leadPos = safeWritePos + handles[0].dsPointerLeadTime;
-      if (leadPos > dsBufferSize) {
-          leadPos -= dsBufferSize;
-      }
+      if ( leadPos > dsBufferSize ) leadPos -= dsBufferSize;
       if ( leadPos < nextWritePos ) leadPos += dsBufferSize; // unwrap offset
-
-
       endWrite = nextWritePos + buffer_bytes;
 
-    // Check whether the entire write region is behind the play pointer.
-
+      // Check whether the entire write region is behind the play pointer.
       if ( leadPos >= endWrite ) break;
 
       // If we are here, then we must wait until the play pointer gets
@@ -7139,28 +7208,24 @@ void RtApiDs :: tickStream()
       double millis = (endWrite - leadPos) * 900.0;
       millis /= ( formatBytes(stream_.deviceFormat[0]) *stream_.nDeviceChannels[0]* stream_.sampleRate);
       if ( millis < 1.0 ) millis = 1.0;
-      if (millis > 50.0) {
+      if ( millis > 50.0 ) {
         static int nOverruns = 0;
         ++nOverruns;
       }
       Sleep( (DWORD) millis );
-      // Sleep( (DWORD) 2);
     }
+
 #ifdef GENERATE_DEBUG_LOG
     writeTime = timeGetTime();
 #endif
-    if (statistics.writeDeviceSafeLeadBytes < dsPointerDifference(safeWritePos,currentWritePos,handles[0].dsBufferSize))
-    {
+
+    if (statistics.writeDeviceSafeLeadBytes < dsPointerDifference(safeWritePos,currentWritePos,handles[0].dsBufferSize)) {
       statistics.writeDeviceSafeLeadBytes = dsPointerDifference(safeWritePos,currentWritePos,handles[0].dsBufferSize);
     }
 
-    if (
-      dsPointerBetween(nextWritePos,safeWritePos,currentWritePos,dsBufferSize)
-      || dsPointerBetween(endWrite,safeWritePos,currentWritePos,dsBufferSize)
-    )
-    { 
-      // we've strayed into the forbidden zone. 
-      // resync the read pointer.
+    if ( dsPointerBetween( nextWritePos, safeWritePos, currentWritePos, dsBufferSize )
+         || dsPointerBetween( endWrite, safeWritePos, currentWritePos, dsBufferSize ) ) { 
+      // We've strayed into the forbidden zone ... resync the read pointer.
       ++statistics.numberOfWriteUnderruns;
       nextWritePos = safeWritePos + handles[0].dsPointerLeadTime-buffer_bytes+dsBufferSize;
       while (nextWritePos >= dsBufferSize) nextWritePos-= dsBufferSize;
@@ -7169,8 +7234,8 @@ void RtApiDs :: tickStream()
     }
     
     // Lock free space in the buffer
-    result = dsBuffer->Lock (nextWritePos, buffer_bytes, &buffer1,
-                             &bufferSize1, &buffer2, &bufferSize2, 0);
+    result = dsBuffer->LocknextWritePos, buffer_bytes, &buffer1,
+                             &bufferSize1, &buffer2, &bufferSize2, 0 );
     if ( FAILED(result) ) {
       sprintf(message_, "RtApiDs: Unable to lock buffer during playback (%s): %s.",
               devices_[stream_.device[0]].name.c_str(), getErrorString(result));
@@ -7182,7 +7247,7 @@ void RtApiDs :: tickStream()
     if (buffer2 != NULL) CopyMemory(buffer2, buffer+bufferSize1, bufferSize2);
 
     // Update our buffer offset and unlock sound buffer
-    dsBuffer->Unlock (buffer1, bufferSize1, buffer2, bufferSize2);
+    dsBuffer->Unlock( buffer1, bufferSize1, buffer2, bufferSize2 );
     if ( FAILED(result) ) {
       sprintf(message_, "RtApiDs: Unable to unlock buffer during playback (%s): %s.",
               devices_[stream_.device[0]].name.c_str(), getErrorString(result));
@@ -7230,9 +7295,9 @@ void RtApiDs :: tickStream()
     // the very complex relationship between phase and increment of the read and write 
     // pointers.
     //
-    // In order to minimize audible dropouts in DUPLEX mode, we will provide a pre-roll 
-    //  period of 0.5 seconds
-    // in which we return zeros from the read buffer while the pointers sync up.
+    // In order to minimize audible dropouts in DUPLEX mode, we will
+    // provide a pre-roll period of 0.5 seconds in which we return
+    // zeros from the read buffer while the pointers sync up.
 
     if (stream_.mode == DUPLEX)
     {
@@ -7381,8 +7446,8 @@ extern "C" unsigned __stdcall callbackHandler(void *ptr)
 }
 
 static bool CALLBACK deviceCountCallback(LPGUID lpguid,
-                                         LPCSTR lpcstrDescription,
-                                         LPCSTR lpcstrModule,
+                                         LPCTSTR description,
+                                         LPCTSTR module,
                                          LPVOID lpContext)
 {
   int *pointer = ((int *) lpContext);
@@ -7391,22 +7456,41 @@ static bool CALLBACK deviceCountCallback(LPGUID lpguid,
   return true;
 }
 
+#include "tchar.h"
+
+std::string convertTChar( LPCTSTR name )
+{
+  std::string s;
+
+#if defined( UNICODE ) || defined( _UNICODE )
+  // Yes, this conversion doesn't make sense for two-byte characters
+  // but RtAudio is currently written to return an std::string of
+  // one-byte chars for the device name.
+  for ( unsigned int i=0; i<wcslen( name ); i++ )
+    s.push_back( name[i] );
+#else
+  s.append( std::string( name ) );
+#endif
+
+  return s;
+}
+
 static bool CALLBACK deviceInfoCallback(LPGUID lpguid,
-                                        LPCSTR lpcstrDescription,
-                                        LPCSTR lpcstrModule,
+                                        LPCTSTR description,
+                                        LPCTSTR module,
                                         LPVOID lpContext)
 {
   enum_info *info = ((enum_info *) lpContext);
-  while (strlen(info->name) > 0) info++;
+  while ( !info->name.empty() ) info++;
 
-  strncpy(info->name, lpcstrDescription, 64);
+  info->name = convertTChar( description );
   info->id = lpguid;
 
-       HRESULT    hr;
+  HRESULT hr;
   info->isValid = false;
   if (info->isInput == true) {
-    DSCCAPS               caps;
-    LPDIRECTSOUNDCAPTURE  object;
+    DSCCAPS caps;
+    LPDIRECTSOUNDCAPTURE object;
 
     hr = DirectSoundCaptureCreate(  lpguid, &object,   NULL );
     if( hr != DS_OK ) return true;
@@ -7420,8 +7504,8 @@ static bool CALLBACK deviceInfoCallback(LPGUID lpguid,
     object->Release();
   }
   else {
-    DSCAPS         caps;
-    LPDIRECTSOUND  object;
+    DSCAPS caps;
+    LPDIRECTSOUND object;
     hr = DirectSoundCreate(  lpguid, &object,   NULL );
     if( hr != DS_OK ) return true;
 
@@ -7438,14 +7522,14 @@ static bool CALLBACK deviceInfoCallback(LPGUID lpguid,
 }
 
 static bool CALLBACK defaultDeviceCallback(LPGUID lpguid,
-                                           LPCSTR lpcstrDescription,
-                                           LPCSTR lpcstrModule,
+                                           LPCTSTR description,
+                                           LPCTSTR module,
                                            LPVOID lpContext)
 {
   enum_info *info = ((enum_info *) lpContext);
 
   if ( lpguid == NULL ) {
-    strncpy(info->name, lpcstrDescription, 64);
+    info->name = convertTChar( description );
     return false;
   }
 
@@ -7453,13 +7537,14 @@ static bool CALLBACK defaultDeviceCallback(LPGUID lpguid,
 }
 
 static bool CALLBACK deviceIdCallback(LPGUID lpguid,
-                                      LPCSTR lpcstrDescription,
-                                      LPCSTR lpcstrModule,
+                                      LPCTSTR description,
+                                      LPCTSTR module,
                                       LPVOID lpContext)
 {
   enum_info *info = ((enum_info *) lpContext);
 
-  if ( strncmp( info->name, lpcstrDescription, 64 ) == 0 ) {
+  std::string s = convertTChar( description );
+  if ( info->name == s ) {
     info->id = lpguid;
     info->isValid = true;
     return false;
index e26f81d186d54e2b7299f0e0290a214577af9a68..d9b8ff243994f2a154e694a00784df0d2775fc20 100644 (file)
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -37,7 +37,7 @@
 */
 /************************************************************************/
 
-// RtAudio: Version 3.0.2 (14 October 2005)
+// RtAudio: Version 3.0.3 (18 November 2005)
 
 #ifndef __RTAUDIO_H
 #define __RTAUDIO_H
@@ -552,6 +552,7 @@ public:
   private:
 
   void initialize(void);
+  bool primeOutputBuffer();
   void probeDeviceInfo( RtApiDevice *info );
   bool probeDeviceOpen( int device, StreamMode mode, int channels, 
                         int sampleRate, RtAudioFormat format,
diff --git a/asio/asio.cpp b/asio/asio.cpp
new file mode 100644 (file)
index 0000000..b241663
--- /dev/null
@@ -0,0 +1,257 @@
+/*\r
+       Steinberg Audio Stream I/O API\r
+       (c) 1996, Steinberg Soft- und Hardware GmbH\r
+\r
+       asio.cpp\r
+       \r
+       asio functions entries which translate the\r
+       asio interface to the asiodrvr class methods\r
+*/ \r
+       \r
+#include <string.h>\r
+#include "asiosys.h"           // platform definition\r
+#include "asio.h"\r
+\r
+#if MAC\r
+#include "asiodrvr.h"\r
+\r
+#pragma export on\r
+\r
+AsioDriver *theAsioDriver = 0;\r
+\r
+extern "C"\r
+{\r
+\r
+long main()\r
+{\r
+       return 'ASIO';\r
+}\r
+\r
+#elif WINDOWS\r
+\r
+#include "windows.h"\r
+#include "iasiodrv.h"\r
+#include "asiodrivers.h"\r
+\r
+IASIO *theAsioDriver = 0;\r
+extern AsioDrivers *asioDrivers;\r
+\r
+#elif SGI || SUN || BEOS || LINUX\r
+#include "asiodrvr.h"\r
+static AsioDriver *theAsioDriver = 0;\r
+#endif\r
+\r
+//-----------------------------------------------------------------------------------------------------\r
+ASIOError ASIOInit(ASIODriverInfo *info)\r
+{\r
+#if MAC || SGI || SUN || BEOS || LINUX\r
+       if(theAsioDriver)\r
+       {\r
+               delete theAsioDriver;\r
+               theAsioDriver = 0;\r
+       }               \r
+       info->driverVersion = 0;\r
+       strcpy(info->name, "No ASIO Driver");\r
+       theAsioDriver = getDriver();\r
+       if(!theAsioDriver)\r
+       {\r
+               strcpy(info->errorMessage, "Not enough memory for the ASIO driver!"); \r
+               return ASE_NotPresent;\r
+       }\r
+       if(!theAsioDriver->init(info->sysRef))\r
+       {\r
+               theAsioDriver->getErrorMessage(info->errorMessage);\r
+               delete theAsioDriver;\r
+               theAsioDriver = 0;\r
+               return ASE_NotPresent;\r
+       }\r
+       strcpy(info->errorMessage, "No ASIO Driver Error");\r
+       theAsioDriver->getDriverName(info->name);\r
+       info->driverVersion = theAsioDriver->getDriverVersion();\r
+       return ASE_OK;\r
+\r
+#else\r
+\r
+       info->driverVersion = 0;\r
+       strcpy(info->name, "No ASIO Driver");\r
+       if(theAsioDriver)       // must be loaded!\r
+       {\r
+               if(!theAsioDriver->init(info->sysRef))\r
+               {\r
+                       theAsioDriver->getErrorMessage(info->errorMessage);\r
+                       theAsioDriver = 0;\r
+                       return ASE_NotPresent;\r
+               }               \r
+\r
+               strcpy(info->errorMessage, "No ASIO Driver Error");\r
+               theAsioDriver->getDriverName(info->name);\r
+               info->driverVersion = theAsioDriver->getDriverVersion();\r
+               return ASE_OK;\r
+       }\r
+       return ASE_NotPresent;\r
+\r
+#endif // !MAC\r
+}\r
+\r
+ASIOError ASIOExit(void)\r
+{\r
+       if(theAsioDriver)\r
+       {\r
+#if WINDOWS\r
+               asioDrivers->removeCurrentDriver();\r
+#else\r
+               delete theAsioDriver;\r
+#endif\r
+       }               \r
+       theAsioDriver = 0;\r
+       return ASE_OK;\r
+}\r
+\r
+ASIOError ASIOStart(void)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->start();\r
+}\r
+\r
+ASIOError ASIOStop(void)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->stop();\r
+}\r
+\r
+ASIOError ASIOGetChannels(long *numInputChannels, long *numOutputChannels)\r
+{\r
+       if(!theAsioDriver)\r
+       {\r
+               *numInputChannels = *numOutputChannels = 0;\r
+               return ASE_NotPresent;\r
+       }\r
+       return theAsioDriver->getChannels(numInputChannels, numOutputChannels);\r
+}\r
+\r
+ASIOError ASIOGetLatencies(long *inputLatency, long *outputLatency)\r
+{\r
+       if(!theAsioDriver)\r
+       {\r
+               *inputLatency = *outputLatency = 0;\r
+               return ASE_NotPresent;\r
+       }\r
+       return theAsioDriver->getLatencies(inputLatency, outputLatency);\r
+}\r
+\r
+ASIOError ASIOGetBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity)\r
+{\r
+       if(!theAsioDriver)\r
+       {\r
+               *minSize = *maxSize = *preferredSize = *granularity = 0;\r
+               return ASE_NotPresent;\r
+       }\r
+       return theAsioDriver->getBufferSize(minSize, maxSize, preferredSize, granularity);\r
+}\r
+\r
+ASIOError ASIOCanSampleRate(ASIOSampleRate sampleRate)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->canSampleRate(sampleRate);\r
+}\r
+\r
+ASIOError ASIOGetSampleRate(ASIOSampleRate *currentRate)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->getSampleRate(currentRate);\r
+}\r
+\r
+ASIOError ASIOSetSampleRate(ASIOSampleRate sampleRate)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->setSampleRate(sampleRate);\r
+}\r
+\r
+ASIOError ASIOGetClockSources(ASIOClockSource *clocks, long *numSources)\r
+{\r
+       if(!theAsioDriver)\r
+       {\r
+               *numSources = 0;\r
+               return ASE_NotPresent;\r
+       }\r
+       return theAsioDriver->getClockSources(clocks, numSources);\r
+}\r
+\r
+ASIOError ASIOSetClockSource(long reference)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->setClockSource(reference);\r
+}\r
+\r
+ASIOError ASIOGetSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->getSamplePosition(sPos, tStamp);\r
+}\r
+\r
+ASIOError ASIOGetChannelInfo(ASIOChannelInfo *info)\r
+{\r
+       if(!theAsioDriver)\r
+       {\r
+               info->channelGroup = -1;\r
+               info->type = ASIOSTInt16MSB;\r
+               strcpy(info->name, "None");\r
+               return ASE_NotPresent;\r
+       }\r
+       return theAsioDriver->getChannelInfo(info);\r
+}\r
+\r
+ASIOError ASIOCreateBuffers(ASIOBufferInfo *bufferInfos, long numChannels,\r
+       long bufferSize, ASIOCallbacks *callbacks)\r
+{\r
+       if(!theAsioDriver)\r
+       {\r
+               ASIOBufferInfo *info = bufferInfos;\r
+               for(long i = 0; i < numChannels; i++, info++)\r
+                       info->buffers[0] = info->buffers[1] = 0;\r
+               return ASE_NotPresent;\r
+       }\r
+       return theAsioDriver->createBuffers(bufferInfos, numChannels, bufferSize, callbacks);\r
+}\r
+\r
+ASIOError ASIODisposeBuffers(void)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->disposeBuffers();\r
+}\r
+\r
+ASIOError ASIOControlPanel(void)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->controlPanel();\r
+}\r
+\r
+ASIOError ASIOFuture(long selector, void *opt)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->future(selector, opt);\r
+}\r
+\r
+ASIOError ASIOOutputReady(void)\r
+{\r
+       if(!theAsioDriver)\r
+               return ASE_NotPresent;\r
+       return theAsioDriver->outputReady();\r
+}\r
+\r
+#if MAC\r
+}      // extern "C"\r
+#pragma export off\r
+#endif\r
+\r
+\r
index 30031306ee97e50dd97e61e34da2ec43a032f789..8ec811f8fe08f5a1ecd0f62bf30e4a8792867bd0 100644 (file)
@@ -3,9 +3,12 @@
 \r
 /*\r
        Steinberg Audio Stream I/O API\r
-       (c) 1997 - 1999, Steinberg Soft- und Hardware GmbH\r
+       (c) 1997 - 2005, Steinberg Media Technologies GmbH\r
+\r
+       ASIO Interface Specification v 2.1\r
+\r
+       2005 - Added support for DSD sample data (in cooperation with Sony)\r
 \r
-       ASIO Interface Specification v 2.0\r
 \r
        basic concept is an i/o synchronous double-buffer scheme:\r
        \r
@@ -131,7 +134,7 @@ enum {
 \r
        // these are used for 32 bit data buffer, with different alignment of the data inside\r
        // 32 bit PCI bus systems can be more easily used with these\r
-       ASIOSTInt32MSB16 = 8,           // 32 bit data with 18 bit alignment\r
+       ASIOSTInt32MSB16 = 8,           // 32 bit data with 16 bit alignment\r
        ASIOSTInt32MSB18 = 9,           // 32 bit data with 18 bit alignment\r
        ASIOSTInt32MSB20 = 10,          // 32 bit data with 20 bit alignment\r
        ASIOSTInt32MSB24 = 11,          // 32 bit data with 24 bit alignment\r
@@ -147,9 +150,56 @@ enum {
        ASIOSTInt32LSB16 = 24,          // 32 bit data with 18 bit alignment\r
        ASIOSTInt32LSB18 = 25,          // 32 bit data with 18 bit alignment\r
        ASIOSTInt32LSB20 = 26,          // 32 bit data with 20 bit alignment\r
-       ASIOSTInt32LSB24 = 27           // 32 bit data with 24 bit alignment\r
+       ASIOSTInt32LSB24 = 27,          // 32 bit data with 24 bit alignment\r
+\r
+       //      ASIO DSD format.\r
+       ASIOSTDSDInt8LSB1   = 32,               // DSD 1 bit data, 8 samples per byte. First sample in Least significant bit.\r
+       ASIOSTDSDInt8MSB1   = 33,               // DSD 1 bit data, 8 samples per byte. First sample in Most significant bit.\r
+       ASIOSTDSDInt8NER8       = 40,           // DSD 8 bit data, 1 sample per byte. No Endianness required.\r
+\r
+       ASIOSTLastEntry\r
 };\r
 \r
+/*-----------------------------------------------------------------------------\r
+// DSD operation and buffer layout\r
+// Definition by Steinberg/Sony Oxford.\r
+//\r
+// We have tried to treat DSD as PCM and so keep a consistant structure across\r
+// the ASIO interface.\r
+//\r
+// DSD's sample rate is normally referenced as a multiple of 44.1Khz, so\r
+// the standard sample rate is refered to as 64Fs (or 2.8224Mhz). We looked\r
+// at making a special case for DSD and adding a field to the ASIOFuture that\r
+// would allow the user to select the Over Sampleing Rate (OSR) as a seperate\r
+// entity but decided in the end just to treat it as a simple value of\r
+// 2.8224Mhz and use the standard interface to set it.\r
+//\r
+// The second problem was the "word" size, in PCM the word size is always a\r
+// greater than or equal to 8 bits (a byte). This makes life easy as we can\r
+// then pack the samples into the "natural" size for the machine.\r
+// In DSD the "word" size is 1 bit. This is not a major problem and can easily\r
+// be dealt with if we ensure that we always deal with a multiple of 8 samples.\r
+//\r
+// DSD brings with it another twist to the Endianness religion. How are the\r
+// samples packed into the byte. It would be nice to just say the most significant\r
+// bit is always the first sample, however there would then be a performance hit\r
+// on little endian machines. Looking at how some of the processing goes...\r
+// Little endian machines like the first sample to be in the Least Significant Bit,\r
+//   this is because when you write it to memory the data is in the correct format\r
+//   to be shifted in and out of the words.\r
+// Big endian machine prefer the first sample to be in the Most Significant Bit,\r
+//   again for the same reasion.\r
+//\r
+// And just when things were looking really muddy there is a proposed extension to\r
+// DSD that uses 8 bit word sizes. It does not care what endianness you use.\r
+//\r
+// Switching the driver between DSD and PCM mode\r
+// ASIOFuture allows for extending the ASIO API quite transparently.\r
+// See kAsioSetIoFormat, kAsioGetIoFormat, kAsioCanDoIoFormat\r
+//\r
+//-----------------------------------------------------------------------------*/\r
+\r
+\r
 //- - - - - - - - - - - - - - - - - - - - - - - - -\r
 // Error codes\r
 //- - - - - - - - - - - - - - - - - - - - - - - - -\r
@@ -403,9 +453,14 @@ enum
        kAsioSupportsTimeInfo,          // if host returns true here, it will expect the\r
                                                                // callback bufferSwitchTimeInfo to be called instead\r
                                                                // of bufferSwitch\r
-       kAsioSupportsTimeCode,          // supports time code reading/writing\r
-\r
-       kAsioSupportsInputMonitor,      // supports input monitoring\r
+       kAsioSupportsTimeCode,          // \r
+       kAsioMMCCommand,                        // unused - value: number of commands, message points to mmc commands\r
+       kAsioSupportsInputMonitor,      // kAsioSupportsXXX return 1 if host supports this\r
+       kAsioSupportsInputGain,     // unused and undefined\r
+       kAsioSupportsInputMeter,    // unused and undefined\r
+       kAsioSupportsOutputGain,    // unused and undefined\r
+       kAsioSupportsOutputMeter,   // unused and undefined\r
+       kAsioOverload,              // driver detected an overload\r
 \r
        kAsioNumMessageSelectors\r
 };\r
@@ -860,7 +915,14 @@ enum
        kAsioCanInputGain,\r
        kAsioCanInputMeter,\r
        kAsioCanOutputGain,\r
-       kAsioCanOutputMeter\r
+       kAsioCanOutputMeter,\r
+\r
+       //      DSD support\r
+       //      The following extensions are required to allow switching\r
+       //      and control of the DSD subsystem.\r
+       kAsioSetIoFormat                        = 0x23111961,           /* ASIOIoFormat * in params.                    */\r
+       kAsioGetIoFormat                        = 0x23111983,           /* ASIOIoFormat * in params.                    */\r
+       kAsioCanDoIoFormat                      = 0x23112004,           /* ASIOIoFormat * in params.                    */\r
 };\r
 \r
 typedef struct ASIOInputMonitor\r
@@ -905,6 +967,43 @@ enum
        kTransMonitor           // trackSwitches\r
 };\r
 \r
+/*\r
+// DSD support\r
+//     Some notes on how to use ASIOIoFormatType.\r
+//\r
+//     The caller will fill the format with the request types.\r
+//     If the board can do the request then it will leave the\r
+//     values unchanged. If the board does not support the\r
+//     request then it will change that entry to Invalid (-1)\r
+//\r
+//     So to request DSD then\r
+//\r
+//     ASIOIoFormat NeedThis={kASIODSDFormat};\r
+//\r
+//     if(ASE_SUCCESS != ASIOFuture(kAsioSetIoFormat,&NeedThis) ){\r
+//             // If the board did not accept one of the parameters then the\r
+//             // whole call will fail and the failing parameter will\r
+//             // have had its value changes to -1.\r
+//     }\r
+//\r
+// Note: Switching between the formats need to be done before the "prepared"\r
+// state (see ASIO 2 documentation) is entered.\r
+*/\r
+typedef long int ASIOIoFormatType;\r
+enum ASIOIoFormatType_e\r
+{\r
+       kASIOFormatInvalid = -1,\r
+       kASIOPCMFormat = 0,\r
+       kASIODSDFormat = 1,\r
+};\r
+\r
+typedef struct ASIOIoFormat_s\r
+{\r
+       ASIOIoFormatType        FormatType;\r
+       char                            future[512-sizeof(ASIOIoFormatType)];\r
+} ASIOIoFormat;\r
+\r
+\r
 ASIOError ASIOOutputReady(void);\r
 /* Purpose:\r
          this tells the driver that the host has completed processing\r
diff --git a/asio/asiodrivers.cpp b/asio/asiodrivers.cpp
new file mode 100644 (file)
index 0000000..5f56454
--- /dev/null
@@ -0,0 +1,186 @@
+#include <string.h>\r
+#include "asiodrivers.h"\r
+\r
+AsioDrivers* asioDrivers = 0;\r
+\r
+bool loadAsioDriver(char *name);\r
+\r
+bool loadAsioDriver(char *name)\r
+{\r
+       if(!asioDrivers)\r
+               asioDrivers = new AsioDrivers();\r
+       if(asioDrivers)\r
+               return asioDrivers->loadDriver(name);\r
+       return false;\r
+}\r
+\r
+//------------------------------------------------------------------------------------\r
+\r
+#if MAC\r
+\r
+bool resolveASIO(unsigned long aconnID);\r
+\r
+AsioDrivers::AsioDrivers() : CodeFragments("ASIO Drivers", 'AsDr', 'Asio')\r
+{\r
+       connID = -1;\r
+       curIndex = -1;\r
+}\r
+\r
+AsioDrivers::~AsioDrivers()\r
+{\r
+       removeCurrentDriver();\r
+}\r
+\r
+bool AsioDrivers::getCurrentDriverName(char *name)\r
+{\r
+       if(curIndex >= 0)\r
+               return getName(curIndex, name);\r
+       return false;\r
+}\r
+\r
+long AsioDrivers::getDriverNames(char **names, long maxDrivers)\r
+{\r
+       for(long i = 0; i < getNumFragments() && i < maxDrivers; i++)\r
+               getName(i, names[i]);\r
+       return getNumFragments() < maxDrivers ? getNumFragments() : maxDrivers;\r
+}\r
+\r
+bool AsioDrivers::loadDriver(char *name)\r
+{\r
+       char dname[64];\r
+       unsigned long newID;\r
+\r
+       for(long i = 0; i < getNumFragments(); i++)\r
+       {\r
+               if(getName(i, dname) && !strcmp(name, dname))\r
+               {\r
+                       if(newInstance(i, &newID))\r
+                       {\r
+                               if(resolveASIO(newID))\r
+                               {\r
+                                       if(connID != -1)\r
+                                               removeInstance(curIndex, connID);\r
+                                       curIndex = i;\r
+                                       connID = newID;\r
+                                       return true;\r
+                               }\r
+                       }\r
+                       break;\r
+               }\r
+       }\r
+       return false;\r
+}\r
+\r
+void AsioDrivers::removeCurrentDriver()\r
+{\r
+       if(connID != -1)\r
+               removeInstance(curIndex, connID);\r
+       connID = -1;\r
+       curIndex = -1;\r
+}\r
+\r
+//------------------------------------------------------------------------------------\r
+\r
+#elif WINDOWS\r
+\r
+#include "iasiodrv.h"\r
+\r
+extern IASIO* theAsioDriver;\r
+\r
+AsioDrivers::AsioDrivers() : AsioDriverList()\r
+{\r
+       curIndex = -1;\r
+}\r
+\r
+AsioDrivers::~AsioDrivers()\r
+{\r
+}\r
+\r
+bool AsioDrivers::getCurrentDriverName(char *name)\r
+{\r
+       if(curIndex >= 0)\r
+               return asioGetDriverName(curIndex, name, 32) == 0 ? true : false;\r
+       name[0] = 0;\r
+       return false;\r
+}\r
+\r
+long AsioDrivers::getDriverNames(char **names, long maxDrivers)\r
+{\r
+       for(long i = 0; i < asioGetNumDev() && i < maxDrivers; i++)\r
+               asioGetDriverName(i, names[i], 32);\r
+       return asioGetNumDev() < maxDrivers ? asioGetNumDev() : maxDrivers;\r
+}\r
+\r
+bool AsioDrivers::loadDriver(char *name)\r
+{\r
+       char dname[64];\r
+       char curName[64];\r
+\r
+       for(long i = 0; i < asioGetNumDev(); i++)\r
+       {\r
+               if(!asioGetDriverName(i, dname, 32) && !strcmp(name, dname))\r
+               {\r
+                       curName[0] = 0;\r
+                       getCurrentDriverName(curName);  // in case we fail...\r
+                       removeCurrentDriver();\r
+\r
+                       if(!asioOpenDriver(i, (void **)&theAsioDriver))\r
+                       {\r
+                               curIndex = i;\r
+                               return true;\r
+                       }\r
+                       else\r
+                       {\r
+                               theAsioDriver = 0;\r
+                               if(curName[0] && strcmp(dname, curName))\r
+                                       loadDriver(curName);    // try restore\r
+                       }\r
+                       break;\r
+               }\r
+       }\r
+       return false;\r
+}\r
+\r
+void AsioDrivers::removeCurrentDriver()\r
+{\r
+       if(curIndex != -1)\r
+               asioCloseDriver(curIndex);\r
+       curIndex = -1;\r
+}\r
+\r
+#elif SGI || BEOS\r
+\r
+#include "asiolist.h"\r
+\r
+AsioDrivers::AsioDrivers() \r
+       : AsioDriverList()\r
+{\r
+       curIndex = -1;\r
+}\r
+\r
+AsioDrivers::~AsioDrivers()\r
+{\r
+}\r
+\r
+bool AsioDrivers::getCurrentDriverName(char *name)\r
+{\r
+       return false;\r
+}\r
+\r
+long AsioDrivers::getDriverNames(char **names, long maxDrivers)\r
+{\r
+       return 0;\r
+}\r
+\r
+bool AsioDrivers::loadDriver(char *name)\r
+{\r
+       return false;\r
+}\r
+\r
+void AsioDrivers::removeCurrentDriver()\r
+{\r
+}\r
+\r
+#else\r
+#error implement me\r
+#endif\r
diff --git a/asio/asiodrvr.h b/asio/asiodrvr.h
new file mode 100644 (file)
index 0000000..663f75a
--- /dev/null
@@ -0,0 +1,76 @@
+/*\r
+       Steinberg Audio Stream I/O API\r
+       (c) 1996, Steinberg Soft- und Hardware GmbH\r
+       charlie (May 1996)\r
+\r
+       asiodrvr.h\r
+       c++ superclass to implement asio functionality. from this,\r
+       you can derive whatever required\r
+*/\r
+\r
+#ifndef _asiodrvr_\r
+#define _asiodrvr_\r
+\r
+// cpu and os system we are running on\r
+#include "asiosys.h"\r
+// basic "C" interface\r
+#include "asio.h"\r
+\r
+class AsioDriver;\r
+extern AsioDriver *getDriver();                // for generic constructor \r
+\r
+#if WINDOWS\r
+#include <windows.h>\r
+#include "combase.h"\r
+#include "iasiodrv.h"\r
+class AsioDriver : public IASIO ,public CUnknown\r
+{\r
+public:\r
+       AsioDriver(LPUNKNOWN pUnk, HRESULT *phr);\r
+\r
+       DECLARE_IUNKNOWN\r
+       // Factory method\r
+       static CUnknown *CreateInstance(LPUNKNOWN pUnk, HRESULT *phr);\r
+       // IUnknown\r
+       virtual HRESULT STDMETHODCALLTYPE NonDelegatingQueryInterface(REFIID riid,void **ppvObject);\r
+\r
+#else\r
+\r
+class AsioDriver\r
+{\r
+public:\r
+       AsioDriver();\r
+#endif\r
+       virtual ~AsioDriver();\r
+\r
+       virtual ASIOBool init(void* sysRef);\r
+       virtual void getDriverName(char *name); // max 32 bytes incl. terminating zero\r
+       virtual long getDriverVersion();\r
+       virtual void getErrorMessage(char *string);     // max 124 bytes incl.\r
+\r
+       virtual ASIOError start();\r
+       virtual ASIOError stop();\r
+\r
+       virtual ASIOError getChannels(long *numInputChannels, long *numOutputChannels);\r
+       virtual ASIOError getLatencies(long *inputLatency, long *outputLatency);\r
+       virtual ASIOError getBufferSize(long *minSize, long *maxSize,\r
+               long *preferredSize, long *granularity);\r
+\r
+       virtual ASIOError canSampleRate(ASIOSampleRate sampleRate);\r
+       virtual ASIOError getSampleRate(ASIOSampleRate *sampleRate);\r
+       virtual ASIOError setSampleRate(ASIOSampleRate sampleRate);\r
+       virtual ASIOError getClockSources(ASIOClockSource *clocks, long *numSources);\r
+       virtual ASIOError setClockSource(long reference);\r
+\r
+       virtual ASIOError getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp);\r
+       virtual ASIOError getChannelInfo(ASIOChannelInfo *info);\r
+\r
+       virtual ASIOError createBuffers(ASIOBufferInfo *bufferInfos, long numChannels,\r
+               long bufferSize, ASIOCallbacks *callbacks);\r
+       virtual ASIOError disposeBuffers();\r
+\r
+       virtual ASIOError controlPanel();\r
+       virtual ASIOError future(long selector, void *opt);\r
+       virtual ASIOError outputReady();\r
+};\r
+#endif\r
diff --git a/asio/asiolist.cpp b/asio/asiolist.cpp
new file mode 100644 (file)
index 0000000..5a62f5b
--- /dev/null
@@ -0,0 +1,268 @@
+#include <windows.h>\r
+#include "iasiodrv.h"\r
+#include "asiolist.h"\r
+\r
+#define ASIODRV_DESC           "description"\r
+#define INPROC_SERVER          "InprocServer32"\r
+#define ASIO_PATH                      "software\\asio"\r
+#define COM_CLSID                      "clsid"\r
+\r
+// ******************************************************************\r
+// Local Functions \r
+// ******************************************************************\r
+static LONG findDrvPath (char *clsidstr,char *dllpath,int dllpathsize)\r
+{\r
+       HKEY                    hkEnum,hksub,hkpath;\r
+       char                    databuf[512];\r
+       LONG                    cr,rc = -1;\r
+       DWORD                   datatype,datasize;\r
+       DWORD                   index;\r
+       OFSTRUCT                ofs;\r
+       HFILE                   hfile;\r
+       BOOL                    found = FALSE;\r
+\r
+       CharLowerBuff(clsidstr,strlen(clsidstr));\r
+       if ((cr = RegOpenKey(HKEY_CLASSES_ROOT,COM_CLSID,&hkEnum)) == ERROR_SUCCESS) {\r
+\r
+               index = 0;\r
+               while (cr == ERROR_SUCCESS && !found) {\r
+                       cr = RegEnumKey(hkEnum,index++,(LPTSTR)databuf,512);\r
+                       if (cr == ERROR_SUCCESS) {\r
+                               CharLowerBuff(databuf,strlen(databuf));\r
+                               if (!(strcmp(databuf,clsidstr))) {\r
+                                       if ((cr = RegOpenKeyEx(hkEnum,(LPCTSTR)databuf,0,KEY_READ,&hksub)) == ERROR_SUCCESS) {\r
+                                               if ((cr = RegOpenKeyEx(hksub,(LPCTSTR)INPROC_SERVER,0,KEY_READ,&hkpath)) == ERROR_SUCCESS) {\r
+                                                       datatype = REG_SZ; datasize = (DWORD)dllpathsize;\r
+                                                       cr = RegQueryValueEx(hkpath,0,0,&datatype,(LPBYTE)dllpath,&datasize);\r
+                                                       if (cr == ERROR_SUCCESS) {\r
+                                                               memset(&ofs,0,sizeof(OFSTRUCT));\r
+                                                               ofs.cBytes = sizeof(OFSTRUCT); \r
+                                                               hfile = OpenFile(dllpath,&ofs,OF_EXIST);\r
+                                                               if (hfile) rc = 0; \r
+                                                       }\r
+                                                       RegCloseKey(hkpath);\r
+                                               }\r
+                                               RegCloseKey(hksub);\r
+                                       }\r
+                                       found = TRUE;   // break out \r
+                               }\r
+                       }\r
+               }                               \r
+               RegCloseKey(hkEnum);\r
+       }\r
+       return rc;\r
+}\r
+\r
+\r
+static LPASIODRVSTRUCT newDrvStruct (HKEY hkey,char *keyname,int drvID,LPASIODRVSTRUCT lpdrv)\r
+{\r
+       HKEY    hksub;\r
+       char    databuf[256];\r
+       char    dllpath[MAXPATHLEN];\r
+       WORD    wData[100];\r
+       CLSID   clsid;\r
+       DWORD   datatype,datasize;\r
+       LONG    cr,rc;\r
+\r
+       if (!lpdrv) {\r
+               if ((cr = RegOpenKeyEx(hkey,(LPCTSTR)keyname,0,KEY_READ,&hksub)) == ERROR_SUCCESS) {\r
+\r
+                       datatype = REG_SZ; datasize = 256;\r
+                       cr = RegQueryValueEx(hksub,COM_CLSID,0,&datatype,(LPBYTE)databuf,&datasize);\r
+                       if (cr == ERROR_SUCCESS) {\r
+                               rc = findDrvPath (databuf,dllpath,MAXPATHLEN);\r
+                               if (rc == 0) {\r
+                                       lpdrv = new ASIODRVSTRUCT[1];\r
+                                       if (lpdrv) {\r
+                                               memset(lpdrv,0,sizeof(ASIODRVSTRUCT));\r
+                                               lpdrv->drvID = drvID;\r
+                                               MultiByteToWideChar(CP_ACP,0,(LPCSTR)databuf,-1,(LPWSTR)wData,100);\r
+                                               if ((cr = CLSIDFromString((LPOLESTR)wData,(LPCLSID)&clsid)) == S_OK) {\r
+                                                       memcpy(&lpdrv->clsid,&clsid,sizeof(CLSID));\r
+                                               }\r
+\r
+                                               datatype = REG_SZ; datasize = 256;\r
+                                               cr = RegQueryValueEx(hksub,ASIODRV_DESC,0,&datatype,(LPBYTE)databuf,&datasize);\r
+                                               if (cr == ERROR_SUCCESS) {\r
+                                                       strcpy(lpdrv->drvname,databuf);\r
+                                               }\r
+                                               else strcpy(lpdrv->drvname,keyname);\r
+                                       }\r
+                               }\r
+                       }\r
+                       RegCloseKey(hksub);\r
+               }\r
+       }       \r
+       else lpdrv->next = newDrvStruct(hkey,keyname,drvID+1,lpdrv->next);\r
+\r
+       return lpdrv;\r
+}\r
+\r
+static void deleteDrvStruct (LPASIODRVSTRUCT lpdrv)\r
+{\r
+       IASIO   *iasio;\r
+\r
+       if (lpdrv != 0) {\r
+               deleteDrvStruct(lpdrv->next);\r
+               if (lpdrv->asiodrv) {\r
+                       iasio = (IASIO *)lpdrv->asiodrv;\r
+                       iasio->Release();\r
+               }\r
+               delete lpdrv;\r
+       }\r
+}\r
+\r
+\r
+static LPASIODRVSTRUCT getDrvStruct (int drvID,LPASIODRVSTRUCT lpdrv)\r
+{\r
+       while (lpdrv) {\r
+               if (lpdrv->drvID == drvID) return lpdrv;\r
+               lpdrv = lpdrv->next;\r
+       }\r
+       return 0;\r
+}\r
+// ******************************************************************\r
+\r
+\r
+// ******************************************************************\r
+//     AsioDriverList\r
+// ******************************************************************\r
+AsioDriverList::AsioDriverList ()\r
+{\r
+       HKEY                    hkEnum = 0;\r
+       char                    keyname[MAXDRVNAMELEN];\r
+       LPASIODRVSTRUCT pdl;\r
+       LONG                    cr;\r
+       DWORD                   index = 0;\r
+       BOOL                    fin = FALSE;\r
+\r
+       numdrv          = 0;\r
+       lpdrvlist       = 0;\r
+\r
+       cr = RegOpenKey(HKEY_LOCAL_MACHINE,ASIO_PATH,&hkEnum);\r
+       while (cr == ERROR_SUCCESS) {\r
+               if ((cr = RegEnumKey(hkEnum,index++,(LPTSTR)keyname,MAXDRVNAMELEN))== ERROR_SUCCESS) {\r
+                       lpdrvlist = newDrvStruct (hkEnum,keyname,0,lpdrvlist);\r
+               }\r
+               else fin = TRUE;\r
+       }\r
+       if (hkEnum) RegCloseKey(hkEnum);\r
+\r
+       pdl = lpdrvlist;\r
+       while (pdl) {\r
+               numdrv++;\r
+               pdl = pdl->next;\r
+       }\r
+\r
+       if (numdrv) CoInitialize(0);    // initialize COM\r
+}\r
+\r
+AsioDriverList::~AsioDriverList ()\r
+{\r
+       if (numdrv) {\r
+               deleteDrvStruct(lpdrvlist);\r
+               CoUninitialize();\r
+       }\r
+}\r
+\r
+\r
+LONG AsioDriverList::asioGetNumDev (VOID)\r
+{\r
+       return (LONG)numdrv;\r
+}\r
+\r
+\r
+LONG AsioDriverList::asioOpenDriver (int drvID,LPVOID *asiodrv)\r
+{\r
+       LPASIODRVSTRUCT lpdrv = 0;\r
+       long                    rc;\r
+\r
+       if (!asiodrv) return DRVERR_INVALID_PARAM;\r
+\r
+       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
+               if (!lpdrv->asiodrv) {\r
+                       rc = CoCreateInstance(lpdrv->clsid,0,CLSCTX_INPROC_SERVER,lpdrv->clsid,asiodrv);\r
+                       if (rc == S_OK) {\r
+                               lpdrv->asiodrv = *asiodrv;\r
+                               return 0;\r
+                       }\r
+                       // else if (rc == REGDB_E_CLASSNOTREG)\r
+                       //      strcpy (info->messageText, "Driver not registered in the Registration Database!");\r
+               }\r
+               else rc = DRVERR_DEVICE_ALREADY_OPEN;\r
+       }\r
+       else rc = DRVERR_DEVICE_NOT_FOUND;\r
+       \r
+       return rc;\r
+}\r
+\r
+\r
+LONG AsioDriverList::asioCloseDriver (int drvID)\r
+{\r
+       LPASIODRVSTRUCT lpdrv = 0;\r
+       IASIO                   *iasio;\r
+\r
+       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
+               if (lpdrv->asiodrv) {\r
+                       iasio = (IASIO *)lpdrv->asiodrv;\r
+                       iasio->Release();\r
+                       lpdrv->asiodrv = 0;\r
+               }\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+LONG AsioDriverList::asioGetDriverName (int drvID,char *drvname,int drvnamesize)\r
+{      \r
+       LPASIODRVSTRUCT                 lpdrv = 0;\r
+\r
+       if (!drvname) return DRVERR_INVALID_PARAM;\r
+\r
+       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
+               if (strlen(lpdrv->drvname) < (unsigned int)drvnamesize) {\r
+                       strcpy(drvname,lpdrv->drvname);\r
+               }\r
+               else {\r
+                       memcpy(drvname,lpdrv->drvname,drvnamesize-4);\r
+                       drvname[drvnamesize-4] = '.';\r
+                       drvname[drvnamesize-3] = '.';\r
+                       drvname[drvnamesize-2] = '.';\r
+                       drvname[drvnamesize-1] = 0;\r
+               }\r
+               return 0;\r
+       }\r
+       return DRVERR_DEVICE_NOT_FOUND;\r
+}\r
+\r
+LONG AsioDriverList::asioGetDriverPath (int drvID,char *dllpath,int dllpathsize)\r
+{\r
+       LPASIODRVSTRUCT                 lpdrv = 0;\r
+\r
+       if (!dllpath) return DRVERR_INVALID_PARAM;\r
+\r
+       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
+               if (strlen(lpdrv->dllpath) < (unsigned int)dllpathsize) {\r
+                       strcpy(dllpath,lpdrv->dllpath);\r
+                       return 0;\r
+               }\r
+               dllpath[0] = 0;\r
+               return DRVERR_INVALID_PARAM;\r
+       }\r
+       return DRVERR_DEVICE_NOT_FOUND;\r
+}\r
+\r
+LONG AsioDriverList::asioGetDriverCLSID (int drvID,CLSID *clsid)\r
+{\r
+       LPASIODRVSTRUCT                 lpdrv = 0;\r
+\r
+       if (!clsid) return DRVERR_INVALID_PARAM;\r
+\r
+       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
+               memcpy(clsid,&lpdrv->clsid,sizeof(CLSID));\r
+               return 0;\r
+       }\r
+       return DRVERR_DEVICE_NOT_FOUND;\r
+}\r
+\r
+\r
diff --git a/asio/iasiodrv.h b/asio/iasiodrv.h
new file mode 100644 (file)
index 0000000..64d2dbb
--- /dev/null
@@ -0,0 +1,37 @@
+#include "asiosys.h"\r
+#include "asio.h"\r
+\r
+/* Forward Declarations */ \r
+\r
+#ifndef __ASIODRIVER_FWD_DEFINED__\r
+#define __ASIODRIVER_FWD_DEFINED__\r
+typedef interface IASIO IASIO;\r
+#endif         /* __ASIODRIVER_FWD_DEFINED__ */\r
+\r
+interface IASIO : public IUnknown\r
+{\r
+\r
+       virtual ASIOBool init(void *sysHandle) = 0;\r
+       virtual void getDriverName(char *name) = 0;     \r
+       virtual long getDriverVersion() = 0;\r
+       virtual void getErrorMessage(char *string) = 0; \r
+       virtual ASIOError start() = 0;\r
+       virtual ASIOError stop() = 0;\r
+       virtual ASIOError getChannels(long *numInputChannels, long *numOutputChannels) = 0;\r
+       virtual ASIOError getLatencies(long *inputLatency, long *outputLatency) = 0;\r
+       virtual ASIOError getBufferSize(long *minSize, long *maxSize,\r
+               long *preferredSize, long *granularity) = 0;\r
+       virtual ASIOError canSampleRate(ASIOSampleRate sampleRate) = 0;\r
+       virtual ASIOError getSampleRate(ASIOSampleRate *sampleRate) = 0;\r
+       virtual ASIOError setSampleRate(ASIOSampleRate sampleRate) = 0;\r
+       virtual ASIOError getClockSources(ASIOClockSource *clocks, long *numSources) = 0;\r
+       virtual ASIOError setClockSource(long reference) = 0;\r
+       virtual ASIOError getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp) = 0;\r
+       virtual ASIOError getChannelInfo(ASIOChannelInfo *info) = 0;\r
+       virtual ASIOError createBuffers(ASIOBufferInfo *bufferInfos, long numChannels,\r
+               long bufferSize, ASIOCallbacks *callbacks) = 0;\r
+       virtual ASIOError disposeBuffers() = 0;\r
+       virtual ASIOError controlPanel() = 0;\r
+       virtual ASIOError future(long selector,void *opt) = 0;\r
+       virtual ASIOError outputReady() = 0;\r
+};\r
diff --git a/asio/iasiothiscallresolver.cpp b/asio/iasiothiscallresolver.cpp
new file mode 100644 (file)
index 0000000..38c39d2
--- /dev/null
@@ -0,0 +1,563 @@
+/*\r
+       IASIOThiscallResolver.cpp see the comments in iasiothiscallresolver.h for\r
+    the top level description - this comment describes the technical details of\r
+    the implementation.\r
+\r
+    The latest version of this file is available from:\r
+    http://www.audiomulch.com/~rossb/code/calliasio\r
+\r
+    please email comments to Ross Bencina <rossb@audiomulch.com>\r
+\r
+    BACKGROUND\r
+\r
+    The IASIO interface declared in the Steinberg ASIO 2 SDK declares\r
+    functions with no explicit calling convention. This causes MSVC++ to default\r
+    to using the thiscall convention, which is a proprietary convention not\r
+    implemented by some non-microsoft compilers - notably borland BCC,\r
+    C++Builder, and gcc. MSVC++ is the defacto standard compiler used by\r
+    Steinberg. As a result of this situation, the ASIO sdk will compile with\r
+    any compiler, however attempting to execute the compiled code will cause a\r
+    crash due to different default calling conventions on non-Microsoft\r
+    compilers.\r
+\r
+    IASIOThiscallResolver solves the problem by providing an adapter class that\r
+    delegates to the IASIO interface using the correct calling convention\r
+    (thiscall). Due to the lack of support for thiscall in the Borland and GCC\r
+    compilers, the calls have been implemented in assembly language.\r
+\r
+    A number of macros are defined for thiscall function calls with different\r
+    numbers of parameters, with and without return values - it may be possible\r
+    to modify the format of these macros to make them work with other inline\r
+    assemblers.\r
+\r
+\r
+    THISCALL DEFINITION\r
+\r
+    A number of definitions of the thiscall calling convention are floating\r
+    around the internet. The following definition has been validated against\r
+    output from the MSVC++ compiler:\r
+\r
+    For non-vararg functions, thiscall works as follows: the object (this)\r
+    pointer is passed in ECX. All arguments are passed on the stack in\r
+    right to left order. The return value is placed in EAX. The callee\r
+    clears the passed arguments from the stack.\r
+\r
+\r
+    FINDING FUNCTION POINTERS FROM AN IASIO POINTER\r
+\r
+    The first field of a COM object is a pointer to its vtble. Thus a pointer\r
+    to an object implementing the IASIO interface also points to a pointer to\r
+    that object's vtbl. The vtble is a table of function pointers for all of\r
+    the virtual functions exposed by the implemented interfaces.\r
+\r
+    If we consider a variable declared as a pointer to IASO:\r
+\r
+    IASIO *theAsioDriver\r
+\r
+    theAsioDriver points to:\r
+\r
+    object implementing IASIO\r
+    {\r
+        IASIOvtbl *vtbl\r
+        other data\r
+    }\r
+\r
+    in other words, theAsioDriver points to a pointer to an IASIOvtbl\r
+\r
+    vtbl points to a table of function pointers:\r
+\r
+    IASIOvtbl ( interface IASIO : public IUnknown )\r
+    {\r
+    (IUnknown functions)\r
+    0   virtual HRESULT STDMETHODCALLTYPE (*QueryInterface)(REFIID riid, void **ppv) = 0;\r
+    4   virtual ULONG STDMETHODCALLTYPE (*AddRef)() = 0;\r
+    8   virtual ULONG STDMETHODCALLTYPE (*Release)() = 0;      \r
+\r
+    (IASIO functions)\r
+    12 virtual ASIOBool (*init)(void *sysHandle) = 0;\r
+    16 virtual void (*getDriverName)(char *name) = 0;\r
+    20 virtual long (*getDriverVersion)() = 0;\r
+    24 virtual void (*getErrorMessage)(char *string) = 0;\r
+    28 virtual ASIOError (*start)() = 0;\r
+    32 virtual ASIOError (*stop)() = 0;\r
+    36 virtual ASIOError (*getChannels)(long *numInputChannels, long *numOutputChannels) = 0;\r
+    40 virtual ASIOError (*getLatencies)(long *inputLatency, long *outputLatency) = 0;\r
+    44 virtual ASIOError (*getBufferSize)(long *minSize, long *maxSize,\r
+            long *preferredSize, long *granularity) = 0;\r
+    48 virtual ASIOError (*canSampleRate)(ASIOSampleRate sampleRate) = 0;\r
+    52 virtual ASIOError (*getSampleRate)(ASIOSampleRate *sampleRate) = 0;\r
+    56 virtual ASIOError (*setSampleRate)(ASIOSampleRate sampleRate) = 0;\r
+    60 virtual ASIOError (*getClockSources)(ASIOClockSource *clocks, long *numSources) = 0;\r
+    64 virtual ASIOError (*setClockSource)(long reference) = 0;\r
+    68 virtual ASIOError (*getSamplePosition)(ASIOSamples *sPos, ASIOTimeStamp *tStamp) = 0;\r
+    72 virtual ASIOError (*getChannelInfo)(ASIOChannelInfo *info) = 0;\r
+    76 virtual ASIOError (*createBuffers)(ASIOBufferInfo *bufferInfos, long numChannels,\r
+            long bufferSize, ASIOCallbacks *callbacks) = 0;\r
+    80 virtual ASIOError (*disposeBuffers)() = 0;\r
+    84 virtual ASIOError (*controlPanel)() = 0;\r
+    88 virtual ASIOError (*future)(long selector,void *opt) = 0;\r
+    92 virtual ASIOError (*outputReady)() = 0;\r
+    };\r
+\r
+    The numbers in the left column show the byte offset of each function ptr\r
+    from the beginning of the vtbl. These numbers are used in the code below\r
+    to select different functions.\r
+\r
+    In order to find the address of a particular function, theAsioDriver\r
+    must first be dereferenced to find the value of the vtbl pointer:\r
+\r
+    mov     eax, theAsioDriver\r
+    mov     edx, [theAsioDriver]  // edx now points to vtbl[0]\r
+\r
+    Then an offset must be added to the vtbl pointer to select a\r
+    particular function, for example vtbl+44 points to the slot containing\r
+    a pointer to the getBufferSize function.\r
+\r
+    Finally vtbl+x must be dereferenced to obtain the value of the function\r
+    pointer stored in that address:\r
+\r
+    call    [edx+44]    // call the function pointed to by\r
+                        // the value in the getBufferSize field of the vtbl\r
+\r
+\r
+    SEE ALSO\r
+\r
+    Martin Fay's OpenASIO DLL at http://www.martinfay.com solves the same\r
+    problem by providing a new COM interface which wraps IASIO with an\r
+    interface that uses portable calling conventions. OpenASIO must be compiled\r
+    with MSVC, and requires that you ship the OpenASIO DLL with your\r
+    application.\r
+\r
+    \r
+    ACKNOWLEDGEMENTS\r
+\r
+    Ross Bencina: worked out the thiscall details above, wrote the original\r
+    Borland asm macros, and a patch for asio.cpp (which is no longer needed).\r
+    Thanks to Martin Fay for introducing me to the issues discussed here,\r
+    and to Rene G. Ceballos for assisting with asm dumps from MSVC++.\r
+\r
+    Antti Silvast: converted the original calliasio to work with gcc and NASM\r
+    by implementing the asm code in a separate file.\r
+\r
+       Fraser Adams: modified the original calliasio containing the Borland inline\r
+    asm to add inline asm for gcc i.e. Intel syntax for Borland and AT&T syntax\r
+    for gcc. This seems a neater approach for gcc than to have a separate .asm\r
+    file and it means that we only need one version of the thiscall patch.\r
+\r
+    Fraser Adams: rewrote the original calliasio patch in the form of the\r
+    IASIOThiscallResolver class in order to avoid modifications to files from\r
+    the Steinberg SDK, which may have had potential licence issues.\r
+\r
+    Andrew Baldwin: contributed fixes for compatibility problems with more\r
+    recent versions of the gcc assembler.\r
+*/\r
+\r
+\r
+// We only need IASIOThiscallResolver at all if we are on Win32. For other\r
+// platforms we simply bypass the IASIOThiscallResolver definition to allow us\r
+// to be safely #include'd whatever the platform to keep client code portable\r
+#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)\r
+\r
+\r
+// If microsoft compiler we can call IASIO directly so IASIOThiscallResolver\r
+// is not used.\r
+#if !defined(_MSC_VER)\r
+\r
+\r
+#include <new>\r
+#include <assert.h>\r
+\r
+// We have a mechanism in iasiothiscallresolver.h to ensure that asio.h is\r
+// #include'd before it in client code, we do NOT want to do this test here.\r
+#define iasiothiscallresolver_sourcefile 1\r
+#include "iasiothiscallresolver.h"\r
+#undef iasiothiscallresolver_sourcefile\r
+\r
+// iasiothiscallresolver.h redefines ASIOInit for clients, but we don't want\r
+// this macro defined in this translation unit.\r
+#undef ASIOInit\r
+\r
+\r
+// theAsioDriver is a global pointer to the current IASIO instance which the\r
+// ASIO SDK uses to perform all actions on the IASIO interface. We substitute\r
+// our own forwarding interface into this pointer.\r
+extern IASIO* theAsioDriver;\r
+\r
+\r
+// The following macros define the inline assembler for BORLAND first then gcc\r
+\r
+#if defined(__BCPLUSPLUS__) || defined(__BORLANDC__)          \r
+\r
+\r
+#define CALL_THISCALL_0( resultName, thisPtr, funcOffset )\\r
+    void *this_ = (thisPtr);                                                \\r
+    __asm {                                                                 \\r
+        mov     ecx, this_            ;                                     \\r
+        mov     eax, [ecx]            ;                                     \\r
+        call    [eax+funcOffset]      ;                                     \\r
+        mov     resultName, eax       ;                                     \\r
+    }\r
+\r
+\r
+#define CALL_VOID_THISCALL_1( thisPtr, funcOffset, param1 )\\r
+    void *this_ = (thisPtr);                                                \\r
+    __asm {                                                                 \\r
+        mov     eax, param1           ;                                     \\r
+        push    eax                   ;                                     \\r
+        mov     ecx, this_            ;                                     \\r
+        mov     eax, [ecx]            ;                                     \\r
+        call    [eax+funcOffset]      ;                                     \\r
+    }\r
+\r
+\r
+#define CALL_THISCALL_1( resultName, thisPtr, funcOffset, param1 )\\r
+    void *this_ = (thisPtr);                                                \\r
+    __asm {                                                                 \\r
+        mov     eax, param1           ;                                     \\r
+        push    eax                   ;                                     \\r
+        mov     ecx, this_            ;                                     \\r
+        mov     eax, [ecx]            ;                                     \\r
+        call    [eax+funcOffset]      ;                                     \\r
+        mov     resultName, eax       ;                                     \\r
+    }\r
+\r
+\r
+#define CALL_THISCALL_1_DOUBLE( resultName, thisPtr, funcOffset, param1 )\\r
+    void *this_ = (thisPtr);                                                \\r
+    void *doubleParamPtr_ (&param1);                                        \\r
+    __asm {                                                                 \\r
+        mov     eax, doubleParamPtr_  ;                                     \\r
+        push    [eax+4]               ;                                     \\r
+        push    [eax]                 ;                                     \\r
+        mov     ecx, this_            ;                                     \\r
+        mov     eax, [ecx]            ;                                     \\r
+        call    [eax+funcOffset]      ;                                     \\r
+        mov     resultName, eax       ;                                     \\r
+    }\r
+\r
+\r
+#define CALL_THISCALL_2( resultName, thisPtr, funcOffset, param1, param2 )\\r
+    void *this_ = (thisPtr);                                                \\r
+    __asm {                                                                 \\r
+        mov     eax, param2           ;                                     \\r
+        push    eax                   ;                                     \\r
+        mov     eax, param1           ;                                     \\r
+        push    eax                   ;                                     \\r
+        mov     ecx, this_            ;                                     \\r
+        mov     eax, [ecx]            ;                                     \\r
+        call    [eax+funcOffset]      ;                                     \\r
+        mov     resultName, eax       ;                                     \\r
+    }\r
+\r
+\r
+#define CALL_THISCALL_4( resultName, thisPtr, funcOffset, param1, param2, param3, param4 )\\r
+    void *this_ = (thisPtr);                                                \\r
+    __asm {                                                                 \\r
+        mov     eax, param4           ;                                     \\r
+        push    eax                   ;                                     \\r
+        mov     eax, param3           ;                                     \\r
+        push    eax                   ;                                     \\r
+        mov     eax, param2           ;                                     \\r
+        push    eax                   ;                                     \\r
+        mov     eax, param1           ;                                     \\r
+        push    eax                   ;                                     \\r
+        mov     ecx, this_            ;                                     \\r
+        mov     eax, [ecx]            ;                                     \\r
+        call    [eax+funcOffset]      ;                                     \\r
+        mov     resultName, eax       ;                                     \\r
+    }\r
+\r
+\r
+#elif defined(__GNUC__)\r
+\r
+\r
+#define CALL_THISCALL_0( resultName, thisPtr, funcOffset )                  \\r
+    __asm__ __volatile__ ("movl (%1), %%edx\n\t"                            \\r
+                          "call *"#funcOffset"(%%edx)\n\t"                  \\r
+                          :"=a"(resultName) /* Output Operands */           \\r
+                          :"c"(thisPtr)     /* Input Operands */            \\r
+                         );                                                 \\r
+\r
+\r
+#define CALL_VOID_THISCALL_1( thisPtr, funcOffset, param1 )                 \\r
+    __asm__ __volatile__ ("pushl %0\n\t"                                    \\r
+                          "movl (%1), %%edx\n\t"                            \\r
+                          "call *"#funcOffset"(%%edx)\n\t"                  \\r
+                          :                 /* Output Operands */           \\r
+                          :"r"(param1),     /* Input Operands */            \\r
+                           "c"(thisPtr)                                     \\r
+                         );                                                 \\r
+\r
+\r
+#define CALL_THISCALL_1( resultName, thisPtr, funcOffset, param1 )          \\r
+    __asm__ __volatile__ ("pushl %1\n\t"                                    \\r
+                          "movl (%2), %%edx\n\t"                            \\r
+                          "call *"#funcOffset"(%%edx)\n\t"                  \\r
+                          :"=a"(resultName) /* Output Operands */           \\r
+                          :"r"(param1),     /* Input Operands */            \\r
+                           "c"(thisPtr)                                     \\r
+                          );                                                \\r
+\r
+\r
+#define CALL_THISCALL_1_DOUBLE( resultName, thisPtr, funcOffset, param1 )   \\r
+    __asm__ __volatile__ ("pushl 4(%1)\n\t"                                 \\r
+                          "pushl (%1)\n\t"                                  \\r
+                          "movl (%2), %%edx\n\t"                            \\r
+                          "call *"#funcOffset"(%%edx);\n\t"                 \\r
+                          :"=a"(resultName) /* Output Operands */           \\r
+                          :"a"(&param1),    /* Input Operands */            \\r
+                           /* Note: Using "r" above instead of "a" fails */ \\r
+                           /* when using GCC 3.3.3, and maybe later versions*/\\r
+                           "c"(thisPtr)                                     \\r
+                          );                                                \\r
+\r
+\r
+#define CALL_THISCALL_2( resultName, thisPtr, funcOffset, param1, param2 )  \\r
+    __asm__ __volatile__ ("pushl %1\n\t"                                    \\r
+                          "pushl %2\n\t"                                    \\r
+                          "movl (%3), %%edx\n\t"                            \\r
+                          "call *"#funcOffset"(%%edx)\n\t"                  \\r
+                          :"=a"(resultName) /* Output Operands */           \\r
+                          :"r"(param2),     /* Input Operands */            \\r
+                           "r"(param1),                                     \\r
+                           "c"(thisPtr)                                     \\r
+                          );                                                \\r
+\r
+\r
+#define CALL_THISCALL_4( resultName, thisPtr, funcOffset, param1, param2, param3, param4 )\\r
+    __asm__ __volatile__ ("pushl %1\n\t"                                    \\r
+                          "pushl %2\n\t"                                    \\r
+                          "pushl %3\n\t"                                    \\r
+                          "pushl %4\n\t"                                    \\r
+                          "movl (%5), %%edx\n\t"                            \\r
+                          "call *"#funcOffset"(%%edx)\n\t"                  \\r
+                          :"=a"(resultName) /* Output Operands */           \\r
+                          :"r"(param4),     /* Input Operands  */           \\r
+                           "r"(param3),                                     \\r
+                           "r"(param2),                                     \\r
+                           "r"(param1),                                     \\r
+                           "c"(thisPtr)                                     \\r
+                          );                                                \\r
+\r
+#endif\r
+\r
+\r
+\r
+// Our static singleton instance.\r
+IASIOThiscallResolver IASIOThiscallResolver::instance;\r
+\r
+// Constructor called to initialize static Singleton instance above. Note that\r
+// it is important not to clear that_ incase it has already been set by the call\r
+// to placement new in ASIOInit().\r
+IASIOThiscallResolver::IASIOThiscallResolver()\r
+{\r
+}\r
+\r
+// Constructor called from ASIOInit() below\r
+IASIOThiscallResolver::IASIOThiscallResolver(IASIO* that)\r
+: that_( that )\r
+{\r
+}\r
+\r
+// Implement IUnknown methods as assert(false). IASIOThiscallResolver is not\r
+// really a COM object, just a wrapper which will work with the ASIO SDK.\r
+// If you wanted to use ASIO without the SDK you might want to implement COM\r
+// aggregation in these methods.\r
+HRESULT STDMETHODCALLTYPE IASIOThiscallResolver::QueryInterface(REFIID riid, void **ppv)\r
+{\r
+    (void)riid;     // suppress unused variable warning\r
+\r
+    assert( false ); // this function should never be called by the ASIO SDK.\r
+\r
+    *ppv = NULL;\r
+    return E_NOINTERFACE;\r
+}\r
+\r
+ULONG STDMETHODCALLTYPE IASIOThiscallResolver::AddRef()\r
+{\r
+    assert( false ); // this function should never be called by the ASIO SDK.\r
+\r
+    return 1;\r
+}\r
+\r
+ULONG STDMETHODCALLTYPE IASIOThiscallResolver::Release()\r
+{\r
+    assert( false ); // this function should never be called by the ASIO SDK.\r
+    \r
+    return 1;\r
+}\r
+\r
+\r
+// Implement the IASIO interface methods by performing the vptr manipulation\r
+// described above then delegating to the real implementation.\r
+ASIOBool IASIOThiscallResolver::init(void *sysHandle)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_1( result, that_, 12, sysHandle );\r
+    return result;\r
+}\r
+\r
+void IASIOThiscallResolver::getDriverName(char *name)\r
+{\r
+    CALL_VOID_THISCALL_1( that_, 16, name );\r
+}\r
+\r
+long IASIOThiscallResolver::getDriverVersion()\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_0( result, that_, 20 );\r
+    return result;\r
+}\r
+\r
+void IASIOThiscallResolver::getErrorMessage(char *string)\r
+{\r
+     CALL_VOID_THISCALL_1( that_, 24, string );\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::start()\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_0( result, that_, 28 );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::stop()\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_0( result, that_, 32 );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::getChannels(long *numInputChannels, long *numOutputChannels)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_2( result, that_, 36, numInputChannels, numOutputChannels );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::getLatencies(long *inputLatency, long *outputLatency)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_2( result, that_, 40, inputLatency, outputLatency );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::getBufferSize(long *minSize, long *maxSize,\r
+        long *preferredSize, long *granularity)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_4( result, that_, 44, minSize, maxSize, preferredSize, granularity );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::canSampleRate(ASIOSampleRate sampleRate)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_1_DOUBLE( result, that_, 48, sampleRate );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::getSampleRate(ASIOSampleRate *sampleRate)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_1( result, that_, 52, sampleRate );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::setSampleRate(ASIOSampleRate sampleRate)\r
+{    \r
+    ASIOBool result;\r
+    CALL_THISCALL_1_DOUBLE( result, that_, 56, sampleRate );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::getClockSources(ASIOClockSource *clocks, long *numSources)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_2( result, that_, 60, clocks, numSources );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::setClockSource(long reference)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_1( result, that_, 64, reference );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_2( result, that_, 68, sPos, tStamp );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::getChannelInfo(ASIOChannelInfo *info)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_1( result, that_, 72, info );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::createBuffers(ASIOBufferInfo *bufferInfos,\r
+        long numChannels, long bufferSize, ASIOCallbacks *callbacks)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_4( result, that_, 76, bufferInfos, numChannels, bufferSize, callbacks );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::disposeBuffers()\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_0( result, that_, 80 );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::controlPanel()\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_0( result, that_, 84 );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::future(long selector,void *opt)\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_2( result, that_, 88, selector, opt );\r
+    return result;\r
+}\r
+\r
+ASIOError IASIOThiscallResolver::outputReady()\r
+{\r
+    ASIOBool result;\r
+    CALL_THISCALL_0( result, that_, 92 );\r
+    return result;\r
+}\r
+\r
+\r
+// Implement our substitute ASIOInit() method\r
+ASIOError IASIOThiscallResolver::ASIOInit(ASIODriverInfo *info)\r
+{\r
+    // To ensure that our instance's vptr is correctly constructed, even if\r
+    // ASIOInit is called prior to main(), we explicitly call its constructor\r
+    // (potentially over the top of an existing instance). Note that this is\r
+    // pretty ugly, and is only safe because IASIOThiscallResolver has no\r
+    // destructor and contains no objects with destructors.\r
+    new((void*)&instance) IASIOThiscallResolver( theAsioDriver );\r
+\r
+    // Interpose between ASIO client code and the real driver.\r
+    theAsioDriver = &instance;\r
+\r
+    // Note that we never need to switch theAsioDriver back to point to the\r
+    // real driver because theAsioDriver is reset to zero in ASIOExit().\r
+\r
+    // Delegate to the real ASIOInit\r
+       return ::ASIOInit(info);\r
+}\r
+\r
+\r
+#endif /* !defined(_MSC_VER) */\r
+\r
+#endif /* Win32 */\r
+\r
diff --git a/asio/iasiothiscallresolver.h b/asio/iasiothiscallresolver.h
new file mode 100644 (file)
index 0000000..b59d910
--- /dev/null
@@ -0,0 +1,201 @@
+// ****************************************************************************\r
+//\r
+// Changed:         I have modified this file slightly (includes) to work  with\r
+//                  RtAudio. RtAudio.cpp must include this file after asio.h.                                                    \r
+//\r
+// File:                       IASIOThiscallResolver.h\r
+// Description:     The IASIOThiscallResolver class implements the IASIO\r
+//                                     interface and acts as a proxy to the real IASIO interface by\r
+//                  calling through its vptr table using the thiscall calling\r
+//                  convention. To put it another way, we interpose\r
+//                  IASIOThiscallResolver between ASIO SDK code and the driver.\r
+//                  This is necessary because most non-Microsoft compilers don't\r
+//                  implement the thiscall calling convention used by IASIO.\r
+//\r
+//                                     iasiothiscallresolver.cpp contains the background of this\r
+//                                     problem plus a technical description of the vptr\r
+//                  manipulations.\r
+//\r
+//                                     In order to use this mechanism one simply has to add\r
+//                                     iasiothiscallresolver.cpp to the list of files to compile\r
+//                  and #include <iasiothiscallresolver.h>\r
+//\r
+//                                     Note that this #include must come after the other ASIO SDK\r
+//                  #includes, for example:\r
+//\r
+//                                     #include <windows.h>\r
+//                                     #include <asiosys.h>\r
+//                                     #include <asio.h>\r
+//                                     #include <asiodrivers.h>\r
+//                                     #include <iasiothiscallresolver.h>\r
+//\r
+//                                     Actually the important thing is to #include\r
+//                  <iasiothiscallresolver.h> after <asio.h>. We have\r
+//                  incorporated a test to enforce this ordering.\r
+//\r
+//                                     The code transparently takes care of the interposition by\r
+//                  using macro substitution to intercept calls to ASIOInit()\r
+//                  and ASIOExit(). We save the original ASIO global\r
+//                  "theAsioDriver" in our "that" variable, and then set\r
+//                  "theAsioDriver" to equal our IASIOThiscallResolver instance.\r
+//\r
+//                                     Whilst this method of resolving the thiscall problem requires\r
+//                                     the addition of #include <iasiothiscallresolver.h> to client\r
+//                  code it has the advantage that it does not break the terms\r
+//                  of the ASIO licence by publishing it. We are NOT modifying\r
+//                  any Steinberg code here, we are merely implementing the IASIO\r
+//                                     interface in the same way that we would need to do if we\r
+//                                     wished to provide an open source ASIO driver.\r
+//\r
+//                                     For compilation with MinGW -lole32 needs to be added to the\r
+//                  linker options. For BORLAND, linking with Import32.lib is\r
+//                  sufficient.\r
+//\r
+//                                     The dependencies are with: CoInitialize, CoUninitialize,\r
+//                                     CoCreateInstance, CLSIDFromString - used by asiolist.cpp\r
+//                                     and are required on Windows whether ThiscallResolver is used\r
+//                                     or not.\r
+//\r
+//                                     Searching for the above strings in the root library path\r
+//                                     of your compiler should enable the correct libraries to be\r
+//                                     identified if they aren't immediately obvious.\r
+//\r
+//                  Note that the current implementation of IASIOThiscallResolver\r
+//                  is not COM compliant - it does not correctly implement the\r
+//                  IUnknown interface. Implementing it is not necessary because\r
+//                  it is not called by parts of the ASIO SDK which call through\r
+//                  theAsioDriver ptr. The IUnknown methods are implemented as\r
+//                  assert(false) to ensure that the code fails if they are\r
+//                  ever called.\r
+// Restrictions:       None. Public Domain & Open Source distribute freely\r
+//                                     You may use IASIOThiscallResolver commercially as well as\r
+//                  privately.\r
+//                                     You the user assume the responsibility for the use of the\r
+//                                     files, binary or text, and there is no guarantee or warranty,\r
+//                                     expressed or implied, including but not limited to the\r
+//                                     implied warranties of merchantability and fitness for a\r
+//                                     particular purpose. You assume all responsibility and agree\r
+//                                     to hold no entity, copyright holder or distributors liable\r
+//                                     for any loss of data or inaccurate representations of data\r
+//                                     as a result of using IASIOThiscallResolver.\r
+// Version:         1.4 Added separate macro CALL_THISCALL_1_DOUBLE from\r
+//                  Andrew Baldwin, and volatile for whole gcc asm blocks,\r
+//                  both for compatibility with newer gcc versions. Cleaned up\r
+//                  Borland asm to use one less register.\r
+//                  1.3 Switched to including assert.h for better compatibility.\r
+//                  Wrapped entire .h and .cpp contents with a check for\r
+//                  _MSC_VER to provide better compatibility with MS compilers.\r
+//                  Changed Singleton implementation to use static instance\r
+//                  instead of freestore allocated instance. Removed ASIOExit\r
+//                  macro as it is no longer needed.\r
+//                  1.2 Removed semicolons from ASIOInit and ASIOExit macros to\r
+//                  allow them to be embedded in expressions (if statements).\r
+//                  Cleaned up some comments. Removed combase.c dependency (it\r
+//                  doesn't compile with BCB anyway) by stubbing IUnknown.\r
+//                  1.1 Incorporated comments from Ross Bencina including things\r
+//                                     such as changing name from ThiscallResolver to\r
+//                                     IASIOThiscallResolver, tidying up the constructor, fixing\r
+//                                     a bug in IASIOThiscallResolver::ASIOExit() and improving\r
+//                                     portability through the use of conditional compilation\r
+//                                     1.0 Initial working version.\r
+// Created:                    6/09/2003\r
+// Authors:         Fraser Adams\r
+//                  Ross Bencina\r
+//                  Rene G. Ceballos\r
+//                  Martin Fay\r
+//                  Antti Silvast\r
+//                  Andrew Baldwin\r
+//\r
+// ****************************************************************************\r
+\r
+\r
+#ifndef included_iasiothiscallresolver_h\r
+#define included_iasiothiscallresolver_h\r
+\r
+// We only need IASIOThiscallResolver at all if we are on Win32. For other\r
+// platforms we simply bypass the IASIOThiscallResolver definition to allow us\r
+// to be safely #include'd whatever the platform to keep client code portable\r
+#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)\r
+\r
+\r
+// If microsoft compiler we can call IASIO directly so IASIOThiscallResolver\r
+// is not used.\r
+#if !defined(_MSC_VER)\r
+\r
+\r
+// The following is in order to ensure that this header is only included after\r
+// the other ASIO headers (except for the case of iasiothiscallresolver.cpp).\r
+// We need to do this because IASIOThiscallResolver works by eclipsing the\r
+// original definition of ASIOInit() with a macro (see below).\r
+#if !defined(iasiothiscallresolver_sourcefile)\r
+       #if !defined(__ASIO_H)\r
+       #error iasiothiscallresolver.h must be included AFTER asio.h\r
+       #endif\r
+#endif\r
+\r
+#include <windows.h>\r
+#include "iasiodrv.h" /* From ASIO SDK */\r
+\r
+\r
+class IASIOThiscallResolver : public IASIO {\r
+private:\r
+       IASIO* that_; // Points to the real IASIO\r
+\r
+       static IASIOThiscallResolver instance; // Singleton instance\r
+\r
+       // Constructors - declared private so construction is limited to\r
+    // our Singleton instance\r
+    IASIOThiscallResolver();\r
+       IASIOThiscallResolver(IASIO* that);\r
+public:\r
+\r
+    // Methods from the IUnknown interface. We don't fully implement IUnknown\r
+    // because the ASIO SDK never calls these methods through theAsioDriver ptr.\r
+    // These methods are implemented as assert(false).\r
+    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);\r
+    virtual ULONG STDMETHODCALLTYPE AddRef();\r
+    virtual ULONG STDMETHODCALLTYPE Release();\r
+\r
+    // Methods from the IASIO interface, implemented as forwarning calls to that.\r
+       virtual ASIOBool init(void *sysHandle);\r
+       virtual void getDriverName(char *name);\r
+       virtual long getDriverVersion();\r
+       virtual void getErrorMessage(char *string);\r
+       virtual ASIOError start();\r
+       virtual ASIOError stop();\r
+       virtual ASIOError getChannels(long *numInputChannels, long *numOutputChannels);\r
+       virtual ASIOError getLatencies(long *inputLatency, long *outputLatency);\r
+       virtual ASIOError getBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity);\r
+       virtual ASIOError canSampleRate(ASIOSampleRate sampleRate);\r
+       virtual ASIOError getSampleRate(ASIOSampleRate *sampleRate);\r
+       virtual ASIOError setSampleRate(ASIOSampleRate sampleRate);\r
+       virtual ASIOError getClockSources(ASIOClockSource *clocks, long *numSources);\r
+       virtual ASIOError setClockSource(long reference);\r
+       virtual ASIOError getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp);\r
+       virtual ASIOError getChannelInfo(ASIOChannelInfo *info);\r
+       virtual ASIOError createBuffers(ASIOBufferInfo *bufferInfos, long numChannels, long bufferSize, ASIOCallbacks *callbacks);\r
+       virtual ASIOError disposeBuffers();\r
+       virtual ASIOError controlPanel();\r
+       virtual ASIOError future(long selector,void *opt);\r
+       virtual ASIOError outputReady();\r
+\r
+    // Class method, see ASIOInit() macro below.\r
+    static ASIOError ASIOInit(ASIODriverInfo *info); // Delegates to ::ASIOInit\r
+};\r
+\r
+\r
+// Replace calls to ASIOInit with our interposing version.\r
+// This macro enables us to perform thiscall resolution simply by #including\r
+// <iasiothiscallresolver.h> after the asio #includes (this file _must_ be\r
+// included _after_ the asio #includes)\r
+\r
+#define ASIOInit(name) IASIOThiscallResolver::ASIOInit((name))\r
+\r
+\r
+#endif /* !defined(_MSC_VER) */\r
+\r
+#endif /* Win32 */\r
+\r
+#endif /* included_iasiothiscallresolver_h */\r
+\r
+\r
index 2d79952bc39aa6a5545fe544a4ce70f4cdbb89b0..802fe24c4f58e534c49490f27d9589e4bb7ff780 100644 (file)
@@ -36,7 +36,7 @@ The RtError class declaration and definition have been extracted to a separate f
 
 \section download Download
 
-Latest Release (14 October 2005): <A href="http://music.mcgill.ca/~gary/rtaudio/release/rtaudio-3.0.2.tar.gz">Version 3.0.2</A>
+Latest Release (18 November 2005): <A href="http://music.mcgill.ca/~gary/rtaudio/release/rtaudio-3.0.3.tar.gz">Version 3.0.3</A>
 
 \section start Getting Started
 
@@ -66,12 +66,12 @@ int main()
 }
 \endcode
 
-Obviously, this example doesn't demonstrate any of the real functionality of RtAudio.  However, all uses of RtAudio must begin with a constructor (either default or overloaded varieties) and must end with class destruction.  Further, it is necessary that all class methods which can throw a C++ exception be called within a try/catch block.
+Obviously, this example doesn't demonstrate any of the real functionality of RtAudio.  However, all uses of RtAudio must begin with a constructor (either default or overloaded varieties) and must end with class destruction.  Further, it is necessary that all class methods that can throw a C++ exception be called within a try/catch block.
 
 
 \section error Error Handling
 
-RtAudio uses a C++ exception handler called RtError, which is declared and defined in RtError.h.  The RtError class is quite simple but it does allow errors to be "caught" by RtError::Type.  Almost all RtAudio methods can "throw" an RtError, most typically if a driver error occurs or a stream function is called when no stream is open.  There are a number of cases within RtAudio where warning messages may be displayed but an exception is not thrown.  There is a protected RtAudio method, error(), which can be modified to globally control how these messages are handled and reported.  By default, error messages are not automatically displayed in RtAudio unless the preprocessor definition __RTAUDIO_DEBUG__ is defined.  Messages associated with caught exceptions can be displayed with, for example, the RtError::printMessage() function.
+RtAudio uses a C++ exception handler called RtError, which is declared and defined in RtError.h.  The RtError class is quite simple but it does allow errors to be "caught" by RtError::Type.  Almost all RtAudio methods can "throw" an RtError, most typically if a driver error occurs or a stream function is called when no stream is open.  There are a number of cases within RtAudio where warning messages may be displayed but an exception is not thrown.  There is a protected RtAudio method, error(), that can be modified to globally control how these messages are handled and reported.  By default, error messages are not automatically displayed in RtAudio unless the preprocessor definition __RTAUDIO_DEBUG__ is defined.  Messages associated with caught exceptions can be displayed with, for example, the RtError::printMessage() function.
 
 
 \section probing Probing Device Capabilities
@@ -152,7 +152,7 @@ The following data formats are defined and fully supported by RtAudio:
   static const RtAudioFormat  RTAUDIO_FLOAT64; // 64-bit double normalized between +/- 1.0
 \endcode
 
-The <I>nativeFormats</I> member of the RtAudioDeviceInfo structure is a bit mask of the above formats which are natively supported by the device.  However, RtAudio will automatically provide format conversion if a particular format is not natively supported.  When the <I>probed</I> member of the RtAudioDeviceInfo structure is false, the remaining structure members are undefined and the device is probably unuseable.
+The <I>nativeFormats</I> member of the RtAudioDeviceInfo structure is a bit mask of the above formats that are natively supported by the device.  However, RtAudio will automatically provide format conversion if a particular format is not natively supported.  When the <I>probed</I> member of the RtAudioDeviceInfo structure is false, the remaining structure members are undefined and the device is probably unuseable.
 
 While some audio devices may require a minimum channel value greater than one, RtAudio will provide automatic channel number compensation when the number of channels set by the user is less than that required by the device.  Channel compensation is <I>NOT</I> possible when the number of channels set by the user is greater than that supported by the device.
 
@@ -201,11 +201,11 @@ int main()
 }
 \endcode
 
-The RtAudio::openStream() method attempts to open a stream with a specified set of parameter values.  In this case, we attempt to open a two channel playback stream with the default output device, 32-bit floating point data, a sample rate of 44100 Hz, a frame rate of 256 sample frames per read/write, and 4 internal device buffers.  When device = 0, RtAudio first attempts to open the default audio device with the given parameters.  If that attempt fails, RtAudio searches through the remaining available devices in an effort to find a device which will meet the given parameters.  If all attempts are unsuccessful, an RtError is thrown.  When a non-zero device value is specified, an attempt is made to open that device \e ONLY (device = 1 specifies the first identified device, as reported by RtAudio::getDeviceInfo()).
+The RtAudio::openStream() method attempts to open a stream with a specified set of parameter values.  In this case, we attempt to open a two channel playback stream with the default output device, 32-bit floating point data, a sample rate of 44100 Hz, a frame rate of 256 sample frames per read/write, and 4 internal device buffers.  When device = 0, RtAudio first attempts to open the default audio device with the given parameters.  If that attempt fails, RtAudio searches through the remaining available devices in an effort to find a device that will meet the given parameters.  If all attempts are unsuccessful, an RtError is thrown.  When a non-zero device value is specified, an attempt is made to open that device \e ONLY (device = 1 specifies the first identified device, as reported by RtAudio::getDeviceInfo()).
 
-RtAudio provides four signed integer and two floating point data formats which can be specified using the RtAudioFormat parameter values mentioned earlier.  If the opened device does not natively support the given format, RtAudio will automatically perform the necessary data format conversion.
+RtAudio provides four signed integer and two floating point data formats that can be specified using the RtAudioFormat parameter values mentioned earlier.  If the opened device does not natively support the given format, RtAudio will automatically perform the necessary data format conversion.
 
-The <I>bufferSize</I> parameter specifies the desired number of sample frames which will be written to and/or read from a device per write/read operation.  The <I>nBuffers</I> parameter is used in setting the underlying device buffer parameters.  Both the <I>bufferSize</I> and <I>nBuffers</I> parameters can be used to control stream latency though there is no guarantee that the passed values will be those used by a device (the <I>nBuffers</I> parameter is ignored when using the OS X CoreAudio, Linux Jack, and the Windows ASIO APIs).  In general, lower values for both parameters will produce less latency but perhaps less robust performance.  Both parameters can be specified with values of zero, in which case the smallest allowable values will be used.  The <I>bufferSize</I> parameter is passed as a pointer and the actual value used by the stream is set during the device setup procedure.  <I>bufferSize</I> values should be a power of two.  Optimal and allowable buffer values tend to vary between systems and devices.  Check the \ref apinotes section for general guidelines.
+The <I>bufferSize</I> parameter specifies the desired number of sample frames that will be written to and/or read from a device per write/read operation.  The <I>nBuffers</I> parameter is used in setting the underlying device buffer parameters.  Both the <I>bufferSize</I> and <I>nBuffers</I> parameters can be used to control stream latency though there is no guarantee that the passed values will be those used by a device (the <I>nBuffers</I> parameter is ignored when using the OS X CoreAudio, Linux Jack, and the Windows ASIO APIs).  In general, lower values for both parameters will produce less latency but perhaps less robust performance.  Both parameters can be specified with values of zero, in which case the smallest allowable values will be used.  The <I>bufferSize</I> parameter is passed as a pointer and the actual value used by the stream is set during the device setup procedure.  <I>bufferSize</I> values should be a power of two.  Optimal and allowable buffer values tend to vary between systems and devices.  Check the \ref apinotes section for general guidelines.
 
 As noted earlier, the device capabilities reported by a driver or underlying audio API are not always accurate and/or may be dependent on a combination of device settings.  Because of this, RtAudio does not attempt to query a device's capabilities or use previously reported values when opening a device.  Instead, RtAudio simply attempts to set the given parameters on a specified device and then checks whether the setup is successful or not.
 
@@ -252,7 +252,7 @@ int main()
     goto cleanup;
   }
 
-  // An example loop which runs for 40000 sample frames
+  // An example loop that runs for 40000 sample frames
   count = 0;
   while (count < 40000) {
     // Generate your samples and fill the buffer with bufferSize sample frames of data
@@ -295,7 +295,7 @@ In general, one should call the RtAudio::stopStream() and RtAudio::closeStream()
 
 \section playbackc Playback (callback functionality)
 
-The primary difference in using RtAudio with callback functionality involves the creation of a user-defined callback function.  Here is an example which produces a sawtooth waveform for playback.
+The primary difference in using RtAudio with callback functionality involves the creation of a user-defined callback function.  Here is an example that produces a sawtooth waveform for playback.
 
 \code
 
@@ -374,7 +374,7 @@ int main()
 }
 \endcode
 
-After opening the device in exactly the same way as the previous example (except with a data format change), we must set our callback function for the stream using RtAudio::setStreamCallback().  When the underlying audio API uses blocking calls (OSS, ALSA, SGI, and Windows DirectSound), this method will spawn a new process (or thread) which automatically calls the callback function when more data is needed.  Callback-based audio APIs (OS X CoreAudio Linux Jack, and ASIO) implement their own event notification schemes.  Note that the callback function is called only when the stream is "running" (between calls to the RtAudio::startStream() and RtAudio::stopStream() methods).  The last argument to RtAudio::setStreamCallback() is a pointer to arbitrary data that you wish to access from within your callback function.
+After opening the device in exactly the same way as the previous example (except with a data format change), we must set our callback function for the stream using RtAudio::setStreamCallback().  When the underlying audio API uses blocking calls (OSS, ALSA, SGI, and Windows DirectSound), this method will spawn a new process (or thread) that automatically calls the callback function when more data is needed.  Callback-based audio APIs (OS X CoreAudio Linux Jack, and ASIO) implement their own event notification schemes.  Note that the callback function is called only when the stream is "running" (between calls to the RtAudio::startStream() and RtAudio::stopStream() methods).  The last argument to RtAudio::setStreamCallback() is a pointer to arbitrary data that you wish to access from within your callback function.
 
 In this example, we stop the stream with an explicit call to RtAudio::stopStream().  When using callback functionality, it is also possible to stop a stream by returning a non-zero value from the callback function.
 
@@ -423,7 +423,7 @@ int main()
     goto cleanup;
   }
 
-  // An example loop which runs for about 40000 sample frames
+  // An example loop that runs for about 40000 sample frames
   count = 0;
   while (count < 40000) {
 
@@ -645,7 +645,7 @@ The example compiler statements above could be used to compile the <TT>probe.cpp
 
 \section debug Debugging
 
-If you are having problems getting RtAudio to run on your system, try passing the preprocessor definition <TT>__RTAUDIO_DEBUG__</TT> to the compiler (or uncomment the definition at the bottom of RtAudio.h).  A variety of warning messages will be displayed which may help in determining the problem.  Also try using the programs included in the <tt>test</tt> directory.  The program <tt>info</tt> displays the queried capabilities of all hardware devices found.
+If you are having problems getting RtAudio to run on your system, try passing the preprocessor definition <TT>__RTAUDIO_DEBUG__</TT> to the compiler (or uncomment the definition at the bottom of RtAudio.h).  A variety of warning messages will be displayed that may help in determining the problem.  Also try using the programs included in the <tt>test</tt> directory.  The program <tt>info</tt> displays the queried capabilities of all hardware devices found.
 
 \section apinotes API Notes
 
@@ -655,7 +655,7 @@ RtAudio is designed to provide a common API across the various supported operati
 
 RtAudio for Linux was developed under Redhat distributions 7.0 - Fedora.  Three different audio APIs are supported on Linux platforms: OSS, <A href="http://www.alsa-project.org/">ALSA</A>, and <A href="http://jackit.sourceforge.net/">Jack</A>.  The OSS API has existed for at least 6 years and the Linux kernel is distributed with free versions of OSS audio drivers.  Therefore, a generic Linux system is most likely to have OSS support (though the availability and quality of OSS drivers for new hardware is decreasing).  The ALSA API, although relatively new, is now part of the Linux development kernel and offers significantly better functionality than the OSS API.  RtAudio provides support for the 1.0 and higher versions of ALSA.  Jack, which is still in development, is a low-latency audio server, written primarily for the GNU/Linux operating system. It can connect a number of different applications to an audio device, as well as allow them to share audio between themselves.  Input/output latency on the order of 15 milliseconds can typically be achieved using any of the Linux APIs by fine-tuning the RtAudio buffer parameters (without kernel modifications).  Latencies on the order of 5 milliseconds or less can be achieved using a low-latency kernel patch and increasing FIFO scheduling priority.  The pthread library, which is used for callback functionality, is a standard component of all Linux distributions.
 
-The ALSA library includes OSS emulation support.  That means that you can run programs compiled for the OSS API even when using the ALSA drivers and library.  It should be noted however that OSS emulation under ALSA is not perfect.  Specifically, channel number queries seem to consistently produce invalid results.  While OSS emulation is successful for the majority of RtAudio tests, it is recommended that the native ALSA implementation of RtAudio be used on systems which have ALSA drivers installed.
+The ALSA library includes OSS emulation support.  That means that you can run programs compiled for the OSS API even when using the ALSA drivers and library.  It should be noted however that OSS emulation under ALSA is not perfect.  Specifically, channel number queries seem to consistently produce invalid results.  While OSS emulation is successful for the majority of RtAudio tests, it is recommended that the native ALSA implementation of RtAudio be used on systems that have ALSA drivers installed.
 
 The ALSA implementation of RtAudio makes no use of the ALSA "plug" interface.  All necessary data format conversions, channel compensation, de-interleaving, and byte-swapping is handled by internal RtAudio routines.
 
@@ -673,13 +673,17 @@ The Irix version of RtAudio was written and tested on an SGI Indy running Irix v
 
 \subsection windowsds Windows (DirectSound):
 
-In order to compile RtAudio under Windows for the DirectSound API, you must have the header and source files for DirectSound version 5.0 or higher.  As far as I know, there is no DirectSoundCapture support for Windows NT.  Audio output latency with DirectSound can be reasonably good (on the order of 20 milliseconds).  On the other hand, input audio latency tends to be terrible (100 milliseconds or more).  Further, DirectSound drivers tend to crash easily when experimenting with buffer parameters.  On my system, I found it necessary to use values around nBuffers = 8 and bufferSize = 512 to avoid crashes.  RtAudio was originally developed with Visual C++ version 6.0.
+In order to compile RtAudio under Windows for the DirectSound API, you must have the header and source files for DirectSound version 5.0 or higher.  As far as I know, there is no DirectSoundCapture support for Windows NT.  Audio output latency with DirectSound can be reasonably good, especially since RtAudio version 3.0.2.  Input audio latency still tends to be bad but better since version 3.0.2.  RtAudio was originally developed with Visual C++ version 6.0 but has been tested with .NET.
+
+The DirectSound version of RtAudio can be compiled with or without the UNICODE preprocessor definition.
 
 \subsection windowsasio Windows (ASIO):
 
 The Steinberg ASIO audio API is based on a callback scheme.  In addition, the API allows only a single device driver to be loaded and accessed at a time.  ASIO device drivers must be supplied by audio hardware manufacturers, though ASIO emulation is possible on top of systems with DirectSound drivers.  The <I>numberOfBuffers</I> parameter to the RtAudio::openStream() function has no affect in this implementation.
 
-A number of ASIO source and header files are required for use with RtAudio.  Specifically, an RtAudio project must include the following files: <TT>asio.h,cpp; asiodrivers.h,cpp; asiolist.h,cpp; asiodrvr.h; asiosys.h; ginclude.h; iasiodrv.h</TT>.  The Visual C++ projects found in <TT>/tests/Windows/</TT> compile both ASIO and DirectSound support.
+A number of ASIO source and header files are required for use with RtAudio.  Specifically, an RtAudio project must include the following files: <TT>asio.h,cpp; asiodrivers.h,cpp; asiolist.h,cpp; asiodrvr.h; asiosys.h; ginclude.h; iasiodrv.h; iasiothiscallresolver.h,cpp</TT>.  The Visual C++ projects found in <TT>/tests/Windows/</TT> compile both ASIO and DirectSound support.
+
+The Steinberg provided <TT>asiolist</TT> class does not compile when the preprocessor definition UNICODE is defined.  Note that this could be an issue when using RtAudio with Qt, though Qt programs appear to compile without the UNICODE definition (try <tt>DEFINES -= UNICODE</tt> in your .pro file).  RtAudio with ASIO support has been tested using the MinGW compiler under Windows XP, as well as in the Visual Studio environment.
 
 \section wishlist Possible Future Changes
 
@@ -694,8 +698,12 @@ There are a few issues that still need to be addressed in future versions of RtA
 
 \section acknowledge Acknowledgements
 
-Thanks to Robin Davies for a number of bug fixes and improvements to
-the DirectSound and ASIO implementations in the 3.0.2 release!
+Many thanks to the following people for providing bug fixes and improvements:
+<UL>
+<LI>Robin Davies (Windows DS and ASIO)</LI>
+<LI>Ryan Williams (Windows non-MS compiler ASIO support)</LI>
+<LI>Ed Wildgoose (Linux ALSA and Jack)</LI>
+</UL>
 
 The RtAudio API incorporates many of the concepts developed in the <A
 href="http://www.portaudio.com/">PortAudio</A> project by Phil Burk
index ba72cc33ce5716000c665ac072668ca67bd0f73c..939501ca5cf3a0dac36625e4bd3dfefd35ac861d 100644 (file)
@@ -2,6 +2,12 @@ RtAudio - a set of C++ classes which provide a common API for realtime audio inp
 
 By Gary P. Scavone, 2001-2005.
 
+v3.0.3: ( November 2005)
+- UNICODE fix for Windows DirectSound API
+- MinGW compiler fix for ASIO API
+- jack support to create virtual devices for each jack plugin
+- support to prefill output buffer with zeroes in duplex mode
+
 v3.0.2: (14 October 2005)
 - modification of ALSA read/write order to fix duplex under/overruns
 - added synchronization of input/output devices for ALSA duplex operation
diff --git a/tests/Windows/asio.cpp b/tests/Windows/asio.cpp
deleted file mode 100644 (file)
index b241663..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*\r
-       Steinberg Audio Stream I/O API\r
-       (c) 1996, Steinberg Soft- und Hardware GmbH\r
-\r
-       asio.cpp\r
-       \r
-       asio functions entries which translate the\r
-       asio interface to the asiodrvr class methods\r
-*/ \r
-       \r
-#include <string.h>\r
-#include "asiosys.h"           // platform definition\r
-#include "asio.h"\r
-\r
-#if MAC\r
-#include "asiodrvr.h"\r
-\r
-#pragma export on\r
-\r
-AsioDriver *theAsioDriver = 0;\r
-\r
-extern "C"\r
-{\r
-\r
-long main()\r
-{\r
-       return 'ASIO';\r
-}\r
-\r
-#elif WINDOWS\r
-\r
-#include "windows.h"\r
-#include "iasiodrv.h"\r
-#include "asiodrivers.h"\r
-\r
-IASIO *theAsioDriver = 0;\r
-extern AsioDrivers *asioDrivers;\r
-\r
-#elif SGI || SUN || BEOS || LINUX\r
-#include "asiodrvr.h"\r
-static AsioDriver *theAsioDriver = 0;\r
-#endif\r
-\r
-//-----------------------------------------------------------------------------------------------------\r
-ASIOError ASIOInit(ASIODriverInfo *info)\r
-{\r
-#if MAC || SGI || SUN || BEOS || LINUX\r
-       if(theAsioDriver)\r
-       {\r
-               delete theAsioDriver;\r
-               theAsioDriver = 0;\r
-       }               \r
-       info->driverVersion = 0;\r
-       strcpy(info->name, "No ASIO Driver");\r
-       theAsioDriver = getDriver();\r
-       if(!theAsioDriver)\r
-       {\r
-               strcpy(info->errorMessage, "Not enough memory for the ASIO driver!"); \r
-               return ASE_NotPresent;\r
-       }\r
-       if(!theAsioDriver->init(info->sysRef))\r
-       {\r
-               theAsioDriver->getErrorMessage(info->errorMessage);\r
-               delete theAsioDriver;\r
-               theAsioDriver = 0;\r
-               return ASE_NotPresent;\r
-       }\r
-       strcpy(info->errorMessage, "No ASIO Driver Error");\r
-       theAsioDriver->getDriverName(info->name);\r
-       info->driverVersion = theAsioDriver->getDriverVersion();\r
-       return ASE_OK;\r
-\r
-#else\r
-\r
-       info->driverVersion = 0;\r
-       strcpy(info->name, "No ASIO Driver");\r
-       if(theAsioDriver)       // must be loaded!\r
-       {\r
-               if(!theAsioDriver->init(info->sysRef))\r
-               {\r
-                       theAsioDriver->getErrorMessage(info->errorMessage);\r
-                       theAsioDriver = 0;\r
-                       return ASE_NotPresent;\r
-               }               \r
-\r
-               strcpy(info->errorMessage, "No ASIO Driver Error");\r
-               theAsioDriver->getDriverName(info->name);\r
-               info->driverVersion = theAsioDriver->getDriverVersion();\r
-               return ASE_OK;\r
-       }\r
-       return ASE_NotPresent;\r
-\r
-#endif // !MAC\r
-}\r
-\r
-ASIOError ASIOExit(void)\r
-{\r
-       if(theAsioDriver)\r
-       {\r
-#if WINDOWS\r
-               asioDrivers->removeCurrentDriver();\r
-#else\r
-               delete theAsioDriver;\r
-#endif\r
-       }               \r
-       theAsioDriver = 0;\r
-       return ASE_OK;\r
-}\r
-\r
-ASIOError ASIOStart(void)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->start();\r
-}\r
-\r
-ASIOError ASIOStop(void)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->stop();\r
-}\r
-\r
-ASIOError ASIOGetChannels(long *numInputChannels, long *numOutputChannels)\r
-{\r
-       if(!theAsioDriver)\r
-       {\r
-               *numInputChannels = *numOutputChannels = 0;\r
-               return ASE_NotPresent;\r
-       }\r
-       return theAsioDriver->getChannels(numInputChannels, numOutputChannels);\r
-}\r
-\r
-ASIOError ASIOGetLatencies(long *inputLatency, long *outputLatency)\r
-{\r
-       if(!theAsioDriver)\r
-       {\r
-               *inputLatency = *outputLatency = 0;\r
-               return ASE_NotPresent;\r
-       }\r
-       return theAsioDriver->getLatencies(inputLatency, outputLatency);\r
-}\r
-\r
-ASIOError ASIOGetBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity)\r
-{\r
-       if(!theAsioDriver)\r
-       {\r
-               *minSize = *maxSize = *preferredSize = *granularity = 0;\r
-               return ASE_NotPresent;\r
-       }\r
-       return theAsioDriver->getBufferSize(minSize, maxSize, preferredSize, granularity);\r
-}\r
-\r
-ASIOError ASIOCanSampleRate(ASIOSampleRate sampleRate)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->canSampleRate(sampleRate);\r
-}\r
-\r
-ASIOError ASIOGetSampleRate(ASIOSampleRate *currentRate)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->getSampleRate(currentRate);\r
-}\r
-\r
-ASIOError ASIOSetSampleRate(ASIOSampleRate sampleRate)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->setSampleRate(sampleRate);\r
-}\r
-\r
-ASIOError ASIOGetClockSources(ASIOClockSource *clocks, long *numSources)\r
-{\r
-       if(!theAsioDriver)\r
-       {\r
-               *numSources = 0;\r
-               return ASE_NotPresent;\r
-       }\r
-       return theAsioDriver->getClockSources(clocks, numSources);\r
-}\r
-\r
-ASIOError ASIOSetClockSource(long reference)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->setClockSource(reference);\r
-}\r
-\r
-ASIOError ASIOGetSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->getSamplePosition(sPos, tStamp);\r
-}\r
-\r
-ASIOError ASIOGetChannelInfo(ASIOChannelInfo *info)\r
-{\r
-       if(!theAsioDriver)\r
-       {\r
-               info->channelGroup = -1;\r
-               info->type = ASIOSTInt16MSB;\r
-               strcpy(info->name, "None");\r
-               return ASE_NotPresent;\r
-       }\r
-       return theAsioDriver->getChannelInfo(info);\r
-}\r
-\r
-ASIOError ASIOCreateBuffers(ASIOBufferInfo *bufferInfos, long numChannels,\r
-       long bufferSize, ASIOCallbacks *callbacks)\r
-{\r
-       if(!theAsioDriver)\r
-       {\r
-               ASIOBufferInfo *info = bufferInfos;\r
-               for(long i = 0; i < numChannels; i++, info++)\r
-                       info->buffers[0] = info->buffers[1] = 0;\r
-               return ASE_NotPresent;\r
-       }\r
-       return theAsioDriver->createBuffers(bufferInfos, numChannels, bufferSize, callbacks);\r
-}\r
-\r
-ASIOError ASIODisposeBuffers(void)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->disposeBuffers();\r
-}\r
-\r
-ASIOError ASIOControlPanel(void)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->controlPanel();\r
-}\r
-\r
-ASIOError ASIOFuture(long selector, void *opt)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->future(selector, opt);\r
-}\r
-\r
-ASIOError ASIOOutputReady(void)\r
-{\r
-       if(!theAsioDriver)\r
-               return ASE_NotPresent;\r
-       return theAsioDriver->outputReady();\r
-}\r
-\r
-#if MAC\r
-}      // extern "C"\r
-#pragma export off\r
-#endif\r
-\r
-\r
diff --git a/tests/Windows/asio.h b/tests/Windows/asio.h
deleted file mode 100644 (file)
index 3003130..0000000
+++ /dev/null
@@ -1,955 +0,0 @@
-//---------------------------------------------------------------------------------------------------\r
-//---------------------------------------------------------------------------------------------------\r
-\r
-/*\r
-       Steinberg Audio Stream I/O API\r
-       (c) 1997 - 1999, Steinberg Soft- und Hardware GmbH\r
-\r
-       ASIO Interface Specification v 2.0\r
-\r
-       basic concept is an i/o synchronous double-buffer scheme:\r
-       \r
-       on bufferSwitch(index == 0), host will read/write:\r
-\r
-               after ASIOStart(), the\r
-  read  first input buffer A (index 0)\r
-       |   will be invalid (empty)\r
-       *   ------------------------\r
-       |------------------------|-----------------------|\r
-       |                        |                       |\r
-       |  Input Buffer A (0)    |   Input Buffer B (1)  |\r
-       |                        |                       |\r
-       |------------------------|-----------------------|\r
-       |                        |                       |\r
-       |  Output Buffer A (0)   |   Output Buffer B (1) |\r
-       |                        |                       |\r
-       |------------------------|-----------------------|\r
-       *                        -------------------------\r
-       |                        before calling ASIOStart(),\r
-  write                      host will have filled output\r
-                             buffer B (index 1) already\r
-\r
-  *please* take special care of proper statement of input\r
-  and output latencies (see ASIOGetLatencies()), these\r
-  control sequencer sync accuracy\r
-\r
-*/\r
-\r
-//---------------------------------------------------------------------------------------------------\r
-//---------------------------------------------------------------------------------------------------\r
-\r
-/*\r
-\r
-prototypes summary:\r
-\r
-ASIOError ASIOInit(ASIODriverInfo *info);\r
-ASIOError ASIOExit(void);\r
-ASIOError ASIOStart(void);\r
-ASIOError ASIOStop(void);\r
-ASIOError ASIOGetChannels(long *numInputChannels, long *numOutputChannels);\r
-ASIOError ASIOGetLatencies(long *inputLatency, long *outputLatency);\r
-ASIOError ASIOGetBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity);\r
-ASIOError ASIOCanSampleRate(ASIOSampleRate sampleRate);\r
-ASIOError ASIOGetSampleRate(ASIOSampleRate *currentRate);\r
-ASIOError ASIOSetSampleRate(ASIOSampleRate sampleRate);\r
-ASIOError ASIOGetClockSources(ASIOClockSource *clocks, long *numSources);\r
-ASIOError ASIOSetClockSource(long reference);\r
-ASIOError ASIOGetSamplePosition (ASIOSamples *sPos, ASIOTimeStamp *tStamp);\r
-ASIOError ASIOGetChannelInfo(ASIOChannelInfo *info);\r
-ASIOError ASIOCreateBuffers(ASIOBufferInfo *bufferInfos, long numChannels,\r
-       long bufferSize, ASIOCallbacks *callbacks);\r
-ASIOError ASIODisposeBuffers(void);\r
-ASIOError ASIOControlPanel(void);\r
-void *ASIOFuture(long selector, void *params);\r
-ASIOError ASIOOutputReady(void);\r
-\r
-*/\r
-\r
-//---------------------------------------------------------------------------------------------------\r
-//---------------------------------------------------------------------------------------------------\r
-\r
-#ifndef __ASIO_H\r
-#define __ASIO_H\r
-\r
-// force 4 byte alignment\r
-#if defined(_MSC_VER) && !defined(__MWERKS__) \r
-#pragma pack(push,4)\r
-#elif PRAGMA_ALIGN_SUPPORTED\r
-#pragma options align = native\r
-#endif\r
-\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-// Type definitions\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
-// number of samples data type is 64 bit integer\r
-#if NATIVE_INT64\r
-       typedef long long int ASIOSamples;\r
-#else\r
-       typedef struct ASIOSamples {\r
-               unsigned long hi;\r
-               unsigned long lo;\r
-       } ASIOSamples;\r
-#endif\r
-\r
-// Timestamp data type is 64 bit integer,\r
-// Time format is Nanoseconds.\r
-#if NATIVE_INT64\r
-       typedef long long int ASIOTimeStamp ;\r
-#else\r
-       typedef struct ASIOTimeStamp {\r
-               unsigned long hi;\r
-               unsigned long lo;\r
-       } ASIOTimeStamp;\r
-#endif\r
-\r
-// Samplerates are expressed in IEEE 754 64 bit double float,\r
-// native format as host computer\r
-#if IEEE754_64FLOAT\r
-       typedef double ASIOSampleRate;\r
-#else\r
-       typedef struct ASIOSampleRate {\r
-               char ieee[8];\r
-       } ASIOSampleRate;\r
-#endif\r
-\r
-// Boolean values are expressed as long\r
-typedef long ASIOBool;\r
-enum {\r
-       ASIOFalse = 0,\r
-       ASIOTrue = 1\r
-};\r
-\r
-// Sample Types are expressed as long\r
-typedef long ASIOSampleType;\r
-enum {\r
-       ASIOSTInt16MSB   = 0,\r
-       ASIOSTInt24MSB   = 1,           // used for 20 bits as well\r
-       ASIOSTInt32MSB   = 2,\r
-       ASIOSTFloat32MSB = 3,           // IEEE 754 32 bit float\r
-       ASIOSTFloat64MSB = 4,           // IEEE 754 64 bit double float\r
-\r
-       // these are used for 32 bit data buffer, with different alignment of the data inside\r
-       // 32 bit PCI bus systems can be more easily used with these\r
-       ASIOSTInt32MSB16 = 8,           // 32 bit data with 18 bit alignment\r
-       ASIOSTInt32MSB18 = 9,           // 32 bit data with 18 bit alignment\r
-       ASIOSTInt32MSB20 = 10,          // 32 bit data with 20 bit alignment\r
-       ASIOSTInt32MSB24 = 11,          // 32 bit data with 24 bit alignment\r
-       \r
-       ASIOSTInt16LSB   = 16,\r
-       ASIOSTInt24LSB   = 17,          // used for 20 bits as well\r
-       ASIOSTInt32LSB   = 18,\r
-       ASIOSTFloat32LSB = 19,          // IEEE 754 32 bit float, as found on Intel x86 architecture\r
-       ASIOSTFloat64LSB = 20,          // IEEE 754 64 bit double float, as found on Intel x86 architecture\r
-\r
-       // these are used for 32 bit data buffer, with different alignment of the data inside\r
-       // 32 bit PCI bus systems can more easily used with these\r
-       ASIOSTInt32LSB16 = 24,          // 32 bit data with 18 bit alignment\r
-       ASIOSTInt32LSB18 = 25,          // 32 bit data with 18 bit alignment\r
-       ASIOSTInt32LSB20 = 26,          // 32 bit data with 20 bit alignment\r
-       ASIOSTInt32LSB24 = 27           // 32 bit data with 24 bit alignment\r
-};\r
-\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-// Error codes\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
-typedef long ASIOError;\r
-enum {\r
-       ASE_OK = 0,             // This value will be returned whenever the call succeeded\r
-       ASE_SUCCESS = 0x3f4847a0,       // unique success return value for ASIOFuture calls\r
-       ASE_NotPresent = -1000, // hardware input or output is not present or available\r
-       ASE_HWMalfunction,      // hardware is malfunctioning (can be returned by any ASIO function)\r
-       ASE_InvalidParameter,   // input parameter invalid\r
-       ASE_InvalidMode,        // hardware is in a bad mode or used in a bad mode\r
-       ASE_SPNotAdvancing,     // hardware is not running when sample position is inquired\r
-       ASE_NoClock,            // sample clock or rate cannot be determined or is not present\r
-       ASE_NoMemory            // not enough memory for completing the request\r
-};\r
-\r
-//---------------------------------------------------------------------------------------------------\r
-//---------------------------------------------------------------------------------------------------\r
-\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-// Time Info support\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
-typedef struct ASIOTimeCode\r
-{       \r
-       double          speed;                  // speed relation (fraction of nominal speed)\r
-                                               // optional; set to 0. or 1. if not supported\r
-       ASIOSamples     timeCodeSamples;        // time in samples\r
-       unsigned long   flags;                  // some information flags (see below)\r
-       char future[64];\r
-} ASIOTimeCode;\r
-\r
-typedef enum ASIOTimeCodeFlags\r
-{\r
-       kTcValid                = 1,\r
-       kTcRunning              = 1 << 1,\r
-       kTcReverse              = 1 << 2,\r
-       kTcOnspeed              = 1 << 3,\r
-       kTcStill                = 1 << 4,\r
-       \r
-       kTcSpeedValid           = 1 << 8\r
-}  ASIOTimeCodeFlags;\r
-\r
-typedef struct AsioTimeInfo\r
-{\r
-       double          speed;                  // absolute speed (1. = nominal)\r
-       ASIOTimeStamp   systemTime;             // system time related to samplePosition, in nanoseconds\r
-                                               // on mac, must be derived from Microseconds() (not UpTime()!)\r
-                                               // on windows, must be derived from timeGetTime()\r
-       ASIOSamples     samplePosition;\r
-       ASIOSampleRate  sampleRate;             // current rate\r
-       unsigned long flags;                    // (see below)\r
-       char reserved[12];\r
-} AsioTimeInfo;\r
-\r
-typedef enum AsioTimeInfoFlags\r
-{\r
-       kSystemTimeValid        = 1,            // must always be valid\r
-       kSamplePositionValid    = 1 << 1,       // must always be valid\r
-       kSampleRateValid        = 1 << 2,\r
-       kSpeedValid             = 1 << 3,\r
-       \r
-       kSampleRateChanged      = 1 << 4,\r
-       kClockSourceChanged     = 1 << 5\r
-} AsioTimeInfoFlags;\r
-\r
-typedef struct ASIOTime                          // both input/output\r
-{\r
-       long reserved[4];                       // must be 0\r
-       struct AsioTimeInfo     timeInfo;       // required\r
-       struct ASIOTimeCode     timeCode;       // optional, evaluated if (timeCode.flags & kTcValid)\r
-} ASIOTime;\r
-\r
-/*\r
-\r
-using time info:\r
-it is recommended to use the new method with time info even if the asio\r
-device does not support timecode; continuous calls to ASIOGetSamplePosition\r
-and ASIOGetSampleRate are avoided, and there is a more defined relationship\r
-between callback time and the time info.\r
-\r
-see the example below.\r
-to initiate time info mode, after you have received the callbacks pointer in\r
-ASIOCreateBuffers, you will call the asioMessage callback with kAsioSupportsTimeInfo\r
-as the argument. if this returns 1, host has accepted time info mode.\r
-now host expects the new callback bufferSwitchTimeInfo to be used instead\r
-of the old bufferSwitch method. the ASIOTime structure is assumed to be valid\r
-and accessible until the callback returns.\r
-\r
-using time code:\r
-if the device supports reading time code, it will call host's asioMessage callback\r
-with kAsioSupportsTimeCode as the selector. it may then fill the according\r
-fields and set the kTcValid flag.\r
-host will call the future method with the kAsioEnableTimeCodeRead selector when\r
-it wants to enable or disable tc reading by the device. you should also support\r
-the kAsioCanTimeInfo and kAsioCanTimeCode selectors in ASIOFuture (see example).\r
-\r
-note:\r
-the AsioTimeInfo/ASIOTimeCode pair is supposed to work in both directions.\r
-as a matter of convention, the relationship between the sample\r
-position counter and the time code at buffer switch time is\r
-(ignoring offset between tc and sample pos when tc is running):\r
-\r
-on input:      sample 0 -> input  buffer sample 0 -> time code 0\r
-on output:     sample 0 -> output buffer sample 0 -> time code 0\r
-\r
-this means that for 'real' calculations, one has to take into account\r
-the according latencies.\r
-\r
-example:\r
-\r
-ASIOTime asioTime;\r
-\r
-in createBuffers()\r
-{\r
-       memset(&asioTime, 0, sizeof(ASIOTime));\r
-       AsioTimeInfo* ti = &asioTime.timeInfo;\r
-       ti->sampleRate = theSampleRate;\r
-       ASIOTimeCode* tc = &asioTime.timeCode;\r
-       tc->speed = 1.;\r
-       timeInfoMode = false;\r
-       canTimeCode = false;\r
-       if(callbacks->asioMessage(kAsioSupportsTimeInfo, 0, 0, 0) == 1)\r
-       {\r
-               timeInfoMode = true;\r
-#if kCanTimeCode\r
-               if(callbacks->asioMessage(kAsioSupportsTimeCode, 0, 0, 0) == 1)\r
-                       canTimeCode = true;\r
-#endif\r
-       }\r
-}\r
-\r
-void switchBuffers(long doubleBufferIndex, bool processNow)\r
-{\r
-       if(timeInfoMode)\r
-       {\r
-               AsioTimeInfo* ti = &asioTime.timeInfo;\r
-               ti->flags =     kSystemTimeValid | kSamplePositionValid | kSampleRateValid;\r
-               ti->systemTime = theNanoSeconds;\r
-               ti->samplePosition = theSamplePosition;\r
-               if(ti->sampleRate != theSampleRate)\r
-                       ti->flags |= kSampleRateChanged;\r
-               ti->sampleRate = theSampleRate;\r
-\r
-#if kCanTimeCode\r
-               if(canTimeCode && timeCodeEnabled)\r
-               {\r
-                       ASIOTimeCode* tc = &asioTime.timeCode;\r
-                       tc->timeCodeSamples = tcSamples;                                                // tc in samples\r
-                       tc->flags = kTcValid | kTcRunning | kTcOnspeed;                 // if so...\r
-               }\r
-               ASIOTime* bb = callbacks->bufferSwitchTimeInfo(&asioTime, doubleBufferIndex, processNow ? ASIOTrue : ASIOFalse);\r
-#else\r
-               callbacks->bufferSwitchTimeInfo(&asioTime, doubleBufferIndex, processNow ? ASIOTrue : ASIOFalse);\r
-#endif\r
-       }\r
-       else\r
-               callbacks->bufferSwitch(doubleBufferIndex, ASIOFalse);\r
-}\r
-\r
-ASIOError ASIOFuture(long selector, void *params)\r
-{\r
-       switch(selector)\r
-       {\r
-               case kAsioEnableTimeCodeRead:\r
-                       timeCodeEnabled = true;\r
-                       return ASE_SUCCESS;\r
-               case kAsioDisableTimeCodeRead:\r
-                       timeCodeEnabled = false;\r
-                       return ASE_SUCCESS;\r
-               case kAsioCanTimeInfo:\r
-                       return ASE_SUCCESS;\r
-               #if kCanTimeCode\r
-               case kAsioCanTimeCode:\r
-                       return ASE_SUCCESS;\r
-               #endif\r
-       }\r
-       return ASE_NotPresent;\r
-};\r
-\r
-*/\r
-\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-// application's audio stream handler callbacks\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
-typedef struct ASIOCallbacks\r
-{\r
-       void (*bufferSwitch) (long doubleBufferIndex, ASIOBool directProcess);\r
-               // bufferSwitch indicates that both input and output are to be processed.\r
-               // the current buffer half index (0 for A, 1 for B) determines\r
-               // - the output buffer that the host should start to fill. the other buffer\r
-               //   will be passed to output hardware regardless of whether it got filled\r
-               //   in time or not.\r
-               // - the input buffer that is now filled with incoming data. Note that\r
-               //   because of the synchronicity of i/o, the input always has at\r
-               //   least one buffer latency in relation to the output.\r
-               // directProcess suggests to the host whether it should immedeately\r
-               // start processing (directProcess == ASIOTrue), or whether its process\r
-               // should be deferred because the call comes from a very low level\r
-               // (for instance, a high level priority interrupt), and direct processing\r
-               // would cause timing instabilities for the rest of the system. If in doubt,\r
-               // directProcess should be set to ASIOFalse.\r
-               // Note: bufferSwitch may be called at interrupt time for highest efficiency.\r
-\r
-       void (*sampleRateDidChange) (ASIOSampleRate sRate);\r
-               // gets called when the AudioStreamIO detects a sample rate change\r
-               // If sample rate is unknown, 0 is passed (for instance, clock loss\r
-               // when externally synchronized).\r
-\r
-       long (*asioMessage) (long selector, long value, void* message, double* opt);\r
-               // generic callback for various purposes, see selectors below.\r
-               // note this is only present if the asio version is 2 or higher\r
-\r
-       ASIOTime* (*bufferSwitchTimeInfo) (ASIOTime* params, long doubleBufferIndex, ASIOBool directProcess);\r
-               // new callback with time info. makes ASIOGetSamplePosition() and various\r
-               // calls to ASIOGetSampleRate obsolete,\r
-               // and allows for timecode sync etc. to be preferred; will be used if\r
-               // the driver calls asioMessage with selector kAsioSupportsTimeInfo.\r
-} ASIOCallbacks;\r
-\r
-// asioMessage selectors\r
-enum\r
-{\r
-       kAsioSelectorSupported = 1,     // selector in <value>, returns 1L if supported,\r
-                                                               // 0 otherwise\r
-    kAsioEngineVersion,                        // returns engine (host) asio implementation version,\r
-                                                               // 2 or higher\r
-       kAsioResetRequest,                      // request driver reset. if accepted, this\r
-                                                               // will close the driver (ASIO_Exit() ) and\r
-                                                               // re-open it again (ASIO_Init() etc). some\r
-                                                               // drivers need to reconfigure for instance\r
-                                                               // when the sample rate changes, or some basic\r
-                                                               // changes have been made in ASIO_ControlPanel().\r
-                                                               // returns 1L; note the request is merely passed\r
-                                                               // to the application, there is no way to determine\r
-                                                               // if it gets accepted at this time (but it usually\r
-                                                               // will be).\r
-       kAsioBufferSizeChange,          // not yet supported, will currently always return 0L.\r
-                                                               // for now, use kAsioResetRequest instead.\r
-                                                               // once implemented, the new buffer size is expected\r
-                                                               // in <value>, and on success returns 1L\r
-       kAsioResyncRequest,                     // the driver went out of sync, such that\r
-                                                               // the timestamp is no longer valid. this\r
-                                                               // is a request to re-start the engine and\r
-                                                               // slave devices (sequencer). returns 1 for ok,\r
-                                                               // 0 if not supported.\r
-       kAsioLatenciesChanged,          // the drivers latencies have changed. The engine\r
-                                                               // will refetch the latencies.\r
-       kAsioSupportsTimeInfo,          // if host returns true here, it will expect the\r
-                                                               // callback bufferSwitchTimeInfo to be called instead\r
-                                                               // of bufferSwitch\r
-       kAsioSupportsTimeCode,          // supports time code reading/writing\r
-\r
-       kAsioSupportsInputMonitor,      // supports input monitoring\r
-\r
-       kAsioNumMessageSelectors\r
-};\r
-\r
-//---------------------------------------------------------------------------------------------------\r
-//---------------------------------------------------------------------------------------------------\r
-\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-// (De-)Construction\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
-typedef struct ASIODriverInfo\r
-{\r
-       long asioVersion;               // currently, 2\r
-       long driverVersion;             // driver specific\r
-       char name[32];\r
-       char errorMessage[124];\r
-       void *sysRef;                   // on input: system reference\r
-                                                       // (Windows: application main window handle, Mac & SGI: 0)\r
-} ASIODriverInfo;\r
-\r
-ASIOError ASIOInit(ASIODriverInfo *info);\r
-/* Purpose:\r
-         Initialize the AudioStreamIO.\r
-       Parameter:\r
-         info: pointer to an ASIODriver structure:\r
-           - asioVersion:\r
-                       - on input, the host version. *** Note *** this is 0 for earlier asio\r
-                       implementations, and the asioMessage callback is implemeted\r
-                       only if asioVersion is 2 or greater. sorry but due to a design fault\r
-                       the driver doesn't have access to the host version in ASIOInit :-(\r
-                       added selector for host (engine) version in the asioMessage callback\r
-                       so we're ok from now on.\r
-                       - on return, asio implementation version.\r
-                         older versions are 1\r
-                         if you support this version (namely, ASIO_outputReady() )\r
-                         this should be 2 or higher. also see the note in\r
-                         ASIO_getTimeStamp() !\r
-           - version: on return, the driver version (format is driver specific)\r
-           - name: on return, a null-terminated string containing the driver's name\r
-               - error message: on return, should contain a user message describing\r
-                 the type of error that occured during ASIOInit(), if any.\r
-               - sysRef: platform specific\r
-       Returns:\r
-         If neither input nor output is present ASE_NotPresent\r
-         will be returned.\r
-         ASE_NoMemory, ASE_HWMalfunction are other possible error conditions\r
-*/\r
-\r
-ASIOError ASIOExit(void);\r
-/* Purpose:\r
-         Terminates the AudioStreamIO.\r
-       Parameter:\r
-         None.\r
-       Returns:\r
-         If neither input nor output is present ASE_NotPresent\r
-         will be returned.\r
-       Notes: this implies ASIOStop() and ASIODisposeBuffers(),\r
-         meaning that no host callbacks must be accessed after ASIOExit().\r
-*/\r
-\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-// Start/Stop\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
-ASIOError ASIOStart(void);\r
-/* Purpose:\r
-         Start input and output processing synchronously.\r
-         This will\r
-         - reset the sample counter to zero\r
-         - start the hardware (both input and output)\r
-           The first call to the hosts' bufferSwitch(index == 0) then tells\r
-           the host to read from input buffer A (index 0), and start\r
-           processing to output buffer A while output buffer B (which\r
-           has been filled by the host prior to calling ASIOStart())\r
-           is possibly sounding (see also ASIOGetLatencies()) \r
-       Parameter:\r
-         None.\r
-       Returns:\r
-         If neither input nor output is present, ASE_NotPresent\r
-         will be returned.\r
-         If the hardware fails to start, ASE_HWMalfunction will be returned.\r
-       Notes:\r
-         There is no restriction on the time that ASIOStart() takes\r
-         to perform (that is, it is not considered a realtime trigger).\r
-*/\r
-\r
-ASIOError ASIOStop(void);\r
-/* Purpose:\r
-         Stops input and output processing altogether.\r
-       Parameter:\r
-         None.\r
-       Returns:\r
-         If neither input nor output is present ASE_NotPresent\r
-         will be returned.\r
-       Notes:\r
-         On return from ASIOStop(), the driver must in no\r
-         case call the hosts' bufferSwitch() routine.\r
-*/\r
-\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-// Inquiry methods and sample rate\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
-ASIOError ASIOGetChannels(long *numInputChannels, long *numOutputChannels);\r
-/* Purpose:\r
-         Returns number of individual input/output channels.\r
-       Parameter:\r
-         numInputChannels will hold the number of available input channels\r
-         numOutputChannels will hold the number of available output channels\r
-       Returns:\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-         If only inputs, or only outputs are available, the according\r
-         other parameter will be zero, and ASE_OK is returned.\r
-*/\r
-\r
-ASIOError ASIOGetLatencies(long *inputLatency, long *outputLatency);\r
-/* Purpose:\r
-         Returns the input and output latencies. This includes\r
-         device specific delays, like FIFOs etc.\r
-       Parameter:\r
-         inputLatency will hold the 'age' of the first sample frame\r
-         in the input buffer when the hosts reads it in bufferSwitch()\r
-         (this is theoretical, meaning it does not include the overhead\r
-         and delay between the actual physical switch, and the time\r
-         when bufferSitch() enters).\r
-         This will usually be the size of one block in sample frames, plus\r
-         device specific latencies.\r
-\r
-         outputLatency will specify the time between the buffer switch,\r
-         and the time when the next play buffer will start to sound.\r
-         The next play buffer is defined as the one the host starts\r
-         processing after (or at) bufferSwitch(), indicated by the\r
-         index parameter (0 for buffer A, 1 for buffer B).\r
-         It will usually be either one block, if the host writes directly\r
-         to a dma buffer, or two or more blocks if the buffer is 'latched' by\r
-         the driver. As an example, on ASIOStart(), the host will have filled\r
-         the play buffer at index 1 already; when it gets the callback (with\r
-         the parameter index == 0), this tells it to read from the input\r
-         buffer 0, and start to fill the play buffer 0 (assuming that now\r
-         play buffer 1 is already sounding). In this case, the output\r
-         latency is one block. If the driver decides to copy buffer 1\r
-         at that time, and pass it to the hardware at the next slot (which\r
-         is most commonly done, but should be avoided), the output latency\r
-         becomes two blocks instead, resulting in a total i/o latency of at least\r
-         3 blocks. As memory access is the main bottleneck in native dsp processing,\r
-         and to acheive less latency, it is highly recommended to try to avoid\r
-         copying (this is also why the driver is the owner of the buffers). To\r
-         summarize, the minimum i/o latency can be acheived if the input buffer\r
-         is processed by the host into the output buffer which will physically\r
-         start to sound on the next time slice. Also note that the host expects\r
-         the bufferSwitch() callback to be accessed for each time slice in order\r
-         to retain sync, possibly recursively; if it fails to process a block in\r
-         time, it will suspend its operation for some time in order to recover.\r
-       Returns:\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-*/\r
-\r
-ASIOError ASIOGetBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity);\r
-/* Purpose:\r
-         Returns min, max, and preferred buffer sizes for input/output\r
-       Parameter:\r
-         minSize will hold the minimum buffer size\r
-         maxSize will hold the maxium possible buffer size\r
-         preferredSize will hold the preferred buffer size (a size which\r
-         best fits performance and hardware requirements)\r
-         granularity will hold the granularity at which buffer sizes\r
-         may differ. Usually, the buffer size will be a power of 2;\r
-         in this case, granularity will hold -1 on return, signalling\r
-         possible buffer sizes starting from minSize, increased in\r
-         powers of 2 up to maxSize.\r
-       Returns:\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-       Notes:\r
-         When minimum and maximum buffer size are equal,\r
-         the preferred buffer size has to be the same value as well; granularity\r
-         should be 0 in this case.\r
-*/\r
-\r
-ASIOError ASIOCanSampleRate(ASIOSampleRate sampleRate);\r
-/* Purpose:\r
-         Inquires the hardware for the available sample rates.\r
-       Parameter:\r
-         sampleRate is the rate in question.\r
-       Returns:\r
-         If the inquired sample rate is not supported, ASE_NoClock will be returned.\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-*/\r
-ASIOError ASIOGetSampleRate(ASIOSampleRate *currentRate);\r
-/* Purpose:\r
-         Get the current sample Rate.\r
-       Parameter:\r
-         currentRate will hold the current sample rate on return.\r
-       Returns:\r
-         If sample rate is unknown, sampleRate will be 0 and ASE_NoClock will be returned.\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-       Notes:\r
-*/\r
-\r
-ASIOError ASIOSetSampleRate(ASIOSampleRate sampleRate);\r
-/* Purpose:\r
-         Set the hardware to the requested sample Rate. If sampleRate == 0,\r
-         enable external sync.\r
-       Parameter:\r
-         sampleRate: on input, the requested rate\r
-       Returns:\r
-         If sampleRate is unknown ASE_NoClock will be returned.\r
-         If the current clock is external, and sampleRate is != 0,\r
-         ASE_InvalidMode will be returned\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-       Notes:\r
-*/\r
-\r
-typedef struct ASIOClockSource\r
-{\r
-       long index;                                     // as used for ASIOSetClockSource()\r
-       long associatedChannel;         // for instance, S/PDIF or AES/EBU\r
-       long associatedGroup;           // see channel groups (ASIOGetChannelInfo())\r
-       ASIOBool isCurrentSource;       // ASIOTrue if this is the current clock source\r
-       char name[32];                          // for user selection\r
-} ASIOClockSource;\r
-\r
-ASIOError ASIOGetClockSources(ASIOClockSource *clocks, long *numSources);\r
-/* Purpose:\r
-         Get the available external audio clock sources\r
-       Parameter:\r
-         clocks points to an array of ASIOClockSource structures:\r
-               - index: this is used to identify the clock source\r
-                 when ASIOSetClockSource() is accessed, should be\r
-                 an index counting from zero\r
-               - associatedInputChannel: the first channel of an associated\r
-                 input group, if any.\r
-               - associatedGroup: the group index of that channel.\r
-                 groups of channels are defined to seperate for\r
-                 instance analog, S/PDIF, AES/EBU, ADAT connectors etc,\r
-                 when present simultaniously. Note that associated channel\r
-                 is enumerated according to numInputs/numOutputs, means it\r
-                 is independant from a group (see also ASIOGetChannelInfo())\r
-                 inputs are associated to a clock if the physical connection\r
-                 transfers both data and clock (like S/PDIF, AES/EBU, or\r
-                 ADAT inputs). if there is no input channel associated with\r
-                 the clock source (like Word Clock, or internal oscillator), both\r
-                 associatedChannel and associatedGroup should be set to -1.\r
-               - isCurrentSource: on exit, ASIOTrue if this is the current clock\r
-                 source, ASIOFalse else\r
-               - name: a null-terminated string for user selection of the available sources.\r
-         numSources:\r
-             on input: the number of allocated array members\r
-             on output: the number of available clock sources, at least\r
-             1 (internal clock generator).\r
-       Returns:\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-       Notes:\r
-*/\r
-\r
-ASIOError ASIOSetClockSource(long index);\r
-/* Purpose:\r
-         Set the audio clock source\r
-       Parameter:\r
-         index as obtained from an inquiry to ASIOGetClockSources()\r
-       Returns:\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-         If the clock can not be selected because an input channel which\r
-         carries the current clock source is active, ASE_InvalidMode\r
-         *may* be returned (this depends on the properties of the driver\r
-         and/or hardware).\r
-       Notes:\r
-         Should *not* return ASE_NoClock if there is no clock signal present\r
-         at the selected source; this will be inquired via ASIOGetSampleRate().\r
-         It should call the host callback procedure sampleRateHasChanged(),\r
-         if the switch causes a sample rate change, or if no external clock\r
-         is present at the selected source.\r
-*/\r
-\r
-ASIOError ASIOGetSamplePosition (ASIOSamples *sPos, ASIOTimeStamp *tStamp);\r
-/* Purpose:\r
-         Inquires the sample position/time stamp pair.\r
-       Parameter:\r
-         sPos will hold the sample position on return. The sample\r
-         position is reset to zero when ASIOStart() gets called.\r
-         tStamp will hold the system time when the sample position\r
-         was latched.\r
-       Returns:\r
-         If no input/output is present, ASE_NotPresent will be returned.\r
-         If there is no clock, ASE_SPNotAdvancing will be returned.\r
-       Notes:\r
-\r
-         in order to be able to synchronise properly,\r
-         the sample position / time stamp pair must refer to the current block,\r
-         that is, the engine will call ASIOGetSamplePosition() in its bufferSwitch()\r
-         callback and expect the time for the current block. thus, when requested\r
-         in the very first bufferSwitch after ASIO_Start(), the sample position\r
-         should be zero, and the time stamp should refer to the very time where\r
-         the stream was started. it also means that the sample position must be\r
-         block aligned. the driver must ensure proper interpolation if the system\r
-         time can not be determined for the block position. the driver is responsible\r
-         for precise time stamps as it usually has most direct access to lower\r
-         level resources. proper behaviour of ASIO_GetSamplePosition() and ASIO_GetLatencies()\r
-         are essential for precise media synchronization!\r
-*/\r
-\r
-typedef struct ASIOChannelInfo\r
-{\r
-       long channel;                   // on input, channel index\r
-       ASIOBool isInput;               // on input\r
-       ASIOBool isActive;              // on exit\r
-       long channelGroup;              // dto\r
-       ASIOSampleType type;    // dto\r
-       char name[32];                  // dto\r
-} ASIOChannelInfo;\r
-\r
-ASIOError ASIOGetChannelInfo(ASIOChannelInfo *info);\r
-/* Purpose:\r
-         retreive information about the nature of a channel\r
-       Parameter:\r
-         info: pointer to a ASIOChannelInfo structure with\r
-               - channel: on input, the channel index of the channel in question.\r
-               - isInput: on input, ASIOTrue if info for an input channel is\r
-                 requested, else output\r
-               - channelGroup: on return, the channel group that the channel\r
-                 belongs to. For drivers which support different types of\r
-                 channels, like analog, S/PDIF, AES/EBU, ADAT etc interfaces,\r
-                 there should be a reasonable grouping of these types. Groups\r
-                 are always independant form a channel index, that is, a channel\r
-                 index always counts from 0 to numInputs/numOutputs regardless\r
-                 of the group it may belong to.\r
-                 There will always be at least one group (group 0). Please\r
-                 also note that by default, the host may decide to activate\r
-                 channels 0 and 1; thus, these should belong to the most\r
-                 useful type (analog i/o, if present).\r
-               - type: on return, contains the sample type of the channel\r
-               - isActive: on return, ASIOTrue if channel is active as it was\r
-                 installed by ASIOCreateBuffers(), ASIOFalse else\r
-               - name:  describing the type of channel in question. Used to allow\r
-                 for user selection, and enabling of specific channels. examples:\r
-             "Analog In", "SPDIF Out" etc\r
-       Returns:\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-       Notes:\r
-         If possible, the string should be organised such that the first\r
-         characters are most significantly describing the nature of the\r
-         port, to allow for identification even if the view showing the\r
-         port name is too small to display more than 8 characters, for\r
-         instance.\r
-*/\r
-\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-// Buffer preparation\r
-//- - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
-typedef struct ASIOBufferInfo\r
-{\r
-       ASIOBool isInput;                       // on input:  ASIOTrue: input, else output\r
-       long channelNum;                        // on input:  channel index\r
-       void *buffers[2];                       // on output: double buffer addresses\r
-} ASIOBufferInfo;\r
-\r
-ASIOError ASIOCreateBuffers(ASIOBufferInfo *bufferInfos, long numChannels,\r
-       long bufferSize, ASIOCallbacks *callbacks);\r
-\r
-/* Purpose:\r
-         Allocates input/output buffers for all input and output channels to be activated.\r
-       Parameter:\r
-         bufferInfos is a pointer to an array of ASIOBufferInfo structures:\r
-           - isInput: on input, ASIOTrue if the buffer is to be allocated\r
-             for an input, output buffer else\r
-           - channelNum: on input, the index of the channel in question\r
-             (counting from 0)\r
-           - buffers: on exit, 2 pointers to the halves of the channels' double-buffer.\r
-             the size of the buffer(s) of course depend on both the ASIOSampleType\r
-             as obtained from ASIOGetChannelInfo(), and bufferSize\r
-         numChannels is the sum of all input and output channels to be created;\r
-         thus bufferInfos is a pointer to an array of numChannels ASIOBufferInfo\r
-         structures.\r
-         bufferSize selects one of the possible buffer sizes as obtained from\r
-         ASIOGetBufferSizes().\r
-         callbacks is a pointer to an ASIOCallbacks structure.\r
-       Returns:\r
-         If not enough memory is available ASE_NoMemory will be returned.\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-         If bufferSize is not supported, or one or more of the bufferInfos elements\r
-         contain invalid settings, ASE_InvalidMode will be returned.\r
-       Notes:\r
-         If individual channel selection is not possible but requested,\r
-         the driver has to handle this. namely, bufferSwitch() will only\r
-         have filled buffers of enabled outputs. If possible, processing\r
-         and buss activities overhead should be avoided for channels which\r
-         were not enabled here.\r
-*/\r
-\r
-ASIOError ASIODisposeBuffers(void);\r
-/* Purpose:\r
-         Releases all buffers for the device.\r
-       Parameter:\r
-         None.\r
-       Returns:\r
-         If no buffer were ever prepared, ASE_InvalidMode will be returned.\r
-         If no input/output is present ASE_NotPresent will be returned.\r
-       Notes:\r
-         This implies ASIOStop().\r
-*/\r
-\r
-ASIOError ASIOControlPanel(void);\r
-/* Purpose:\r
-         request the driver to start a control panel component\r
-         for device specific user settings. This will not be\r
-         accessed on some platforms (where the component is accessed\r
-         instead).\r
-       Parameter:\r
-         None.\r
-       Returns:\r
-         If no panel is available ASE_NotPresent will be returned.\r
-         Actually, the return code is ignored.\r
-       Notes:\r
-         if the user applied settings which require a re-configuration\r
-         of parts or all of the enigine and/or driver (such as a change of\r
-         the block size), the asioMessage callback can be used (see\r
-         ASIO_Callbacks).\r
-*/\r
-\r
-ASIOError ASIOFuture(long selector, void *params);\r
-/* Purpose:\r
-         various\r
-       Parameter:\r
-         selector: operation Code as to be defined. zero is reserved for\r
-         testing purposes.\r
-         params: depends on the selector; usually pointer to a structure\r
-         for passing and retreiving any type and amount of parameters.\r
-       Returns:\r
-         the return value is also selector dependant. if the selector\r
-         is unknown, ASE_InvalidParameter should be returned to prevent\r
-         further calls with this selector. on success, ASE_SUCCESS\r
-         must be returned (note: ASE_OK is *not* sufficient!)\r
-       Notes:\r
-         see selectors defined below.    \r
-*/\r
-\r
-enum\r
-{\r
-       kAsioEnableTimeCodeRead = 1,    // no arguments\r
-       kAsioDisableTimeCodeRead,               // no arguments\r
-       kAsioSetInputMonitor,                   // ASIOInputMonitor* in params\r
-       kAsioTransport,                                 // ASIOTransportParameters* in params\r
-       kAsioSetInputGain,                              // ASIOChannelControls* in params, apply gain\r
-       kAsioGetInputMeter,                             // ASIOChannelControls* in params, fill meter\r
-       kAsioSetOutputGain,                             // ASIOChannelControls* in params, apply gain\r
-       kAsioGetOutputMeter,                    // ASIOChannelControls* in params, fill meter\r
-       kAsioCanInputMonitor,                   // no arguments for kAsioCanXXX selectors\r
-       kAsioCanTimeInfo,\r
-       kAsioCanTimeCode,\r
-       kAsioCanTransport,\r
-       kAsioCanInputGain,\r
-       kAsioCanInputMeter,\r
-       kAsioCanOutputGain,\r
-       kAsioCanOutputMeter\r
-};\r
-\r
-typedef struct ASIOInputMonitor\r
-{\r
-       long input;             // this input was set to monitor (or off), -1: all\r
-       long output;    // suggested output for monitoring the input (if so)\r
-       long gain;              // suggested gain, ranging 0 - 0x7fffffffL (-inf to +12 dB)\r
-       ASIOBool state; // ASIOTrue => on, ASIOFalse => off\r
-       long pan;               // suggested pan, 0 => all left, 0x7fffffff => right\r
-} ASIOInputMonitor;\r
-\r
-typedef struct ASIOChannelControls\r
-{\r
-       long channel;                   // on input, channel index\r
-       ASIOBool isInput;               // on input\r
-       long gain;                              // on input,  ranges 0 thru 0x7fffffff\r
-       long meter;                             // on return, ranges 0 thru 0x7fffffff\r
-       char future[32];\r
-} ASIOChannelControls;\r
-\r
-typedef struct ASIOTransportParameters\r
-{\r
-       long command;           // see enum below\r
-       ASIOSamples samplePosition;\r
-       long track;\r
-       long trackSwitches[16];         // 512 tracks on/off\r
-       char future[64];\r
-} ASIOTransportParameters;\r
-\r
-enum\r
-{\r
-       kTransStart = 1,\r
-       kTransStop,\r
-       kTransLocate,           // to samplePosition\r
-       kTransPunchIn,\r
-       kTransPunchOut,\r
-       kTransArmOn,            // track\r
-       kTransArmOff,           // track\r
-       kTransMonitorOn,        // track\r
-       kTransMonitorOff,       // track\r
-       kTransArm,                      // trackSwitches\r
-       kTransMonitor           // trackSwitches\r
-};\r
-\r
-ASIOError ASIOOutputReady(void);\r
-/* Purpose:\r
-         this tells the driver that the host has completed processing\r
-         the output buffers. if the data format required by the hardware\r
-         differs from the supported asio formats, but the hardware\r
-         buffers are DMA buffers, the driver will have to convert\r
-         the audio stream data; as the bufferSwitch callback is\r
-         usually issued at dma block switch time, the driver will\r
-         have to convert the *previous* host buffer, which increases\r
-         the output latency by one block.\r
-         when the host finds out that ASIOOutputReady() returns\r
-         true, it will issue this call whenever it completed\r
-         output processing. then the driver can convert the\r
-         host data directly to the dma buffer to be played next,\r
-         reducing output latency by one block.\r
-         another way to look at it is, that the buffer switch is called\r
-         in order to pass the *input* stream to the host, so that it can\r
-         process the input into the output, and the output stream is passed\r
-         to the driver when the host has completed its process.\r
-       Parameter:\r
-               None\r
-       Returns:\r
-         only if the above mentioned scenario is given, and a reduction\r
-         of output latency can be acheived by this mechanism, should\r
-         ASE_OK be returned. otherwise (and usually), ASE_NotPresent\r
-         should be returned in order to prevent further calls to this\r
-         function. note that the host may want to determine if it is\r
-         to use this when the system is not yet fully initialized, so\r
-         ASE_OK should always be returned if the mechanism makes sense.          \r
-       Notes:\r
-         please remeber to adjust ASIOGetLatencies() according to\r
-         whether ASIOOutputReady() was ever called or not, if your\r
-         driver supports this scenario.\r
-         also note that the engine may fail to call ASIO_OutputReady()\r
-         in time in overload cases. as already mentioned, bufferSwitch\r
-      should be called for every block regardless of whether a block\r
-      could be processed in time.\r
-*/\r
-\r
-// restore old alignment\r
-#if defined(_MSC_VER) && !defined(__MWERKS__) \r
-#pragma pack(pop)\r
-#elif PRAGMA_ALIGN_SUPPORTED\r
-#pragma options align = reset\r
-#endif\r
-\r
-#endif\r
-\r
diff --git a/tests/Windows/asiodrivers.cpp b/tests/Windows/asiodrivers.cpp
deleted file mode 100644 (file)
index 5f56454..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-#include <string.h>\r
-#include "asiodrivers.h"\r
-\r
-AsioDrivers* asioDrivers = 0;\r
-\r
-bool loadAsioDriver(char *name);\r
-\r
-bool loadAsioDriver(char *name)\r
-{\r
-       if(!asioDrivers)\r
-               asioDrivers = new AsioDrivers();\r
-       if(asioDrivers)\r
-               return asioDrivers->loadDriver(name);\r
-       return false;\r
-}\r
-\r
-//------------------------------------------------------------------------------------\r
-\r
-#if MAC\r
-\r
-bool resolveASIO(unsigned long aconnID);\r
-\r
-AsioDrivers::AsioDrivers() : CodeFragments("ASIO Drivers", 'AsDr', 'Asio')\r
-{\r
-       connID = -1;\r
-       curIndex = -1;\r
-}\r
-\r
-AsioDrivers::~AsioDrivers()\r
-{\r
-       removeCurrentDriver();\r
-}\r
-\r
-bool AsioDrivers::getCurrentDriverName(char *name)\r
-{\r
-       if(curIndex >= 0)\r
-               return getName(curIndex, name);\r
-       return false;\r
-}\r
-\r
-long AsioDrivers::getDriverNames(char **names, long maxDrivers)\r
-{\r
-       for(long i = 0; i < getNumFragments() && i < maxDrivers; i++)\r
-               getName(i, names[i]);\r
-       return getNumFragments() < maxDrivers ? getNumFragments() : maxDrivers;\r
-}\r
-\r
-bool AsioDrivers::loadDriver(char *name)\r
-{\r
-       char dname[64];\r
-       unsigned long newID;\r
-\r
-       for(long i = 0; i < getNumFragments(); i++)\r
-       {\r
-               if(getName(i, dname) && !strcmp(name, dname))\r
-               {\r
-                       if(newInstance(i, &newID))\r
-                       {\r
-                               if(resolveASIO(newID))\r
-                               {\r
-                                       if(connID != -1)\r
-                                               removeInstance(curIndex, connID);\r
-                                       curIndex = i;\r
-                                       connID = newID;\r
-                                       return true;\r
-                               }\r
-                       }\r
-                       break;\r
-               }\r
-       }\r
-       return false;\r
-}\r
-\r
-void AsioDrivers::removeCurrentDriver()\r
-{\r
-       if(connID != -1)\r
-               removeInstance(curIndex, connID);\r
-       connID = -1;\r
-       curIndex = -1;\r
-}\r
-\r
-//------------------------------------------------------------------------------------\r
-\r
-#elif WINDOWS\r
-\r
-#include "iasiodrv.h"\r
-\r
-extern IASIO* theAsioDriver;\r
-\r
-AsioDrivers::AsioDrivers() : AsioDriverList()\r
-{\r
-       curIndex = -1;\r
-}\r
-\r
-AsioDrivers::~AsioDrivers()\r
-{\r
-}\r
-\r
-bool AsioDrivers::getCurrentDriverName(char *name)\r
-{\r
-       if(curIndex >= 0)\r
-               return asioGetDriverName(curIndex, name, 32) == 0 ? true : false;\r
-       name[0] = 0;\r
-       return false;\r
-}\r
-\r
-long AsioDrivers::getDriverNames(char **names, long maxDrivers)\r
-{\r
-       for(long i = 0; i < asioGetNumDev() && i < maxDrivers; i++)\r
-               asioGetDriverName(i, names[i], 32);\r
-       return asioGetNumDev() < maxDrivers ? asioGetNumDev() : maxDrivers;\r
-}\r
-\r
-bool AsioDrivers::loadDriver(char *name)\r
-{\r
-       char dname[64];\r
-       char curName[64];\r
-\r
-       for(long i = 0; i < asioGetNumDev(); i++)\r
-       {\r
-               if(!asioGetDriverName(i, dname, 32) && !strcmp(name, dname))\r
-               {\r
-                       curName[0] = 0;\r
-                       getCurrentDriverName(curName);  // in case we fail...\r
-                       removeCurrentDriver();\r
-\r
-                       if(!asioOpenDriver(i, (void **)&theAsioDriver))\r
-                       {\r
-                               curIndex = i;\r
-                               return true;\r
-                       }\r
-                       else\r
-                       {\r
-                               theAsioDriver = 0;\r
-                               if(curName[0] && strcmp(dname, curName))\r
-                                       loadDriver(curName);    // try restore\r
-                       }\r
-                       break;\r
-               }\r
-       }\r
-       return false;\r
-}\r
-\r
-void AsioDrivers::removeCurrentDriver()\r
-{\r
-       if(curIndex != -1)\r
-               asioCloseDriver(curIndex);\r
-       curIndex = -1;\r
-}\r
-\r
-#elif SGI || BEOS\r
-\r
-#include "asiolist.h"\r
-\r
-AsioDrivers::AsioDrivers() \r
-       : AsioDriverList()\r
-{\r
-       curIndex = -1;\r
-}\r
-\r
-AsioDrivers::~AsioDrivers()\r
-{\r
-}\r
-\r
-bool AsioDrivers::getCurrentDriverName(char *name)\r
-{\r
-       return false;\r
-}\r
-\r
-long AsioDrivers::getDriverNames(char **names, long maxDrivers)\r
-{\r
-       return 0;\r
-}\r
-\r
-bool AsioDrivers::loadDriver(char *name)\r
-{\r
-       return false;\r
-}\r
-\r
-void AsioDrivers::removeCurrentDriver()\r
-{\r
-}\r
-\r
-#else\r
-#error implement me\r
-#endif\r
diff --git a/tests/Windows/asiodrivers.h b/tests/Windows/asiodrivers.h
deleted file mode 100644 (file)
index 2ddf7ad..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef __AsioDrivers__\r
-#define __AsioDrivers__\r
-\r
-#include "ginclude.h"\r
-\r
-#if MAC\r
-#include "CodeFragments.hpp"\r
-\r
-class AsioDrivers : public CodeFragments\r
-\r
-#elif WINDOWS\r
-#include <windows.h>\r
-#include "asiolist.h"\r
-\r
-class AsioDrivers : public AsioDriverList\r
-\r
-#elif SGI || BEOS\r
-#include "asiolist.h"\r
-\r
-class AsioDrivers : public AsioDriverList\r
-\r
-#else\r
-#error implement me\r
-#endif\r
-\r
-{\r
-public:\r
-       AsioDrivers();\r
-       ~AsioDrivers();\r
-       \r
-       bool getCurrentDriverName(char *name);\r
-       long getDriverNames(char **names, long maxDrivers);\r
-       bool loadDriver(char *name);\r
-       void removeCurrentDriver();\r
-       long getCurrentDriverIndex() {return curIndex;}\r
-protected:\r
-       unsigned long connID;\r
-       long curIndex;\r
-};\r
-\r
-#endif\r
diff --git a/tests/Windows/asiodrvr.h b/tests/Windows/asiodrvr.h
deleted file mode 100644 (file)
index 663f75a..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*\r
-       Steinberg Audio Stream I/O API\r
-       (c) 1996, Steinberg Soft- und Hardware GmbH\r
-       charlie (May 1996)\r
-\r
-       asiodrvr.h\r
-       c++ superclass to implement asio functionality. from this,\r
-       you can derive whatever required\r
-*/\r
-\r
-#ifndef _asiodrvr_\r
-#define _asiodrvr_\r
-\r
-// cpu and os system we are running on\r
-#include "asiosys.h"\r
-// basic "C" interface\r
-#include "asio.h"\r
-\r
-class AsioDriver;\r
-extern AsioDriver *getDriver();                // for generic constructor \r
-\r
-#if WINDOWS\r
-#include <windows.h>\r
-#include "combase.h"\r
-#include "iasiodrv.h"\r
-class AsioDriver : public IASIO ,public CUnknown\r
-{\r
-public:\r
-       AsioDriver(LPUNKNOWN pUnk, HRESULT *phr);\r
-\r
-       DECLARE_IUNKNOWN\r
-       // Factory method\r
-       static CUnknown *CreateInstance(LPUNKNOWN pUnk, HRESULT *phr);\r
-       // IUnknown\r
-       virtual HRESULT STDMETHODCALLTYPE NonDelegatingQueryInterface(REFIID riid,void **ppvObject);\r
-\r
-#else\r
-\r
-class AsioDriver\r
-{\r
-public:\r
-       AsioDriver();\r
-#endif\r
-       virtual ~AsioDriver();\r
-\r
-       virtual ASIOBool init(void* sysRef);\r
-       virtual void getDriverName(char *name); // max 32 bytes incl. terminating zero\r
-       virtual long getDriverVersion();\r
-       virtual void getErrorMessage(char *string);     // max 124 bytes incl.\r
-\r
-       virtual ASIOError start();\r
-       virtual ASIOError stop();\r
-\r
-       virtual ASIOError getChannels(long *numInputChannels, long *numOutputChannels);\r
-       virtual ASIOError getLatencies(long *inputLatency, long *outputLatency);\r
-       virtual ASIOError getBufferSize(long *minSize, long *maxSize,\r
-               long *preferredSize, long *granularity);\r
-\r
-       virtual ASIOError canSampleRate(ASIOSampleRate sampleRate);\r
-       virtual ASIOError getSampleRate(ASIOSampleRate *sampleRate);\r
-       virtual ASIOError setSampleRate(ASIOSampleRate sampleRate);\r
-       virtual ASIOError getClockSources(ASIOClockSource *clocks, long *numSources);\r
-       virtual ASIOError setClockSource(long reference);\r
-\r
-       virtual ASIOError getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp);\r
-       virtual ASIOError getChannelInfo(ASIOChannelInfo *info);\r
-\r
-       virtual ASIOError createBuffers(ASIOBufferInfo *bufferInfos, long numChannels,\r
-               long bufferSize, ASIOCallbacks *callbacks);\r
-       virtual ASIOError disposeBuffers();\r
-\r
-       virtual ASIOError controlPanel();\r
-       virtual ASIOError future(long selector, void *opt);\r
-       virtual ASIOError outputReady();\r
-};\r
-#endif\r
diff --git a/tests/Windows/asiolist.cpp b/tests/Windows/asiolist.cpp
deleted file mode 100644 (file)
index 5a62f5b..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-#include <windows.h>\r
-#include "iasiodrv.h"\r
-#include "asiolist.h"\r
-\r
-#define ASIODRV_DESC           "description"\r
-#define INPROC_SERVER          "InprocServer32"\r
-#define ASIO_PATH                      "software\\asio"\r
-#define COM_CLSID                      "clsid"\r
-\r
-// ******************************************************************\r
-// Local Functions \r
-// ******************************************************************\r
-static LONG findDrvPath (char *clsidstr,char *dllpath,int dllpathsize)\r
-{\r
-       HKEY                    hkEnum,hksub,hkpath;\r
-       char                    databuf[512];\r
-       LONG                    cr,rc = -1;\r
-       DWORD                   datatype,datasize;\r
-       DWORD                   index;\r
-       OFSTRUCT                ofs;\r
-       HFILE                   hfile;\r
-       BOOL                    found = FALSE;\r
-\r
-       CharLowerBuff(clsidstr,strlen(clsidstr));\r
-       if ((cr = RegOpenKey(HKEY_CLASSES_ROOT,COM_CLSID,&hkEnum)) == ERROR_SUCCESS) {\r
-\r
-               index = 0;\r
-               while (cr == ERROR_SUCCESS && !found) {\r
-                       cr = RegEnumKey(hkEnum,index++,(LPTSTR)databuf,512);\r
-                       if (cr == ERROR_SUCCESS) {\r
-                               CharLowerBuff(databuf,strlen(databuf));\r
-                               if (!(strcmp(databuf,clsidstr))) {\r
-                                       if ((cr = RegOpenKeyEx(hkEnum,(LPCTSTR)databuf,0,KEY_READ,&hksub)) == ERROR_SUCCESS) {\r
-                                               if ((cr = RegOpenKeyEx(hksub,(LPCTSTR)INPROC_SERVER,0,KEY_READ,&hkpath)) == ERROR_SUCCESS) {\r
-                                                       datatype = REG_SZ; datasize = (DWORD)dllpathsize;\r
-                                                       cr = RegQueryValueEx(hkpath,0,0,&datatype,(LPBYTE)dllpath,&datasize);\r
-                                                       if (cr == ERROR_SUCCESS) {\r
-                                                               memset(&ofs,0,sizeof(OFSTRUCT));\r
-                                                               ofs.cBytes = sizeof(OFSTRUCT); \r
-                                                               hfile = OpenFile(dllpath,&ofs,OF_EXIST);\r
-                                                               if (hfile) rc = 0; \r
-                                                       }\r
-                                                       RegCloseKey(hkpath);\r
-                                               }\r
-                                               RegCloseKey(hksub);\r
-                                       }\r
-                                       found = TRUE;   // break out \r
-                               }\r
-                       }\r
-               }                               \r
-               RegCloseKey(hkEnum);\r
-       }\r
-       return rc;\r
-}\r
-\r
-\r
-static LPASIODRVSTRUCT newDrvStruct (HKEY hkey,char *keyname,int drvID,LPASIODRVSTRUCT lpdrv)\r
-{\r
-       HKEY    hksub;\r
-       char    databuf[256];\r
-       char    dllpath[MAXPATHLEN];\r
-       WORD    wData[100];\r
-       CLSID   clsid;\r
-       DWORD   datatype,datasize;\r
-       LONG    cr,rc;\r
-\r
-       if (!lpdrv) {\r
-               if ((cr = RegOpenKeyEx(hkey,(LPCTSTR)keyname,0,KEY_READ,&hksub)) == ERROR_SUCCESS) {\r
-\r
-                       datatype = REG_SZ; datasize = 256;\r
-                       cr = RegQueryValueEx(hksub,COM_CLSID,0,&datatype,(LPBYTE)databuf,&datasize);\r
-                       if (cr == ERROR_SUCCESS) {\r
-                               rc = findDrvPath (databuf,dllpath,MAXPATHLEN);\r
-                               if (rc == 0) {\r
-                                       lpdrv = new ASIODRVSTRUCT[1];\r
-                                       if (lpdrv) {\r
-                                               memset(lpdrv,0,sizeof(ASIODRVSTRUCT));\r
-                                               lpdrv->drvID = drvID;\r
-                                               MultiByteToWideChar(CP_ACP,0,(LPCSTR)databuf,-1,(LPWSTR)wData,100);\r
-                                               if ((cr = CLSIDFromString((LPOLESTR)wData,(LPCLSID)&clsid)) == S_OK) {\r
-                                                       memcpy(&lpdrv->clsid,&clsid,sizeof(CLSID));\r
-                                               }\r
-\r
-                                               datatype = REG_SZ; datasize = 256;\r
-                                               cr = RegQueryValueEx(hksub,ASIODRV_DESC,0,&datatype,(LPBYTE)databuf,&datasize);\r
-                                               if (cr == ERROR_SUCCESS) {\r
-                                                       strcpy(lpdrv->drvname,databuf);\r
-                                               }\r
-                                               else strcpy(lpdrv->drvname,keyname);\r
-                                       }\r
-                               }\r
-                       }\r
-                       RegCloseKey(hksub);\r
-               }\r
-       }       \r
-       else lpdrv->next = newDrvStruct(hkey,keyname,drvID+1,lpdrv->next);\r
-\r
-       return lpdrv;\r
-}\r
-\r
-static void deleteDrvStruct (LPASIODRVSTRUCT lpdrv)\r
-{\r
-       IASIO   *iasio;\r
-\r
-       if (lpdrv != 0) {\r
-               deleteDrvStruct(lpdrv->next);\r
-               if (lpdrv->asiodrv) {\r
-                       iasio = (IASIO *)lpdrv->asiodrv;\r
-                       iasio->Release();\r
-               }\r
-               delete lpdrv;\r
-       }\r
-}\r
-\r
-\r
-static LPASIODRVSTRUCT getDrvStruct (int drvID,LPASIODRVSTRUCT lpdrv)\r
-{\r
-       while (lpdrv) {\r
-               if (lpdrv->drvID == drvID) return lpdrv;\r
-               lpdrv = lpdrv->next;\r
-       }\r
-       return 0;\r
-}\r
-// ******************************************************************\r
-\r
-\r
-// ******************************************************************\r
-//     AsioDriverList\r
-// ******************************************************************\r
-AsioDriverList::AsioDriverList ()\r
-{\r
-       HKEY                    hkEnum = 0;\r
-       char                    keyname[MAXDRVNAMELEN];\r
-       LPASIODRVSTRUCT pdl;\r
-       LONG                    cr;\r
-       DWORD                   index = 0;\r
-       BOOL                    fin = FALSE;\r
-\r
-       numdrv          = 0;\r
-       lpdrvlist       = 0;\r
-\r
-       cr = RegOpenKey(HKEY_LOCAL_MACHINE,ASIO_PATH,&hkEnum);\r
-       while (cr == ERROR_SUCCESS) {\r
-               if ((cr = RegEnumKey(hkEnum,index++,(LPTSTR)keyname,MAXDRVNAMELEN))== ERROR_SUCCESS) {\r
-                       lpdrvlist = newDrvStruct (hkEnum,keyname,0,lpdrvlist);\r
-               }\r
-               else fin = TRUE;\r
-       }\r
-       if (hkEnum) RegCloseKey(hkEnum);\r
-\r
-       pdl = lpdrvlist;\r
-       while (pdl) {\r
-               numdrv++;\r
-               pdl = pdl->next;\r
-       }\r
-\r
-       if (numdrv) CoInitialize(0);    // initialize COM\r
-}\r
-\r
-AsioDriverList::~AsioDriverList ()\r
-{\r
-       if (numdrv) {\r
-               deleteDrvStruct(lpdrvlist);\r
-               CoUninitialize();\r
-       }\r
-}\r
-\r
-\r
-LONG AsioDriverList::asioGetNumDev (VOID)\r
-{\r
-       return (LONG)numdrv;\r
-}\r
-\r
-\r
-LONG AsioDriverList::asioOpenDriver (int drvID,LPVOID *asiodrv)\r
-{\r
-       LPASIODRVSTRUCT lpdrv = 0;\r
-       long                    rc;\r
-\r
-       if (!asiodrv) return DRVERR_INVALID_PARAM;\r
-\r
-       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
-               if (!lpdrv->asiodrv) {\r
-                       rc = CoCreateInstance(lpdrv->clsid,0,CLSCTX_INPROC_SERVER,lpdrv->clsid,asiodrv);\r
-                       if (rc == S_OK) {\r
-                               lpdrv->asiodrv = *asiodrv;\r
-                               return 0;\r
-                       }\r
-                       // else if (rc == REGDB_E_CLASSNOTREG)\r
-                       //      strcpy (info->messageText, "Driver not registered in the Registration Database!");\r
-               }\r
-               else rc = DRVERR_DEVICE_ALREADY_OPEN;\r
-       }\r
-       else rc = DRVERR_DEVICE_NOT_FOUND;\r
-       \r
-       return rc;\r
-}\r
-\r
-\r
-LONG AsioDriverList::asioCloseDriver (int drvID)\r
-{\r
-       LPASIODRVSTRUCT lpdrv = 0;\r
-       IASIO                   *iasio;\r
-\r
-       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
-               if (lpdrv->asiodrv) {\r
-                       iasio = (IASIO *)lpdrv->asiodrv;\r
-                       iasio->Release();\r
-                       lpdrv->asiodrv = 0;\r
-               }\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-LONG AsioDriverList::asioGetDriverName (int drvID,char *drvname,int drvnamesize)\r
-{      \r
-       LPASIODRVSTRUCT                 lpdrv = 0;\r
-\r
-       if (!drvname) return DRVERR_INVALID_PARAM;\r
-\r
-       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
-               if (strlen(lpdrv->drvname) < (unsigned int)drvnamesize) {\r
-                       strcpy(drvname,lpdrv->drvname);\r
-               }\r
-               else {\r
-                       memcpy(drvname,lpdrv->drvname,drvnamesize-4);\r
-                       drvname[drvnamesize-4] = '.';\r
-                       drvname[drvnamesize-3] = '.';\r
-                       drvname[drvnamesize-2] = '.';\r
-                       drvname[drvnamesize-1] = 0;\r
-               }\r
-               return 0;\r
-       }\r
-       return DRVERR_DEVICE_NOT_FOUND;\r
-}\r
-\r
-LONG AsioDriverList::asioGetDriverPath (int drvID,char *dllpath,int dllpathsize)\r
-{\r
-       LPASIODRVSTRUCT                 lpdrv = 0;\r
-\r
-       if (!dllpath) return DRVERR_INVALID_PARAM;\r
-\r
-       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
-               if (strlen(lpdrv->dllpath) < (unsigned int)dllpathsize) {\r
-                       strcpy(dllpath,lpdrv->dllpath);\r
-                       return 0;\r
-               }\r
-               dllpath[0] = 0;\r
-               return DRVERR_INVALID_PARAM;\r
-       }\r
-       return DRVERR_DEVICE_NOT_FOUND;\r
-}\r
-\r
-LONG AsioDriverList::asioGetDriverCLSID (int drvID,CLSID *clsid)\r
-{\r
-       LPASIODRVSTRUCT                 lpdrv = 0;\r
-\r
-       if (!clsid) return DRVERR_INVALID_PARAM;\r
-\r
-       if ((lpdrv = getDrvStruct(drvID,lpdrvlist)) != 0) {\r
-               memcpy(clsid,&lpdrv->clsid,sizeof(CLSID));\r
-               return 0;\r
-       }\r
-       return DRVERR_DEVICE_NOT_FOUND;\r
-}\r
-\r
-\r
diff --git a/tests/Windows/asiolist.h b/tests/Windows/asiolist.h
deleted file mode 100644 (file)
index 01c64f0..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef __asiolist__\r
-#define __asiolist__\r
-\r
-#define DRVERR                 -5000\r
-#define DRVERR_INVALID_PARAM           DRVERR-1\r
-#define DRVERR_DEVICE_ALREADY_OPEN     DRVERR-2\r
-#define DRVERR_DEVICE_NOT_FOUND                DRVERR-3\r
-\r
-#define MAXPATHLEN                     512\r
-#define MAXDRVNAMELEN          128\r
-\r
-struct asiodrvstruct\r
-{\r
-       int                                             drvID;\r
-       CLSID                                   clsid;\r
-       char                                    dllpath[MAXPATHLEN];\r
-       char                                    drvname[MAXDRVNAMELEN];\r
-       LPVOID                                  asiodrv;\r
-       struct asiodrvstruct    *next;\r
-};\r
-\r
-typedef struct asiodrvstruct ASIODRVSTRUCT;\r
-typedef ASIODRVSTRUCT  *LPASIODRVSTRUCT;\r
-\r
-class AsioDriverList {\r
-public:\r
-       AsioDriverList();\r
-       ~AsioDriverList();\r
-       \r
-       LONG asioOpenDriver (int,VOID **);\r
-       LONG asioCloseDriver (int);\r
-\r
-       // nice to have\r
-       LONG asioGetNumDev (VOID);\r
-       LONG asioGetDriverName (int,char *,int);                \r
-       LONG asioGetDriverPath (int,char *,int);\r
-       LONG asioGetDriverCLSID (int,CLSID *);\r
-\r
-       // or use directly access\r
-       LPASIODRVSTRUCT lpdrvlist;\r
-       int                             numdrv;\r
-};\r
-\r
-typedef class AsioDriverList *LPASIODRIVERLIST;\r
-\r
-#endif\r
diff --git a/tests/Windows/asiosys.h b/tests/Windows/asiosys.h
deleted file mode 100644 (file)
index 37f7a48..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef __asiosys__\r
-       #define __asiosys__\r
-\r
-       #ifdef WIN32\r
-               #undef MAC \r
-               #define PPC 0\r
-               #define WINDOWS 1\r
-               #define SGI 0\r
-               #define SUN 0\r
-               #define LINUX 0\r
-               #define BEOS 0\r
-\r
-               #define NATIVE_INT64 0\r
-               #define IEEE754_64FLOAT 1\r
-       \r
-       #elif BEOS\r
-               #define MAC 0\r
-               #define PPC 0\r
-               #define WINDOWS 0\r
-               #define PC 0\r
-               #define SGI 0\r
-               #define SUN 0\r
-               #define LINUX 0\r
-               \r
-               #define NATIVE_INT64 0\r
-               #define IEEE754_64FLOAT 1\r
-               \r
-               #ifndef DEBUG\r
-                       #define DEBUG 0\r
-                       #if DEBUG\r
-                               void DEBUGGERMESSAGE(char *string);\r
-                       #else\r
-                               #define DEBUGGERMESSAGE(a)\r
-                       #endif\r
-               #endif\r
-\r
-       #elif SGI\r
-               #define MAC 0\r
-               #define PPC 0\r
-               #define WINDOWS 0\r
-               #define PC 0\r
-               #define SUN 0\r
-               #define LINUX 0\r
-               #define BEOS 0\r
-               \r
-               #define NATIVE_INT64 0\r
-               #define IEEE754_64FLOAT 1\r
-               \r
-               #ifndef DEBUG\r
-                       #define DEBUG 0\r
-                       #if DEBUG\r
-                               void DEBUGGERMESSAGE(char *string);\r
-                       #else\r
-                               #define DEBUGGERMESSAGE(a)\r
-                       #endif\r
-               #endif\r
-\r
-       #else   // MAC\r
-\r
-               #define MAC 1\r
-               #define PPC 1\r
-               #define WINDOWS 0\r
-               #define PC 0\r
-               #define SGI 0\r
-               #define SUN 0\r
-               #define LINUX 0\r
-               #define BEOS 0\r
-\r
-               #define NATIVE_INT64 0\r
-               #define IEEE754_64FLOAT 1\r
-\r
-               #ifndef DEBUG\r
-                       #define DEBUG 0\r
-                       #if DEBUG\r
-                               void DEBUGGERMESSAGE(char *string);\r
-                       #else\r
-                               #define DEBUGGERMESSAGE(a)\r
-                       #endif\r
-               #endif\r
-       #endif\r
-\r
-#endif\r
index 6af5e2e493a3921ede35280225971c97bf30d73d..490dacc234ff335f94ea4b8fba5423a7a79e5ccf 100644 (file)
@@ -87,15 +87,15 @@ LINK32=link.exe
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.cpp\r
+SOURCE=..\..\asio\asio.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.cpp\r
+SOURCE=..\..\asio\asiodrivers.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.cpp\r
+SOURCE=..\..\asio\asiolist.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -103,6 +103,10 @@ SOURCE=..\call_inout.cpp
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\asio\iasiothiscallresolver.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\RtAudio.cpp\r
 # End Source File\r
 # End Group\r
@@ -111,31 +115,35 @@ SOURCE=..\..\RtAudio.cpp
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.h\r
+SOURCE=..\..\asio\asio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\asiodrivers.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.h\r
+SOURCE=..\..\asio\asiodrvr.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrvr.h\r
+SOURCE=..\..\asio\asiolist.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.h\r
+SOURCE=..\..\asio\asiosys.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiosys.h\r
+SOURCE=..\..\asio\ginclude.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\ginclude.h\r
+SOURCE=..\..\asio\iasiodrv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\iasiodrv.h\r
+SOURCE=..\..\asio\iasiothiscallresolver.h\r
 # End Source File\r
 # Begin Source File\r
 \r
index 8db91ca0a8b1afa7db4df4de600f3ac1e4f8a7ea..0c1fcd969b1d76aa3317570b1490f30df00a299b 100644 (file)
@@ -87,15 +87,15 @@ LINK32=link.exe
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.cpp\r
+SOURCE=..\..\asio\asio.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.cpp\r
+SOURCE=..\..\asio\asiodrivers.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.cpp\r
+SOURCE=..\..\asio\asiolist.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -103,6 +103,10 @@ SOURCE=..\call_saw.cpp
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\asio\iasiothiscallresolver.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\RtAudio.cpp\r
 # End Source File\r
 # End Group\r
@@ -111,31 +115,35 @@ SOURCE=..\..\RtAudio.cpp
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.h\r
+SOURCE=..\..\asio\asio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\asiodrivers.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.h\r
+SOURCE=..\..\asio\asiodrvr.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrvr.h\r
+SOURCE=..\..\asio\asiolist.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.h\r
+SOURCE=..\..\asio\asiosys.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiosys.h\r
+SOURCE=..\..\asio\ginclude.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\ginclude.h\r
+SOURCE=..\..\asio\iasiodrv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\iasiodrv.h\r
+SOURCE=..\..\asio\iasiothiscallresolver.h\r
 # End Source File\r
 # Begin Source File\r
 \r
diff --git a/tests/Windows/ginclude.h b/tests/Windows/ginclude.h
deleted file mode 100644 (file)
index b627dc2..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __gInclude__\r
-#define __gInclude__\r
-\r
-#if SGI \r
-       #undef BEOS \r
-       #undef MAC \r
-       #undef WINDOWS\r
-       //\r
-       #define ASIO_BIG_ENDIAN 1\r
-       #define ASIO_CPU_MIPS 1\r
-#elif defined WIN32\r
-       #undef BEOS \r
-       #undef MAC \r
-       #undef SGI\r
-       #define WINDOWS 1\r
-       #define ASIO_LITTLE_ENDIAN 1\r
-       #define ASIO_CPU_X86 1\r
-#elif BEOS\r
-       #undef MAC \r
-       #undef SGI\r
-       #undef WINDOWS\r
-       #define ASIO_LITTLE_ENDIAN 1\r
-       #define ASIO_CPU_X86 1\r
-       //\r
-#else\r
-       #define MAC 1\r
-       #undef BEOS \r
-       #undef WINDOWS\r
-       #undef SGI\r
-       #define ASIO_BIG_ENDIAN 1\r
-       #define ASIO_CPU_PPC 1\r
-#endif\r
-\r
-// always\r
-#define NATIVE_INT64 0\r
-#define IEEE754_64FLOAT 1\r
-\r
-#endif // __gInclude__\r
diff --git a/tests/Windows/iasiodrv.h b/tests/Windows/iasiodrv.h
deleted file mode 100644 (file)
index 64d2dbb..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "asiosys.h"\r
-#include "asio.h"\r
-\r
-/* Forward Declarations */ \r
-\r
-#ifndef __ASIODRIVER_FWD_DEFINED__\r
-#define __ASIODRIVER_FWD_DEFINED__\r
-typedef interface IASIO IASIO;\r
-#endif         /* __ASIODRIVER_FWD_DEFINED__ */\r
-\r
-interface IASIO : public IUnknown\r
-{\r
-\r
-       virtual ASIOBool init(void *sysHandle) = 0;\r
-       virtual void getDriverName(char *name) = 0;     \r
-       virtual long getDriverVersion() = 0;\r
-       virtual void getErrorMessage(char *string) = 0; \r
-       virtual ASIOError start() = 0;\r
-       virtual ASIOError stop() = 0;\r
-       virtual ASIOError getChannels(long *numInputChannels, long *numOutputChannels) = 0;\r
-       virtual ASIOError getLatencies(long *inputLatency, long *outputLatency) = 0;\r
-       virtual ASIOError getBufferSize(long *minSize, long *maxSize,\r
-               long *preferredSize, long *granularity) = 0;\r
-       virtual ASIOError canSampleRate(ASIOSampleRate sampleRate) = 0;\r
-       virtual ASIOError getSampleRate(ASIOSampleRate *sampleRate) = 0;\r
-       virtual ASIOError setSampleRate(ASIOSampleRate sampleRate) = 0;\r
-       virtual ASIOError getClockSources(ASIOClockSource *clocks, long *numSources) = 0;\r
-       virtual ASIOError setClockSource(long reference) = 0;\r
-       virtual ASIOError getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp) = 0;\r
-       virtual ASIOError getChannelInfo(ASIOChannelInfo *info) = 0;\r
-       virtual ASIOError createBuffers(ASIOBufferInfo *bufferInfos, long numChannels,\r
-               long bufferSize, ASIOCallbacks *callbacks) = 0;\r
-       virtual ASIOError disposeBuffers() = 0;\r
-       virtual ASIOError controlPanel() = 0;\r
-       virtual ASIOError future(long selector,void *opt) = 0;\r
-       virtual ASIOError outputReady() = 0;\r
-};\r
index 4113ca1ee780b528506d7149dd53e8db257f523c..f9cfd7d4339fdea70cd76e9c7f87d4a904a8a9e8 100644 (file)
@@ -87,15 +87,19 @@ LINK32=link.exe
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.cpp\r
+SOURCE=..\..\asio\asio.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.cpp\r
+SOURCE=..\..\asio\asiodrivers.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.cpp\r
+SOURCE=..\..\asio\asiolist.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\iasiothiscallresolver.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -111,31 +115,35 @@ SOURCE=..\..\RtAudio.cpp
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.h\r
+SOURCE=..\..\asio\asio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\asiodrivers.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.h\r
+SOURCE=..\..\asio\asiodrvr.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrvr.h\r
+SOURCE=..\..\asio\asiolist.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.h\r
+SOURCE=..\..\asio\asiosys.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiosys.h\r
+SOURCE=..\..\asio\ginclude.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\ginclude.h\r
+SOURCE=..\..\asio\iasiodrv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\iasiodrv.h\r
+SOURCE=..\..\asio\iasiothiscallresolver.h\r
 # End Source File\r
 # Begin Source File\r
 \r
index 02facd8c5bd39b16fdcbd9db4153297d5f3532ac..d69a64e0432eb8fadbfb8f517d8dbfd69440d3df 100644 (file)
@@ -87,15 +87,19 @@ LINK32=link.exe
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.cpp\r
+SOURCE=..\..\asio\asio.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.cpp\r
+SOURCE=..\..\asio\asiodrivers.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.cpp\r
+SOURCE=..\..\asio\asiolist.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\iasiothiscallresolver.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -111,31 +115,35 @@ SOURCE=..\..\RtAudio.cpp
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.h\r
+SOURCE=..\..\asio\asio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\asiodrivers.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.h\r
+SOURCE=..\..\asio\asiodrvr.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrvr.h\r
+SOURCE=..\..\asio\asiolist.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.h\r
+SOURCE=..\..\asio\asiosys.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiosys.h\r
+SOURCE=..\..\asio\ginclude.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\ginclude.h\r
+SOURCE=..\..\asio\iasiodrv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\iasiodrv.h\r
+SOURCE=..\..\asio\iasiothiscallresolver.h\r
 # End Source File\r
 # Begin Source File\r
 \r
index 5f3eba913499f926baa831d6c58408f1b2848eca..51f2f01dc5c962f17229399dbc380c06a90f9e95 100644 (file)
@@ -87,15 +87,19 @@ LINK32=link.exe
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.cpp\r
+SOURCE=..\..\asio\asio.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.cpp\r
+SOURCE=..\..\asio\asiodrivers.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.cpp\r
+SOURCE=..\..\asio\asiolist.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\iasiothiscallresolver.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -111,31 +115,35 @@ SOURCE=..\..\RtAudio.cpp
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.h\r
+SOURCE=..\..\asio\asio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\asiodrivers.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.h\r
+SOURCE=..\..\asio\asiodrvr.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrvr.h\r
+SOURCE=..\..\asio\asiolist.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.h\r
+SOURCE=..\..\asio\asiosys.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiosys.h\r
+SOURCE=..\..\asio\ginclude.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\ginclude.h\r
+SOURCE=..\..\asio\iasiodrv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\iasiodrv.h\r
+SOURCE=..\..\asio\iasiothiscallresolver.h\r
 # End Source File\r
 # Begin Source File\r
 \r
index 92bff12e9c2758be6cfd93e1331c53e3ee66e5f6..d769d9bd7e0132e1b532b412ba7cc2f3d03a9c67 100644 (file)
@@ -87,15 +87,19 @@ LINK32=link.exe
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.cpp\r
+SOURCE=..\..\asio\asio.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.cpp\r
+SOURCE=..\..\asio\asiodrivers.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.cpp\r
+SOURCE=..\..\asio\asiolist.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\iasiothiscallresolver.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -111,31 +115,35 @@ SOURCE=..\..\RtAudio.cpp
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.h\r
+SOURCE=..\..\asio\asio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\asiodrivers.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.h\r
+SOURCE=..\..\asio\asiodrvr.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrvr.h\r
+SOURCE=..\..\asio\asiolist.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.h\r
+SOURCE=..\..\asio\asiosys.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiosys.h\r
+SOURCE=..\..\asio\ginclude.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\ginclude.h\r
+SOURCE=..\..\asio\iasiodrv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\iasiodrv.h\r
+SOURCE=..\..\asio\iasiothiscallresolver.h\r
 # End Source File\r
 # Begin Source File\r
 \r
index 65f8285a7d2a6daf42d525286366c0769759c83c..2092a61accca820bc8ea34ec82dcce45b977b8ab 100644 (file)
@@ -87,15 +87,19 @@ LINK32=link.exe
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.cpp\r
+SOURCE=..\..\asio\asio.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.cpp\r
+SOURCE=..\..\asio\asiodrivers.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.cpp\r
+SOURCE=..\..\asio\asiolist.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\iasiothiscallresolver.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -111,31 +115,35 @@ SOURCE=..\..\RtAudio.cpp
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.h\r
+SOURCE=..\..\asio\asio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\asiodrivers.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.h\r
+SOURCE=..\..\asio\asiodrvr.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrvr.h\r
+SOURCE=..\..\asio\asiolist.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.h\r
+SOURCE=..\..\asio\asiosys.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiosys.h\r
+SOURCE=..\..\asio\ginclude.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\ginclude.h\r
+SOURCE=..\..\asio\iasiodrv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\iasiodrv.h\r
+SOURCE=..\..\asio\iasiothiscallresolver.h\r
 # End Source File\r
 # Begin Source File\r
 \r
index 9e67e023887e28df2d2b52382df94d5c6a66ebe2..303de359334af5b3df2ca19e28f339e5cf3401ed 100644 (file)
@@ -87,15 +87,19 @@ LINK32=link.exe
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.cpp\r
+SOURCE=..\..\asio\asio.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.cpp\r
+SOURCE=..\..\asio\asiodrivers.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.cpp\r
+SOURCE=..\..\asio\asiolist.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\iasiothiscallresolver.cpp\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -111,31 +115,35 @@ SOURCE=..\twostreams.cpp
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
-SOURCE=.\asio.h\r
+SOURCE=..\..\asio\asio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\asio\asiodrivers.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrivers.h\r
+SOURCE=..\..\asio\asiodrvr.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiodrvr.h\r
+SOURCE=..\..\asio\asiolist.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiolist.h\r
+SOURCE=..\..\asio\asiosys.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\asiosys.h\r
+SOURCE=..\..\asio\ginclude.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\ginclude.h\r
+SOURCE=..\..\asio\iasiodrv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\iasiodrv.h\r
+SOURCE=..\..\asio\iasiothiscallresolver.h\r
 # End Source File\r
 # Begin Source File\r
 \r