diff options
author | Mamadou DIOP <bossiel@yahoo.fr> | 2015-08-17 01:56:35 +0200 |
---|---|---|
committer | Mamadou DIOP <bossiel@yahoo.fr> | 2015-08-17 01:56:35 +0200 |
commit | 631fffee8a28b1bec5ed1f1d26a20e0135967f99 (patch) | |
tree | 74afe3bf3efe15aa82bcd0272b2b0f4d48c2d837 /plugins/pluginWASAPI/plugin_wasapi_utils.cxx | |
parent | 7908865936604036e6f200f1b5e069f8752f3a3a (diff) | |
download | doubango-631fffee8a28b1bec5ed1f1d26a20e0135967f99.zip doubango-631fffee8a28b1bec5ed1f1d26a20e0135967f99.tar.gz |
-
Diffstat (limited to 'plugins/pluginWASAPI/plugin_wasapi_utils.cxx')
-rw-r--r-- | plugins/pluginWASAPI/plugin_wasapi_utils.cxx | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/plugins/pluginWASAPI/plugin_wasapi_utils.cxx b/plugins/pluginWASAPI/plugin_wasapi_utils.cxx new file mode 100644 index 0000000..bc2d45e --- /dev/null +++ b/plugins/pluginWASAPI/plugin_wasapi_utils.cxx @@ -0,0 +1,81 @@ +/* Copyright (C) 2013 Mamadou DIOP +* Copyright (C) 2013 Doubango Telecom <http://www.doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +*/ +#include "plugin_wasapi_utils.h" + +#include "tsk_debug.h" + +bool WASAPIUtils::g_bStarted = false; + +HRESULT WASAPIUtils::Startup() +{ + if(!g_bStarted) + { + HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); + if(SUCCEEDED(hr) || hr == 0x80010106) // 0x80010106 when called from managed code (e.g. Boghe) - More info: http://support.microsoft.com/kb/824480 + { + hr = S_OK; + } + g_bStarted = SUCCEEDED(hr); + return hr; + } + return S_OK; +} + +HRESULT WASAPIUtils::Shutdown() +{ + return S_OK; +} + +void WASAPIUtils::PrintError(const char* pcFileName, const char* pcFuncName, unsigned nLineNumber, HRESULT hr) +{ + CHAR message[1024] = {0}; + +#if PLUGIN_WASAPI_UNDER_WINDOWS_RT + // FormatMessageA not allowed on the Store + static WCHAR wBuff[1024] = {0}; + FormatMessageW( + FORMAT_MESSAGE_FROM_SYSTEM, + tsk_null, + hr, + 0, + wBuff, + sizeof(wBuff)-1, + tsk_null); + WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wBuff, wcslen(wBuff), message, sizeof(message) - 1, NULL, NULL); +#else +#ifdef _WIN32_WCE + FormatMessage +#else + FormatMessageA +#endif + ( +#if !PLUGIN_WASAPI_UNDER_WINDOWS_RT + FORMAT_MESSAGE_ALLOCATE_BUFFER | +#endif + FORMAT_MESSAGE_FROM_SYSTEM, + tsk_null, + hr, + 0, + message, + sizeof(message) - 1, + tsk_null); +#endif + + TSK_DEBUG_ERROR("[WASAPI] File:%s\n Function=%s\n Line:%u\n Message:%s", pcFileName, pcFuncName, nLineNumber, message); +}
\ No newline at end of file |