lib/fmt/RuntimeError: new library
Replacing FormatRuntimeError().
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
#include "EncoderList.hxx"
|
||||
#include "EncoderPlugin.hxx"
|
||||
#include "config/Block.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "util/StringAPI.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
|
||||
static const EncoderPlugin &
|
||||
GetConfiguredEncoderPlugin(const ConfigBlock &block, bool shout_legacy)
|
||||
@@ -43,7 +43,7 @@ GetConfiguredEncoderPlugin(const ConfigBlock &block, bool shout_legacy)
|
||||
|
||||
const auto plugin = encoder_plugin_get(name);
|
||||
if (plugin == nullptr)
|
||||
throw FormatRuntimeError("No such encoder: %s", name);
|
||||
throw FmtRuntimeError("No such encoder: {}", name);
|
||||
|
||||
return *plugin;
|
||||
}
|
||||
|
@@ -35,6 +35,9 @@ encoder_glue = static_library(
|
||||
'ToOutputStream.cxx',
|
||||
'EncoderList.cxx',
|
||||
include_directories: inc,
|
||||
dependencies: [
|
||||
fmt_dep,
|
||||
],
|
||||
)
|
||||
|
||||
encoder_glue_dep = declare_dependency(
|
||||
|
@@ -21,8 +21,8 @@
|
||||
#include "../EncoderAPI.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "pcm/Buffer.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "util/DynamicFifoBuffer.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/Serial.hxx"
|
||||
#include "util/SpanCast.hxx"
|
||||
#include "util/StringUtil.hxx"
|
||||
@@ -147,25 +147,25 @@ flac_encoder_setup(FLAC__StreamEncoder *fse, unsigned compression, bool oggflac,
|
||||
}
|
||||
|
||||
if (!FLAC__stream_encoder_set_compression_level(fse, compression))
|
||||
throw FormatRuntimeError("error setting flac compression to %d",
|
||||
compression);
|
||||
throw FmtRuntimeError("error setting flac compression to {}",
|
||||
compression);
|
||||
|
||||
if (!FLAC__stream_encoder_set_channels(fse, audio_format.channels))
|
||||
throw FormatRuntimeError("error setting flac channels num to %d",
|
||||
audio_format.channels);
|
||||
throw FmtRuntimeError("error setting flac channels num to {}",
|
||||
audio_format.channels);
|
||||
|
||||
if (!FLAC__stream_encoder_set_bits_per_sample(fse, bits_per_sample))
|
||||
throw FormatRuntimeError("error setting flac bit format to %d",
|
||||
bits_per_sample);
|
||||
throw FmtRuntimeError("error setting flac bit format to {}",
|
||||
bits_per_sample);
|
||||
|
||||
if (!FLAC__stream_encoder_set_sample_rate(fse,
|
||||
audio_format.sample_rate))
|
||||
throw FormatRuntimeError("error setting flac sample rate to %d",
|
||||
audio_format.sample_rate);
|
||||
throw FmtRuntimeError("error setting flac sample rate to {}",
|
||||
audio_format.sample_rate);
|
||||
|
||||
if (oggflac && !FLAC__stream_encoder_set_ogg_serial_number(fse,
|
||||
GenerateSerial()))
|
||||
throw FormatRuntimeError("error setting ogg serial number");
|
||||
throw std::runtime_error{"error setting ogg serial number"};
|
||||
}
|
||||
|
||||
FlacEncoder::FlacEncoder(AudioFormat _audio_format, FLAC__StreamEncoder *_fse, unsigned _compression, bool _oggflac, bool _oggchaining)
|
||||
@@ -188,8 +188,8 @@ FlacEncoder::FlacEncoder(AudioFormat _audio_format, FLAC__StreamEncoder *_fse, u
|
||||
this);
|
||||
|
||||
if (init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
|
||||
throw FormatRuntimeError("failed to initialize encoder: %s\n",
|
||||
FLAC__StreamEncoderInitStatusString[init_status]);
|
||||
throw FmtRuntimeError("failed to initialize encoder: {}",
|
||||
FLAC__StreamEncoderInitStatusString[init_status]);
|
||||
}
|
||||
|
||||
Encoder *
|
||||
@@ -250,8 +250,8 @@ FlacEncoder::SendTag(const Tag &tag)
|
||||
FLAC__metadata_object_delete(metadata);
|
||||
|
||||
if (init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
|
||||
throw FormatRuntimeError("failed to initialize encoder: %s\n",
|
||||
FLAC__StreamEncoderInitStatusString[init_status]);
|
||||
throw FmtRuntimeError("failed to initialize encoder: {}",
|
||||
FLAC__StreamEncoderInitStatusString[init_status]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@@ -20,9 +20,9 @@
|
||||
#include "LameEncoderPlugin.hxx"
|
||||
#include "../EncoderAPI.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "util/NumberParser.hxx"
|
||||
#include "util/ReusableArray.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/SpanCast.hxx"
|
||||
|
||||
#include <lame/lame.h>
|
||||
@@ -79,9 +79,9 @@ PreparedLameEncoder::PreparedLameEncoder(const ConfigBlock &block)
|
||||
quality = float(ParseDouble(value, &endptr));
|
||||
|
||||
if (*endptr != '\0' || quality < -1.0f || quality > 10.0f)
|
||||
throw FormatRuntimeError("quality \"%s\" is not a number in the "
|
||||
"range -1 to 10",
|
||||
value);
|
||||
throw FmtRuntimeError("quality \"{}\" is not a number in the "
|
||||
"range -1 to 10",
|
||||
value);
|
||||
|
||||
if (block.GetBlockValue("bitrate") != nullptr)
|
||||
throw std::runtime_error("quality and bitrate are both defined");
|
||||
|
@@ -20,8 +20,8 @@
|
||||
#include "ShineEncoderPlugin.hxx"
|
||||
#include "../EncoderAPI.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "util/DynamicFifoBuffer.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/SpanCast.hxx"
|
||||
|
||||
extern "C"
|
||||
@@ -121,11 +121,11 @@ SetupShine(shine_config_t config, AudioFormat &audio_format)
|
||||
audio_format.channels == 2 ? PCM_STEREO : PCM_MONO;
|
||||
|
||||
if (shine_check_config(config.wave.samplerate, config.mpeg.bitr) < 0)
|
||||
throw FormatRuntimeError("error configuring shine. "
|
||||
"samplerate %d and bitrate %d configuration"
|
||||
" not supported.",
|
||||
config.wave.samplerate,
|
||||
config.mpeg.bitr);
|
||||
throw FmtRuntimeError("error configuring shine. "
|
||||
"samplerate {} and bitrate {} configuration"
|
||||
" not supported.",
|
||||
config.wave.samplerate,
|
||||
config.mpeg.bitr);
|
||||
|
||||
auto shine = shine_initialise(&config);
|
||||
if (!shine)
|
||||
|
@@ -20,8 +20,8 @@
|
||||
#include "TwolameEncoderPlugin.hxx"
|
||||
#include "../EncoderAPI.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "util/NumberParser.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/SpanCast.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
@@ -96,9 +96,9 @@ PreparedTwolameEncoder::PreparedTwolameEncoder(const ConfigBlock &block)
|
||||
quality = float(ParseDouble(value, &endptr));
|
||||
|
||||
if (*endptr != '\0' || quality < -1.0f || quality > 10.0f)
|
||||
throw FormatRuntimeError("quality \"%s\" is not a number in the "
|
||||
"range -1 to 10",
|
||||
value);
|
||||
throw FmtRuntimeError("quality \"{}\" is not a number in the "
|
||||
"range -1 to 10",
|
||||
value);
|
||||
|
||||
if (block.GetBlockValue("bitrate") != nullptr)
|
||||
throw std::runtime_error("quality and bitrate are both defined");
|
||||
|
@@ -19,12 +19,12 @@
|
||||
|
||||
#include "VorbisEncoderPlugin.hxx"
|
||||
#include "OggEncoder.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "lib/xiph/VorbisComment.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "config/Domain.hxx"
|
||||
#include "util/StringUtil.hxx"
|
||||
#include "util/NumberParser.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
|
||||
#include <vorbis/vorbisenc.h>
|
||||
|
||||
@@ -88,9 +88,9 @@ PreparedVorbisEncoder::PreparedVorbisEncoder(const ConfigBlock &block)
|
||||
quality = ParseDouble(value, &endptr);
|
||||
|
||||
if (*endptr != '\0' || quality < -1.0f || quality > 10.0f)
|
||||
throw FormatRuntimeError("quality \"%s\" is not a number in the "
|
||||
"range -1 to 10",
|
||||
value);
|
||||
throw FmtRuntimeError("quality \"{}\" is not a number in the "
|
||||
"range -1 to 10",
|
||||
value);
|
||||
|
||||
if (block.GetBlockValue("bitrate") != nullptr)
|
||||
throw std::runtime_error("quality and bitrate are both defined");
|
||||
|
Reference in New Issue
Block a user