Ticket #4561: snd_detect_openal_complete_wmi_removal.patch

File snd_detect_openal_complete_wmi_removal.patch, 29.6 KB (added by Itms, 7 years ago)
  • build/premake/premake4.lua

     
    803803    extern_libs = {
    804804        "boost",
    805805        "sdl",
     806        "openal",
    806807        "opengl",
    807808        "libpng",
    808809        "zlib",
  • source/lib/snd.cpp

     
     1/* Copyright (c) 2017 Wildfire Games
     2 *
     3 * Permission is hereby granted, free of charge, to any person obtaining
     4 * a copy of this software and associated documentation files (the
     5 * "Software"), to deal in the Software without restriction, including
     6 * without limitation the rights to use, copy, modify, merge, publish,
     7 * distribute, sublicense, and/or sell copies of the Software, and to
     8 * permit persons to whom the Software is furnished to do so, subject to
     9 * the following conditions:
     10 *
     11 * The above copyright notice and this permission notice shall be included
     12 * in all copies or substantial portions of the Software.
     13 *
     14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
     18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     21 */
     22
     23/*
     24 * sound card detection.
     25 */
     26
     27#include "precompiled.h"
     28#include "lib/snd.h"
     29
     30#include <stdio.h>
     31#include <stdlib.h>
     32
     33#include "lib/external_libraries/openal.h"
     34
     35std::string snd_card;
     36std::string snd_drv_ver;
     37
     38void snd_detect()
     39{
     40    // OpenAL alGetString might not return anything interesting on certain platforms
     41    // (see https://stackoverflow.com/questions/28960638 for an example).
     42    // However our previous code supported only Windows, and alGetString does work on
     43    // Windows, so this is an improvement.
     44
     45    // Sound cards
     46
     47    const ALCchar* devices = NULL;
     48    if (alcIsExtensionPresent(NULL, "ALC_enumeration_EXT") == AL_TRUE)
     49    {
     50        if (alcIsExtensionPresent(NULL, "ALC_enumerate_all_EXT") == AL_TRUE)
     51            devices = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
     52        else
     53            devices = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
     54    }
     55    WARN_IF_FALSE(devices);
     56
     57    snd_card.clear();
     58    do {
     59        snd_card += devices;
     60        devices += strlen(devices) + 1;
     61        snd_card += "; ";
     62    } while (*devices);
     63
     64    // Driver version
     65    snd_drv_ver = alGetString(AL_VERSION);
     66}
  • source/lib/snd.h

    Property changes on: source/lib/snd.cpp
    ___________________________________________________________________
    Added: svn:eol-style
    ## -0,0 +1 ##
    +native
    \ No newline at end of property
     
     1/* Copyright (c) 2017 Wildfire Games
     2 *
     3 * Permission is hereby granted, free of charge, to any person obtaining
     4 * a copy of this software and associated documentation files (the
     5 * "Software"), to deal in the Software without restriction, including
     6 * without limitation the rights to use, copy, modify, merge, publish,
     7 * distribute, sublicense, and/or sell copies of the Software, and to
     8 * permit persons to whom the Software is furnished to do so, subject to
     9 * the following conditions:
     10 *
     11 * The above copyright notice and this permission notice shall be included
     12 * in all copies or substantial portions of the Software.
     13 *
     14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
     18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     21 */
     22
     23/*
     24 * sound card detection.
     25 */
     26
     27#ifndef INCLUDED_SND
     28#define INCLUDED_SND
     29
     30#include <string>
     31
     32/**
     33 * description of sound card.
     34 **/
     35extern std::string snd_card;
     36
     37/**
     38 * sound driver identification and version.
     39 **/
     40extern std::string snd_drv_ver;
     41
     42/**
     43 * detect sound card and set the above information.
     44 **/
     45extern void snd_detect();
     46
     47#endif  // #ifndef INCLUDED_SND
  • source/lib/sysdep/gfx.cpp

    Property changes on: source/lib/snd.h
    ___________________________________________________________________
    Added: svn:eol-style
    ## -0,0 +1 ##
    +native
    \ No newline at end of property
     
    3939
    4040std::wstring CardName()
    4141{
    42     // GL_VENDOR+GL_RENDERER are good enough here, so we don't use wgfx_CardName,
    43     // plus that can cause crashes with Nvidia Optimus and some netbooks
     42    // GL_VENDOR+GL_RENDERER are good enough here, so we don't use WMI to detect the cards.
     43    // On top of that WMI can cause crashes with Nvidia Optimus and some netbooks
    4444    // see http://trac.wildfiregames.com/ticket/1952
    4545    //     http://trac.wildfiregames.com/ticket/1575
    4646    wchar_t cardName[128];
  • source/lib/sysdep/os/win/wgfx.cpp

     
    1 /* Copyright (c) 2010 Wildfire Games
     1/* Copyright (c) 2017 Wildfire Games
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
    44 * a copy of this software and associated documentation files (the
     
    3030#include "lib/sysdep/gfx.h"
    3131#include "lib/sysdep/os/win/wdll_ver.h"
    3232#include "lib/sysdep/os/win/wutil.h"
    33 #include "lib/sysdep/os/win/wmi.h"
    3433
    3534#if MSC_VERSION
    3635#pragma comment(lib, "advapi32.lib")    // registry
     
    137136}
    138137
    139138
    140 Status wgfx_CardName(wchar_t* cardName, size_t numChars)
    141 {
    142     WmiInstances instances;
    143     RETURN_STATUS_IF_ERR(wmi_GetClassInstances(L"Win32_VideoController", instances));
    144     wchar_t* pos = cardName;
    145     for(WmiInstances::iterator it = instances.begin(); it != instances.end(); ++it)
    146     {
    147         if((*it)[L"Availability"].intVal == 8)  // offline
    148             continue;
    149         const int ret = swprintf_s(pos, numChars-(pos-cardName), L"%ls; ", (*it)[L"Caption"].bstrVal);
    150         if(ret > 0)
    151             pos += ret;
    152         return INFO::OK;
    153     }
    154 
    155     return ERR::FAIL;   // no active card found
    156 }
    157 
    158 
    159139std::wstring wgfx_DriverInfo()
    160140{
    161141    VersionList versionList;
  • source/lib/sysdep/os/win/wgfx.h

     
    1 /* Copyright (c) 2010 Wildfire Games
     1/* Copyright (c) 2017 Wildfire Games
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
    44 * a copy of this software and associated documentation files (the
     
    2323#ifndef INCLUDED_WGFX
    2424#define INCLUDED_WGFX
    2525
    26 extern Status wgfx_CardName(wchar_t* cardName, size_t numChars);
    2726extern std::wstring wgfx_DriverInfo();
    2827
    2928#endif  // #ifndef INCLUDED_WGFX
  • source/lib/sysdep/os/win/wmi.cpp

     
    1 /* Copyright (c) 2011 Wildfire Games
    2  *
    3  * Permission is hereby granted, free of charge, to any person obtaining
    4  * a copy of this software and associated documentation files (the
    5  * "Software"), to deal in the Software without restriction, including
    6  * without limitation the rights to use, copy, modify, merge, publish,
    7  * distribute, sublicense, and/or sell copies of the Software, and to
    8  * permit persons to whom the Software is furnished to do so, subject to
    9  * the following conditions:
    10  *
    11  * The above copyright notice and this permission notice shall be included
    12  * in all copies or substantial portions of the Software.
    13  *
    14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    21  */
    22 
    23 /*
    24  * wrapper for Windows Management Instrumentation
    25  */
    26 
    27 #include "precompiled.h"
    28 #include "lib/sysdep/os/win/wmi.h"
    29 
    30 #include <wbemidl.h>
    31 
    32 #include "lib/module_init.h"
    33 
    34 #pragma comment(lib, "wbemuuid.lib")
    35 
    36 
    37 static IWbemServices* pSvc;
    38 
    39 _COM_SMARTPTR_TYPEDEF(IWbemLocator, __uuidof(IWbemLocator));
    40 _COM_SMARTPTR_TYPEDEF(IWbemClassObject, __uuidof(IWbemClassObject));
    41 _COM_SMARTPTR_TYPEDEF(IEnumWbemClassObject, __uuidof(IEnumWbemClassObject));
    42 
    43 static ModuleInitState initState;
    44 
    45 static bool didInitCOM = false;
    46 
    47 static Status Init()
    48 {
    49     HRESULT hr;
    50 
    51     hr = CoInitialize(0);
    52     ENSURE(hr == S_OK || hr == S_FALSE);    // S_FALSE => already initialized
    53 
    54     // balance calls to CoInitialize and CoUninitialize
    55     if (hr == S_FALSE)
    56         CoUninitialize();
    57     else if (hr == S_OK)
    58         didInitCOM = true;
    59 
    60     hr = CoInitializeSecurity(0, -1, 0, 0, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, 0, EOAC_NONE, 0);
    61     if(FAILED(hr))
    62         WARN_RETURN(ERR::_2);
    63 
    64     {
    65         IWbemLocatorPtr pLoc = 0;
    66         hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (void**)&pLoc);
    67         if(FAILED(hr))
    68             WARN_RETURN(ERR::_3);
    69 
    70         hr = pLoc->ConnectServer(_bstr_t(L"ROOT\\CIMV2"), 0, 0, 0, 0, 0, 0, &pSvc);
    71         if(FAILED(hr))
    72             return ERR::_4; // NOWARN (happens if WMI service is disabled)
    73     }
    74 
    75     hr = CoSetProxyBlanket(pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, 0, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, 0, EOAC_NONE);
    76     if(FAILED(hr))
    77         WARN_RETURN(ERR::_5);
    78 
    79     return INFO::OK;
    80 }
    81 
    82 static void Shutdown()
    83 {
    84     pSvc->Release();
    85 
    86     if (didInitCOM)
    87     {
    88         /* From MSDN documentation: A thread must call CoUninitialize once for each successful call
    89          * it has made to the CoInitialize or CoInitializeEx function, including any call that returns
    90          * S_FALSE. Only the CoUninitialize call corresponding to the CoInitialize or CoInitializeEx
    91          * call that initialized the library can close it.
    92          *
    93          * So it should be perfectly safe to call this, since it balances out the CoInitialize in Init
    94          */
    95         CoUninitialize();
    96         didInitCOM = false;
    97     }
    98 }
    99 
    100 void wmi_Shutdown()
    101 {
    102     ModuleShutdown(&initState, Shutdown);
    103 }
    104 
    105 
    106 Status wmi_GetClassInstances(const wchar_t* className, WmiInstances& instances)
    107 {
    108     RETURN_STATUS_IF_ERR(ModuleInit(&initState, Init));
    109 
    110     IEnumWbemClassObjectPtr pEnum = 0;
    111     wchar_t query[200];
    112     swprintf_s(query, ARRAY_SIZE(query), L"SELECT * FROM %ls", className);
    113     HRESULT hr = pSvc->ExecQuery(L"WQL", _bstr_t(query), WBEM_FLAG_FORWARD_ONLY|WBEM_FLAG_RETURN_IMMEDIATELY, 0, &pEnum);
    114     if(FAILED(hr))
    115         WARN_RETURN(ERR::FAIL);
    116     ENSURE(pEnum);
    117 
    118     for(;;)
    119     {
    120         IWbemClassObjectPtr pObj = 0;
    121         ULONG numReturned = 0;
    122         hr = pEnum->Next((LONG)WBEM_INFINITE, 1, &pObj, &numReturned);
    123         if(FAILED(hr))
    124             WARN_RETURN(ERR::FAIL);
    125         if(numReturned == 0)
    126             break;
    127         ENSURE(pEnum);
    128 
    129         WmiInstance instance;
    130         pObj->BeginEnumeration(WBEM_FLAG_NONSYSTEM_ONLY);
    131         for(;;)
    132         {
    133             BSTR name = NULL;
    134             VARIANT value;
    135             VariantInit(&value);
    136             if(pObj->Next(0, &name, &value, 0, 0) != WBEM_S_NO_ERROR)
    137             {
    138                 SysFreeString(name);
    139                 break;
    140             }
    141             instance[name] = value;
    142             SysFreeString(name);
    143         }
    144         instances.push_back(instance);
    145     }
    146 
    147     return INFO::OK;
    148 }
  • source/lib/sysdep/os/win/wmi.h

    Property changes on: source/lib/sysdep/os/win/wmi.cpp
    ___________________________________________________________________
    Deleted: svn:eol-style
    ## -1 +0,0 ##
    -native
    \ No newline at end of property
     
    1 /* Copyright (c) 2010 Wildfire Games
    2  *
    3  * Permission is hereby granted, free of charge, to any person obtaining
    4  * a copy of this software and associated documentation files (the
    5  * "Software"), to deal in the Software without restriction, including
    6  * without limitation the rights to use, copy, modify, merge, publish,
    7  * distribute, sublicense, and/or sell copies of the Software, and to
    8  * permit persons to whom the Software is furnished to do so, subject to
    9  * the following conditions:
    10  *
    11  * The above copyright notice and this permission notice shall be included
    12  * in all copies or substantial portions of the Software.
    13  *
    14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    21  */
    22 
    23 /*
    24  * wrapper for Windows Management Instrumentation
    25  */
    26 
    27 #ifndef INCLUDED_WMI
    28 #define INCLUDED_WMI
    29 
    30 #include <map>
    31 
    32 // note: we expose the VARIANT value as returned by WMI. this allows other
    33 // modules to use the values they want directly, rather than forcing
    34 // everything to be converted to/parsed from strings. it does drag in
    35 // OLE headers, but this module is entirely Windows-specific anyway.
    36 #define _WIN32_DCOM
    37 #include "lib/sysdep/os/win/win.h"
    38 #include <comdef.h> // VARIANT
    39 // contains name and value of all instance properties
    40 typedef std::map<std::wstring, VARIANT> WmiInstance;
    41 
    42 typedef std::vector<WmiInstance> WmiInstances;
    43 
    44 /**
    45  * get all instances of the requested class.
    46  **/
    47 extern Status wmi_GetClassInstances(const wchar_t* className, WmiInstances& instances);
    48 
    49 extern void wmi_Shutdown();
    50 
    51 #endif  // #ifndef INCLUDED_WMI
  • source/lib/sysdep/os/win/wsnd.cpp

    Property changes on: source/lib/sysdep/os/win/wmi.h
    ___________________________________________________________________
    Deleted: svn:eol-style
    ## -1 +0,0 ##
    -native
    \ No newline at end of property
     
    1 /* Copyright (c) 2010 Wildfire Games
    2  *
    3  * Permission is hereby granted, free of charge, to any person obtaining
    4  * a copy of this software and associated documentation files (the
    5  * "Software"), to deal in the Software without restriction, including
    6  * without limitation the rights to use, copy, modify, merge, publish,
    7  * distribute, sublicense, and/or sell copies of the Software, and to
    8  * permit persons to whom the Software is furnished to do so, subject to
    9  * the following conditions:
    10  *
    11  * The above copyright notice and this permission notice shall be included
    12  * in all copies or substantial portions of the Software.
    13  *
    14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    21  */
    22 
    23 /*
    24  * sound card detection on Windows.
    25  */
    26 
    27 #include "precompiled.h"
    28 #include "lib/sysdep/snd.h"
    29 
    30 #include <stdio.h>
    31 #include <stdlib.h>
    32 #include <string>
    33 #include <set>
    34 
    35 #include "lib/file/file_system.h"
    36 #include "lib/sysdep/os/win/wdll_ver.h"
    37 #include "lib/sysdep/os/win/wversion.h"
    38 #include "lib/sysdep/os/win/wutil.h"
    39 #include "lib/sysdep/os/win/wmi.h"
    40 
    41 
    42 static bool IsOpenAlDllName(const Path::String& name)
    43 {
    44     // (matches "*oal.dll" and "*OpenAL*", as with OpenAL router's search)
    45     return name.find(L"oal.dll") != Path::String::npos || name.find(L"OpenAL") != Path::String::npos;
    46 }
    47 
    48 // ensures each OpenAL DLL is only listed once (even if present in several
    49 // directories on our search path).
    50 typedef std::set<Path::String> StringSet;
    51 
    52 // find all OpenAL DLLs in a dir.
    53 // call in library search order (exe dir, then win sys dir); otherwise,
    54 // DLLs in the executable's starting directory hide those of the
    55 // same name in the system directory.
    56 static void add_oal_dlls_in_dir(const OsPath& path, StringSet& dlls, VersionList& versionList)
    57 {
    58     CFileInfos files;
    59     (void)GetDirectoryEntries(path, &files, 0);
    60     for(size_t i = 0; i < files.size(); i++)
    61     {
    62         const Path::String name = files[i].Name().string();
    63         if(!IsOpenAlDllName(name))
    64             continue;
    65 
    66         // already in StringSet (i.e. has already been wdll_ver_list_add-ed)
    67         std::pair<StringSet::iterator, bool> ret = dlls.insert(name);
    68         if(!ret.second) // insert failed - element already there
    69             continue;
    70 
    71         wdll_ver_Append(path / name, versionList);
    72     }
    73 }
    74 
    75 
    76 //-----------------------------------------------------------------------------
    77 // DirectSound driver version
    78 
    79 // we've seen audio problems caused by buggy DirectSound drivers (because
    80 // OpenAL can use them in its implementation), so their version should be
    81 // retrieved as well. the only way I know of is to enumerate all DS devices.
    82 //
    83 // unfortunately this fails with Vista's DS emulation - it returns some
    84 // GUID crap as the module name. to avoidc crashing when attempting to get
    85 // the version info for that bogus driver path, we'll skip this code there.
    86 // (delay-loading dsound.dll eliminates any overhead)
    87 
    88 static OsPath directSoundDriverPath;
    89 
    90 // store sound card name and path to DirectSound driver.
    91 // called for each DirectSound driver, but aborts after first valid driver.
    92 static BOOL CALLBACK DirectSoundCallback(void* guid, const wchar_t* UNUSED(description),
    93     const wchar_t* module, void* UNUSED(cbData))
    94 {
    95     // skip first dummy entry (description == "Primary Sound Driver")
    96     if(guid == NULL)
    97         return TRUE;    // continue calling
    98 
    99     // note: $system\\drivers is not in LoadLibrary's search list,
    100     // so we have to give the full pathname.
    101     directSoundDriverPath = wutil_SystemPath()/"drivers" / module;
    102 
    103     // we assume the first "driver name" (sound card) is the one we want;
    104     // stick with that and stop calling.
    105     return FALSE;
    106 }
    107 
    108 static const OsPath& GetDirectSoundDriverPath()
    109 {
    110 #define DS_OK 0
    111     typedef BOOL (CALLBACK* LPDSENUMCALLBACKW)(void*, const wchar_t*, const wchar_t*, void*);
    112     HMODULE hDsoundDll = LoadLibraryW(L"dsound.dll");
    113     WUTIL_FUNC(pDirectSoundEnumerateW, HRESULT, (LPDSENUMCALLBACKW, void*));
    114     WUTIL_IMPORT(hDsoundDll, DirectSoundEnumerateW, pDirectSoundEnumerateW);
    115     if(pDirectSoundEnumerateW)
    116     {
    117         HRESULT ret = pDirectSoundEnumerateW(DirectSoundCallback, (void*)0);
    118         ENSURE(ret == DS_OK);
    119     }
    120     FreeLibrary(hDsoundDll);
    121 
    122     return directSoundDriverPath;
    123 }
    124 
    125 //-----------------------------------------------------------------------------
    126 
    127 Status win_get_snd_info()
    128 {
    129     WmiInstances instances;
    130     RETURN_STATUS_IF_ERR(wmi_GetClassInstances(L"Win32_SoundDevice", instances));
    131     std::set<std::wstring> names;   // get rid of duplicate "High Definition Audio Device" entries
    132     for(WmiInstances::iterator it = instances.begin(); it != instances.end(); ++it)
    133     {
    134         if((*it)[L"Availability"].intVal != 8)  // not offline
    135             names.insert(std::wstring((*it)[L"ProductName"].bstrVal));
    136     }
    137     wchar_t* pos = snd_card;
    138     for(std::set<std::wstring>::const_iterator it = names.begin(); it != names.end(); ++it)
    139     {
    140         const int ret = swprintf_s(pos, SND_CARD_LEN-(pos-snd_card), L"%ls; ", it->c_str());
    141         if(ret > 0)
    142             pos += ret;
    143     }
    144 
    145     // find all DLLs related to OpenAL and retrieve their versions.
    146     VersionList versionList;
    147     if(wversion_Number() < WVERSION_VISTA)
    148         wdll_ver_Append(GetDirectSoundDriverPath(), versionList);
    149     StringSet dlls; // ensures uniqueness
    150     (void)add_oal_dlls_in_dir(wutil_ExecutablePath(), dlls, versionList);
    151     (void)add_oal_dlls_in_dir(wutil_SystemPath(), dlls, versionList);
    152     wcscpy_s(snd_drv_ver, SND_DRV_VER_LEN, versionList.c_str());
    153 
    154     return INFO::OK;
    155 }
  • source/lib/sysdep/os/win/wsnd.h

    Property changes on: source/lib/sysdep/os/win/wsnd.cpp
    ___________________________________________________________________
    Deleted: svn:eol-style
    ## -1 +0,0 ##
    -native
    \ No newline at end of property
     
    1 /* Copyright (c) 2010 Wildfire Games
    2  *
    3  * Permission is hereby granted, free of charge, to any person obtaining
    4  * a copy of this software and associated documentation files (the
    5  * "Software"), to deal in the Software without restriction, including
    6  * without limitation the rights to use, copy, modify, merge, publish,
    7  * distribute, sublicense, and/or sell copies of the Software, and to
    8  * permit persons to whom the Software is furnished to do so, subject to
    9  * the following conditions:
    10  *
    11  * The above copyright notice and this permission notice shall be included
    12  * in all copies or substantial portions of the Software.
    13  *
    14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    21  */
    22 
    23 #ifndef INCLUDED_WSND
    24 #define INCLUDED_WSND
    25 
    26 extern Status win_get_snd_info();
    27 
    28 #endif  // #ifndef INCLUDED_WSND
  • source/lib/sysdep/snd.cpp

    Property changes on: source/lib/sysdep/os/win/wsnd.h
    ___________________________________________________________________
    Deleted: svn:eol-style
    ## -1 +0,0 ##
    -native
    \ No newline at end of property
     
    1 /* Copyright (c) 2010 Wildfire Games
    2  *
    3  * Permission is hereby granted, free of charge, to any person obtaining
    4  * a copy of this software and associated documentation files (the
    5  * "Software"), to deal in the Software without restriction, including
    6  * without limitation the rights to use, copy, modify, merge, publish,
    7  * distribute, sublicense, and/or sell copies of the Software, and to
    8  * permit persons to whom the Software is furnished to do so, subject to
    9  * the following conditions:
    10  *
    11  * The above copyright notice and this permission notice shall be included
    12  * in all copies or substantial portions of the Software.
    13  *
    14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    21  */
    22 
    23 /*
    24  * sound card detection.
    25  */
    26 
    27 #include "precompiled.h"
    28 #include "lib/sysdep/snd.h"
    29 
    30 #if OS_WIN
    31 # include "lib/sysdep/os/win/wsnd.h"
    32 #endif
    33 
    34 
    35 wchar_t snd_card[SND_CARD_LEN];
    36 wchar_t snd_drv_ver[SND_DRV_VER_LEN];
    37 
    38 void snd_detect()
    39 {
    40     // note: OpenAL alGetString is worthless: it only returns
    41     // OpenAL API version and renderer (e.g. "Software").
    42 
    43 #if OS_WIN
    44     win_get_snd_info();
    45 #else
    46     // At least reset the values for unhandled platforms.
    47     ENSURE(SND_CARD_LEN >= 8 && SND_DRV_VER_LEN >= 8);  // protect strcpy
    48     wcscpy_s(snd_card, ARRAY_SIZE(snd_card), L"Unknown");
    49     wcscpy_s(snd_drv_ver, ARRAY_SIZE(snd_drv_ver), L"Unknown");
    50 #endif
    51 }
  • source/lib/sysdep/snd.h

    Property changes on: source/lib/sysdep/snd.cpp
    ___________________________________________________________________
    Deleted: svn:eol-style
    ## -1 +0,0 ##
    -native
    \ No newline at end of property
     
    1 /* Copyright (c) 2015 Wildfire Games
    2  *
    3  * Permission is hereby granted, free of charge, to any person obtaining
    4  * a copy of this software and associated documentation files (the
    5  * "Software"), to deal in the Software without restriction, including
    6  * without limitation the rights to use, copy, modify, merge, publish,
    7  * distribute, sublicense, and/or sell copies of the Software, and to
    8  * permit persons to whom the Software is furnished to do so, subject to
    9  * the following conditions:
    10  *
    11  * The above copyright notice and this permission notice shall be included
    12  * in all copies or substantial portions of the Software.
    13  *
    14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    21  */
    22 
    23 /*
    24  * sound card detection.
    25  */
    26 
    27 #ifndef INCLUDED_SND
    28 #define INCLUDED_SND
    29 
    30 const size_t SND_CARD_LEN = 512;
    31 /**
    32  * description of sound card.
    33  **/
    34 extern wchar_t snd_card[SND_CARD_LEN];
    35 
    36 const size_t SND_DRV_VER_LEN = 512;
    37 /**
    38  * sound driver identification and version.
    39  **/
    40 extern wchar_t snd_drv_ver[SND_DRV_VER_LEN];
    41 
    42 /**
    43  * detect sound card and set the above information.
    44  **/
    45 extern void snd_detect();
    46 
    47 #endif  // #ifndef INCLUDED_SND
  • source/ps/GameSetup/GameSetup.cpp

    Property changes on: source/lib/sysdep/snd.h
    ___________________________________________________________________
    Deleted: svn:eol-style
    ## -1 +0,0 ##
    -native
    \ No newline at end of property
     
    100100#define MUST_INIT_X11 0
    101101#endif
    102102
    103 #if OS_WIN
    104 extern void wmi_Shutdown();
    105 #endif
    106 
    107103extern void restart_engine();
    108104
    109105#include <iostream>
     
    757753
    758754    g_Profiler2.ShutdownGPU();
    759755
    760     #if OS_WIN
    761         TIMER_BEGIN(L"shutdown wmi");
    762         wmi_Shutdown();
    763         TIMER_END(L"shutdown wmi");
    764     #endif
    765 
    766756    // Free cursors before shutting down SDL, as they may depend on SDL.
    767757    cursor_shutdown();
    768758
  • source/ps/GameSetup/HWDetect.cpp

     
    1 /* Copyright (C) 2015 Wildfire Games.
     1/* Copyright (C) 2017 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    2020#include "scriptinterface/ScriptInterface.h"
    2121
    2222#include "lib/ogl.h"
     23#include "lib/snd.h"
    2324#include "lib/svn_revision.h"
    2425#include "lib/timer.h"
    2526#include "lib/utf8.h"
     
    3031#include "lib/sysdep/gfx.h"
    3132#include "lib/sysdep/numa.h"
    3233#include "lib/sysdep/os_cpu.h"
    33 #include "lib/sysdep/snd.h"
    3434#if ARCH_X86_X64
    3535# include "lib/sysdep/arch/x86_x64/cache.h"
    3636# include "lib/sysdep/arch/x86_x64/topology.h"
     
    265265    scriptInterface.SetProperty(settings, "gfx_card", gfx::CardName());
    266266    scriptInterface.SetProperty(settings, "gfx_drv_ver", gfx::DriverInfo());
    267267
    268     scriptInterface.SetProperty(settings, "snd_card", std::wstring(snd_card));
    269     scriptInterface.SetProperty(settings, "snd_drv_ver", std::wstring(snd_drv_ver));
     268    scriptInterface.SetProperty(settings, "snd_card", snd_card);
     269    scriptInterface.SetProperty(settings, "snd_drv_ver", snd_drv_ver);
    270270
    271271    ReportGLLimits(scriptInterface, settings);
    272272
  • source/ps/Util.cpp

     
    1 /* Copyright (C) 2016 Wildfire Games.
     1/* Copyright (C) 2017 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    2121
    2222#include "lib/posix/posix_utsname.h"
    2323#include "lib/ogl.h"
     24#include "lib/snd.h"
    2425#include "lib/timer.h"
    2526#include "lib/bits.h"   // round_up
    2627#include "lib/allocators/shared_ptr.h"
    2728#include "lib/sysdep/sysdep.h"  // sys_OpenFile
    2829#include "lib/sysdep/gfx.h"
    29 #include "lib/sysdep/snd.h"
    3030#include "lib/sysdep/cpu.h"
    3131#include "lib/sysdep/os_cpu.h"
    3232#if ARCH_X86_X64
     
    137137    fprintf(f, "Video Mode     : %dx%d:%d\n", g_VideoMode.GetXRes(), g_VideoMode.GetYRes(), g_VideoMode.GetBPP());
    138138
    139139    // sound
    140     fprintf(f, "Sound Card     : %ls\n", snd_card);
    141     fprintf(f, "Sound Drivers  : %ls\n", snd_drv_ver);
     140    fprintf(f, "Sound Card     : %s\n", snd_card.c_str());
     141    fprintf(f, "Sound Drivers  : %s\n", snd_drv_ver.c_str());
    142142
    143143    // OpenGL extensions (write them last, since it's a lot of text)
    144144    const char* exts = ogl_ExtensionString();