1
0

main.cpp 1.9 KB

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