lib/fmt/RuntimeError: new library
Replacing FormatRuntimeError().
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "lib/alsa/NonBlock.hxx"
|
||||
#include "lib/alsa/PeriodBuffer.hxx"
|
||||
#include "lib/alsa/Version.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "lib/fmt/ToBuffer.hxx"
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "../Error.hxx"
|
||||
@@ -34,7 +35,6 @@
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "thread/Cond.hxx"
|
||||
#include "util/Manual.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "event/MultiSocketMonitor.hxx"
|
||||
#include "event/InjectEvent.hxx"
|
||||
@@ -846,8 +846,8 @@ AlsaOutput::Open(AudioFormat &audio_format)
|
||||
);
|
||||
} catch (...) {
|
||||
snd_pcm_close(pcm);
|
||||
std::throw_with_nested(FormatRuntimeError("Error opening ALSA device \"%s\"",
|
||||
GetDevice()));
|
||||
std::throw_with_nested(FmtRuntimeError("Error opening ALSA device \"{}\"",
|
||||
GetDevice()));
|
||||
}
|
||||
|
||||
work_around_drain_bug = MaybeDmix(pcm) &&
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
#include "AoOutputPlugin.hxx"
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "thread/SafeSingleton.hxx"
|
||||
#include "system/Error.hxx"
|
||||
#include "util/IterableSplitString.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/StringAPI.hxx"
|
||||
#include "util/StringSplit.hxx"
|
||||
@@ -121,8 +121,8 @@ AoOutput::AoOutput(const ConfigBlock &block)
|
||||
driver = ao_driver_id(value);
|
||||
|
||||
if (driver < 0)
|
||||
throw FormatRuntimeError("\"%s\" is not a valid ao driver",
|
||||
value);
|
||||
throw FmtRuntimeError("\"{}\" is not a valid ao driver",
|
||||
value);
|
||||
|
||||
ao_info *ai = ao_driver_info(driver);
|
||||
if (ai == nullptr)
|
||||
@@ -136,8 +136,8 @@ AoOutput::AoOutput(const ConfigBlock &block)
|
||||
for (const std::string_view i : IterableSplitString(value, ';')) {
|
||||
const auto [n, v] = Split(Strip(i), '=');
|
||||
if (n.empty() || v.data() == nullptr)
|
||||
throw FormatRuntimeError("problems parsing option \"%.*s\"",
|
||||
int(i.size()), i.data());
|
||||
throw FmtRuntimeError("problems parsing option \"{}\"",
|
||||
i);
|
||||
|
||||
ao_append_option(&options, std::string{n}.c_str(),
|
||||
std::string{v}.c_str());
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "../Timer.hxx"
|
||||
#include "lib/fmt/PathFormatter.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "fs/FileInfo.hxx"
|
||||
#include "lib/fmt/SystemError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "Log.hxx"
|
||||
#include "open.h"
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
class FifoOutput final : AudioOutput {
|
||||
const AllocatedPath path;
|
||||
std::string path_utf8;
|
||||
|
||||
int input = -1;
|
||||
int output = -1;
|
||||
@@ -84,8 +83,6 @@ FifoOutput::FifoOutput(const ConfigBlock &block)
|
||||
if (path.IsNull())
|
||||
throw std::runtime_error("No \"path\" parameter specified");
|
||||
|
||||
path_utf8 = path.ToUTF8();
|
||||
|
||||
OpenFifo();
|
||||
}
|
||||
|
||||
@@ -147,8 +144,8 @@ FifoOutput::Check()
|
||||
}
|
||||
|
||||
if (!S_ISFIFO(st.st_mode))
|
||||
throw FormatRuntimeError("\"%s\" already exists, but is not a FIFO",
|
||||
path_utf8.c_str());
|
||||
throw FmtRuntimeError("\"{}\" already exists, but is not a FIFO",
|
||||
path);
|
||||
}
|
||||
|
||||
inline void
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "../Error.hxx"
|
||||
#include "output/Features.h"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/IterableSplitString.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/SpanCast.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
@@ -123,8 +123,8 @@ private:
|
||||
|
||||
void Shutdown(const char *reason) noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
error = std::make_exception_ptr(FormatRuntimeError("JACK connection shutdown: %s",
|
||||
reason));
|
||||
error = std::make_exception_ptr(FmtRuntimeError("JACK connection shutdown: {}",
|
||||
reason));
|
||||
}
|
||||
|
||||
static void OnShutdown(jack_status_t, const char *reason,
|
||||
@@ -416,8 +416,8 @@ JackOutput::Connect()
|
||||
jack_status_t status;
|
||||
client = jack_client_open(name, options, &status, server_name);
|
||||
if (client == nullptr)
|
||||
throw FormatRuntimeError("Failed to connect to JACK server, status=%d",
|
||||
status);
|
||||
throw FmtRuntimeError("Failed to connect to JACK server, status={}",
|
||||
(unsigned)status);
|
||||
|
||||
jack_set_process_callback(client, Process, this);
|
||||
jack_on_info_shutdown(client, OnShutdown, this);
|
||||
@@ -430,8 +430,8 @@ JackOutput::Connect()
|
||||
portflags, 0);
|
||||
if (ports[i] == nullptr) {
|
||||
Disconnect();
|
||||
throw FormatRuntimeError("Cannot register output port \"%s\"",
|
||||
source_ports[i].c_str());
|
||||
throw FmtRuntimeError("Cannot register output port \"{}\"",
|
||||
source_ports[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -590,8 +590,8 @@ JackOutput::Start()
|
||||
dports[i]);
|
||||
if (ret != 0) {
|
||||
Stop();
|
||||
throw FormatRuntimeError("Not a valid JACK port: %s",
|
||||
dports[i]);
|
||||
throw FmtRuntimeError("Not a valid JACK port: {}",
|
||||
dports[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,8 +604,8 @@ JackOutput::Start()
|
||||
duplicate_port);
|
||||
if (ret != 0) {
|
||||
Stop();
|
||||
throw FormatRuntimeError("Not a valid JACK port: %s",
|
||||
duplicate_port);
|
||||
throw FmtRuntimeError("Not a valid JACK port: {}",
|
||||
duplicate_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "apple/Throw.hxx"
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "mixer/plugins/OSXMixerPlugin.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Manual.hxx"
|
||||
#include "pcm/Export.hxx"
|
||||
@@ -247,8 +247,8 @@ osx_output_parse_channel_map(const char *device_name,
|
||||
|
||||
while (*channel_map_str) {
|
||||
if (inserted_channels >= num_channels)
|
||||
throw FormatRuntimeError("%s: channel map contains more than %u entries or trailing garbage",
|
||||
device_name, num_channels);
|
||||
throw FmtRuntimeError("{}: channel map contains more than {} entries or trailing garbage",
|
||||
device_name, num_channels);
|
||||
|
||||
if (!want_number && *channel_map_str == ',') {
|
||||
++channel_map_str;
|
||||
@@ -262,8 +262,8 @@ osx_output_parse_channel_map(const char *device_name,
|
||||
char *endptr;
|
||||
channel_map[inserted_channels] = strtol(channel_map_str, &endptr, 10);
|
||||
if (channel_map[inserted_channels] < -1)
|
||||
throw FormatRuntimeError("%s: channel map value %d not allowed (must be -1 or greater)",
|
||||
device_name, channel_map[inserted_channels]);
|
||||
throw FmtRuntimeError("{}: channel map value {} not allowed (must be -1 or greater)",
|
||||
device_name, channel_map[inserted_channels]);
|
||||
|
||||
channel_map_str = endptr;
|
||||
want_number = false;
|
||||
@@ -275,13 +275,13 @@ osx_output_parse_channel_map(const char *device_name,
|
||||
continue;
|
||||
}
|
||||
|
||||
throw FormatRuntimeError("%s: invalid character '%c' in channel map",
|
||||
device_name, *channel_map_str);
|
||||
throw FmtRuntimeError("{}: invalid character '{}' in channel map",
|
||||
device_name, *channel_map_str);
|
||||
}
|
||||
|
||||
if (inserted_channels < num_channels)
|
||||
throw FormatRuntimeError("%s: channel map contains less than %u entries",
|
||||
device_name, num_channels);
|
||||
throw FmtRuntimeError("{}: channel map contains less than {} entries",
|
||||
device_name, num_channels);
|
||||
}
|
||||
|
||||
static UInt32
|
||||
@@ -453,8 +453,8 @@ osx_output_set_device_format(AudioDeviceID dev_id,
|
||||
sizeof(output_format),
|
||||
&output_format);
|
||||
if (err != noErr)
|
||||
throw FormatRuntimeError("Failed to change the stream format: %d",
|
||||
err);
|
||||
throw FmtRuntimeError("Failed to change the stream format: {}",
|
||||
err);
|
||||
}
|
||||
|
||||
return output_format.mSampleRate;
|
||||
@@ -582,8 +582,7 @@ FindAudioDeviceByName(const char *name)
|
||||
return id;
|
||||
}
|
||||
|
||||
throw FormatRuntimeError("Found no audio device with name '%s' ",
|
||||
name);
|
||||
throw FmtRuntimeError("Found no audio device names '{}'", name);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "OpenALOutputPlugin.hxx"
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -126,14 +126,14 @@ OpenALOutput::SetupContext()
|
||||
{
|
||||
device = alcOpenDevice(device_name);
|
||||
if (device == nullptr)
|
||||
throw FormatRuntimeError("Error opening OpenAL device \"%s\"",
|
||||
device_name);
|
||||
throw FmtRuntimeError("Error opening OpenAL device \"{}\"",
|
||||
device_name);
|
||||
|
||||
context = alcCreateContext(device, nullptr);
|
||||
if (context == nullptr) {
|
||||
alcCloseDevice(device);
|
||||
throw FormatRuntimeError("Error creating context for \"%s\"",
|
||||
device_name);
|
||||
throw FmtRuntimeError("Error creating context for \"{}\"",
|
||||
device_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "encoder/EncoderInterface.hxx"
|
||||
#include "encoder/Configured.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/StringAPI.hxx"
|
||||
@@ -105,8 +105,8 @@ require_block_string(const ConfigBlock &block, const char *name)
|
||||
{
|
||||
const char *value = block.GetBlockValue(name);
|
||||
if (value == nullptr)
|
||||
throw FormatRuntimeError("no \"%s\" defined for shout device defined "
|
||||
"at line %d\n", name, block.line);
|
||||
throw FmtRuntimeError("no \"{}\" defined for shout device defined "
|
||||
"at line {}\n", name, block.line);
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -140,8 +140,8 @@ ParseShoutTls(const char *value)
|
||||
else if (StringIsEqual(value, "rfc2817"))
|
||||
return SHOUT_TLS_RFC2817;
|
||||
else
|
||||
throw FormatRuntimeError("invalid shout TLS option \"%s\"",
|
||||
value);
|
||||
throw FmtRuntimeError("invalid shout TLS option \"{}\"",
|
||||
value);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -163,17 +163,17 @@ ParseShoutProtocol(const char *value, const char *mime_type)
|
||||
|
||||
if (StringIsEqual(value, "shoutcast")) {
|
||||
if (!StringIsEqual(mime_type, "audio/mpeg"))
|
||||
throw FormatRuntimeError("you cannot stream \"%s\" to shoutcast, use mp3",
|
||||
mime_type);
|
||||
throw FmtRuntimeError("you cannot stream \"{}\" to shoutcast, use mp3",
|
||||
mime_type);
|
||||
return SHOUT_PROTOCOL_ICY;
|
||||
} else if (StringIsEqual(value, "icecast1"))
|
||||
return SHOUT_PROTOCOL_XAUDIOCAST;
|
||||
else if (StringIsEqual(value, "icecast2"))
|
||||
return SHOUT_PROTOCOL_HTTP;
|
||||
else
|
||||
throw FormatRuntimeError("shout protocol \"%s\" is not \"shoutcast\" or "
|
||||
"\"icecast1\"or \"icecast2\"",
|
||||
value);
|
||||
throw FmtRuntimeError("shout protocol \"{}\" is not \"shoutcast\" or "
|
||||
"\"icecast1\"or \"icecast2\"",
|
||||
value);
|
||||
}
|
||||
|
||||
inline
|
||||
@@ -309,16 +309,16 @@ HandleShoutError(shout_t *shout_conn, int err)
|
||||
|
||||
case SHOUTERR_UNCONNECTED:
|
||||
case SHOUTERR_SOCKET:
|
||||
throw FormatRuntimeError("Lost shout connection to %s:%i: %s",
|
||||
shout_get_host(shout_conn),
|
||||
shout_get_port(shout_conn),
|
||||
shout_get_error(shout_conn));
|
||||
throw FmtRuntimeError("Lost shout connection to {}:{}: {}",
|
||||
shout_get_host(shout_conn),
|
||||
shout_get_port(shout_conn),
|
||||
shout_get_error(shout_conn));
|
||||
|
||||
default:
|
||||
throw FormatRuntimeError("connection to %s:%i error: %s",
|
||||
shout_get_host(shout_conn),
|
||||
shout_get_port(shout_conn),
|
||||
shout_get_error(shout_conn));
|
||||
throw FmtRuntimeError("connection to {}:{} error: {}",
|
||||
shout_get_host(shout_conn),
|
||||
shout_get_port(shout_conn),
|
||||
shout_get_error(shout_conn));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,10 +381,10 @@ ShoutOpen(shout_t *shout_conn)
|
||||
break;
|
||||
|
||||
default:
|
||||
throw FormatRuntimeError("problem opening connection to shout server %s:%i: %s",
|
||||
shout_get_host(shout_conn),
|
||||
shout_get_port(shout_conn),
|
||||
shout_get_error(shout_conn));
|
||||
throw FmtRuntimeError("problem opening connection to shout server {}:{}: {}",
|
||||
shout_get_host(shout_conn),
|
||||
shout_get_port(shout_conn),
|
||||
shout_get_error(shout_conn));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "pcm/Buffer.hxx"
|
||||
#include "mixer/plugins/WinmmMixerPlugin.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
|
||||
#include <array>
|
||||
@@ -91,7 +91,7 @@ MakeWaveOutError(MMRESULT result, const char *prefix)
|
||||
char buffer[256];
|
||||
if (waveOutGetErrorTextA(result, buffer,
|
||||
std::size(buffer)) == MMSYSERR_NOERROR)
|
||||
return FormatRuntimeError("%s: %s", prefix, buffer);
|
||||
return FmtRuntimeError("{}: {}", prefix, buffer);
|
||||
else
|
||||
return std::runtime_error(prefix);
|
||||
}
|
||||
@@ -122,8 +122,8 @@ get_device_id(const char *device_name)
|
||||
UINT id = strtoul(device_name, &endptr, 0);
|
||||
if (endptr > device_name && *endptr == 0) {
|
||||
if (id >= numdevs)
|
||||
throw FormatRuntimeError("device \"%s\" is not found",
|
||||
device_name);
|
||||
throw FmtRuntimeError("device \"{}\" is not found",
|
||||
device_name);
|
||||
|
||||
return id;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ get_device_id(const char *device_name)
|
||||
return i;
|
||||
}
|
||||
|
||||
throw FormatRuntimeError("device \"%s\" is not found", device_name);
|
||||
throw FmtRuntimeError("device \"{}\" is not found", device_name);
|
||||
}
|
||||
|
||||
WinmmOutput::WinmmOutput(const ConfigBlock &block)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "output/OutputAPI.hxx"
|
||||
#include "lib/icu/Win32.hxx"
|
||||
#include "lib/fmt/AudioFormatFormatter.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "mixer/plugins/WasapiMixerPlugin.hxx"
|
||||
#include "output/Error.hxx"
|
||||
#include "pcm/Export.hxx"
|
||||
@@ -36,7 +37,6 @@
|
||||
#include "thread/Thread.hxx"
|
||||
#include "util/AllocatedString.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/StringBuffer.hxx"
|
||||
#include "win32/Com.hxx"
|
||||
@@ -806,8 +806,8 @@ WasapiOutput::ChooseDevice()
|
||||
if (!SafeSilenceTry([this, &id]() { id = std::stoul(device_config); })) {
|
||||
device = SearchDevice(*enumerator, device_config);
|
||||
if (!device)
|
||||
throw FormatRuntimeError("Device '%s' not found",
|
||||
device_config.c_str());
|
||||
throw FmtRuntimeError("Device '{}' not found",
|
||||
device_config);
|
||||
} else
|
||||
device = GetDevice(*enumerator, id);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user