1
0

main.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #define WIN32_LEAN_AND_MEAN
  2. #include "api__albumart.h"
  3. #include <bfc/platform/export.h>
  4. #include "../Agave/Component/ifc_wa5component.h"
  5. #include "../nu/Singleton.h"
  6. #include "AlbumArt.h"
  7. api_service *WASABI_API_SVC=0;
  8. api_memmgr *WASABI_API_MEMMGR=0;
  9. api_metadata *AGAVE_API_METADATA=0;
  10. api_syscb *WASABI_API_SYSCB=0;
  11. static AlbumArt album_art;
  12. static SingletonServiceFactory<api_albumart, AlbumArt> album_art_factory;
  13. class AlbumArtComponent : public ifc_wa5component
  14. {
  15. public:
  16. void RegisterServices(api_service *service);
  17. int RegisterServicesSafeModeOk();
  18. void DeregisterServices(api_service *service);
  19. protected:
  20. RECVS_DISPATCH;
  21. };
  22. template <class api_T>
  23. void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  24. {
  25. if (WASABI_API_SVC)
  26. {
  27. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  28. if (factory)
  29. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  30. }
  31. }
  32. template <class api_T>
  33. void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  34. {
  35. if (WASABI_API_SVC && api_t)
  36. {
  37. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  38. if (factory)
  39. factory->releaseInterface(api_t);
  40. }
  41. api_t = NULL;
  42. }
  43. void AlbumArtComponent::RegisterServices(api_service *service)
  44. {
  45. WASABI_API_SVC = service;
  46. ServiceBuild(WASABI_API_MEMMGR, memMgrApiServiceGuid);
  47. ServiceBuild(AGAVE_API_METADATA, api_metadataGUID);
  48. ServiceBuild(WASABI_API_SYSCB, syscbApiServiceGuid);
  49. album_art_factory.Register(WASABI_API_SVC, &album_art);
  50. }
  51. int AlbumArtComponent::RegisterServicesSafeModeOk()
  52. {
  53. return 1;
  54. }
  55. void AlbumArtComponent::DeregisterServices(api_service *service)
  56. {
  57. ServiceRelease(WASABI_API_MEMMGR, memMgrApiServiceGuid);
  58. ServiceRelease(AGAVE_API_METADATA, api_metadataGUID);
  59. ServiceRelease(WASABI_API_SYSCB, syscbApiServiceGuid);
  60. album_art_factory.Deregister(WASABI_API_SVC);
  61. }
  62. static AlbumArtComponent component;
  63. extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
  64. {
  65. return &component;
  66. }
  67. #define CBCLASS AlbumArtComponent
  68. START_DISPATCH;
  69. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  70. CB(15, RegisterServicesSafeModeOk)
  71. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  72. END_DISPATCH;
  73. #undef CBCLASS