1
0

main.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* copyright 2006 Ben Allison */
  2. #include "api__alac.h"
  3. #include "wa5_alac.h"
  4. #include "factory_alac.h"
  5. #include <bfc/platform/export.h>
  6. #include <api/service/waservicefactory.h>
  7. api_service *WASABI_API_SVC = 0;
  8. api_config *AGAVE_API_CONFIG = 0;
  9. static ALACFactory alacFactory;
  10. static WA5_ALAC wa5_alac;
  11. template <class api_T>
  12. void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  13. {
  14. if (WASABI_API_SVC)
  15. {
  16. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  17. if (factory)
  18. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  19. }
  20. }
  21. template <class api_T>
  22. void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  23. {
  24. if (WASABI_API_SVC && api_t)
  25. {
  26. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  27. if (factory)
  28. factory->releaseInterface(api_t);
  29. }
  30. api_t = NULL;
  31. }
  32. void WA5_ALAC::RegisterServices(api_service *service)
  33. {
  34. WASABI_API_SVC = service;
  35. ServiceBuild(AGAVE_API_CONFIG, AgaveConfigGUID);
  36. WASABI_API_SVC->service_register(&alacFactory);
  37. }
  38. int WA5_ALAC::RegisterServicesSafeModeOk()
  39. {
  40. return 1;
  41. }
  42. void WA5_ALAC::DeregisterServices(api_service *service)
  43. {
  44. service->service_deregister(&alacFactory);
  45. ServiceRelease(AGAVE_API_CONFIG, AgaveConfigGUID);
  46. }
  47. extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
  48. {
  49. return &wa5_alac;
  50. }
  51. #ifdef CBCLASS
  52. #undef CBCLASS
  53. #endif
  54. #define CBCLASS WA5_ALAC
  55. START_DISPATCH;
  56. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  57. CB(15, RegisterServicesSafeModeOk)
  58. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  59. END_DISPATCH;