1
0

wa5_bmp.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "api__bmp.h"
  2. #include "wa5_bmp.h"
  3. #include <bfc/platform/export.h>
  4. #include "MyFactory.h"
  5. #include "../nu/Singleton.h"
  6. #include "BMPLoader.h"
  7. #include "BMPWriter.h"
  8. #include "avi_decoder.h"
  9. WA5_BMP wa5_bmp;
  10. // {BE7F448F-9107-489a-B3B0-7B1563C92BFE}
  11. static const GUID bmpWriterGUID =
  12. { 0xbe7f448f, 0x9107, 0x489a, { 0xb3, 0xb0, 0x7b, 0x15, 0x63, 0xc9, 0x2b, 0xfe } };
  13. // {D984CD4A-9D1E-4060-A624-5BFD0BF37050}
  14. static const GUID bmpLoaderGUID =
  15. { 0xd984cd4a, 0x9d1e, 0x4060, { 0xa6, 0x24, 0x5b, 0xfd, 0xb, 0xf3, 0x70, 0x50 } };
  16. MyFactory<BMPWriter, svc_imageWriter> bmpWriteFactory(bmpWriterGUID);
  17. MyFactory<BMPLoader, svc_imageLoader> bmpLoadFactory(bmpLoaderGUID);
  18. api_service *WASABI_API_SVC = 0;
  19. api_memmgr *WASABI_API_MEMMGR = 0;
  20. static AVIDecoderCreator aviCreator;
  21. static SingletonServiceFactory<svc_avidecoder, AVIDecoderCreator> aviFactory;
  22. void WA5_BMP::RegisterServices(api_service *service)
  23. {
  24. WASABI_API_SVC = service;
  25. // get memory manager
  26. waServiceFactory *sf = WASABI_API_SVC->service_getServiceByGuid(memMgrApiServiceGuid);
  27. if (sf) memoryManager = reinterpret_cast<api_memmgr *>(sf->getInterface());
  28. WASABI_API_SVC->service_register(&bmpLoadFactory);
  29. WASABI_API_SVC->service_register(&bmpWriteFactory);
  30. aviFactory.Register(WASABI_API_SVC, &aviCreator);
  31. }
  32. int WA5_BMP::RegisterServicesSafeModeOk()
  33. {
  34. return 1;
  35. }
  36. void WA5_BMP::DeregisterServices(api_service *service)
  37. {
  38. service->service_deregister(&bmpWriteFactory);
  39. service->service_deregister(&bmpLoadFactory);
  40. aviFactory.Deregister(WASABI_API_SVC);
  41. waServiceFactory *sf = WASABI_API_SVC->service_getServiceByGuid(memMgrApiServiceGuid);
  42. if (sf) sf->releaseInterface(memoryManager);
  43. }
  44. extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
  45. {
  46. return &wa5_bmp;
  47. }
  48. #define CBCLASS WA5_BMP
  49. START_DISPATCH;
  50. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  51. CB(15, RegisterServicesSafeModeOk)
  52. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  53. END_DISPATCH;
  54. #undef CBCLASS