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.

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