array conversions
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
e08c85ae2d
commit
9bcd425a85
@ -37,6 +37,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
@ -90,12 +91,12 @@ private:
|
|||||||
/* this should be enough - is it? */
|
/* this should be enough - is it? */
|
||||||
static constexpr unsigned MAX_SIGNAL = 64;
|
static constexpr unsigned MAX_SIGNAL = 64;
|
||||||
|
|
||||||
static SignalHandler signal_handlers[MAX_SIGNAL];
|
static std::array<SignalHandler, MAX_SIGNAL> signal_handlers;
|
||||||
|
|
||||||
#ifdef USE_SIGNALFD
|
#ifdef USE_SIGNALFD
|
||||||
static sigset_t signal_mask;
|
static sigset_t signal_mask;
|
||||||
#else
|
#else
|
||||||
static std::atomic_bool signal_pending[MAX_SIGNAL];
|
static std::array<std::atomic_bool, MAX_SIGNAL> signal_pending;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Manual<SignalMonitor> monitor;
|
static Manual<SignalMonitor> monitor;
|
||||||
@ -153,7 +154,7 @@ void
|
|||||||
SignalMonitorFinish() noexcept
|
SignalMonitorFinish() noexcept
|
||||||
{
|
{
|
||||||
#ifdef USE_SIGNALFD
|
#ifdef USE_SIGNALFD
|
||||||
std::fill_n(signal_handlers, MAX_SIGNAL, nullptr);
|
signal_handlers = {};
|
||||||
#else
|
#else
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = 0;
|
||||||
@ -167,7 +168,7 @@ SignalMonitorFinish() noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fill_n(signal_pending, MAX_SIGNAL, false);
|
std::fill(signal_pending.begin(), signal_pending.end(), false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
monitor.Destruct();
|
monitor.Destruct();
|
||||||
|
@ -760,7 +760,7 @@ Play_44_1_Silence(snd_pcm_t *pcm)
|
|||||||
throw Alsa::MakeError(err, "snd_pcm_prepare() failed");
|
throw Alsa::MakeError(err, "snd_pcm_prepare() failed");
|
||||||
|
|
||||||
AllocatedArray<int16_t> buffer{channels * period_size};
|
AllocatedArray<int16_t> buffer{channels * period_size};
|
||||||
std::fill(buffer.begin(), buffer.end(), 0);
|
buffer = {};
|
||||||
|
|
||||||
/* play at least 250ms of silence */
|
/* play at least 250ms of silence */
|
||||||
for (snd_pcm_uframes_t remaining_frames = rate / 4;;) {
|
for (snd_pcm_uframes_t remaining_frames = rate / 4;;) {
|
||||||
|
@ -172,7 +172,7 @@ void
|
|||||||
Dsd2Pcm::Reset() noexcept
|
Dsd2Pcm::Reset() noexcept
|
||||||
{
|
{
|
||||||
/* my favorite silence pattern */
|
/* my favorite silence pattern */
|
||||||
std::fill_n(fifo, std::size(fifo), 0x69);
|
fifo.fill(0x69);
|
||||||
|
|
||||||
fifopos = 0;
|
fifopos = 0;
|
||||||
/* 0x69 = 01101001
|
/* 0x69 = 01101001
|
||||||
@ -186,7 +186,7 @@ inline void
|
|||||||
Dsd2Pcm::ApplySample(size_t ffp, uint8_t src) noexcept
|
Dsd2Pcm::ApplySample(size_t ffp, uint8_t src) noexcept
|
||||||
{
|
{
|
||||||
fifo[ffp] = src;
|
fifo[ffp] = src;
|
||||||
uint8_t *p = fifo + ((ffp-CTABLES) & FIFOMASK);
|
uint8_t *p = fifo.data() + ((ffp-CTABLES) & FIFOMASK);
|
||||||
*p = bit_reverse(*p);
|
*p = bit_reverse(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ private:
|
|||||||
/** bit mask for FIFO offsets */
|
/** bit mask for FIFO offsets */
|
||||||
static constexpr size_t FIFOMASK = FIFOSIZE - 1;
|
static constexpr size_t FIFOMASK = FIFOSIZE - 1;
|
||||||
|
|
||||||
uint8_t fifo[FIFOSIZE];
|
std::array<uint8_t, FIFOSIZE> fifo;
|
||||||
size_t fifopos;
|
size_t fifopos;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "ASCII.hxx"
|
#include "ASCII.hxx"
|
||||||
#include "SplitString.hxx"
|
#include "SplitString.hxx"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ gcc_pure
|
|||||||
static const char *
|
static const char *
|
||||||
SkipUriScheme(const char *uri) noexcept
|
SkipUriScheme(const char *uri) noexcept
|
||||||
{
|
{
|
||||||
static const char *const schemes[] = {
|
static constexpr auto schemes = std::array {
|
||||||
"http://", "https://",
|
"http://", "https://",
|
||||||
"ftp://",
|
"ftp://",
|
||||||
"smb://",
|
"smb://",
|
||||||
@ -100,7 +101,7 @@ uri_remove_auth(const char *uri) noexcept
|
|||||||
if (slash == nullptr)
|
if (slash == nullptr)
|
||||||
slash = auth + strlen(auth);
|
slash = auth + strlen(auth);
|
||||||
|
|
||||||
const char *at = (const char *)std::memchr(auth, '@', slash - auth);
|
auto at = (const char *)std::memchr(auth, '@', slash - auth);
|
||||||
if (at == nullptr)
|
if (at == nullptr)
|
||||||
/* no auth info present, do nothing */
|
/* no auth info present, do nothing */
|
||||||
return std::string();
|
return std::string();
|
||||||
|
Loading…
Reference in New Issue
Block a user