1
0

api.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "../../Library/ml_pmp/pmp.h"
  2. #include "api.h"
  3. #include <api/service/waservicefactory.h>
  4. api_albumart *AGAVE_API_ALBUMART=0;
  5. api_language *WASABI_API_LNG = 0;
  6. api_application *WASABI_API_APP = 0;
  7. HINSTANCE WASABI_API_LNG_HINST = 0, WASABI_API_ORIG_HINST = 0;
  8. api_downloadManager *WAC_API_DOWNLOADMANAGER =0;
  9. api_config *AGAVE_API_CONFIG=0;
  10. api_devicemanager *AGAVE_API_DEVICEMANAGER = 0;
  11. api_metadata *AGAVE_API_METADATA=0;
  12. api_memmgr *WASABI_API_MEMMGR=0;
  13. Wasabi2::api_service *WASABI2_API_SVC=0;
  14. Wasabi2::api_ssdp *REPLICANT_API_SSDP=0;
  15. extern PMPDevicePlugin plugin;
  16. template <class api_T>
  17. void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  18. {
  19. if (plugin.service)
  20. {
  21. waServiceFactory *factory = plugin.service->service_getServiceByGuid(factoryGUID_t);
  22. if (factory)
  23. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  24. }
  25. }
  26. template <class api_T>
  27. void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  28. {
  29. if (plugin.service && api_t)
  30. {
  31. waServiceFactory *factory = plugin.service->service_getServiceByGuid(factoryGUID_t);
  32. if (factory)
  33. factory->releaseInterface(api_t);
  34. }
  35. api_t = NULL;
  36. }
  37. void WasabiInit()
  38. {
  39. ServiceBuild(WASABI_API_APP, applicationApiServiceGuid);
  40. ServiceBuild(WASABI_API_LNG, languageApiGUID);
  41. ServiceBuild( WAC_API_DOWNLOADMANAGER, DownloadManagerGUID);
  42. ServiceBuild(AGAVE_API_CONFIG, AgaveConfigGUID);
  43. ServiceBuild(AGAVE_API_DEVICEMANAGER, DeviceManagerGUID);
  44. ServiceBuild(AGAVE_API_ALBUMART, albumArtGUID);
  45. ServiceBuild(AGAVE_API_METADATA, api_metadataGUID);
  46. ServiceBuild(WASABI_API_MEMMGR, memMgrApiServiceGuid);
  47. ServiceBuild(WASABI2_API_SVC, Wasabi2::api_service::GetServiceGUID());
  48. // need to have this initialised before we try to do anything with localisation features
  49. // TODO: WASABI_API_START_LANG(plugin.hDllInstance,InAviLangGUID);
  50. if (WASABI2_API_SVC)
  51. WASABI2_API_SVC->GetService(&REPLICANT_API_SSDP);
  52. }
  53. void WasabiQuit()
  54. {
  55. ServiceRelease(WASABI_API_APP, applicationApiServiceGuid);
  56. ServiceRelease(WASABI_API_LNG, languageApiGUID);
  57. ServiceRelease( WAC_API_DOWNLOADMANAGER, DownloadManagerGUID);
  58. ServiceRelease(AGAVE_API_CONFIG, AgaveConfigGUID);
  59. ServiceRelease(AGAVE_API_DEVICEMANAGER, DeviceManagerGUID);
  60. ServiceRelease(AGAVE_API_ALBUMART, albumArtGUID);
  61. ServiceRelease(AGAVE_API_METADATA, api_metadataGUID);
  62. ServiceRelease(WASABI_API_MEMMGR, memMgrApiServiceGuid);
  63. ServiceRelease(WASABI2_API_SVC, Wasabi2::api_service::GetServiceGUID());
  64. if (REPLICANT_API_SSDP)
  65. REPLICANT_API_SSDP->Release();
  66. }