/// <summary>
        /// Initializes a new instance of the <see cref="AsioDriverExt"/> class based on an already
        /// instantiated AsioDriver instance.
        /// </summary>
        /// <param name="driver">A AsioDriver already instantiated.</param>
        public AsioDriverExt(AsioDriver driver)
        {
            this.driver = driver;

            if (!driver.Init(IntPtr.Zero))
            {
                throw new InvalidOperationException(driver.GetErrorMessage());
            }

            callbacks = new AsioCallbacks();
            callbacks.pasioMessage          = AsioMessageCallBack;
            callbacks.pbufferSwitch         = BufferSwitchCallBack;
            callbacks.pbufferSwitchTimeInfo = BufferSwitchTimeInfoCallBack;
            callbacks.psampleRateDidChange  = SampleRateDidChangeCallBack;

            BuildCapabilities();
        }
 /// <summary>
 /// Creates the buffers.
 /// </summary>
 /// <param name="bufferInfos">The buffer infos.</param>
 /// <param name="numChannels">The num channels.</param>
 /// <param name="bufferSize">Size of the buffer.</param>
 /// <param name="callbacks">The callbacks.</param>
 public void CreateBuffers(IntPtr bufferInfos, int numChannels, int bufferSize, ref AsioCallbacks callbacks)
 {
     // next two lines suggested by droidi on codeplex issue tracker
     pinnedcallbacks = Marshal.AllocHGlobal(Marshal.SizeOf(callbacks));
     Marshal.StructureToPtr(callbacks, pinnedcallbacks, false);
     HandleException(
         asioDriverVTable.createBuffers(pAsioComObject, bufferInfos, numChannels, bufferSize, pinnedcallbacks),
         "createBuffers");
 }