1
0

main.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "api.h"
  2. #include "../nu/Singleton.h"
  3. #include "../nu/factoryt.h"
  4. #include "AVIAACDecoder.h"
  5. #include "FLVAACDecoder.h"
  6. #include "MKVAACDecoder.h"
  7. #include "MP4AACDecoder.h"
  8. #include "ADTSAACDecoder.h"
  9. #include "NSVAACDecoder.h"
  10. #include <bfc/platform/export.h>
  11. #include "../Agave/Component/ifc_wa5component.h"
  12. class AACDecoderComponent : public ifc_wa5component
  13. {
  14. public:
  15. void RegisterServices(api_service *service);
  16. int RegisterServicesSafeModeOk();
  17. void DeregisterServices(api_service *service);
  18. protected:
  19. RECVS_DISPATCH;
  20. };
  21. template <class api_T>
  22. void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  23. {
  24. if (WASABI_API_SVC)
  25. {
  26. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  27. if (factory)
  28. api_t = (api_T *)factory->getInterface();
  29. }
  30. }
  31. template <class api_T>
  32. void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  33. {
  34. if (WASABI_API_SVC && api_t)
  35. {
  36. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  37. if (factory)
  38. factory->releaseInterface(api_t);
  39. }
  40. api_t = 0;
  41. }
  42. static SingletonServiceFactory<svc_avidecoder, AVIDecoder> avi_factory;
  43. static AVIDecoder avi_decoder;
  44. static SingletonServiceFactory<svc_mkvdecoder, MKVDecoder> mkv_factory;
  45. static MKVDecoder mkv_decoder;
  46. static SingletonServiceFactory<svc_flvdecoder, FLVDecoder> flv_factory;
  47. static FLVDecoder flv_decoder;
  48. static ServiceFactoryT<MP4AudioDecoder, MP4AACDecoder> mp4_factory;
  49. static ServiceFactoryT<adts, ADTSAACDecoder> adts_factory;
  50. static NSVDecoder nsv_decoder;
  51. static SingletonServiceFactory<svc_nsvFactory, NSVDecoder> nsv_factory;
  52. void AACDecoderComponent::RegisterServices(api_service *service)
  53. {
  54. WASABI_API_SVC = service;
  55. avi_factory.Register(WASABI_API_SVC, &avi_decoder);
  56. mkv_factory.Register(WASABI_API_SVC, &mkv_decoder);
  57. flv_factory.Register(WASABI_API_SVC, &flv_decoder);
  58. nsv_factory.Register(WASABI_API_SVC, &nsv_decoder);
  59. mp4_factory.Register(WASABI_API_SVC);
  60. adts_factory.Register(WASABI_API_SVC);
  61. ServiceBuild(AGAVE_API_CONFIG, AgaveConfigGUID);
  62. ServiceBuild(WASABI_API_MEMMGR, memMgrApiServiceGuid);
  63. }
  64. void AACDecoderComponent::DeregisterServices(api_service *service)
  65. {
  66. avi_factory.Deregister(WASABI_API_SVC);
  67. mkv_factory.Deregister(WASABI_API_SVC);
  68. mp4_factory.Deregister(WASABI_API_SVC);
  69. flv_factory.Deregister(WASABI_API_SVC);
  70. nsv_factory.Deregister(WASABI_API_SVC);
  71. adts_factory.Deregister(WASABI_API_SVC);
  72. ServiceRelease(AGAVE_API_CONFIG, AgaveConfigGUID);
  73. ServiceRelease(WASABI_API_MEMMGR, memMgrApiServiceGuid);
  74. }
  75. int AACDecoderComponent::RegisterServicesSafeModeOk()
  76. {
  77. return 1;
  78. }
  79. AACDecoderComponent aac_decoder_component;
  80. extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
  81. {
  82. return &aac_decoder_component;
  83. }
  84. #define CBCLASS AACDecoderComponent
  85. START_DISPATCH;
  86. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  87. CB(15, RegisterServicesSafeModeOk)
  88. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  89. END_DISPATCH;
  90. #undef CBCLASS