ASIO to JACK driver for WINE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
5.5KB

  1. /*
  2. * Copyright (C) 2006 Robert Reif
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  17. */
  18. #include <stdarg.h>
  19. #include "windef.h"
  20. #include "winbase.h"
  21. #include "winuser.h"
  22. #include "winreg.h"
  23. #include "objbase.h"
  24. #ifdef DEBUG
  25. #include "wine/debug.h"
  26. #endif
  27. /* WINE_DEFAULT_DEBUG_CHANNEL(asio); */
  28. /* {48D0C522-BFCC-45cc-8B84-17F25F33E6E8} */
  29. static GUID const CLSID_WineASIO = {
  30. 0x48d0c522, 0xbfcc, 0x45cc, { 0x8b, 0x84, 0x17, 0xf2, 0x5f, 0x33, 0xe6, 0xe8 } };
  31. typedef struct {
  32. const IClassFactoryVtbl * lpVtbl;
  33. LONG ref;
  34. } IClassFactoryImpl;
  35. extern HRESULT WINAPI WineASIOCreateInstance(REFIID riid, LPVOID *ppobj);
  36. /*******************************************************************************
  37. * ClassFactory
  38. */
  39. static HRESULT WINAPI CF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
  40. {
  41. /* IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  42. FIXME("(%p, %s, %p) stub!\n", This, debugstr_guid(riid), ppobj); */
  43. if (ppobj == NULL)
  44. return E_POINTER;
  45. return E_NOINTERFACE;
  46. }
  47. static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface)
  48. {
  49. IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  50. ULONG ref = InterlockedIncrement(&(This->ref));
  51. /* TRACE("iface: %p, ref has been set to %x\n", This, ref); */
  52. return ref;
  53. }
  54. static ULONG WINAPI CF_Release(LPCLASSFACTORY iface)
  55. {
  56. IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  57. ULONG ref = InterlockedDecrement(&(This->ref));
  58. /* TRACE("iface %p, ref has been set to %x\n", This, ref); */
  59. /* static class, won't be freed */
  60. return ref;
  61. }
  62. static HRESULT WINAPI CF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
  63. {
  64. /* IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  65. TRACE("iface: %p, pOuter: %p, riid: %s, ppobj: %p)\n", This, pOuter, debugstr_guid(riid), ppobj); */
  66. if (pOuter)
  67. return CLASS_E_NOAGGREGATION;
  68. if (ppobj == NULL) {
  69. /* WARN("invalid parameter\n"); */
  70. return E_INVALIDARG;
  71. }
  72. *ppobj = NULL;
  73. /* TRACE("Creating the WineASIO object\n"); */
  74. return WineASIOCreateInstance(riid, ppobj);
  75. }
  76. static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
  77. {
  78. /* IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  79. FIXME("iface: %p, dolock: %d) stub!\n", This, dolock); */
  80. return S_OK;
  81. }
  82. static const IClassFactoryVtbl CF_Vtbl = {
  83. CF_QueryInterface,
  84. CF_AddRef,
  85. CF_Release,
  86. CF_CreateInstance,
  87. CF_LockServer
  88. };
  89. static IClassFactoryImpl WINEASIO_CF = { &CF_Vtbl, 1 };
  90. /*******************************************************************************
  91. * DllGetClassObject [DSOUND.@]
  92. * Retrieves class object from a DLL object
  93. *
  94. * NOTES
  95. * Docs say returns STDAPI
  96. *
  97. * PARAMS
  98. * rclsid [I] CLSID for the class object
  99. * riid [I] Reference to identifier of interface for class object
  100. * ppv [O] Address of variable to receive interface pointer for riid
  101. *
  102. * RETURNS
  103. * Success: S_OK
  104. * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
  105. * E_UNEXPECTED
  106. */
  107. HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
  108. {
  109. /* TRACE("rclsid: %s, riid: %s, ppv: %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); */
  110. if (ppv == NULL) {
  111. /* WARN("invalid parameter\n"); */
  112. return E_INVALIDARG;
  113. }
  114. *ppv = NULL;
  115. if (!IsEqualIID(riid, &IID_IClassFactory) && !IsEqualIID(riid, &IID_IUnknown))
  116. {
  117. /* WARN("no interface for %s\n", debugstr_guid(riid)); */
  118. return E_NOINTERFACE;
  119. }
  120. if (IsEqualGUID(rclsid, &CLSID_WineASIO))
  121. {
  122. CF_AddRef((IClassFactory*) &WINEASIO_CF);
  123. *ppv = &WINEASIO_CF;
  124. return S_OK;
  125. }
  126. /* WARN("rclsid: %s, riid: %s, ppv: %p): no class found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); */
  127. return CLASS_E_CLASSNOTAVAILABLE;
  128. }
  129. /*******************************************************************************
  130. * DllCanUnloadNow
  131. * Determines whether the DLL is in use.
  132. *
  133. * RETURNS
  134. * Success: S_OK
  135. * Failure: S_FALSE
  136. */
  137. HRESULT WINAPI DllCanUnloadNow(void)
  138. {
  139. /* FIXME("(void): stub\n"); */
  140. return S_FALSE;
  141. }
  142. /***********************************************************************
  143. * DllMain (ASIO.init)
  144. */
  145. BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
  146. {
  147. /* TRACE("hInstDLL: %p, fdwReason: %x lpvReserved: %p)\n", hInstDLL, fdwReason, lpvReserved); */
  148. switch (fdwReason) {
  149. case DLL_PROCESS_ATTACH:
  150. /* TRACE("DLL_PROCESS_ATTACH\n"); */
  151. break;
  152. case DLL_PROCESS_DETACH:
  153. /* TRACE("DLL_PROCESS_DETACH\n"); */
  154. break;
  155. case DLL_THREAD_ATTACH:
  156. /* TRACE("DLL_THREAD_ATTACH\n"); */
  157. break;
  158. case DLL_THREAD_DETACH:
  159. /* TRACE("DLL_THREAD_DETACH\n"); */
  160. break;
  161. default:
  162. /* TRACE("UNKNOWN REASON\n"); */
  163. break;
  164. }
  165. return TRUE;
  166. }