aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-04 11:39:13 -0700
committerChris Robinson <[email protected]>2023-05-04 11:39:13 -0700
commit7cbf3ba2e2bab5c3aecb001e1d387c89309dbec4 (patch)
tree6fae4aae25d87e7435b2f0b0936b822360851c9b
parent6e0a0a2692a4303d6410c24bf83e09ca47ac6759 (diff)
Use std::byte instead of a custom al::byte
-rw-r--r--CMakeLists.txt1
-rw-r--r--al/buffer.cpp14
-rw-r--r--al/buffer.h4
-rw-r--r--al/event.cpp1
-rw-r--r--alc/alc.cpp4
-rw-r--r--alc/backends/alsa.cpp15
-rw-r--r--alc/backends/base.cpp2
-rw-r--r--alc/backends/base.h4
-rw-r--r--alc/backends/coreaudio.cpp6
-rw-r--r--alc/backends/dsound.cpp4
-rw-r--r--alc/backends/oboe.cpp4
-rw-r--r--alc/backends/opensl.cpp6
-rw-r--r--alc/backends/oss.cpp9
-rw-r--r--alc/backends/pipewire.cpp10
-rw-r--r--alc/backends/portaudio.cpp4
-rw-r--r--alc/backends/pulseaudio.cpp15
-rw-r--r--alc/backends/sndio.cpp16
-rw-r--r--alc/backends/solaris.cpp7
-rw-r--r--alc/backends/wasapi.cpp4
-rw-r--r--alc/backends/wave.cpp3
-rw-r--r--alc/backends/winmm.cpp4
-rw-r--r--alc/effects/convolution.cpp3
-rw-r--r--common/albyte.h17
-rw-r--r--common/ringbuffer.cpp85
-rw-r--r--common/ringbuffer.h39
-rw-r--r--core/buffer_storage.h4
-rw-r--r--core/converter.cpp10
-rw-r--r--core/effects/base.h1
-rw-r--r--core/fmt_traits.h20
-rw-r--r--core/hrtf.cpp6
-rw-r--r--core/voice.cpp35
-rw-r--r--core/voice.h5
-rw-r--r--utils/uhjdecoder.cpp53
33 files changed, 191 insertions, 224 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07377ddb..fe46a688 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -589,7 +589,6 @@ check_symbol_exists(getopt unistd.h HAVE_GETOPT)
# router, and certain tools and examples.
set(COMMON_OBJS
common/albit.h
- common/albyte.h
common/alcomplex.cpp
common/alcomplex.h
common/aldeque.h
diff --git a/al/buffer.cpp b/al/buffer.cpp
index ad74a7f7..1a042f46 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -26,6 +26,7 @@
#include <array>
#include <atomic>
#include <cassert>
+#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
@@ -44,7 +45,6 @@
#include "AL/alext.h"
#include "albit.h"
-#include "albyte.h"
#include "alc/context.h"
#include "alc/device.h"
#include "alc/inprogext.h"
@@ -277,7 +277,7 @@ ALuint SanitizeAlignment(FmtType type, ALuint align)
/** Loads the specified data into the buffer, using the specified format. */
void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
- const FmtChannels DstChannels, const FmtType DstType, const al::byte *SrcData,
+ const FmtChannels DstChannels, const FmtType DstType, const std::byte *SrcData,
ALbitfieldSOFT access)
{
if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) UNLIKELY
@@ -343,7 +343,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
*/
if(newsize != ALBuf->mDataStorage.size())
{
- auto newdata = al::vector<al::byte,16>(newsize, al::byte{});
+ auto newdata = al::vector<std::byte,16>(newsize, std::byte{});
if((access&AL_PRESERVE_DATA_BIT_SOFT))
{
const size_t tocopy{minz(newdata.size(), ALBuf->mDataStorage.size())};
@@ -437,7 +437,7 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
/** Prepares the buffer to use caller-specified storage. */
void PrepareUserPtr(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
- const FmtChannels DstChannels, const FmtType DstType, al::byte *sdata, const ALuint sdatalen)
+ const FmtChannels DstChannels, const FmtType DstType, std::byte *sdata, const ALuint sdatalen)
{
if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) UNLIKELY
return context->setError(AL_INVALID_OPERATION, "Modifying storage for in-use buffer %u",
@@ -506,7 +506,7 @@ void PrepareUserPtr(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
#endif
decltype(ALBuf->mDataStorage){}.swap(ALBuf->mDataStorage);
- ALBuf->mData = {static_cast<al::byte*>(sdata), sdatalen};
+ ALBuf->mData = {static_cast<std::byte*>(sdata), sdatalen};
#ifdef ALSOFT_EAX
eax_x_ram_clear(*context->mALDevice, *ALBuf);
@@ -767,7 +767,7 @@ START_API_FUNC
else
{
LoadData(context.get(), albuf, freq, static_cast<ALuint>(size), usrfmt->channels,
- usrfmt->type, static_cast<const al::byte*>(data), flags);
+ usrfmt->type, static_cast<const std::byte*>(data), flags);
}
}
}
@@ -796,7 +796,7 @@ START_API_FUNC
return context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format);
PrepareUserPtr(context.get(), albuf, freq, usrfmt->channels, usrfmt->type,
- static_cast<al::byte*>(data), static_cast<ALuint>(size));
+ static_cast<std::byte*>(data), static_cast<ALuint>(size));
}
END_API_FUNC
diff --git a/al/buffer.h b/al/buffer.h
index 64ebe1f3..3df1fa4c 100644
--- a/al/buffer.h
+++ b/al/buffer.h
@@ -2,10 +2,10 @@
#define AL_BUFFER_H
#include <atomic>
+#include <cstddef>
#include "AL/al.h"
-#include "albyte.h"
#include "alc/inprogext.h"
#include "almalloc.h"
#include "atomic.h"
@@ -26,7 +26,7 @@ enum class EaxStorage : uint8_t {
struct ALbuffer : public BufferStorage {
ALbitfieldSOFT Access{0u};
- al::vector<al::byte,16> mDataStorage;
+ al::vector<std::byte,16> mDataStorage;
ALuint OriginalSize{0};
diff --git a/al/event.cpp b/al/event.cpp
index 1bc39d1e..acb4958a 100644
--- a/al/event.cpp
+++ b/al/event.cpp
@@ -17,7 +17,6 @@
#include "AL/al.h"
#include "AL/alc.h"
-#include "albyte.h"
#include "alc/context.h"
#include "alc/effects/base.h"
#include "alc/inprogext.h"
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 149223f4..d226b39d 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -38,6 +38,7 @@
#include <climits>
#include <cmath>
#include <csignal>
+#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
@@ -68,7 +69,6 @@
#include "al/listener.h"
#include "al/source.h"
#include "albit.h"
-#include "albyte.h"
#include "alconfig.h"
#include "almalloc.h"
#include "alnumeric.h"
@@ -3883,7 +3883,7 @@ START_API_FUNC
return;
}
- backend->captureSamples(static_cast<al::byte*>(buffer), usamples);
+ backend->captureSamples(static_cast<std::byte*>(buffer), usamples);
}
END_API_FUNC
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp
index b162f84e..74713590 100644
--- a/alc/backends/alsa.cpp
+++ b/alc/backends/alsa.cpp
@@ -36,7 +36,6 @@
#include <utility>
#include "albit.h"
-#include "albyte.h"
#include "alc/alconfig.h"
#include "almalloc.h"
#include "alnumeric.h"
@@ -439,7 +438,7 @@ struct AlsaPlayback final : public BackendBase {
std::mutex mMutex;
uint mFrameStep{};
- al::vector<al::byte> mBuffer;
+ al::vector<std::byte> mBuffer;
std::atomic<bool> mKillNow{true};
std::thread mThread;
@@ -585,7 +584,7 @@ int AlsaPlayback::mixerNoMMapProc()
continue;
}
- al::byte *WritePtr{mBuffer.data()};
+ std::byte *WritePtr{mBuffer.data()};
avail = snd_pcm_bytes_to_frames(mPcmHandle, static_cast<ssize_t>(mBuffer.size()));
std::lock_guard<std::mutex> _{mMutex};
mDevice->renderSamples(WritePtr, static_cast<uint>(avail), mFrameStep);
@@ -874,13 +873,13 @@ struct AlsaCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
ClockLatency getClockLatency() override;
snd_pcm_t *mPcmHandle{nullptr};
- al::vector<al::byte> mBuffer;
+ al::vector<std::byte> mBuffer;
bool mDoCapture{false};
RingBufferPtr mRing{nullptr};
@@ -1024,7 +1023,7 @@ void AlsaCapture::stop()
/* The ring buffer implicitly captures when checking availability.
* Direct access needs to explicitly capture it into temp storage.
*/
- auto temp = al::vector<al::byte>(
+ auto temp = al::vector<std::byte>(
static_cast<size_t>(snd_pcm_frames_to_bytes(mPcmHandle, avail)));
captureSamples(temp.data(), avail);
mBuffer = std::move(temp);
@@ -1035,7 +1034,7 @@ void AlsaCapture::stop()
mDoCapture = false;
}
-void AlsaCapture::captureSamples(al::byte *buffer, uint samples)
+void AlsaCapture::captureSamples(std::byte *buffer, uint samples)
{
if(mRing)
{
@@ -1093,7 +1092,7 @@ void AlsaCapture::captureSamples(al::byte *buffer, uint samples)
}
if(samples > 0)
std::fill_n(buffer, snd_pcm_frames_to_bytes(mPcmHandle, samples),
- al::byte((mDevice->FmtType == DevFmtUByte) ? 0x80 : 0));
+ std::byte((mDevice->FmtType == DevFmtUByte) ? 0x80 : 0));
}
uint AlsaCapture::availableSamples()
diff --git a/alc/backends/base.cpp b/alc/backends/base.cpp
index 45254c47..ab3ad028 100644
--- a/alc/backends/base.cpp
+++ b/alc/backends/base.cpp
@@ -37,7 +37,7 @@ backend_exception::~backend_exception() = default;
bool BackendBase::reset()
{ throw al::backend_exception{al::backend_error::DeviceError, "Invalid BackendBase call"}; }
-void BackendBase::captureSamples(al::byte*, uint)
+void BackendBase::captureSamples(std::byte*, uint)
{ }
uint BackendBase::availableSamples()
diff --git a/alc/backends/base.h b/alc/backends/base.h
index b6b3d922..07b430e0 100644
--- a/alc/backends/base.h
+++ b/alc/backends/base.h
@@ -3,11 +3,11 @@
#include <chrono>
#include <cstdarg>
+#include <cstddef>
#include <memory>
#include <ratio>
#include <string>
-#include "albyte.h"
#include "core/device.h"
#include "core/except.h"
@@ -26,7 +26,7 @@ struct BackendBase {
virtual void start() = 0;
virtual void stop() = 0;
- virtual void captureSamples(al::byte *buffer, uint samples);
+ virtual void captureSamples(std::byte *buffer, uint samples);
virtual uint availableSamples();
virtual ClockLatency getClockLatency();
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp
index ae220d7a..19a1f753 100644
--- a/alc/backends/coreaudio.cpp
+++ b/alc/backends/coreaudio.cpp
@@ -568,7 +568,7 @@ struct CoreAudioCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
AudioUnit mAudioUnit{0};
@@ -598,7 +598,7 @@ OSStatus CoreAudioCapture::RecordProc(AudioUnitRenderActionFlags *ioActionFlags,
AudioBufferList*) noexcept
{
union {
- al::byte _[maxz(sizeof(AudioBufferList), offsetof(AudioBufferList, mBuffers[1]))];
+ std::byte _[maxz(sizeof(AudioBufferList), offsetof(AudioBufferList, mBuffers[1]))];
AudioBufferList list;
} audiobuf{};
@@ -878,7 +878,7 @@ void CoreAudioCapture::stop()
ERR("AudioOutputUnitStop failed: '%s' (%u)\n", FourCCPrinter{err}.c_str(), err);
}
-void CoreAudioCapture::captureSamples(al::byte *buffer, uint samples)
+void CoreAudioCapture::captureSamples(std::byte *buffer, uint samples)
{
if(!mConverter)
{
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp
index 8b967c95..05117781 100644
--- a/alc/backends/dsound.cpp
+++ b/alc/backends/dsound.cpp
@@ -551,7 +551,7 @@ struct DSoundCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
ComPtr<IDirectSoundCapture> mDSC;
@@ -717,7 +717,7 @@ void DSoundCapture::stop()
}
}
-void DSoundCapture::captureSamples(al::byte *buffer, uint samples)
+void DSoundCapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
uint DSoundCapture::availableSamples()
diff --git a/alc/backends/oboe.cpp b/alc/backends/oboe.cpp
index 461f5a6a..4c47190e 100644
--- a/alc/backends/oboe.cpp
+++ b/alc/backends/oboe.cpp
@@ -215,7 +215,7 @@ struct OboeCapture final : public BackendBase, public oboe::AudioStreamCallback
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
};
@@ -322,7 +322,7 @@ void OboeCapture::stop()
uint OboeCapture::availableSamples()
{ return static_cast<uint>(mRing->readSpace()); }
-void OboeCapture::captureSamples(al::byte *buffer, uint samples)
+void OboeCapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
} // namespace
diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp
index f5b98fb8..0c2936b2 100644
--- a/alc/backends/opensl.cpp
+++ b/alc/backends/opensl.cpp
@@ -648,7 +648,7 @@ struct OpenSLCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
/* engine interfaces */
@@ -819,7 +819,7 @@ void OpenSLCapture::open(const char* name)
if(SL_RESULT_SUCCESS == result)
{
const uint chunk_size{mDevice->UpdateSize * mFrameSize};
- const auto silence = (mDevice->FmtType == DevFmtUByte) ? al::byte{0x80} : al::byte{0};
+ const auto silence = (mDevice->FmtType == DevFmtUByte) ? std::byte{0x80} : std::byte{0};
auto data = mRing->getWriteVector();
std::fill_n(data.first.buf, data.first.len*chunk_size, silence);
@@ -883,7 +883,7 @@ void OpenSLCapture::stop()
}
}
-void OpenSLCapture::captureSamples(al::byte *buffer, uint samples)
+void OpenSLCapture::captureSamples(std::byte *buffer, uint samples)
{
const uint update_size{mDevice->UpdateSize};
const uint chunk_size{update_size * mFrameSize};
diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp
index f76024f4..9e247be1 100644
--- a/alc/backends/oss.cpp
+++ b/alc/backends/oss.cpp
@@ -41,7 +41,6 @@
#include <thread>
#include <utility>
-#include "albyte.h"
#include "alc/alconfig.h"
#include "almalloc.h"
#include "alnumeric.h"
@@ -237,7 +236,7 @@ struct OSSPlayback final : public BackendBase {
int mFd{-1};
- al::vector<al::byte> mMixData;
+ al::vector<std::byte> mMixData;
std::atomic<bool> mKillNow{true};
std::thread mThread;
@@ -283,7 +282,7 @@ int OSSPlayback::mixerProc()
continue;
}
- al::byte *write_ptr{mMixData.data()};
+ std::byte *write_ptr{mMixData.data()};
size_t to_write{mMixData.size()};
mDevice->renderSamples(write_ptr, static_cast<uint>(to_write/frame_size), frame_step);
while(to_write > 0 && !mKillNow.load(std::memory_order_acquire))
@@ -449,7 +448,7 @@ struct OSScapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
int mFd{-1};
@@ -619,7 +618,7 @@ void OSScapture::stop()
ERR("Error resetting device: %s\n", strerror(errno));
}
-void OSScapture::captureSamples(al::byte *buffer, uint samples)
+void OSScapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
uint OSScapture::availableSamples()
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index 5b1596aa..3f372a4a 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -24,6 +24,7 @@
#include <algorithm>
#include <atomic>
+#include <cstddef>
#include <cstring>
#include <cerrno>
#include <chrono>
@@ -38,7 +39,6 @@
#include <utility>
#include "albit.h"
-#include "albyte.h"
#include "alc/alconfig.h"
#include "almalloc.h"
#include "alnumeric.h"
@@ -1528,7 +1528,7 @@ bool PipeWirePlayback::reset()
* magic value.
*/
constexpr uint32_t pod_buffer_size{1024};
- auto pod_buffer = std::make_unique<al::byte[]>(pod_buffer_size);
+ auto pod_buffer = std::make_unique<std::byte[]>(pod_buffer_size);
spa_pod_builder b{make_pod_builder(pod_buffer.get(), pod_buffer_size)};
const spa_pod *params{spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &info)};
@@ -1793,7 +1793,7 @@ class PipeWireCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
uint64_t mTargetId{PwIdAny};
@@ -1954,7 +1954,7 @@ void PipeWireCapture::open(const char *name)
spa_audio_info_raw info{make_spa_info(mDevice, is51rear, UseDevType)};
constexpr uint32_t pod_buffer_size{1024};
- auto pod_buffer = std::make_unique<al::byte[]>(pod_buffer_size);
+ auto pod_buffer = std::make_unique<std::byte[]>(pod_buffer_size);
spa_pod_builder b{make_pod_builder(pod_buffer.get(), pod_buffer_size)};
const spa_pod *params[]{spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &info)};
@@ -2055,7 +2055,7 @@ void PipeWireCapture::stop()
uint PipeWireCapture::availableSamples()
{ return static_cast<uint>(mRing->readSpace()); }
-void PipeWireCapture::captureSamples(al::byte *buffer, uint samples)
+void PipeWireCapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
} // namespace
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index d652d4cd..2551f448 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -248,7 +248,7 @@ struct PortCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
PaStream *mStream{nullptr};
@@ -349,7 +349,7 @@ void PortCapture::stop()
uint PortCapture::availableSamples()
{ return static_cast<uint>(mRing->readSpace()); }
-void PortCapture::captureSamples(al::byte *buffer, uint samples)
+void PortCapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
} // namespace
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 6e8bfe1b..e5696817 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -39,7 +39,6 @@
#include <utility>
#include "albit.h"
-#include "albyte.h"
#include "alc/alconfig.h"
#include "almalloc.h"
#include "alnumeric.h"
@@ -1037,7 +1036,7 @@ struct PulseCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
ClockLatency getClockLatency() override;
@@ -1045,12 +1044,12 @@ struct PulseCapture final : public BackendBase {
std::optional<std::string> mDeviceName{std::nullopt};
- al::span<const al::byte> mCapBuffer;
+ al::span<const std::byte> mCapBuffer;
size_t mHoleLength{0};
size_t mPacketLength{0};
uint mLastReadable{0u};
- al::byte mSilentVal{};
+ std::byte mSilentVal{};
pa_buffer_attr mAttr{};
pa_sample_spec mSpec{};
@@ -1159,7 +1158,7 @@ void PulseCapture::open(const char *name)
switch(mDevice->FmtType)
{
case DevFmtUByte:
- mSilentVal = al::byte(0x80);
+ mSilentVal = std::byte(0x80);
mSpec.format = PA_SAMPLE_U8;
break;
case DevFmtShort:
@@ -1231,9 +1230,9 @@ void PulseCapture::stop()
plock.waitForOperation(op);
}
-void PulseCapture::captureSamples(al::byte *buffer, uint samples)
+void PulseCapture::captureSamples(std::byte *buffer, uint samples)
{
- al::span<al::byte> dstbuf{buffer, samples * pa_frame_size(&mSpec)};
+ al::span<std::byte> dstbuf{buffer, samples * pa_frame_size(&mSpec)};
/* Capture is done in fragment-sized chunks, so we loop until we get all
* that's available.
@@ -1291,7 +1290,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
if(!capbuf) UNLIKELY
mHoleLength = caplen;
else
- mCapBuffer = {static_cast<const al::byte*>(capbuf), caplen};
+ mCapBuffer = {static_cast<const std::byte*>(capbuf), caplen};
mPacketLength = caplen;
}
if(!dstbuf.empty())
diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp
index 077e77f2..2040dd3a 100644
--- a/alc/backends/sndio.cpp
+++ b/alc/backends/sndio.cpp
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <thread>
+#include <vector>
#include "alnumeric.h"
#include "core/device.h"
@@ -36,7 +37,6 @@
#include "core/logging.h"
#include "ringbuffer.h"
#include "threads.h"
-#include "vector.h"
#include <sndio.h>
@@ -65,7 +65,7 @@ struct SndioPlayback final : public BackendBase {
sio_hdl *mSndHandle{nullptr};
uint mFrameStep{};
- al::vector<al::byte> mBuffer;
+ std::vector<std::byte> mBuffer;
std::atomic<bool> mKillNow{true};
std::thread mThread;
@@ -91,7 +91,7 @@ int SndioPlayback::mixerProc()
while(!mKillNow.load(std::memory_order_acquire)
&& mDevice->Connected.load(std::memory_order_acquire))
{
- al::span<al::byte> buffer{mBuffer};
+ al::span<std::byte> buffer{mBuffer};
mDevice->renderSamples(buffer.data(), static_cast<uint>(buffer.size() / frameSize),
frameStep);
@@ -231,9 +231,9 @@ retry_params:
mBuffer.resize(mDevice->UpdateSize * par.pchan*par.bps);
if(par.sig == 1)
- std::fill(mBuffer.begin(), mBuffer.end(), al::byte{});
+ std::fill(mBuffer.begin(), mBuffer.end(), std::byte{});
else if(par.bits == 8)
- std::fill_n(mBuffer.data(), mBuffer.size(), al::byte(0x80));
+ std::fill_n(mBuffer.data(), mBuffer.size(), std::byte(0x80));
else if(par.bits == 16)
std::fill_n(reinterpret_cast<uint16_t*>(mBuffer.data()), mBuffer.size()/2, 0x8000);
else if(par.bits == 32)
@@ -283,7 +283,7 @@ struct SndioCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
sio_hdl *mSndHandle{nullptr};
@@ -349,7 +349,7 @@ int SndioCapture::recordProc()
continue;
auto data = mRing->getWriteVector();
- al::span<al::byte> buffer{data.first.buf, data.first.len*frameSize};
+ al::span<std::byte> buffer{data.first.buf, data.first.len*frameSize};
while(!buffer.empty())
{
size_t got{sio_read(mSndHandle, buffer.data(), buffer.size())};
@@ -496,7 +496,7 @@ void SndioCapture::stop()
ERR("Error stopping device\n");
}
-void SndioCapture::captureSamples(al::byte *buffer, uint samples)
+void SndioCapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
uint SndioCapture::availableSamples()
diff --git a/alc/backends/solaris.cpp b/alc/backends/solaris.cpp
index 791609ce..4eeeafac 100644
--- a/alc/backends/solaris.cpp
+++ b/alc/backends/solaris.cpp
@@ -39,7 +39,6 @@
#include <thread>
#include <functional>
-#include "albyte.h"
#include "alc/alconfig.h"
#include "core/device.h"
#include "core/helpers.h"
@@ -71,7 +70,7 @@ struct SolarisBackend final : public BackendBase {
int mFd{-1};
uint mFrameStep{};
- al::vector<al::byte> mBuffer;
+ al::vector<std::byte> mBuffer;
std::atomic<bool> mKillNow{true};
std::thread mThread;
@@ -116,7 +115,7 @@ int SolarisBackend::mixerProc()
continue;
}
- al::byte *write_ptr{mBuffer.data()};
+ std::byte *write_ptr{mBuffer.data()};
size_t to_write{mBuffer.size()};
mDevice->renderSamples(write_ptr, static_cast<uint>(to_write/frame_size), frame_step);
while(to_write > 0 && !mKillNow.load(std::memory_order_acquire))
@@ -231,7 +230,7 @@ bool SolarisBackend::reset()
setDefaultChannelOrder();
mBuffer.resize(mDevice->UpdateSize * size_t{frame_size});
- std::fill(mBuffer.begin(), mBuffer.end(), al::byte{});
+ std::fill(mBuffer.begin(), mBuffer.end(), std::byte{});
return true;
}
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index ea6ecbe0..16576733 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -1309,7 +1309,7 @@ struct WasapiCapture final : public BackendBase, WasapiProxy {
void stop() override;
void stopProxy() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
HRESULT mOpenStatus{E_FAIL};
@@ -1881,7 +1881,7 @@ void WasapiCapture::stopProxy()
}
-void WasapiCapture::captureSamples(al::byte *buffer, uint samples)
+void WasapiCapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
uint WasapiCapture::availableSamples()
diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp
index 1b40640c..f8302f1e 100644
--- a/alc/backends/wave.cpp
+++ b/alc/backends/wave.cpp
@@ -34,7 +34,6 @@
#include <thread>
#include "albit.h"
-#include "albyte.h"
#include "alc/alconfig.h"
#include "almalloc.h"
#include "alnumeric.h"
@@ -105,7 +104,7 @@ struct WaveBackend final : public BackendBase {
FILE *mFile{nullptr};
long mDataStart{-1};
- al::vector<al::byte> mBuffer;
+ al::vector<std::byte> mBuffer;
std::atomic<bool> mKillNow{true};
std::thread mThread;
diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp
index 38e1193f..135b59df 100644
--- a/alc/backends/winmm.cpp
+++ b/alc/backends/winmm.cpp
@@ -372,7 +372,7 @@ struct WinMMCapture final : public BackendBase {
void open(const char *name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
std::atomic<uint> mReadable{0u};
@@ -571,7 +571,7 @@ void WinMMCapture::stop()
mIdx = 0;
}
-void WinMMCapture::captureSamples(al::byte *buffer, uint samples)
+void WinMMCapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
uint WinMMCapture::availableSamples()
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 7f36c415..4ca31246 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -17,7 +17,6 @@
#include <arm_neon.h>
#endif
-#include "albyte.h"
#include "alcomplex.h"
#include "almalloc.h"
#include "alnumbers.h"
@@ -72,7 +71,7 @@ namespace {
*/
-void LoadSamples(float *RESTRICT dst, const al::byte *src, const size_t srcstep, FmtType srctype,
+void LoadSamples(float *RESTRICT dst, const std::byte *src, const size_t srcstep, FmtType srctype,
const size_t samples) noexcept
{
#define HANDLE_FMT(T) case T: al::LoadSampleArray<T>(dst, src, srcstep, samples); break
diff --git a/common/albyte.h b/common/albyte.h
deleted file mode 100644
index be586869..00000000
--- a/common/albyte.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef AL_BYTE_H
-#define AL_BYTE_H
-
-#include <cstddef>
-#include <cstdint>
-#include <limits>
-#include <type_traits>
-
-using uint = unsigned int;
-
-namespace al {
-
-using byte = unsigned char;
-
-} // namespace al
-
-#endif /* AL_BYTE_H */
diff --git a/common/ringbuffer.cpp b/common/ringbuffer.cpp
index 0aec1d49..af1f3669 100644
--- a/common/ringbuffer.cpp
+++ b/common/ringbuffer.cpp
@@ -29,9 +29,9 @@
#include "almalloc.h"
-RingBufferPtr RingBuffer::Create(size_t sz, size_t elem_sz, int limit_writes)
+RingBufferPtr RingBuffer::Create(std::size_t sz, std::size_t elem_sz, int limit_writes)
{
- size_t power_of_two{0u};
+ std::size_t power_of_two{0u};
if(sz > 0)
{
power_of_two = sz;
@@ -40,15 +40,14 @@ RingBufferPtr RingBuffer::Create(size_t sz, size_t elem_sz, int limit_writes)
power_of_two |= power_of_two>>4;
power_of_two |= power_of_two>>8;
power_of_two |= power_of_two>>16;
-#if SIZE_MAX > UINT_MAX
- power_of_two |= power_of_two>>32;
-#endif
+ if constexpr(SIZE_MAX > UINT_MAX)
+ power_of_two |= power_of_two>>32;
}
++power_of_two;
- if(power_of_two <= sz || power_of_two > std::numeric_limits<size_t>::max()/elem_sz)
+ if(power_of_two <= sz || power_of_two > std::numeric_limits<std::size_t>::max()/elem_sz)
throw std::overflow_error{"Ring buffer size overflow"};
- const size_t bufbytes{power_of_two * elem_sz};
+ const std::size_t bufbytes{power_of_two * elem_sz};
RingBufferPtr rb{new(FamCount(bufbytes)) RingBuffer{bufbytes}};
rb->mWriteSize = limit_writes ? sz : (power_of_two-1);
rb->mSizeMask = power_of_two - 1;
@@ -61,20 +60,20 @@ void RingBuffer::reset() noexcept
{
mWritePtr.store(0, std::memory_order_relaxed);
mReadPtr.store(0, std::memory_order_relaxed);
- std::fill_n(mBuffer.begin(), (mSizeMask+1)*mElemSize, al::byte{});
+ std::fill_n(mBuffer.begin(), (mSizeMask+1)*mElemSize, std::byte{});
}
-size_t RingBuffer::read(void *dest, size_t cnt) noexcept
+std::size_t RingBuffer::read(void *dest, std::size_t cnt) noexcept
{
- const size_t free_cnt{readSpace()};
+ const std::size_t free_cnt{readSpace()};
if(free_cnt == 0) return 0;
- const size_t to_read{std::min(cnt, free_cnt)};
- size_t read_ptr{mReadPtr.load(std::memory_order_relaxed) & mSizeMask};
+ const std::size_t to_read{std::min(cnt, free_cnt)};
+ std::size_t read_ptr{mReadPtr.load(std::memory_order_relaxed) & mSizeMask};
- size_t n1, n2;
- const size_t cnt2{read_ptr + to_read};
+ std::size_t n1, n2;
+ const std::size_t cnt2{read_ptr + to_read};
if(cnt2 > mSizeMask+1)
{
n1 = mSizeMask+1 - read_ptr;
@@ -87,7 +86,7 @@ size_t RingBuffer::read(void *dest, size_t cnt) noexcept
}
auto outiter = std::copy_n(mBuffer.begin() + read_ptr*mElemSize, n1*mElemSize,
- static_cast<al::byte*>(dest));
+ static_cast<std::byte*>(dest));
read_ptr += n1;
if(n2 > 0)
{
@@ -98,16 +97,16 @@ size_t RingBuffer::read(void *dest, size_t cnt) noexcept
return to_read;
}
-size_t RingBuffer::peek(void *dest, size_t cnt) const noexcept
+std::size_t RingBuffer::peek(void *dest, std::size_t cnt) const noexcept
{
- const size_t free_cnt{readSpace()};
+ const std::size_t free_cnt{readSpace()};
if(free_cnt == 0) return 0;
- const size_t to_read{std::min(cnt, free_cnt)};
- size_t read_ptr{mReadPtr.load(std::memory_order_relaxed) & mSizeMask};
+ const std::size_t to_read{std::min(cnt, free_cnt)};
+ std::size_t read_ptr{mReadPtr.load(std::memory_order_relaxed) & mSizeMask};
- size_t n1, n2;
- const size_t cnt2{read_ptr + to_read};
+ std::size_t n1, n2;
+ const std::size_t cnt2{read_ptr + to_read};
if(cnt2 > mSizeMask+1)
{
n1 = mSizeMask+1 - read_ptr;
@@ -120,22 +119,22 @@ size_t RingBuffer::peek(void *dest, size_t cnt) const noexcept
}
auto outiter = std::copy_n(mBuffer.begin() + read_ptr*mElemSize, n1*mElemSize,
- static_cast<al::byte*>(dest));
+ static_cast<std::byte*>(dest));
if(n2 > 0)
std::copy_n(mBuffer.begin(), n2*mElemSize, outiter);
return to_read;
}
-size_t RingBuffer::write(const void *src, size_t cnt) noexcept
+std::size_t RingBuffer::write(const void *src, std::size_t cnt) noexcept
{
- const size_t free_cnt{writeSpace()};
+ const std::size_t free_cnt{writeSpace()};
if(free_cnt == 0) return 0;
- const size_t to_write{std::min(cnt, free_cnt)};
- size_t write_ptr{mWritePtr.load(std::memory_order_relaxed) & mSizeMask};
+ const std::size_t to_write{std::min(cnt, free_cnt)};
+ std::size_t write_ptr{mWritePtr.load(std::memory_order_relaxed) & mSizeMask};
- size_t n1, n2;
- const size_t cnt2{write_ptr + to_write};
+ std::size_t n1, n2;
+ const std::size_t cnt2{write_ptr + to_write};
if(cnt2 > mSizeMask+1)
{
n1 = mSizeMask+1 - write_ptr;
@@ -147,7 +146,7 @@ size_t RingBuffer::write(const void *src, size_t cnt) noexcept
n2 = 0;
}
- auto srcbytes = static_cast<const al::byte*>(src);
+ auto srcbytes = static_cast<const std::byte*>(src);
std::copy_n(srcbytes, n1*mElemSize, mBuffer.begin() + write_ptr*mElemSize);
write_ptr += n1;
if(n2 > 0)
@@ -164,26 +163,26 @@ auto RingBuffer::getReadVector() const noexcept -> DataPair
{
DataPair ret;
- size_t w{mWritePtr.load(std::memory_order_acquire)};
- size_t r{mReadPtr.load(std::memory_order_acquire)};
+ std::size_t w{mWritePtr.load(std::memory_order_acquire)};
+ std::size_t r{mReadPtr.load(std::memory_order_acquire)};
w &= mSizeMask;
r &= mSizeMask;
- const size_t free_cnt{(w-r) & mSizeMask};
+ const std::size_t free_cnt{(w-r) & mSizeMask};
- const size_t cnt2{r + free_cnt};
+ const std::size_t cnt2{r + free_cnt};
if(cnt2 > mSizeMask+1)
{
/* Two part vector: the rest of the buffer after the current read ptr,
* plus some from the start of the buffer. */
- ret.first.buf = const_cast<al::byte*>(mBuffer.data() + r*mElemSize);
+ ret.first.buf = const_cast<std::byte*>(mBuffer.data() + r*mElemSize);
ret.first.len = mSizeMask+1 - r;
- ret.second.buf = const_cast<al::byte*>(mBuffer.data());
+ ret.second.buf = const_cast<std::byte*>(mBuffer.data());
ret.second.len = cnt2 & mSizeMask;
}
else
{
/* Single part vector: just the rest of the buffer */
- ret.first.buf = const_cast<al::byte*>(mBuffer.data() + r*mElemSize);
+ ret.first.buf = const_cast<std::byte*>(mBuffer.data() + r*mElemSize);
ret.first.len = free_cnt;
ret.second.buf = nullptr;
ret.second.len = 0;
@@ -196,25 +195,25 @@ auto RingBuffer::getWriteVector() const noexcept -> DataPair
{
DataPair ret;
- size_t w{mWritePtr.load(std::memory_order_acquire)};
- size_t r{mReadPtr.load(std::memory_order_acquire) + mWriteSize - mSizeMask};
+ std::size_t w{mWritePtr.load(std::memory_order_acquire)};
+ std::size_t r{mReadPtr.load(std::memory_order_acquire) + mWriteSize - mSizeMask};
w &= mSizeMask;
r &= mSizeMask;
- const size_t free_cnt{(r-w-1) & mSizeMask};
+ const std::size_t free_cnt{(r-w-1) & mSizeMask};
- const size_t cnt2{w + free_cnt};
+ const std::size_t cnt2{w + free_cnt};
if(cnt2 > mSizeMask+1)
{
/* Two part vector: the rest of the buffer after the current write ptr,
* plus some from the start of the buffer. */
- ret.first.buf = const_cast<al::byte*>(mBuffer.data() + w*mElemSize);
+ ret.first.buf = const_cast<std::byte*>(mBuffer.data() + w*mElemSize);
ret.first.len = mSizeMask+1 - w;
- ret.second.buf = const_cast<al::byte*>(mBuffer.data());
+ ret.second.buf = const_cast<std::byte*>(mBuffer.data());
ret.second.len = cnt2 & mSizeMask;
}
else
{
- ret.first.buf = const_cast<al::byte*>(mBuffer.data() + w*mElemSize);
+ ret.first.buf = const_cast<std::byte*>(mBuffer.data() + w*mElemSize);
ret.first.len = free_cnt;
ret.second.buf = nullptr;
ret.second.len = 0;
diff --git a/common/ringbuffer.h b/common/ringbuffer.h
index 2a3797b0..8c65c3af 100644
--- a/common/ringbuffer.h
+++ b/common/ringbuffer.h
@@ -2,11 +2,10 @@
#define RINGBUFFER_H
#include <atomic>
+#include <cstddef>
#include <memory>
-#include <stddef.h>
#include <utility>
-#include "albyte.h"
#include "almalloc.h"
@@ -18,23 +17,23 @@
struct RingBuffer {
private:
- std::atomic<size_t> mWritePtr{0u};
- std::atomic<size_t> mReadPtr{0u};
- size_t mWriteSize{0u};
- size_t mSizeMask{0u};
- size_t mElemSize{0u};
+ std::atomic<std::size_t> mWritePtr{0u};
+ std::atomic<std::size_t> mReadPtr{0u};
+ std::size_t mWriteSize{0u};
+ std::size_t mSizeMask{0u};
+ std::size_t mElemSize{0u};
- al::FlexArray<al::byte, 16> mBuffer;
+ al::FlexArray<std::byte, 16> mBuffer;
public:
struct Data {
- al::byte *buf;
- size_t len;
+ std::byte *buf;
+ std::size_t len;
};
using DataPair = std::pair<Data,Data>;
- RingBuffer(const size_t count) : mBuffer{count} { }
+ RingBuffer(const std::size_t count) : mBuffer{count} { }
/** Reset the read and write pointers to zero. This is not thread safe. */
void reset() noexcept;
@@ -56,7 +55,7 @@ public:
* Return the number of elements available for reading. This is the number
* of elements in front of the read pointer and behind the write pointer.
*/
- size_t readSpace() const noexcept
+ std::size_t readSpace() const noexcept
{
const size_t w{mWritePtr.load(std::memory_order_acquire)};
const size_t r{mReadPtr.load(std::memory_order_acquire)};
@@ -67,14 +66,14 @@ public:
* The copying data reader. Copy at most `cnt' elements into `dest'.
* Returns the actual number of elements copied.
*/
- size_t read(void *dest, size_t cnt) noexcept;
+ std::size_t read(void *dest, std::size_t cnt) noexcept;
/**
* The copying data reader w/o read pointer advance. Copy at most `cnt'
* elements into `dest'. Returns the actual number of elements copied.
*/
- size_t peek(void *dest, size_t cnt) const noexcept;
+ std::size_t peek(void *dest, std::size_t cnt) const noexcept;
/** Advance the read pointer `cnt' places. */
- void readAdvance(size_t cnt) noexcept
+ void readAdvance(std::size_t cnt) noexcept
{ mReadPtr.fetch_add(cnt, std::memory_order_acq_rel); }
@@ -82,7 +81,7 @@ public:
* Return the number of elements available for writing. This is the number
* of elements in front of the write pointer and behind the read pointer.
*/
- size_t writeSpace() const noexcept
+ std::size_t writeSpace() const noexcept
{
const size_t w{mWritePtr.load(std::memory_order_acquire)};
const size_t r{mReadPtr.load(std::memory_order_acquire) + mWriteSize - mSizeMask};
@@ -93,12 +92,12 @@ public:
* The copying data writer. Copy at most `cnt' elements from `src'. Returns
* the actual number of elements copied.
*/
- size_t write(const void *src, size_t cnt) noexcept;
+ std::size_t write(const void *src, std::size_t cnt) noexcept;
/** Advance the write pointer `cnt' places. */
- void writeAdvance(size_t cnt) noexcept
+ void writeAdvance(std::size_t cnt) noexcept
{ mWritePtr.fetch_add(cnt, std::memory_order_acq_rel); }
- size_t getElemSize() const noexcept { return mElemSize; }
+ std::size_t getElemSize() const noexcept { return mElemSize; }
/**
* Create a new ringbuffer to hold at least `sz' elements of `elem_sz'
@@ -106,7 +105,7 @@ public:
* (even if it is already a power of two, to ensure the requested amount
* can be written).
*/
- static std::unique_ptr<RingBuffer> Create(size_t sz, size_t elem_sz, int limit_writes);
+ static std::unique_ptr<RingBuffer> Create(std::size_t sz, std::size_t elem_sz, int limit_writes);
DEF_FAM_NEWDEL(RingBuffer, mBuffer)
};
diff --git a/core/buffer_storage.h b/core/buffer_storage.h
index 282d5b53..d8ab0b67 100644
--- a/core/buffer_storage.h
+++ b/core/buffer_storage.h
@@ -2,8 +2,8 @@
#define CORE_BUFFER_STORAGE_H
#include <atomic>
+#include <cstddef>
-#include "albyte.h"
#include "alnumeric.h"
#include "alspan.h"
#include "ambidefs.h"
@@ -85,7 +85,7 @@ struct BufferStorage {
CallbackType mCallback{nullptr};
void *mUserData{nullptr};
- al::span<al::byte> mData;
+ al::span<std::byte> mData;
uint mSampleRate{0u};
FmtChannels mChannels{FmtMono};
diff --git a/core/converter.cpp b/core/converter.cpp
index a5141448..b3994d3f 100644
--- a/core/converter.cpp
+++ b/core/converter.cpp
@@ -6,12 +6,12 @@
#include <algorithm>
#include <cassert>
#include <cmath>
+#include <cstddef>
#include <cstdint>
#include <iterator>
#include <limits.h>
#include "albit.h"
-#include "albyte.h"
#include "alnumeric.h"
#include "fpu_ctrl.h"
@@ -219,7 +219,7 @@ uint SampleConverter::convert(const void **src, uint *srcframes, void *dst, uint
const uint SrcFrameSize{static_cast<uint>(mChan.size()) * mSrcTypeSize};
const uint DstFrameSize{static_cast<uint>(mChan.size()) * mDstTypeSize};
const uint increment{mIncrement};
- auto SamplesIn = static_cast<const al::byte*>(*src);
+ auto SamplesIn = static_cast<const std::byte*>(*src);
uint NumSrcSamples{*srcframes};
FPUCtl mixer_mode{};
@@ -265,8 +265,8 @@ uint SampleConverter::convert(const void **src, uint *srcframes, void *dst, uint
for(size_t chan{0u};chan < mChan.size();chan++)
{
- const al::byte *SrcSamples{SamplesIn + mSrcTypeSize*chan};
- al::byte *DstSamples = static_cast<al::byte*>(dst) + mDstTypeSize*chan;
+ const std::byte *SrcSamples{SamplesIn + mSrcTypeSize*chan};
+ std::byte *DstSamples = static_cast<std::byte*>(dst) + mDstTypeSize*chan;
/* Load the previous samples into the source data first, then the
* new samples from the input buffer.
@@ -299,7 +299,7 @@ uint SampleConverter::convert(const void **src, uint *srcframes, void *dst, uint
SamplesIn += SrcFrameSize*srcread;
NumSrcSamples -= srcread;
- dst = static_cast<al::byte*>(dst) + DstFrameSize*DstSize;
+ dst = static_cast<std::byte*>(dst) + DstFrameSize*DstSize;
pos += DstSize;
}
diff --git a/core/effects/base.h b/core/effects/base.h
index 4ee19f37..b02d33b7 100644
--- a/core/effects/base.h
+++ b/core/effects/base.h
@@ -3,7 +3,6 @@
#include <stddef.h>
-#include "albyte.h"
#include "almalloc.h"
#include "alspan.h"
#include "atomic.h"
diff --git a/core/fmt_traits.h b/core/fmt_traits.h
index f797f836..1879c81b 100644
--- a/core/fmt_traits.h
+++ b/core/fmt_traits.h
@@ -1,10 +1,9 @@
#ifndef CORE_FMT_TRAITS_H
#define CORE_FMT_TRAITS_H
-#include <stddef.h>
+#include <cstddef>
#include <stdint.h>
-#include "albyte.h"
#include "buffer_storage.h"
@@ -22,36 +21,35 @@ struct FmtTypeTraits<FmtUByte> {
using Type = uint8_t;
template<typename OutT>
- static constexpr inline OutT to(const Type val) noexcept
- { return val*OutT{1.0/128.0} - OutT{1.0}; }
+ static constexpr OutT to(const Type val) noexcept { return val*OutT{1.0/128.0} - OutT{1.0}; }
};
template<>
struct FmtTypeTraits<FmtShort> {
using Type = int16_t;
template<typename OutT>
- static constexpr inline OutT to(const Type val) noexcept { return val*OutT{1.0/32768.0}; }
+ static constexpr OutT to(const Type val) noexcept { return val*OutT{1.0/32768.0}; }
};
template<>
struct FmtTypeTraits<FmtFloat> {
using Type = float;
template<typename OutT>
- static constexpr inline OutT to(const Type val) noexcept { return val; }
+ static constexpr OutT to(const Type val) noexcept { return val; }
};
template<>
struct FmtTypeTraits<FmtDouble> {
using Type = double;
template<typename OutT>
- static constexpr inline OutT to(const Type val) noexcept { return static_cast<OutT>(val); }
+ static constexpr OutT to(const Type val) noexcept { return static_cast<OutT>(val); }
};
template<>
struct FmtTypeTraits<FmtMulaw> {
using Type = uint8_t;
template<typename OutT>
- static constexpr inline OutT to(const Type val) noexcept
+ static constexpr OutT to(const Type val) noexcept
{ return muLawDecompressionTable[val] * OutT{1.0/32768.0}; }
};
template<>
@@ -59,14 +57,14 @@ struct FmtTypeTraits<FmtAlaw> {
using Type = uint8_t;
template<typename OutT>
- static constexpr inline OutT to(const Type val) noexcept
+ static constexpr OutT to(const Type val) noexcept
{ return aLawDecompressionTable[val] * OutT{1.0/32768.0}; }
};
template<FmtType SrcType, typename DstT>
-inline void LoadSampleArray(DstT *RESTRICT dst, const al::byte *src, const size_t srcstep,
- const size_t samples) noexcept
+inline void LoadSampleArray(DstT *RESTRICT dst, const std::byte *src, const std::size_t srcstep,
+ const std::size_t samples) noexcept
{
using TypeTraits = FmtTypeTraits<SrcType>;
using SampleType = typename TypeTraits::Type;
diff --git a/core/hrtf.cpp b/core/hrtf.cpp
index c54d96d1..1d9bc368 100644
--- a/core/hrtf.cpp
+++ b/core/hrtf.cpp
@@ -8,6 +8,7 @@
#include <cassert>
#include <cctype>
#include <cmath>
+#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstring>
@@ -21,7 +22,6 @@
#include <utility>
#include "albit.h"
-#include "albyte.h"
#include "alfstream.h"
#include "almalloc.h"
#include "alnumbers.h"
@@ -492,10 +492,10 @@ T> readle(std::istream &data)
static_assert(num_bits <= sizeof(T)*8, "num_bits is too large for the type");
T ret{};
- al::byte b[sizeof(T)]{};
+ std::byte b[sizeof(T)]{};
if(!data.read(reinterpret_cast<char*>(b), num_bits/8))
return static_cast<T>(EOF);
- std::reverse_copy(std::begin(b), std::end(b), reinterpret_cast<al::byte*>(&ret));
+ std::reverse_copy(std::begin(b), std::end(b), reinterpret_cast<std::byte*>(&ret));
return fixsign<num_bits>(ret);
}
diff --git a/core/voice.cpp b/core/voice.cpp
index 090b10a3..cbf84c2a 100644
--- a/core/voice.cpp
+++ b/core/voice.cpp
@@ -17,7 +17,6 @@
#include <utility>
#include <vector>
-#include "albyte.h"
#include "alnumeric.h"
#include "alspan.h"
#include "alstring.h"
@@ -264,7 +263,7 @@ const float *DoFilters(BiquadFilter &lpfilter, BiquadFilter &hpfilter, float *ds
template<FmtType Type>
-inline void LoadSamples(float *RESTRICT dstSamples, const al::byte *src, const size_t srcChan,
+inline void LoadSamples(float *RESTRICT dstSamples, const std::byte *src, const size_t srcChan,
const size_t srcOffset, const size_t srcStep, const size_t /*samplesPerBlock*/,
const size_t samplesToLoad) noexcept
{
@@ -275,7 +274,7 @@ inline void LoadSamples(float *RESTRICT dstSamples, const al::byte *src, const s
}
template<>
-inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src,
+inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const std::byte *src,
const size_t srcChan, const size_t srcOffset, const size_t srcStep,
const size_t samplesPerBlock, const size_t samplesToLoad) noexcept
{
@@ -293,8 +292,8 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src
/* Each IMA4 block starts with a signed 16-bit sample, and a signed
* 16-bit table index. The table index needs to be clamped.
*/
- int sample{src[srcChan*4] | (src[srcChan*4 + 1] << 8)};
- int index{src[srcChan*4 + 2] | (src[srcChan*4 + 3] << 8)};
+ int sample{int(src[srcChan*4]) | (int(src[srcChan*4 + 1]) << 8)};
+ int index{int(src[srcChan*4 + 2]) | (int(src[srcChan*4 + 3]) << 8)};
sample = (sample^0x8000) - 32768;
index = clampi((index^0x8000) - 32768, 0, MaxStepIndex);
@@ -326,7 +325,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src
* always be less than the block size). They need to be decoded despite
* being ignored for proper state on the remaining samples.
*/
- const al::byte *nibbleData{src + (srcStep+srcChan)*4};
+ const std::byte *nibbleData{src + (srcStep+srcChan)*4};
size_t nibbleOffset{0};
const size_t startOffset{skip + 1};
for(;skip;--skip)
@@ -336,7 +335,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src
const size_t byteOffset{wordOffset*srcStep + ((nibbleOffset>>1)&3u)};
++nibbleOffset;
- std::ignore = decode_sample((nibbleData[byteOffset]>>byteShift) & 15u);
+ std::ignore = decode_sample(uint(nibbleData[byteOffset]>>byteShift) & 15u);
}
/* Second, decode the rest of the block and write to the output, until
@@ -350,7 +349,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src
const size_t byteOffset{wordOffset*srcStep + ((nibbleOffset>>1)&3u)};
++nibbleOffset;
- const int result{decode_sample((nibbleData[byteOffset]>>byteShift) & 15u)};
+ const int result{decode_sample(uint(nibbleData[byteOffset]>>byteShift) & 15u)};
dstSamples[wrote++] = static_cast<float>(result) / 32768.0f;
}
if(wrote == samplesToLoad)
@@ -361,7 +360,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src
}
template<>
-inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte *src,
+inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const std::byte *src,
const size_t srcChan, const size_t srcOffset, const size_t srcStep,
const size_t samplesPerBlock, const size_t samplesToLoad) noexcept
{
@@ -378,16 +377,16 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte *
* nibble sample value. This is followed by the two initial 16-bit
* sample history values.
*/
- const al::byte *input{src};
- const uint8_t blockpred{std::min(input[srcChan], uint8_t{6})};
+ const std::byte *input{src};
+ const uint8_t blockpred{std::min(uint8_t(input[srcChan]), uint8_t{6})};
input += srcStep;
- int delta{input[2*srcChan + 0] | (input[2*srcChan + 1] << 8)};
+ int delta{int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1]) << 8)};
input += srcStep*2;
int sampleHistory[2]{};
- sampleHistory[0] = input[2*srcChan + 0] | (input[2*srcChan + 1]<<8);
+ sampleHistory[0] = int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1])<<8);
input += srcStep*2;
- sampleHistory[1] = input[2*srcChan + 0] | (input[2*srcChan + 1]<<8);
+ sampleHistory[1] = int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1])<<8);
input += srcStep*2;
const auto coeffs = al::as_span(MSADPCMAdaptionCoeff[blockpred]);
@@ -440,7 +439,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte *
const size_t byteShift{((nibbleOffset&1)^1) * 4};
nibbleOffset += srcStep;
- std::ignore = decode_sample((input[byteOffset]>>byteShift) & 15);
+ std::ignore = decode_sample(int(input[byteOffset]>>byteShift) & 15);
}
/* Now decode the rest of the block, until the end of the block or the
@@ -453,7 +452,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte *
const size_t byteShift{((nibbleOffset&1)^1) * 4};
nibbleOffset += srcStep;
- const int sample{decode_sample((input[byteOffset]>>byteShift) & 15)};
+ const int sample{decode_sample(int(input[byteOffset]>>byteShift) & 15)};
dstSamples[wrote++] = static_cast<float>(sample) / 32768.0f;
}
if(wrote == samplesToLoad)
@@ -463,7 +462,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte *
} while(true);
}
-void LoadSamples(float *dstSamples, const al::byte *src, const size_t srcChan,
+void LoadSamples(float *dstSamples, const std::byte *src, const size_t srcChan,
const size_t srcOffset, const FmtType srcType, const size_t srcStep,
const size_t samplesPerBlock, const size_t samplesToLoad) noexcept
{
@@ -1102,7 +1101,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
{
const size_t byteOffset{blocksDone*mBytesPerBlock};
const size_t byteEnd{mNumCallbackBlocks*mBytesPerBlock};
- al::byte *data{BufferListItem->mSamples};
+ std::byte *data{BufferListItem->mSamples};
std::copy(data+byteOffset, data+byteEnd, data);
mNumCallbackBlocks -= blocksDone;
mCallbackBlockBase += blocksDone;
diff --git a/core/voice.h b/core/voice.h
index 9d74ff6b..a599eda8 100644
--- a/core/voice.h
+++ b/core/voice.h
@@ -5,12 +5,11 @@
#include <atomic>
#include <bitset>
#include <chrono>
+#include <cstddef>
#include <memory>
#include <optional>
-#include <stddef.h>
#include <string>
-#include "albyte.h"
#include "almalloc.h"
#include "alspan.h"
#include "bufferline.h"
@@ -100,7 +99,7 @@ struct VoiceBufferItem {
uint mLoopStart{0u};
uint mLoopEnd{0u};
- al::byte *mSamples{nullptr};
+ std::byte *mSamples{nullptr};
};
diff --git a/utils/uhjdecoder.cpp b/utils/uhjdecoder.cpp
index 6d992e30..c7efa376 100644
--- a/utils/uhjdecoder.cpp
+++ b/utils/uhjdecoder.cpp
@@ -26,15 +26,14 @@
#include <array>
#include <complex>
+#include <cstddef>
#include <cstring>
#include <memory>
-#include <stddef.h>
#include <string>
#include <utility>
#include <vector>
#include "albit.h"
-#include "albyte.h"
#include "alcomplex.h"
#include "almalloc.h"
#include "alnumbers.h"
@@ -64,7 +63,7 @@ using ushort = unsigned short;
using uint = unsigned int;
using complex_d = std::complex<double>;
-using byte4 = std::array<al::byte,4>;
+using byte4 = std::array<std::byte,4>;
constexpr ubyte SUBTYPE_BFORMAT_FLOAT[]{
@@ -113,7 +112,7 @@ using FloatBufferSpan = al::span<float,BufferLineSize>;
struct UhjDecoder {
- constexpr static size_t sFilterDelay{1024};
+ constexpr static std::size_t sFilterDelay{1024};
alignas(16) std::array<float,BufferLineSize+sFilterDelay> mS{};
alignas(16) std::array<float,BufferLineSize+sFilterDelay> mD{};
@@ -126,10 +125,10 @@ struct UhjDecoder {
alignas(16) std::array<float,BufferLineSize + sFilterDelay*2> mTemp{};
- void decode(const float *RESTRICT InSamples, const size_t InChannels,
- const al::span<FloatBufferLine> OutSamples, const size_t SamplesToDo);
+ void decode(const float *RESTRICT InSamples, const std::size_t InChannels,
+ const al::span<FloatBufferLine> OutSamples, const std::size_t SamplesToDo);
void decode2(const float *RESTRICT InSamples, const al::span<FloatBufferLine> OutSamples,
- const size_t SamplesToDo);
+ const std::size_t SamplesToDo);
DEF_NEWDEL(UhjDecoder)
};
@@ -210,8 +209,8 @@ const PhaseShifterT<UhjDecoder::sFilterDelay*2> PShift{};
*
* Not halving produces a result matching the original input.
*/
-void UhjDecoder::decode(const float *RESTRICT InSamples, const size_t InChannels,
- const al::span<FloatBufferLine> OutSamples, const size_t SamplesToDo)
+void UhjDecoder::decode(const float *RESTRICT InSamples, const std::size_t InChannels,
+ const al::span<FloatBufferLine> OutSamples, const std::size_t SamplesToDo)
{
ASSUME(SamplesToDo > 0);
@@ -224,23 +223,23 @@ void UhjDecoder::decode(const float *RESTRICT InSamples, const size_t InChannels
*/
/* S = Left + Right */
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
mS[sFilterDelay+i] = InSamples[i*InChannels + 0] + InSamples[i*InChannels + 1];
/* D = Left - Right */
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
mD[sFilterDelay+i] = InSamples[i*InChannels + 0] - InSamples[i*InChannels + 1];
if(InChannels > 2)
{
/* T */
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
mT[sFilterDelay+i] = InSamples[i*InChannels + 2];
}
if(InChannels > 3)
{
/* Q */
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
mQ[sFilterDelay+i] = InSamples[i*InChannels + 3];
}
@@ -251,7 +250,7 @@ void UhjDecoder::decode(const float *RESTRICT InSamples, const size_t InChannels
std::copy_n(mTemp.cbegin()+SamplesToDo, mDTHistory.size(), mDTHistory.begin());
PShift.process({xoutput, SamplesToDo}, mTemp.data());
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
{
/* W = 0.981532*S + 0.197484*j(0.828331*D + 0.767820*T) */
woutput[i] = 0.981532f*mS[i] + 0.197484f*xoutput[i];
@@ -265,7 +264,7 @@ void UhjDecoder::decode(const float *RESTRICT InSamples, const size_t InChannels
std::copy_n(mTemp.cbegin()+SamplesToDo, mSHistory.size(), mSHistory.begin());
PShift.process({youtput, SamplesToDo}, mTemp.data());
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
{
/* Y = 0.795968*D - 0.676392*T + j(0.186633*S) */
youtput[i] = 0.795968f*mD[i] - 0.676392f*mT[i] + 0.186633f*youtput[i];
@@ -275,7 +274,7 @@ void UhjDecoder::decode(const float *RESTRICT InSamples, const size_t InChannels
{
float *zoutput{OutSamples[3].data()};
/* Z = 1.023332*Q */
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
zoutput[i] = 1.023332f*mQ[i];
}
@@ -305,7 +304,7 @@ void UhjDecoder::decode(const float *RESTRICT InSamples, const size_t InChannels
* halving here is merely a -6dB reduction in output, but it's still incorrect.
*/
void UhjDecoder::decode2(const float *RESTRICT InSamples,
- const al::span<FloatBufferLine> OutSamples, const size_t SamplesToDo)
+ const al::span<FloatBufferLine> OutSamples, const std::size_t SamplesToDo)
{
ASSUME(SamplesToDo > 0);
@@ -314,11 +313,11 @@ void UhjDecoder::decode2(const float *RESTRICT InSamples,
float *youtput{OutSamples[2].data()};
/* S = Left + Right */
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
mS[sFilterDelay+i] = InSamples[i*2 + 0] + InSamples[i*2 + 1];
/* D = Left - Right */
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
mD[sFilterDelay+i] = InSamples[i*2 + 0] - InSamples[i*2 + 1];
/* Precompute j*D and store in xoutput. */
@@ -327,7 +326,7 @@ void UhjDecoder::decode2(const float *RESTRICT InSamples,
std::copy_n(mTemp.cbegin()+SamplesToDo, mDTHistory.size(), mDTHistory.begin());
PShift.process({xoutput, SamplesToDo}, mTemp.data());
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
{
/* W = 0.981530*S + j*0.163585*D */
woutput[i] = 0.981530f*mS[i] + 0.163585f*xoutput[i];
@@ -341,7 +340,7 @@ void UhjDecoder::decode2(const float *RESTRICT InSamples,
std::copy_n(mTemp.cbegin()+SamplesToDo, mSHistory.size(), mSHistory.begin());
PShift.process({youtput, SamplesToDo}, mTemp.data());
- for(size_t i{0};i < SamplesToDo;++i)
+ for(std::size_t i{0};i < SamplesToDo;++i)
{
/* Y = 0.762956*D + j*0.384230*S */
youtput[i] = 0.762956f*mD[i] + 0.384230f*youtput[i];
@@ -368,7 +367,7 @@ int main(int argc, char **argv)
return 1;
}
- size_t num_files{0}, num_decoded{0};
+ std::size_t num_files{0}, num_decoded{0};
bool use_general{true};
for(int fidx{1};fidx < argc;++fidx)
{
@@ -473,7 +472,7 @@ int main(int argc, char **argv)
* be fed through the decoder after reaching the end of the input file
* to ensure none of the original input is lost.
*/
- size_t LeadIn{UhjDecoder::sFilterDelay};
+ std::size_t LeadIn{UhjDecoder::sFilterDelay};
sf_count_t LeadOut{UhjDecoder::sFilterDelay};
while(LeadOut > 0)
{
@@ -487,7 +486,7 @@ int main(int argc, char **argv)
LeadOut -= remaining;
}
- auto got = static_cast<size_t>(sgot);
+ auto got = static_cast<std::size_t>(sgot);
if(ininfo.channels > 2 || use_general)
decoder->decode(inmem.get(), static_cast<uint>(ininfo.channels), decmem, got);
else
@@ -499,16 +498,16 @@ int main(int argc, char **argv)
}
got -= LeadIn;
- for(size_t i{0};i < got;++i)
+ for(std::size_t i{0};i < got;++i)
{
/* Attenuate by -3dB for FuMa output levels. */
constexpr auto inv_sqrt2 = static_cast<float>(1.0/al::numbers::sqrt2);
- for(size_t j{0};j < outchans;++j)
+ for(std::size_t j{0};j < outchans;++j)
outmem[i*outchans + j] = f32AsLEBytes(decmem[j][LeadIn+i] * inv_sqrt2);
}
LeadIn = 0;
- size_t wrote{fwrite(outmem.get(), sizeof(byte4)*outchans, got, outfile.get())};
+ std::size_t wrote{fwrite(outmem.get(), sizeof(byte4)*outchans, got, outfile.get())};
if(wrote < got)
{
fprintf(stderr, "Error writing wave data: %s (%d)\n", strerror(errno), errno);