mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
update openal-soft to 1.24.3
keeping the alt 87514151c4 (diff-73a8dc1ce58605f6c5ea53548454c3bae516ec5132a29c9d7ff7edf9730c75be)
This commit is contained in:
parent
12db0500e8
commit
ba32094b7b
276 changed files with 49304 additions and 8712 deletions
|
|
@ -36,14 +36,14 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include "alnumeric.h"
|
||||
#include "alsem.h"
|
||||
#include "alstring.h"
|
||||
#include "althrd_setname.h"
|
||||
#include "core/device.h"
|
||||
#include "core/helpers.h"
|
||||
#include "core/logging.h"
|
||||
#include "fmt/core.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "strutils.h"
|
||||
#include "vector.h"
|
||||
|
|
@ -54,9 +54,6 @@
|
|||
|
||||
namespace {
|
||||
|
||||
#define DEVNAME_HEAD "OpenAL Soft on "
|
||||
|
||||
|
||||
std::vector<std::string> PlaybackDevices;
|
||||
std::vector<std::string> CaptureDevices;
|
||||
|
||||
|
|
@ -76,19 +73,15 @@ void ProbePlaybackDevices()
|
|||
WAVEOUTCAPSW WaveCaps{};
|
||||
if(waveOutGetDevCapsW(i, &WaveCaps, sizeof(WaveCaps)) == MMSYSERR_NOERROR)
|
||||
{
|
||||
const std::string basename{DEVNAME_HEAD + wstr_to_utf8(std::data(WaveCaps.szPname))};
|
||||
const auto basename = wstr_to_utf8(std::data(WaveCaps.szPname));
|
||||
|
||||
int count{1};
|
||||
std::string newname{basename};
|
||||
auto count = 1;
|
||||
auto newname = basename;
|
||||
while(checkName(PlaybackDevices, newname))
|
||||
{
|
||||
newname = basename;
|
||||
newname += " #";
|
||||
newname += std::to_string(++count);
|
||||
}
|
||||
newname = fmt::format("{} #{}", basename, ++count);
|
||||
dname = std::move(newname);
|
||||
|
||||
TRACE("Got device \"%s\", ID %u\n", dname.c_str(), i);
|
||||
TRACE("Got device \"{}\", ID {}", dname, i);
|
||||
}
|
||||
PlaybackDevices.emplace_back(std::move(dname));
|
||||
}
|
||||
|
|
@ -107,19 +100,15 @@ void ProbeCaptureDevices()
|
|||
WAVEINCAPSW WaveCaps{};
|
||||
if(waveInGetDevCapsW(i, &WaveCaps, sizeof(WaveCaps)) == MMSYSERR_NOERROR)
|
||||
{
|
||||
const std::string basename{DEVNAME_HEAD + wstr_to_utf8(std::data(WaveCaps.szPname))};
|
||||
const auto basename = wstr_to_utf8(std::data(WaveCaps.szPname));
|
||||
|
||||
int count{1};
|
||||
std::string newname{basename};
|
||||
auto count = 1;
|
||||
auto newname = basename;
|
||||
while(checkName(CaptureDevices, newname))
|
||||
{
|
||||
newname = basename;
|
||||
newname += " #";
|
||||
newname += std::to_string(++count);
|
||||
}
|
||||
newname = fmt::format("{} #{}", basename, ++count);
|
||||
dname = std::move(newname);
|
||||
|
||||
TRACE("Got device \"%s\", ID %u\n", dname.c_str(), i);
|
||||
TRACE("Got device \"{}\", ID {}", dname, i);
|
||||
}
|
||||
CaptureDevices.emplace_back(std::move(dname));
|
||||
}
|
||||
|
|
@ -127,7 +116,7 @@ void ProbeCaptureDevices()
|
|||
|
||||
|
||||
struct WinMMPlayback final : public BackendBase {
|
||||
WinMMPlayback(DeviceBase *device) noexcept : BackendBase{device} { }
|
||||
explicit WinMMPlayback(DeviceBase *device) noexcept : BackendBase{device} { }
|
||||
~WinMMPlayback() override;
|
||||
|
||||
void CALLBACK waveOutProc(HWAVEOUT device, UINT msg, DWORD_PTR param1, DWORD_PTR param2) noexcept;
|
||||
|
|
@ -194,7 +183,7 @@ FORCE_ALIGN int WinMMPlayback::mixerProc()
|
|||
WAVEHDR &waveHdr = mWaveBuffer[widx];
|
||||
if(++widx == mWaveBuffer.size()) widx = 0;
|
||||
|
||||
mDevice->renderSamples(waveHdr.lpData, mDevice->UpdateSize, mFormat.nChannels);
|
||||
mDevice->renderSamples(waveHdr.lpData, mDevice->mUpdateSize, mFormat.nChannels);
|
||||
mWritable.fetch_sub(1, std::memory_order_acq_rel);
|
||||
waveOutWrite(mOutHdl, &waveHdr, sizeof(WAVEHDR));
|
||||
} while(--todo);
|
||||
|
|
@ -215,8 +204,8 @@ void WinMMPlayback::open(std::string_view name)
|
|||
std::find(PlaybackDevices.cbegin(), PlaybackDevices.cend(), name) :
|
||||
PlaybackDevices.cbegin();
|
||||
if(iter == PlaybackDevices.cend())
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%.*s\" not found",
|
||||
al::sizei(name), name.data()};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"{}\" not found",
|
||||
name};
|
||||
auto DeviceID = static_cast<UINT>(std::distance(PlaybackDevices.cbegin(), iter));
|
||||
|
||||
DevFmtType fmttype{mDevice->FmtType};
|
||||
|
|
@ -238,7 +227,7 @@ void WinMMPlayback::open(std::string_view name)
|
|||
}
|
||||
format.nChannels = ((mDevice->FmtChans == DevFmtMono) ? 1 : 2);
|
||||
format.nBlockAlign = static_cast<WORD>(format.wBitsPerSample * format.nChannels / 8);
|
||||
format.nSamplesPerSec = mDevice->Frequency;
|
||||
format.nSamplesPerSec = mDevice->mSampleRate;
|
||||
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
|
||||
format.cbSize = 0;
|
||||
|
||||
|
|
@ -248,7 +237,7 @@ void WinMMPlayback::open(std::string_view name)
|
|||
if(res == MMSYSERR_NOERROR) break;
|
||||
|
||||
if(fmttype != DevFmtFloat)
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "waveOutOpen failed: %u",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "waveOutOpen failed: {}",
|
||||
res};
|
||||
|
||||
fmttype = DevFmtShort;
|
||||
|
|
@ -256,16 +245,16 @@ void WinMMPlayback::open(std::string_view name)
|
|||
|
||||
mFormat = format;
|
||||
|
||||
mDevice->DeviceName = PlaybackDevices[DeviceID];
|
||||
mDeviceName = PlaybackDevices[DeviceID];
|
||||
}
|
||||
|
||||
bool WinMMPlayback::reset()
|
||||
{
|
||||
mDevice->BufferSize = static_cast<uint>(uint64_t{mDevice->BufferSize} *
|
||||
mFormat.nSamplesPerSec / mDevice->Frequency);
|
||||
mDevice->BufferSize = (mDevice->BufferSize+3) & ~0x3u;
|
||||
mDevice->UpdateSize = mDevice->BufferSize / 4;
|
||||
mDevice->Frequency = mFormat.nSamplesPerSec;
|
||||
mDevice->mBufferSize = static_cast<uint>(uint64_t{mDevice->mBufferSize} *
|
||||
mFormat.nSamplesPerSec / mDevice->mSampleRate);
|
||||
mDevice->mBufferSize = (mDevice->mBufferSize+3) & ~0x3u;
|
||||
mDevice->mUpdateSize = mDevice->mBufferSize / 4;
|
||||
mDevice->mSampleRate = mFormat.nSamplesPerSec;
|
||||
|
||||
if(mFormat.wFormatTag == WAVE_FORMAT_IEEE_FLOAT)
|
||||
{
|
||||
|
|
@ -273,7 +262,7 @@ bool WinMMPlayback::reset()
|
|||
mDevice->FmtType = DevFmtFloat;
|
||||
else
|
||||
{
|
||||
ERR("Unhandled IEEE float sample depth: %d\n", mFormat.wBitsPerSample);
|
||||
ERR("Unhandled IEEE float sample depth: {}", mFormat.wBitsPerSample);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -285,13 +274,13 @@ bool WinMMPlayback::reset()
|
|||
mDevice->FmtType = DevFmtUByte;
|
||||
else
|
||||
{
|
||||
ERR("Unhandled PCM sample depth: %d\n", mFormat.wBitsPerSample);
|
||||
ERR("Unhandled PCM sample depth: {}", mFormat.wBitsPerSample);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("Unhandled format tag: 0x%04x\n", mFormat.wFormatTag);
|
||||
ERR("Unhandled format tag: {:#04x}", as_unsigned(mFormat.wFormatTag));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -301,12 +290,12 @@ bool WinMMPlayback::reset()
|
|||
mDevice->FmtChans = DevFmtMono;
|
||||
else
|
||||
{
|
||||
ERR("Unhandled channel count: %d\n", mFormat.nChannels);
|
||||
ERR("Unhandled channel count: {}", mFormat.nChannels);
|
||||
return false;
|
||||
}
|
||||
setDefaultWFXChannelOrder();
|
||||
|
||||
const uint BufferSize{mDevice->UpdateSize * mFormat.nChannels * mDevice->bytesFromFmt()};
|
||||
const uint BufferSize{mDevice->mUpdateSize * mFormat.nChannels * mDevice->bytesFromFmt()};
|
||||
|
||||
decltype(mBuffer)(BufferSize*mWaveBuffer.size()).swap(mBuffer);
|
||||
mWaveBuffer[0] = WAVEHDR{};
|
||||
|
|
@ -331,11 +320,11 @@ void WinMMPlayback::start()
|
|||
mWritable.store(static_cast<uint>(mWaveBuffer.size()), std::memory_order_release);
|
||||
|
||||
mKillNow.store(false, std::memory_order_release);
|
||||
mThread = std::thread{std::mem_fn(&WinMMPlayback::mixerProc), this};
|
||||
mThread = std::thread{&WinMMPlayback::mixerProc, this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
"Failed to start mixing thread: {}", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +343,7 @@ void WinMMPlayback::stop()
|
|||
|
||||
|
||||
struct WinMMCapture final : public BackendBase {
|
||||
WinMMCapture(DeviceBase *device) noexcept : BackendBase{device} { }
|
||||
explicit WinMMCapture(DeviceBase *device) noexcept : BackendBase{device} { }
|
||||
~WinMMCapture() override;
|
||||
|
||||
void CALLBACK waveInProc(HWAVEIN device, UINT msg, DWORD_PTR param1, DWORD_PTR param2) noexcept;
|
||||
|
|
@ -446,8 +435,8 @@ void WinMMCapture::open(std::string_view name)
|
|||
std::find(CaptureDevices.cbegin(), CaptureDevices.cend(), name) :
|
||||
CaptureDevices.cbegin();
|
||||
if(iter == CaptureDevices.cend())
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%.*s\" not found",
|
||||
al::sizei(name), name.data()};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"{}\" not found",
|
||||
name};
|
||||
auto DeviceID = static_cast<UINT>(std::distance(CaptureDevices.cbegin(), iter));
|
||||
|
||||
switch(mDevice->FmtChans)
|
||||
|
|
@ -464,7 +453,7 @@ void WinMMCapture::open(std::string_view name)
|
|||
case DevFmtX7144:
|
||||
case DevFmtX3D71:
|
||||
case DevFmtAmbi3D:
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s capture not supported",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "{} capture not supported",
|
||||
DevFmtChannelsString(mDevice->FmtChans)};
|
||||
}
|
||||
|
||||
|
|
@ -479,7 +468,7 @@ void WinMMCapture::open(std::string_view name)
|
|||
case DevFmtByte:
|
||||
case DevFmtUShort:
|
||||
case DevFmtUInt:
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s samples not supported",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "{} samples not supported",
|
||||
DevFmtTypeString(mDevice->FmtType)};
|
||||
}
|
||||
|
||||
|
|
@ -489,7 +478,7 @@ void WinMMCapture::open(std::string_view name)
|
|||
mFormat.nChannels = static_cast<WORD>(mDevice->channelsFromFmt());
|
||||
mFormat.wBitsPerSample = static_cast<WORD>(mDevice->bytesFromFmt() * 8);
|
||||
mFormat.nBlockAlign = static_cast<WORD>(mFormat.wBitsPerSample * mFormat.nChannels / 8);
|
||||
mFormat.nSamplesPerSec = mDevice->Frequency;
|
||||
mFormat.nSamplesPerSec = mDevice->mSampleRate;
|
||||
mFormat.nAvgBytesPerSec = mFormat.nSamplesPerSec * mFormat.nBlockAlign;
|
||||
mFormat.cbSize = 0;
|
||||
|
||||
|
|
@ -497,7 +486,7 @@ void WinMMCapture::open(std::string_view name)
|
|||
reinterpret_cast<DWORD_PTR>(&WinMMCapture::waveInProcC),
|
||||
reinterpret_cast<DWORD_PTR>(this), CALLBACK_FUNCTION)};
|
||||
if(res != MMSYSERR_NOERROR)
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "waveInOpen failed: %u", res};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "waveInOpen failed: {}", res};
|
||||
|
||||
// Ensure each buffer is 50ms each
|
||||
DWORD BufferSize{mFormat.nAvgBytesPerSec / 20u};
|
||||
|
|
@ -505,7 +494,7 @@ void WinMMCapture::open(std::string_view name)
|
|||
|
||||
// Allocate circular memory buffer for the captured audio
|
||||
// Make sure circular buffer is at least 100ms in size
|
||||
const auto CapturedDataSize = std::max<size_t>(mDevice->BufferSize,
|
||||
const auto CapturedDataSize = std::max<size_t>(mDevice->mBufferSize,
|
||||
BufferSize*mWaveBuffer.size());
|
||||
|
||||
mRing = RingBuffer::Create(CapturedDataSize, mFormat.nBlockAlign, false);
|
||||
|
|
@ -521,7 +510,7 @@ void WinMMCapture::open(std::string_view name)
|
|||
mWaveBuffer[i].dwBufferLength = mWaveBuffer[i-1].dwBufferLength;
|
||||
}
|
||||
|
||||
mDevice->DeviceName = CaptureDevices[DeviceID];
|
||||
mDeviceName = CaptureDevices[DeviceID];
|
||||
}
|
||||
|
||||
void WinMMCapture::start()
|
||||
|
|
@ -534,13 +523,13 @@ void WinMMCapture::start()
|
|||
}
|
||||
|
||||
mKillNow.store(false, std::memory_order_release);
|
||||
mThread = std::thread{std::mem_fn(&WinMMCapture::captureProc), this};
|
||||
mThread = std::thread{&WinMMCapture::captureProc, this};
|
||||
|
||||
waveInStart(mInHdl);
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start recording thread: %s", e.what()};
|
||||
"Failed to start recording thread: {}", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue