main.cpp 1.9 KB

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