diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Library/ml_devices/wasabi.cpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Plugins/Library/ml_devices/wasabi.cpp')
-rw-r--r-- | Src/Plugins/Library/ml_devices/wasabi.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/Src/Plugins/Library/ml_devices/wasabi.cpp b/Src/Plugins/Library/ml_devices/wasabi.cpp new file mode 100644 index 00000000..f71f4bed --- /dev/null +++ b/Src/Plugins/Library/ml_devices/wasabi.cpp @@ -0,0 +1,107 @@ +#include "main.h" +#include "./wasabi.h" + +#include <api/service/waservicefactory.h> + +api_application *WASABI_API_APP = NULL; +api_language *WASABI_API_LNG = NULL; +api_devicemanager *WASABI_API_DEVICES = NULL; +api_winamp *WASABI_API_WINAMP = NULL; + +HINSTANCE WASABI_API_LNG_HINST = NULL; +HINSTANCE WASABI_API_ORIG_HINST = NULL; + +static unsigned long wasabiReference = 0; +static BOOL defaultServicesLoaded = FALSE; +EXTERN_C winampMediaLibraryPlugin plugin; + +static void Wasabi_Uninitialize() +{ + Wasabi_ReleaseInterface(applicationApiServiceGuid, WASABI_API_APP); + Wasabi_ReleaseInterface(languageApiGUID, WASABI_API_LNG); + Wasabi_ReleaseInterface(DeviceManagerGUID, WASABI_API_DEVICES); + Wasabi_ReleaseInterface(winampApiGuid, WASABI_API_WINAMP); + + WASABI_API_APP = NULL; + WASABI_API_LNG = NULL; + WASABI_API_DEVICES = NULL; + WASABI_API_WINAMP = NULL; + defaultServicesLoaded = FALSE; +} + +BOOL Wasabi_Initialize(HINSTANCE instance) +{ + defaultServicesLoaded = FALSE; + + WASABI_API_APP = NULL; + WASABI_API_DEVICES = NULL; + + WASABI_API_LNG = NULL; + WASABI_API_ORIG_HINST = instance; + WASABI_API_LNG_HINST = WASABI_API_ORIG_HINST; + + Wasabi_AddRef(); + return TRUE; +} + +BOOL Wasabi_InitializeFromWinamp(HINSTANCE instance, HWND winampWindow) +{ + return Wasabi_Initialize(instance); +} + +BOOL Wasabi_LoadDefaultServices(void) +{ + if (FALSE != defaultServicesLoaded) + return FALSE; + + WASABI_API_APP = Wasabi_QueryInterface(api_application, applicationApiServiceGuid); + WASABI_API_DEVICES = Wasabi_QueryInterface(api_devicemanager, DeviceManagerGUID); + WASABI_API_WINAMP = Wasabi_QueryInterface(api_winamp, winampApiGuid); + + WASABI_API_LNG = Wasabi_QueryInterface(api_language, languageApiGUID); + if (NULL != WASABI_API_LNG) + { + WASABI_API_LNG_HINST = WASABI_API_LNG->StartLanguageSupport(WASABI_API_ORIG_HINST, MlDevicesLangGUID); + } + + defaultServicesLoaded = TRUE; + return TRUE; +} + +unsigned long +Wasabi_AddRef(void) +{ + return InterlockedIncrement((LONG*)&wasabiReference); +} + +unsigned long +Wasabi_Release(void) +{ + if (0 == wasabiReference) + return wasabiReference; + + LONG r = InterlockedDecrement((LONG*)&wasabiReference); + if (0 == r) + { + Wasabi_Uninitialize(); + } + return r; +} + +void * Wasabi_QueryInterface0(const GUID &interfaceGuid) +{ + waServiceFactory *serviceFactory = plugin.service->service_getServiceByGuid(interfaceGuid); + if (NULL == serviceFactory) + return NULL; + + return serviceFactory->getInterface(); +} + +void Wasabi_ReleaseInterface0(const GUID &interfaceGuid, void *interfaceInstance) +{ + waServiceFactory *serviceFactory = plugin.service->service_getServiceByGuid(interfaceGuid); + if (NULL == serviceFactory) + return; + + serviceFactory->releaseInterface(interfaceInstance); +} |