From 0fb742581af9a16c5b421570bdec26ebbf19abfe Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 25 Jun 2017 22:47:37 -0700 Subject: [PATCH 1/8] CMake: remove duplicated call to find OpenAL --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25d78829bc..cfdea29ead 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -626,8 +626,6 @@ else() set(PNG png) endif() -find_package(OpenAL) - # Using static soundtouch from Externals # Unable to use system soundtouch library: We require shorts, not floats. add_subdirectory(Externals/soundtouch) From 56961f5561c22b5face92a27f71050ab74469dfb Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 25 Jun 2017 23:02:57 -0700 Subject: [PATCH 2/8] OpenALStream: don't include headers if not building --- Source/Core/AudioCommon/OpenALStream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index 25dd14e7b2..75ba493a07 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#if defined HAVE_OPENAL && HAVE_OPENAL + #include #include #include @@ -13,8 +15,6 @@ #include "Common/Thread.h" #include "Core/ConfigManager.h" -#if defined HAVE_OPENAL && HAVE_OPENAL - #ifdef _WIN32 #pragma comment(lib, "openal32.lib") #endif From 32470ef284485d9d5db73e115bc56e718524c81a Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 25 Jun 2017 23:12:44 -0700 Subject: [PATCH 3/8] clean up OpenALStream::Start() --- Source/Core/AudioCommon/OpenALStream.cpp | 67 +++++++++++------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index 75ba493a07..753a925288 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -24,48 +24,41 @@ // bool OpenALStream::Start() { - m_run_thread.Set(); - bool bReturn = false; - ALDeviceList pDeviceList; - if (pDeviceList.GetNumDevices()) - { - char* defDevName = pDeviceList.GetDeviceName(pDeviceList.GetDefaultDevice()); - - INFO_LOG(AUDIO, "Found OpenAL device %s", defDevName); - - ALCdevice* pDevice = alcOpenDevice(defDevName); - if (pDevice) - { - ALCcontext* pContext = alcCreateContext(pDevice, nullptr); - if (pContext) - { - // Used to determine an appropriate period size (2x period = total buffer size) - // ALCint refresh; - // alcGetIntegerv(pDevice, ALC_REFRESH, 1, &refresh); - // period_size_in_millisec = 1000 / refresh; - - alcMakeContextCurrent(pContext); - thread = std::thread(&OpenALStream::SoundLoop, this); - bReturn = true; - } - else - { - alcCloseDevice(pDevice); - PanicAlertT("OpenAL: can't create context for device %s", defDevName); - } - } - else - { - PanicAlertT("OpenAL: can't open device %s", defDevName); - } - } - else + if (!pDeviceList.GetNumDevices()) { PanicAlertT("OpenAL: can't find sound devices"); + return false; } - return bReturn; + char* defDevName = pDeviceList.GetDeviceName(pDeviceList.GetDefaultDevice()); + + INFO_LOG(AUDIO, "Found OpenAL device %s", defDevName); + + ALCdevice* pDevice = alcOpenDevice(defDevName); + if (!pDevice) + { + PanicAlertT("OpenAL: can't open device %s", defDevName); + return false; + } + + ALCcontext* pContext = alcCreateContext(pDevice, nullptr); + if (!pContext) + { + alcCloseDevice(pDevice); + PanicAlertT("OpenAL: can't create context for device %s", defDevName); + return false; + } + + // Used to determine an appropriate period size (2x period = total buffer size) + // ALCint refresh; + // alcGetIntegerv(pDevice, ALC_REFRESH, 1, &refresh); + // period_size_in_millisec = 1000 / refresh; + + alcMakeContextCurrent(pContext); + m_run_thread.Set(); + thread = std::thread(&OpenALStream::SoundLoop, this); + return true; } void OpenALStream::Stop() From 42ea1c8ecf079087ba6101a42995b64106a63a8f Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 25 Jun 2017 23:17:56 -0700 Subject: [PATCH 4/8] OpenAL: remove aldlist.cpp --- Source/Core/AudioCommon/AudioCommon.vcxproj | 2 - .../AudioCommon/AudioCommon.vcxproj.filters | 2 - Source/Core/AudioCommon/CMakeLists.txt | 2 +- Source/Core/AudioCommon/OpenALStream.cpp | 15 +- Source/Core/AudioCommon/aldlist.cpp | 386 ------------------ Source/Core/AudioCommon/aldlist.h | 52 --- 6 files changed, 7 insertions(+), 452 deletions(-) delete mode 100644 Source/Core/AudioCommon/aldlist.cpp delete mode 100644 Source/Core/AudioCommon/aldlist.h diff --git a/Source/Core/AudioCommon/AudioCommon.vcxproj b/Source/Core/AudioCommon/AudioCommon.vcxproj index dad6e891ed..1429782557 100644 --- a/Source/Core/AudioCommon/AudioCommon.vcxproj +++ b/Source/Core/AudioCommon/AudioCommon.vcxproj @@ -36,7 +36,6 @@ - @@ -52,7 +51,6 @@ - diff --git a/Source/Core/AudioCommon/AudioCommon.vcxproj.filters b/Source/Core/AudioCommon/AudioCommon.vcxproj.filters index 661c6ce0ea..9d7975c53f 100644 --- a/Source/Core/AudioCommon/AudioCommon.vcxproj.filters +++ b/Source/Core/AudioCommon/AudioCommon.vcxproj.filters @@ -6,7 +6,6 @@ - @@ -30,7 +29,6 @@ - diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt index 7ede29eb41..7ed1eba65d 100644 --- a/Source/Core/AudioCommon/CMakeLists.txt +++ b/Source/Core/AudioCommon/CMakeLists.txt @@ -39,7 +39,7 @@ if(ENABLE_OPENAL) find_package(OpenAL) if(OPENAL_FOUND) message(STATUS "OpenAL found, enabling OpenAL sound backend") - target_sources(audiocommon PRIVATE OpenALStream.cpp aldlist.cpp) + target_sources(audiocommon PRIVATE OpenALStream.cpp) target_link_libraries(audiocommon PRIVATE OpenAL::OpenAL) target_compile_definitions(audiocommon PRIVATE HAVE_OPENAL=1) else() diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index 753a925288..ffb0bf93dd 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -9,7 +9,6 @@ #include #include "AudioCommon/OpenALStream.h" -#include "AudioCommon/aldlist.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/Thread.h" @@ -24,21 +23,19 @@ // bool OpenALStream::Start() { - ALDeviceList pDeviceList; - if (!pDeviceList.GetNumDevices()) + if (!alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT")) { PanicAlertT("OpenAL: can't find sound devices"); return false; } - char* defDevName = pDeviceList.GetDeviceName(pDeviceList.GetDefaultDevice()); + const char* defaultDeviceName = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER); + INFO_LOG(AUDIO, "Found OpenAL device %s", defaultDeviceName); - INFO_LOG(AUDIO, "Found OpenAL device %s", defDevName); - - ALCdevice* pDevice = alcOpenDevice(defDevName); + ALCdevice* pDevice = alcOpenDevice(defaultDeviceName); if (!pDevice) { - PanicAlertT("OpenAL: can't open device %s", defDevName); + PanicAlertT("OpenAL: can't open device %s", defaultDeviceName); return false; } @@ -46,7 +43,7 @@ bool OpenALStream::Start() if (!pContext) { alcCloseDevice(pDevice); - PanicAlertT("OpenAL: can't create context for device %s", defDevName); + PanicAlertT("OpenAL: can't create context for device %s", defaultDeviceName); return false; } diff --git a/Source/Core/AudioCommon/aldlist.cpp b/Source/Core/AudioCommon/aldlist.cpp deleted file mode 100644 index accd13c595..0000000000 --- a/Source/Core/AudioCommon/aldlist.cpp +++ /dev/null @@ -1,386 +0,0 @@ -// Copyright 2009 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -/* - * Copyright (c) 2006, Creative Labs Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of - * conditions and - * the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions - * and the following disclaimer in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Creative Labs Inc. nor the names of its contributors may be used to - * endorse or - * promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "AudioCommon/aldlist.h" -#include "Common/CommonFuncs.h" -#include "Common/CommonTypes.h" -#ifdef _WIN32 -#include "../../../Externals/OpenAL/include/al.h" -#include "../../../Externals/OpenAL/include/alc.h" -#elif defined(__APPLE__) -#include -#include -#else -#include -#include -#endif - -/* - * Init call - */ -ALDeviceList::ALDeviceList() -{ - ALDEVICEINFO ALDeviceInfo; - - // DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec - // version #, and extension support - vDeviceInfo.clear(); - vDeviceInfo.reserve(10); - - defaultDeviceIndex = 0; - - // grab function pointers for 1.0-API functions, and if successful proceed to enumerate all - // devices - // if (LoadOAL10Library(nullptr, &ALFunction) == TRUE) { - if (alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT")) - { - const char* devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER); - const char* defaultDeviceName = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER); - // go through device list (each device terminated with a single nullptr, list terminated with - // double nullptr) - for (s32 index = 0; devices != nullptr && strlen(devices) > 0; - index++, devices += strlen(devices) + 1) - { - if (strcmp(defaultDeviceName, devices) == 0) - { - defaultDeviceIndex = index; - } - ALCdevice* device = alcOpenDevice(devices); - if (device) - { - ALCcontext* context = alcCreateContext(device, nullptr); - if (context) - { - alcMakeContextCurrent(context); - // if new actual device name isn't already in the list, then add it... - const char* actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER); - bool bNewName = true; - for (s32 i = 0; i < GetNumDevices(); i++) - { - if (strcmp(GetDeviceName(i), actualDeviceName) == 0) - { - bNewName = false; - } - } - if ((bNewName) && (actualDeviceName != nullptr) && (strlen(actualDeviceName) > 0)) - { - ALDeviceInfo.bSelected = true; - ALDeviceInfo.strDeviceName = actualDeviceName; - alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(s32), &ALDeviceInfo.iMajorVersion); - alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(s32), &ALDeviceInfo.iMinorVersion); - - ALDeviceInfo.pvstrExtensions = new std::vector; - - // Check for ALC Extensions - if (alcIsExtensionPresent(device, "ALC_EXT_CAPTURE") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_CAPTURE"); - if (alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_EFX"); - - // Check for AL Extensions - if (alIsExtensionPresent("AL_EXT_OFFSET") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_OFFSET"); - - if (alIsExtensionPresent("AL_EXT_LINEAR_DISTANCE") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_LINEAR_DISTANCE"); - if (alIsExtensionPresent("AL_EXT_EXPONENT_DISTANCE") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_EXPONENT_DISTANCE"); - - if (alIsExtensionPresent("EAX2.0") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX2.0"); - if (alIsExtensionPresent("EAX3.0") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX3.0"); - if (alIsExtensionPresent("EAX4.0") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX4.0"); - if (alIsExtensionPresent("EAX5.0") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX5.0"); - - if (alIsExtensionPresent("EAX-RAM") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX-RAM"); - - // Get Source Count - ALDeviceInfo.uiSourceCount = GetMaxNumSources(); - - vDeviceInfo.push_back(ALDeviceInfo); - } - alcMakeContextCurrent(nullptr); - alcDestroyContext(context); - } - alcCloseDevice(device); - } - } - } - //} - - ResetFilters(); -} - -/* - * Exit call - */ -ALDeviceList::~ALDeviceList() -{ - for (auto& di : vDeviceInfo) - { - if (di.pvstrExtensions) - { - di.pvstrExtensions->clear(); - delete di.pvstrExtensions; - } - } - - vDeviceInfo.clear(); -} - -/* - * Returns the number of devices in the complete device list - */ -s32 ALDeviceList::GetNumDevices() -{ - return (s32)vDeviceInfo.size(); -} - -/* - * Returns the device name at an index in the complete device list - */ -char* ALDeviceList::GetDeviceName(s32 index) -{ - if (index < GetNumDevices()) - return (char*)vDeviceInfo[index].strDeviceName.c_str(); - else - return nullptr; -} - -/* - * Returns the major and minor version numbers for a device at a specified index in the complete - * list - */ -void ALDeviceList::GetDeviceVersion(s32 index, s32* major, s32* minor) -{ - if (index < GetNumDevices()) - { - if (major) - *major = vDeviceInfo[index].iMajorVersion; - if (minor) - *minor = vDeviceInfo[index].iMinorVersion; - } -} - -/* - * Returns the maximum number of Sources that can be generate on the given device - */ -u32 ALDeviceList::GetMaxNumSources(s32 index) -{ - if (index < GetNumDevices()) - return vDeviceInfo[index].uiSourceCount; - else - return 0; -} - -/* - * Checks if the extension is supported on the given device - */ -bool ALDeviceList::IsExtensionSupported(s32 index, char* szExtName) -{ - bool bReturn = false; - - if (index < GetNumDevices()) - { - for (auto& ext : *vDeviceInfo[index].pvstrExtensions) - { - if (!strcasecmp(ext.c_str(), szExtName)) - { - bReturn = true; - break; - } - } - } - - return bReturn; -} - -/* - * returns the index of the default device in the complete device list - */ -s32 ALDeviceList::GetDefaultDevice() -{ - return defaultDeviceIndex; -} - -/* - * Deselects devices which don't have the specified minimum version - */ -void ALDeviceList::FilterDevicesMinVer(s32 major, s32 minor) -{ - s32 dMajor = 0, dMinor = 0; - for (u32 i = 0; i < vDeviceInfo.size(); i++) - { - GetDeviceVersion(i, &dMajor, &dMinor); - if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) - { - vDeviceInfo[i].bSelected = false; - } - } -} - -/* - * Deselects devices which don't have the specified maximum version - */ -void ALDeviceList::FilterDevicesMaxVer(s32 major, s32 minor) -{ - s32 dMajor = 0, dMinor = 0; - for (u32 i = 0; i < vDeviceInfo.size(); i++) - { - GetDeviceVersion(i, &dMajor, &dMinor); - if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) - { - vDeviceInfo[i].bSelected = false; - } - } -} - -/* - * Deselects device which don't support the given extension name - */ -void ALDeviceList::FilterDevicesExtension(char* szExtName) -{ - bool bFound; - - for (auto& di : vDeviceInfo) - { - bFound = false; - for (auto& ext : *di.pvstrExtensions) - { - if (!strcasecmp(ext.c_str(), szExtName)) - { - bFound = true; - break; - } - } - - if (!bFound) - di.bSelected = false; - } -} - -/* - * Resets all filtering, such that all devices are in the list - */ -void ALDeviceList::ResetFilters() -{ - for (s32 i = 0; i < GetNumDevices(); i++) - { - vDeviceInfo[i].bSelected = true; - } - - filterIndex = 0; -} - -/* - * Gets index of first filtered device - */ -s32 ALDeviceList::GetFirstFilteredDevice() -{ - s32 i; - - for (i = 0; i < GetNumDevices(); i++) - { - if (vDeviceInfo[i].bSelected == true) - { - break; - } - } - - filterIndex = i + 1; - return i; -} - -/* - * Gets index of next filtered device - */ -s32 ALDeviceList::GetNextFilteredDevice() -{ - s32 i; - - for (i = filterIndex; i < GetNumDevices(); i++) - { - if (vDeviceInfo[i].bSelected == true) - { - break; - } - } - - filterIndex = i + 1; - return i; -} - -/* - * Internal function to determine max number of Sources that can be generated - */ -u32 ALDeviceList::GetMaxNumSources() -{ - ALuint uiSources[256]; - u32 iSourceCount = 0; - - // Clear AL Error Code - alGetError(); - - // Generate up to 256 Sources, checking for any errors - for (iSourceCount = 0; iSourceCount < 256; iSourceCount++) - { - alGenSources(1, &uiSources[iSourceCount]); - if (alGetError() != AL_NO_ERROR) - break; - } - - // Release the Sources - alDeleteSources(iSourceCount, uiSources); - if (alGetError() != AL_NO_ERROR) - { - for (auto& uiSource : uiSources) - { - alDeleteSources(1, &uiSource); - } - } - - return iSourceCount; -} diff --git a/Source/Core/AudioCommon/aldlist.h b/Source/Core/AudioCommon/aldlist.h deleted file mode 100644 index 733c407ae7..0000000000 --- a/Source/Core/AudioCommon/aldlist.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2009 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -#include "Common/CommonTypes.h" - -#ifdef _WIN32 -#pragma warning(disable : 4786) // disable warning "identifier was truncated to -//'255' characters in the browser information" -#endif - -typedef struct -{ - std::string strDeviceName; - s32 iMajorVersion; - s32 iMinorVersion; - u32 uiSourceCount; - std::vector* pvstrExtensions; - bool bSelected; -} ALDEVICEINFO, *LPALDEVICEINFO; - -class ALDeviceList -{ -private: - std::vector vDeviceInfo; - s32 defaultDeviceIndex; - s32 filterIndex; - -public: - ALDeviceList(); - ~ALDeviceList(); - s32 GetNumDevices(); - char* GetDeviceName(s32 index); - void GetDeviceVersion(s32 index, s32* major, s32* minor); - u32 GetMaxNumSources(s32 index); - bool IsExtensionSupported(s32 index, char* szExtName); - s32 GetDefaultDevice(); - void FilterDevicesMinVer(s32 major, s32 minor); - void FilterDevicesMaxVer(s32 major, s32 minor); - void FilterDevicesExtension(char* szExtName); - void ResetFilters(); - s32 GetFirstFilteredDevice(); - s32 GetNextFilteredDevice(); - -private: - u32 GetMaxNumSources(); -}; From 18e70cdf917fc355e59558dce8614431a29cc5ed Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 25 Jun 2017 23:52:51 -0700 Subject: [PATCH 5/8] Only build OpenAL on Windows --- CMakeLists.txt | 1 - Source/Core/AudioCommon/CMakeLists.txt | 27 +++++++++--------------- Source/Core/AudioCommon/OpenALStream.cpp | 4 ++-- Source/Core/AudioCommon/OpenALStream.h | 15 +++---------- Source/VSProps/Base.props | 1 - 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfdea29ead..098caad8bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,6 @@ option(ENABLE_GENERIC "Enables generic build that should run on any little-endia option(ENABLE_HEADLESS "Enables running Dolphin as a headless variant" OFF) option(ENABLE_ALSA "Enables ALSA sound backend" ON) option(ENABLE_PULSEAUDIO "Enables PulseAudio sound backend" ON) -option(ENABLE_OPENAL "Enables OpenAL sound backend" ON) option(ENABLE_LLVM "Enables LLVM support, for disassembly" ON) # Maintainers: if you consider blanket disabling this for your users, please diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt index 7ed1eba65d..e39296d6cb 100644 --- a/Source/Core/AudioCommon/CMakeLists.txt +++ b/Source/Core/AudioCommon/CMakeLists.txt @@ -32,23 +32,6 @@ else() message(STATUS "ALSA explicitly disabled, disabling ALSA sound backend") endif() -if(ENABLE_OPENAL) - if(WIN32) - set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/Externals/OpenAL) - endif() - find_package(OpenAL) - if(OPENAL_FOUND) - message(STATUS "OpenAL found, enabling OpenAL sound backend") - target_sources(audiocommon PRIVATE OpenALStream.cpp) - target_link_libraries(audiocommon PRIVATE OpenAL::OpenAL) - target_compile_definitions(audiocommon PRIVATE HAVE_OPENAL=1) - else() - message(STATUS "OpenAL NOT found, disabling OpenAL sound backend") - endif() -else() - message(STATUS "OpenAL explicitly disabled, disabling OpenAL sound backend") -endif() - if(ENABLE_PULSEAUDIO) # PulseAudio ships with a PulseAudioConfig.cmake with no imported target # So we use our own FindPulseAudio instead with "MODULE" @@ -75,6 +58,16 @@ if(WIN32) ) target_link_libraries(audiocommon PRIVATE audiocommon_xaudio27) + set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/Externals/OpenAL) + find_package(OpenAL) + if(OPENAL_FOUND) + message(STATUS "OpenAL found, enabling OpenAL sound backend") + target_sources(audiocommon PRIVATE OpenALStream.cpp) + target_link_libraries(audiocommon PRIVATE OpenAL::OpenAL) + else() + message(FATAL_ERROR "OpenAL NOT found in Externals") + endif() + elseif(APPLE) target_sources(audiocommon PRIVATE CoreAudioSoundStream.cpp) endif() diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index ffb0bf93dd..1265b27ae2 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#if defined HAVE_OPENAL && HAVE_OPENAL +#ifdef _WIN32 #include #include @@ -347,4 +347,4 @@ void OpenALStream::SoundLoop() } } -#endif // HAVE_OPENAL +#endif // _WIN32 diff --git a/Source/Core/AudioCommon/OpenALStream.h b/Source/Core/AudioCommon/OpenALStream.h index 5e4b49c027..2fb7d8cd27 100644 --- a/Source/Core/AudioCommon/OpenALStream.h +++ b/Source/Core/AudioCommon/OpenALStream.h @@ -12,19 +12,10 @@ #include "Core/HW/AudioInterface.h" #include "Core/HW/SystemTimers.h" -#if defined HAVE_OPENAL && HAVE_OPENAL #ifdef _WIN32 #include #include #include -#elif defined __APPLE__ -#include -#include -#else -#include -#include -#include -#endif #define SFX_MAX_SOURCE 1 #define OAL_MAX_BUFFERS 32 @@ -40,7 +31,7 @@ #define FRAME_SURROUND_FLOAT SURROUND_CHANNELS* SIZE_FLOAT #define FRAME_SURROUND_SHORT SURROUND_CHANNELS* SIZE_SHORT #define FRAME_SURROUND_INT32 SURROUND_CHANNELS* SIZE_INT32 -#endif +#endif // _WIN32 // From AL_EXT_float32 #ifndef AL_FORMAT_STEREO_FLOAT32 @@ -63,7 +54,7 @@ class OpenALStream final : public SoundStream { -#if defined HAVE_OPENAL && HAVE_OPENAL +#ifdef _WIN32 public: OpenALStream() : uiSource(0) {} bool Start() override; @@ -87,5 +78,5 @@ private: ALfloat fVolume; u8 numBuffers; -#endif // HAVE_OPENAL +#endif // _WIN32 }; diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props index b7d04a6602..1bad01e9d0 100644 --- a/Source/VSProps/Base.props +++ b/Source/VSProps/Base.props @@ -61,7 +61,6 @@ SFML_STATIC;%(PreprocessorDefinitions) USE_ANALYTICS=1;%(PreprocessorDefinitions) CURL_STATICLIB;%(PreprocessorDefinitions) - HAVE_OPENAL=1;%(PreprocessorDefinitions) _ARCH_64=1;_M_X86_64=1;%(PreprocessorDefinitions) - $(ExternalsDir)OpenAL\lib;$(ExternalsDir)ffmpeg\lib;%(AdditionalLibraryDirectories) + $(ExternalsDir)ffmpeg\lib;%(AdditionalLibraryDirectories) avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;%(AdditionalDependencies) Console @@ -88,27 +88,8 @@ - - - - - - - - - \ No newline at end of file + From 749889236d0d7608fe8162b26846744f236b5054 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Tue, 27 Jun 2017 00:04:07 -0700 Subject: [PATCH 8/8] OpenALStream: remove commented-out ALC_REFRESH code --- Source/Core/AudioCommon/OpenALStream.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index bce38d8811..21b2ae0acc 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -118,11 +118,6 @@ bool OpenALStream::Start() return false; } - // Used to determine an appropriate period size (2x period = total buffer size) - // ALCint refresh; - // palcGetIntegerv(pDevice, ALC_REFRESH, 1, &refresh); - // period_size_in_millisec = 1000 / refresh; - palcMakeContextCurrent(pContext); m_run_thread.Set(); thread = std::thread(&OpenALStream::SoundLoop, this);