📄 iasiothiscallresolver.cpp
字号:
__asm__ __volatile__ ("pushl %0\n\t" \ "movl (%1), %%edx\n\t" \ "call *"#funcOffset"(%%edx)\n\t" \ : /* Output Operands */ \ :"r"(param1), /* Input Operands */ \ "c"(thisPtr) \ ); \#define CALL_THISCALL_1( resultName, thisPtr, funcOffset, param1 ) \ __asm__ __volatile__ ("pushl %1\n\t" \ "movl (%2), %%edx\n\t" \ "call *"#funcOffset"(%%edx)\n\t" \ :"=a"(resultName) /* Output Operands */ \ :"r"(param1), /* Input Operands */ \ "c"(thisPtr) \ ); \#define CALL_THISCALL_1_DOUBLE( resultName, thisPtr, funcOffset, param1 ) \ __asm__ __volatile__ ("pushl 4(%1)\n\t" \ "pushl (%1)\n\t" \ "movl (%2), %%edx\n\t" \ "call *"#funcOffset"(%%edx);\n\t" \ :"=a"(resultName) /* Output Operands */ \ :"a"(¶m1), /* Input Operands */ \ /* Note: Using "r" above instead of "a" fails */ \ /* when using GCC 3.3.3, and maybe later versions*/\ "c"(thisPtr) \ ); \#define CALL_THISCALL_2( resultName, thisPtr, funcOffset, param1, param2 ) \ __asm__ __volatile__ ("pushl %1\n\t" \ "pushl %2\n\t" \ "movl (%3), %%edx\n\t" \ "call *"#funcOffset"(%%edx)\n\t" \ :"=a"(resultName) /* Output Operands */ \ :"r"(param2), /* Input Operands */ \ "r"(param1), \ "c"(thisPtr) \ ); \#define CALL_THISCALL_4( resultName, thisPtr, funcOffset, param1, param2, param3, param4 )\ __asm__ __volatile__ ("pushl %1\n\t" \ "pushl %2\n\t" \ "pushl %3\n\t" \ "pushl %4\n\t" \ "movl (%5), %%edx\n\t" \ "call *"#funcOffset"(%%edx)\n\t" \ :"=a"(resultName) /* Output Operands */ \ :"r"(param4), /* Input Operands */ \ "r"(param3), \ "r"(param2), \ "r"(param1), \ "c"(thisPtr) \ ); \#endif// Our static singleton instance.IASIOThiscallResolver IASIOThiscallResolver::instance;// Constructor called to initialize static Singleton instance above. Note that// it is important not to clear that_ incase it has already been set by the call// to placement new in ASIOInit().IASIOThiscallResolver::IASIOThiscallResolver(){}// Constructor called from ASIOInit() belowIASIOThiscallResolver::IASIOThiscallResolver(IASIO* that): that_( that ){}// Implement IUnknown methods as assert(false). IASIOThiscallResolver is not// really a COM object, just a wrapper which will work with the ASIO SDK.// If you wanted to use ASIO without the SDK you might want to implement COM// aggregation in these methods.HRESULT STDMETHODCALLTYPE IASIOThiscallResolver::QueryInterface(REFIID riid, void **ppv){ (void)riid; // suppress unused variable warning assert( false ); // this function should never be called by the ASIO SDK. *ppv = NULL; return E_NOINTERFACE;}ULONG STDMETHODCALLTYPE IASIOThiscallResolver::AddRef(){ assert( false ); // this function should never be called by the ASIO SDK. return 1;}ULONG STDMETHODCALLTYPE IASIOThiscallResolver::Release(){ assert( false ); // this function should never be called by the ASIO SDK. return 1;}// Implement the IASIO interface methods by performing the vptr manipulation// described above then delegating to the real implementation.ASIOBool IASIOThiscallResolver::init(void *sysHandle){ ASIOBool result; CALL_THISCALL_1( result, that_, 12, sysHandle ); return result;}void IASIOThiscallResolver::getDriverName(char *name){ CALL_VOID_THISCALL_1( that_, 16, name );}long IASIOThiscallResolver::getDriverVersion(){ ASIOBool result; CALL_THISCALL_0( result, that_, 20 ); return result;}void IASIOThiscallResolver::getErrorMessage(char *string){ CALL_VOID_THISCALL_1( that_, 24, string );}ASIOError IASIOThiscallResolver::start(){ ASIOBool result; CALL_THISCALL_0( result, that_, 28 ); return result;}ASIOError IASIOThiscallResolver::stop(){ ASIOBool result; CALL_THISCALL_0( result, that_, 32 ); return result;}ASIOError IASIOThiscallResolver::getChannels(long *numInputChannels, long *numOutputChannels){ ASIOBool result; CALL_THISCALL_2( result, that_, 36, numInputChannels, numOutputChannels ); return result;}ASIOError IASIOThiscallResolver::getLatencies(long *inputLatency, long *outputLatency){ ASIOBool result; CALL_THISCALL_2( result, that_, 40, inputLatency, outputLatency ); return result;}ASIOError IASIOThiscallResolver::getBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity){ ASIOBool result; CALL_THISCALL_4( result, that_, 44, minSize, maxSize, preferredSize, granularity ); return result;}ASIOError IASIOThiscallResolver::canSampleRate(ASIOSampleRate sampleRate){ ASIOBool result; CALL_THISCALL_1_DOUBLE( result, that_, 48, sampleRate ); return result;}ASIOError IASIOThiscallResolver::getSampleRate(ASIOSampleRate *sampleRate){ ASIOBool result; CALL_THISCALL_1( result, that_, 52, sampleRate ); return result;}ASIOError IASIOThiscallResolver::setSampleRate(ASIOSampleRate sampleRate){ ASIOBool result; CALL_THISCALL_1_DOUBLE( result, that_, 56, sampleRate ); return result;}ASIOError IASIOThiscallResolver::getClockSources(ASIOClockSource *clocks, long *numSources){ ASIOBool result; CALL_THISCALL_2( result, that_, 60, clocks, numSources ); return result;}ASIOError IASIOThiscallResolver::setClockSource(long reference){ ASIOBool result; CALL_THISCALL_1( result, that_, 64, reference ); return result;}ASIOError IASIOThiscallResolver::getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp){ ASIOBool result; CALL_THISCALL_2( result, that_, 68, sPos, tStamp ); return result;}ASIOError IASIOThiscallResolver::getChannelInfo(ASIOChannelInfo *info){ ASIOBool result; CALL_THISCALL_1( result, that_, 72, info ); return result;}ASIOError IASIOThiscallResolver::createBuffers(ASIOBufferInfo *bufferInfos, long numChannels, long bufferSize, ASIOCallbacks *callbacks){ ASIOBool result; CALL_THISCALL_4( result, that_, 76, bufferInfos, numChannels, bufferSize, callbacks ); return result;}ASIOError IASIOThiscallResolver::disposeBuffers(){ ASIOBool result; CALL_THISCALL_0( result, that_, 80 ); return result;}ASIOError IASIOThiscallResolver::controlPanel(){ ASIOBool result; CALL_THISCALL_0( result, that_, 84 ); return result;}ASIOError IASIOThiscallResolver::future(long selector,void *opt){ ASIOBool result; CALL_THISCALL_2( result, that_, 88, selector, opt ); return result;}ASIOError IASIOThiscallResolver::outputReady(){ ASIOBool result; CALL_THISCALL_0( result, that_, 92 ); return result;}// Implement our substitute ASIOInit() methodASIOError IASIOThiscallResolver::ASIOInit(ASIODriverInfo *info){ // To ensure that our instance's vptr is correctly constructed, even if // ASIOInit is called prior to main(), we explicitly call its constructor // (potentially over the top of an existing instance). Note that this is // pretty ugly, and is only safe because IASIOThiscallResolver has no // destructor and contains no objects with destructors. new((void*)&instance) IASIOThiscallResolver( theAsioDriver ); // Interpose between ASIO client code and the real driver. theAsioDriver = &instance; // Note that we never need to switch theAsioDriver back to point to the // real driver because theAsioDriver is reset to zero in ASIOExit(). // Delegate to the real ASIOInit return ::ASIOInit(info);}#endif /* !defined(_MSC_VER) */#endif /* Win32 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -