plugin_wasapi_utils.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright (C) 2013 Mamadou DIOP
  2. * Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * This file is part of Open Source Doubango Framework.
  5. *
  6. * DOUBANGO is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DOUBANGO is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DOUBANGO.
  18. */
  19. #ifndef PLUGIN_WASAPI_UTILS_H
  20. #define PLUGIN_WASAPI_UTILS_H
  21. #include "plugin_wasapi_config.h"
  22. #include <Windows.h>
  23. #undef SafeRelease
  24. #define SafeRelease(ppT) \
  25. { \
  26. if (*ppT) \
  27. { \
  28. (*ppT)->Release(); \
  29. *ppT = NULL; \
  30. } \
  31. }
  32. #undef CHECK_HR
  33. // In CHECK_HR(x) When (x) is a function it will be executed twice when used in "TSK_DEBUG_ERROR(x)" and "If(x)"
  34. #define CHECK_HR(x) { HRESULT __hr__ = (x); if (FAILED(__hr__)) { TSK_DEBUG_ERROR("Operation Failed (%08x)", __hr__); goto bail; } }
  35. #define PLUGIN_WASAPI_ERROR(hr) WASAPIUtils::PrintError(__FILE__, __FUNCTION__, __LINE__, (hr))
  36. class WASAPIUtils
  37. {
  38. public:
  39. static HRESULT Startup();
  40. static HRESULT Shutdown();
  41. static void PrintError(const char* pcFileName, const char* pcFuncName, unsigned nLineNumber, HRESULT hr);
  42. private:
  43. static bool g_bStarted;
  44. };
  45. #endif /* PLUGIN_WASAPI_UTILS_H */