util/Macros: replace with std::size() (C++17)
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
@@ -71,7 +70,7 @@ adplug_file_decode(DecoderClient &client, Path path_fs)
|
||||
break;
|
||||
|
||||
int16_t buffer[2048];
|
||||
constexpr unsigned frames_per_buffer = ARRAY_SIZE(buffer) / 2;
|
||||
constexpr unsigned frames_per_buffer = std::size(buffer) / 2;
|
||||
opl.update(buffer, frames_per_buffer);
|
||||
cmd = client.SubmitData(nullptr,
|
||||
buffer, sizeof(buffer),
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <fluidsynth.h>
|
||||
@@ -169,7 +168,7 @@ fluidsynth_file_decode(DecoderClient &client, Path path_fs)
|
||||
DecoderCommand cmd;
|
||||
while (fluid_player_get_status(player) == FLUID_PLAYER_PLAYING) {
|
||||
int16_t buffer[2048];
|
||||
const unsigned max_frames = ARRAY_SIZE(buffer) / 2;
|
||||
const unsigned max_frames = std::size(buffer) / 2;
|
||||
|
||||
/* read samples from fluidsynth and send them to the
|
||||
MPD core */
|
||||
|
@@ -24,13 +24,14 @@
|
||||
#include "pcm/Traits.hxx"
|
||||
#include "tag/Handler.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/Clamp.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <mpc/mpcdec.h>
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
struct mpc_decoder_data {
|
||||
@@ -216,7 +217,7 @@ mpcdec_decode(DecoderClient &client, InputStream &is)
|
||||
mpc_uint32_t ret = frame.samples;
|
||||
ret *= info.channels;
|
||||
|
||||
MpcdecSampleTraits::value_type chunk[ARRAY_SIZE(sample_buffer)];
|
||||
MpcdecSampleTraits::value_type chunk[std::size(sample_buffer)];
|
||||
mpc_to_mpd_buffer(chunk, sample_buffer, ret);
|
||||
|
||||
long bit_rate = unsigned(frame.bits) * audio_format.sample_rate
|
||||
|
@@ -29,7 +29,6 @@
|
||||
#include "fs/io/FileReader.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#endif
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/StringFormat.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
@@ -52,6 +51,8 @@
|
||||
#include <sidplay/utils/SidDatabase.h>
|
||||
#endif
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -392,7 +393,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
|
||||
do {
|
||||
short buffer[4096];
|
||||
|
||||
const auto result = player.play(buffer, ARRAY_SIZE(buffer));
|
||||
const auto result = player.play(buffer, std::size(buffer));
|
||||
if (result <= 0)
|
||||
break;
|
||||
|
||||
@@ -421,7 +422,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
|
||||
|
||||
/* ignore data until target time is reached */
|
||||
while (data_time < target_time &&
|
||||
player.play(buffer, ARRAY_SIZE(buffer)) > 0)
|
||||
player.play(buffer, std::size(buffer)) > 0)
|
||||
data_time = player.time();
|
||||
|
||||
client.CommandFinished();
|
||||
|
@@ -29,7 +29,6 @@
|
||||
#include "input/Reader.hxx"
|
||||
#include "OggCodec.hxx"
|
||||
#include "pcm/Interleave.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/Handler.hxx"
|
||||
@@ -41,6 +40,7 @@
|
||||
#include <tremor/ivorbiscodec.h>
|
||||
#endif /* HAVE_TREMOR */
|
||||
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
|
||||
class VorbisDecoder final : public OggDecoder {
|
||||
@@ -209,7 +209,7 @@ VorbisDecoder::SubmitSomePcm()
|
||||
|
||||
out_sample_t buffer[4096];
|
||||
const unsigned channels = audio_format.channels;
|
||||
size_t max_frames = ARRAY_SIZE(buffer) / channels;
|
||||
size_t max_frames = std::size(buffer) / channels;
|
||||
size_t n_frames = std::min(size_t(result), max_frames);
|
||||
|
||||
#ifdef HAVE_TREMOR
|
||||
|
@@ -24,7 +24,6 @@
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/Handler.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/Alloc.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
@@ -32,6 +31,7 @@
|
||||
#include <wavpack/wavpack.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
|
||||
#include <cstdlib>
|
||||
@@ -235,7 +235,7 @@ wavpack_decode(DecoderClient &client, WavpackContext *wpc, bool can_seek)
|
||||
|
||||
/* wavpack gives us all kind of samples in a 32-bit space */
|
||||
int32_t chunk[1024];
|
||||
const uint32_t samples_requested = ARRAY_SIZE(chunk) /
|
||||
const uint32_t samples_requested = std::size(chunk) /
|
||||
audio_format.channels;
|
||||
|
||||
DecoderCommand cmd = client.GetCommand();
|
||||
|
Reference in New Issue
Block a user