1
0

Wasabi1.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "api__wasabi2.h"
  2. #include "../Winamp/wa_ipc.h"
  3. namespace Wasabi {
  4. #include <api/service/waservicefactory.h>
  5. #include "../nu/ServiceWatcher.h"
  6. }
  7. Wasabi::ServiceWatcher serviceWatcher;
  8. template <class api_T>
  9. static void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  10. {
  11. if (WASABI_API_SVC)
  12. {
  13. Wasabi::waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  14. if (factory)
  15. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  16. }
  17. }
  18. template <class api_T>
  19. static void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  20. {
  21. if (WASABI_API_SVC && api_t)
  22. {
  23. Wasabi::waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  24. if (factory)
  25. factory->releaseInterface(api_t);
  26. }
  27. api_t = NULL;
  28. }
  29. Wasabi::api_service *WASABI_API_SVC=0;
  30. Wasabi::api_application *WASABI_API_APP=0;
  31. Wasabi::api_memmgr *WASABI_API_MEMMGR=0;
  32. Wasabi::api_albumart *AGAVE_API_ALBUMART=0;
  33. void Wasabi1_Initialize(Wasabi::api_service *svc_api)
  34. {
  35. WASABI_API_SVC = svc_api;
  36. ServiceBuild(WASABI_API_APP, Wasabi::applicationApiServiceGuid);
  37. ServiceBuild(AGAVE_API_ALBUMART, Wasabi::albumArtGUID);
  38. ServiceBuild(WASABI_API_MEMMGR, Wasabi::memMgrApiServiceGuid);
  39. serviceWatcher.WatchWith(WASABI_API_SVC);
  40. serviceWatcher.WatchFor(&AGAVE_API_ALBUMART, Wasabi::albumArtGUID);
  41. }
  42. void Wasabi1_Quit()
  43. {
  44. serviceWatcher.StopWatching();
  45. serviceWatcher.Clear();
  46. ServiceRelease(WASABI_API_APP, Wasabi::applicationApiServiceGuid);
  47. ServiceRelease(AGAVE_API_ALBUMART, Wasabi::albumArtGUID);
  48. ServiceRelease(WASABI_API_MEMMGR, Wasabi::memMgrApiServiceGuid);
  49. }
  50. namespace Wasabi {
  51. #include "../nu/ServiceWatcher.cpp"
  52. }