1
0

Native.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include "stdafx.h"
  2. #include "Native.h"
  3. #include "NativeUtils.h"
  4. #include "../../common/ComponentManager.h"
  5. #if defined(_MSC_VER)
  6. #pragma comment(lib, "advapi32.lib")
  7. #pragma comment(lib, "bcrypt.lib")
  8. #pragma comment(lib, "ncrypt.lib")
  9. #pragma comment(lib, "ole32.lib")
  10. #pragma comment(lib, "rpcrt4.lib")
  11. #pragma comment(lib, "shell32.lib")
  12. #pragma comment(lib, "shlwapi.lib")
  13. #pragma comment(lib, "strmiids.lib")
  14. #if (_WIN32_WINNT >= 0x600)
  15. #pragma comment(lib, "avrt.lib")
  16. #endif
  17. #if defined(MPT_WITH_DIRECTSOUND)
  18. #pragma comment(lib, "dsound.lib")
  19. #endif // MPT_WITH_DIRECTSOUND
  20. #pragma comment(lib, "winmm.lib")
  21. #pragma comment(lib, "ksuser.lib")
  22. #if defined(_MSC_VER) && !defined(__clang__)
  23. #pragma comment( linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df'\"" )
  24. #endif
  25. #endif
  26. OPENMPT_NAMESPACE_BEGIN
  27. #if defined(MPT_ASSERT_HANDLER_NEEDED) && defined(MPT_BUILD_WINESUPPORT)
  28. MPT_NOINLINE void AssertHandler(const mpt::source_location &loc, const char *expr, const char *msg)
  29. {
  30. if(msg)
  31. {
  32. mpt::log::GlobalLogger().SendLogMessage(loc, LogError, "ASSERT",
  33. U_("ASSERTION FAILED: ") + mpt::ToUnicode(mpt::Charset::ASCII, msg) + U_(" (") + mpt::ToUnicode(mpt::Charset::ASCII, expr) + U_(")")
  34. );
  35. } else
  36. {
  37. mpt::log::GlobalLogger().SendLogMessage(loc, LogError, "ASSERT",
  38. U_("ASSERTION FAILED: ") + mpt::ToUnicode(mpt::Charset::ASCII, expr)
  39. );
  40. }
  41. }
  42. #endif
  43. namespace Wine
  44. {
  45. class ComponentManagerSettings
  46. : public IComponentManagerSettings
  47. {
  48. virtual bool LoadOnStartup() const { return true; } // required to simplify object lifetimes
  49. virtual bool KeepLoaded() const { return true; } // required to simplify object lifetimes
  50. virtual bool IsBlocked(const std::string &key) const { MPT_UNREFERENCED_PARAMETER(key); return false; }
  51. virtual mpt::PathString Path() const { return mpt::PathString(); }
  52. };
  53. static ComponentManagerSettings & ComponentManagerSettingsSingleton()
  54. {
  55. static ComponentManagerSettings gs_Settings;
  56. return gs_Settings;
  57. }
  58. void Init()
  59. {
  60. ComponentManager::Init(ComponentManagerSettingsSingleton());
  61. ComponentManager::Instance()->Startup();
  62. }
  63. void Fini()
  64. {
  65. ComponentManager::Release();
  66. }
  67. } // namespace Wine
  68. OPENMPT_NAMESPACE_END
  69. extern "C" {
  70. OPENMPT_WINESUPPORT_API uintptr_t OPENMPT_WINESUPPORT_CALL OpenMPT_Init(void)
  71. {
  72. OPENMPT_NAMESPACE::Wine::Init();
  73. return 0;
  74. }
  75. OPENMPT_WINESUPPORT_API uintptr_t OPENMPT_WINESUPPORT_CALL OpenMPT_Fini(void)
  76. {
  77. OPENMPT_NAMESPACE::Wine::Fini();
  78. return 0;
  79. }
  80. } // extern "C"