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.

192 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. #include "wine/debug.h"
  25. /* WINE_DEFAULT_DEBUG_CHANNEL(asio); */
  26. /* {48D0C522-BFCC-45cc-8B84-17F25F33E6E8} */
  27. static GUID const CLSID_WineASIO = {
  28. 0x48d0c522, 0xbfcc, 0x45cc, { 0x8b, 0x84, 0x17, 0xf2, 0x5f, 0x33, 0xe6, 0xe8 } };
  29. typedef struct {
  30. const IClassFactoryVtbl * lpVtbl;
  31. LONG ref;
  32. } IClassFactoryImpl;
  33. extern HRESULT WINAPI WineASIOCreateInstance(REFIID riid, LPVOID *ppobj);
  34. /*******************************************************************************
  35. * ClassFactory
  36. */
  37. static HRESULT WINAPI CF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
  38. {
  39. /* IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  40. FIXME("(%p, %s, %p) stub!\n", This, debugstr_guid(riid), ppobj); */
  41. if (ppobj == NULL)
  42. return E_POINTER;
  43. return E_NOINTERFACE;
  44. }
  45. static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface)
  46. {
  47. IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  48. ULONG ref = InterlockedIncrement(&(This->ref));
  49. /* TRACE("iface: %p, ref has been set to %x\n", This, ref); */
  50. return ref;
  51. }
  52. static ULONG WINAPI CF_Release(LPCLASSFACTORY iface)
  53. {
  54. IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  55. ULONG ref = InterlockedDecrement(&(This->ref));
  56. /* TRACE("iface %p, ref has been set to %x\n", This, ref); */
  57. /* static class, won't be freed */
  58. return ref;
  59. }
  60. static HRESULT WINAPI CF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
  61. {
  62. /* IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  63. TRACE("iface: %p, pOuter: %p, riid: %s, ppobj: %p)\n", This, pOuter, debugstr_guid(riid), ppobj); */
  64. if (pOuter)
  65. return CLASS_E_NOAGGREGATION;
  66. if (ppobj == NULL) {
  67. /* WARN("invalid parameter\n"); */
  68. return E_INVALIDARG;
  69. }
  70. *ppobj = NULL;
  71. /* TRACE("Creating the WineASIO object\n"); */
  72. return WineASIOCreateInstance(riid, ppobj);
  73. }
  74. static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
  75. {
  76. /* IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
  77. FIXME("iface: %p, dolock: %d) stub!\n", This, dolock); */
  78. return S_OK;
  79. }
  80. static const IClassFactoryVtbl CF_Vtbl = {
  81. CF_QueryInterface,
  82. CF_AddRef,
  83. CF_Release,
  84. CF_CreateInstance,
  85. CF_LockServer
  86. };
  87. static IClassFactoryImpl WINEASIO_CF = { &CF_Vtbl, 1 };
  88. /*******************************************************************************
  89. * DllGetClassObject [DSOUND.@]
  90. * Retrieves class object from a DLL object
  91. *
  92. * NOTES
  93. * Docs say returns STDAPI
  94. *
  95. * PARAMS
  96. * rclsid [I] CLSID for the class object
  97. * riid [I] Reference to identifier of interface for class object
  98. * ppv [O] Address of variable to receive interface pointer for riid
  99. *
  100. * RETURNS
  101. * Success: S_OK
  102. * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
  103. * E_UNEXPECTED
  104. */
  105. HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
  106. {
  107. /* TRACE("rclsid: %s, riid: %s, ppv: %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); */
  108. if (ppv == NULL) {
  109. /* WARN("invalid parameter\n"); */
  110. return E_INVALIDARG;
  111. }
  112. *ppv = NULL;
  113. if (!IsEqualIID(riid, &IID_IClassFactory) && !IsEqualIID(riid, &IID_IUnknown))
  114. {
  115. /* WARN("no interface for %s\n", debugstr_guid(riid)); */
  116. return E_NOINTERFACE;
  117. }
  118. if (IsEqualGUID(rclsid, &CLSID_WineASIO))
  119. {
  120. CF_AddRef((IClassFactory*) &WINEASIO_CF);
  121. *ppv = &WINEASIO_CF;
  122. return S_OK;
  123. }
  124. /* WARN("rclsid: %s, riid: %s, ppv: %p): no class found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); */
  125. return CLASS_E_CLASSNOTAVAILABLE;
  126. }
  127. /*******************************************************************************
  128. * DllCanUnloadNow
  129. * Determines whether the DLL is in use.
  130. *
  131. * RETURNS
  132. * Success: S_OK
  133. * Failure: S_FALSE
  134. */
  135. HRESULT WINAPI DllCanUnloadNow(void)
  136. {
  137. /* FIXME("(void): stub\n"); */
  138. return S_FALSE;
  139. }
  140. /***********************************************************************
  141. * DllMain (ASIO.init)
  142. */
  143. BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
  144. {
  145. /* TRACE("hInstDLL: %p, fdwReason: %x lpvReserved: %p)\n", hInstDLL, fdwReason, lpvReserved); */
  146. switch (fdwReason) {
  147. case DLL_PROCESS_ATTACH:
  148. /* TRACE("DLL_PROCESS_ATTACH\n"); */
  149. break;
  150. case DLL_PROCESS_DETACH:
  151. /* TRACE("DLL_PROCESS_DETACH\n"); */
  152. break;
  153. case DLL_THREAD_ATTACH:
  154. /* TRACE("DLL_THREAD_ATTACH\n"); */
  155. break;
  156. case DLL_THREAD_DETACH:
  157. /* TRACE("DLL_THREAD_DETACH\n"); */
  158. break;
  159. default:
  160. /* TRACE("UNKNOWN REASON\n"); */
  161. break;
  162. }
  163. return TRUE;
  164. }