*: let libfmt quote strings

This commit is contained in:
Max Kellermann
2024-04-16 11:06:34 +02:00
parent 39c9e92f42
commit 0c1ecc96a8
71 changed files with 160 additions and 160 deletions

View File

@@ -268,7 +268,7 @@ AudioOutputControl::Open(std::unique_lock<Mutex> &lock,
output->mixer->LockOpen();
} catch (...) {
FmtError(output_domain,
"Failed to open mixer for '{}': {}",
"Failed to open mixer for {:?}: {}",
GetName(), std::current_exception());
}
}

View File

@@ -56,7 +56,7 @@ audio_output_detect()
continue;
FmtInfo(output_domain,
"Attempting to detect a {} audio device",
"Attempting to detect a {:?} audio device",
plugin->name);
if (ao_plugin_test_default_device(plugin))
return plugin;
@@ -154,7 +154,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block,
config_audio_format.Clear();
}
log_name = fmt::format("\"{}\" ({})", name, plugin_name);
log_name = fmt::format("{:?} ({})", name, plugin_name);
/* create the normalization filter (if configured) */
@@ -173,7 +173,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block,
has been set up already and even an empty one will
work (if only with unexpected behaviour) */
FmtError(output_domain,
"Failed to initialize filter chain for '{}': {}",
"Failed to initialize filter chain for {:?}: {}",
name, std::current_exception());
}
}
@@ -223,7 +223,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
mixer_listener);
} catch (...) {
FmtError(output_domain,
"Failed to initialize hardware mixer for '{}': {}",
"Failed to initialize hardware mixer for {:?}: {}",
name, std::current_exception());
}
@@ -235,7 +235,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
mixer, 100);
else
FmtError(output_domain,
"No such mixer for output '{}'", name);
"No such mixer for output {:?}", name);
} else if (!StringIsEqual(replay_gain_handler, "software") &&
prepared_replay_gain_filter != nullptr) {
throw std::runtime_error("Invalid \"replay_gain_handler\" value");

View File

@@ -57,7 +57,7 @@ audio_output_state_read(const char *line, MultipleOutputs &outputs)
auto *ao = outputs.FindByName(name);
if (ao == nullptr) {
FmtDebug(output_domain,
"Ignoring device state for '{}'", name);
"Ignoring device state for {:?}", name);
return true;
}

View File

@@ -792,14 +792,14 @@ AlsaOutput::Open(AudioFormat &audio_format)
SND_PCM_STREAM_PLAYBACK, mode);
if (err < 0)
throw Alsa::MakeError(err,
FmtBuffer<256>("Failed to open ALSA device \"{}\"",
FmtBuffer<256>("Failed to open ALSA device {:?}",
GetDevice()));
const char *pcm_name = snd_pcm_name(pcm);
if (pcm_name == nullptr)
pcm_name = "?";
FmtDebug(alsa_output_domain, "opened {} type={}",
FmtDebug(alsa_output_domain, "opened {:?} type={}",
pcm_name,
snd_pcm_type_name(snd_pcm_type(pcm)));
@@ -830,7 +830,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
);
} catch (...) {
snd_pcm_close(pcm);
std::throw_with_nested(FmtRuntimeError("Error opening ALSA device \"{}\"",
std::throw_with_nested(FmtRuntimeError("Error opening ALSA device {:?}",
GetDevice()));
}
@@ -891,11 +891,11 @@ AlsaOutput::Recover(int err) noexcept
{
if (err == -EPIPE) {
FmtDebug(alsa_output_domain,
"Underrun on ALSA device \"{}\"",
"Underrun on ALSA device {:?}",
GetDevice());
} else if (err == -ESTRPIPE) {
FmtDebug(alsa_output_domain,
"ALSA device \"{}\" was suspended",
"ALSA device {:?} was suspended",
GetDevice());
}

View File

@@ -105,14 +105,14 @@ AoOutput::AoOutput(const ConfigBlock &block)
driver = ao_driver_id(value);
if (driver < 0)
throw FmtRuntimeError("\"{}\" is not a valid ao driver",
throw FmtRuntimeError("{:?} is not a valid ao driver",
value);
ao_info *ai = ao_driver_info(driver);
if (ai == nullptr)
throw std::runtime_error("problems getting driver info");
FmtDebug(ao_output_domain, "using ao driver \"{}\" for \"{}\"\n",
FmtDebug(ao_output_domain, "using ao driver {:?} for {:?}\n",
ai->short_name, block.GetBlockValue("name", nullptr));
value = block.GetBlockValue("options", nullptr);
@@ -120,7 +120,7 @@ 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 FmtRuntimeError("problems parsing option \"{}\"",
throw FmtRuntimeError("problems parsing option {:?}",
i);
ao_append_option(&options, std::string{n}.c_str(),

View File

@@ -74,7 +74,7 @@ inline void
FifoOutput::Delete()
{
FmtDebug(fifo_output_domain,
"Removing FIFO \"{}\"", path);
"Removing FIFO {:?}", path);
try {
RemoveFile(path);
@@ -108,7 +108,7 @@ inline void
FifoOutput::Create()
{
if (!MakeFifo(path, 0666))
throw FmtErrno("Couldn't create FIFO \"{}\"", path);
throw FmtErrno("Couldn't create FIFO {:?}", path);
created = true;
}
@@ -124,11 +124,11 @@ FifoOutput::Check()
return;
}
throw FmtErrno("Failed to stat FIFO \"{}\"", path);
throw FmtErrno("Failed to stat FIFO {:?}", path);
}
if (!S_ISFIFO(st.st_mode))
throw FmtRuntimeError("\"{}\" already exists, but is not a FIFO",
throw FmtRuntimeError("{:?} already exists, but is not a FIFO",
path);
}
@@ -139,12 +139,12 @@ try {
input = OpenFile(path, O_RDONLY|O_NONBLOCK|O_BINARY, 0).Steal();
if (input < 0)
throw FmtErrno("Could not open FIFO \"{}\" for reading",
throw FmtErrno("Could not open FIFO {:?} for reading",
path);
output = OpenFile(path, O_WRONLY|O_NONBLOCK|O_BINARY, 0).Steal();
if (output < 0)
throw FmtErrno("Could not open FIFO \"{}\" for writing");
throw FmtErrno("Could not open FIFO {:?} for writing");
} catch (...) {
CloseFifo();
throw;
@@ -175,7 +175,7 @@ FifoOutput::Cancel() noexcept
if (bytes < 0 && errno != EAGAIN) {
FmtError(fifo_output_domain,
"Flush of FIFO \"{}\" failed: {}",
"Flush of FIFO {:?} failed: {}",
path, strerror(errno));
}
}

View File

@@ -410,7 +410,7 @@ JackOutput::Connect()
portflags, 0);
if (ports[i] == nullptr) {
Disconnect();
throw FmtRuntimeError("Cannot register output port \"{}\"",
throw FmtRuntimeError("Cannot register output port {:?}",
source_ports[i]);
}
}
@@ -521,7 +521,7 @@ JackOutput::Start()
jports[num_dports] != nullptr;
++num_dports) {
FmtDebug(jack_output_domain,
"destination_port[{}] = '{}'\n",
"destination_port[{}] = {:?}\n",
num_dports, jports[num_dports]);
dports[num_dports] = jports[num_dports];
}

View File

@@ -260,7 +260,7 @@ osx_output_parse_channel_map(const char *device_name,
continue;
}
throw FmtRuntimeError("{}: invalid character '{}' in channel map",
throw FmtRuntimeError("{}: invalid character {:?} in channel map",
device_name, *channel_map_str);
}
@@ -567,7 +567,7 @@ FindAudioDeviceByName(const char *name)
return id;
}
throw FmtRuntimeError("Found no audio device names '{}'", name);
throw FmtRuntimeError("Found no audio device names {:?}", name);
}
static void

View File

@@ -110,13 +110,13 @@ OpenALOutput::SetupContext()
{
device = alcOpenDevice(device_name);
if (device == nullptr)
throw FmtRuntimeError("Error opening OpenAL device \"{}\"",
throw FmtRuntimeError("Error opening OpenAL device {:?}",
device_name);
context = alcCreateContext(device, nullptr);
if (context == nullptr) {
alcCloseDevice(device);
throw FmtRuntimeError("Error creating context for \"{}\"",
throw FmtRuntimeError("Error creating context for {:?}",
device_name);
}
}

View File

@@ -166,7 +166,7 @@ oss_output_test_default_device() noexcept
return true;
FmtError(oss_output_domain,
"Error opening OSS device \"{}\": {}",
"Error opening OSS device {:?}: {}",
default_devices[i], strerror(errno));
}
@@ -621,7 +621,7 @@ try {
assert(!fd.IsDefined());
if (!fd.Open(device, O_WRONLY))
throw FmtErrno("Error opening OSS device \"{}\"", device);
throw FmtErrno("Error opening OSS device {:?}", device);
OssIoctlExact(fd, SNDCTL_DSP_CHANNELS, effective_channels,
"Failed to set channel count");
@@ -638,7 +638,7 @@ void
OssOutput::Open(AudioFormat &_audio_format)
try {
if (!fd.Open(device, O_WRONLY))
throw FmtErrno("Error opening OSS device \"{}\"", device);
throw FmtErrno("Error opening OSS device {:?}", device);
SetupOrDop(_audio_format);
} catch (...) {
@@ -676,7 +676,7 @@ OssOutput::Play(std::span<const std::byte> src)
return pcm_export->CalcInputSize(ret);
if (ret < 0 && errno != EINTR)
throw FmtErrno("Write error on {}", device);
throw FmtErrno("Write error on {:?}", device);
}
}

View File

@@ -45,7 +45,7 @@ PipeOutput::Open([[maybe_unused]] AudioFormat &audio_format)
{
fh = popen(cmd.c_str(), "w");
if (fh == nullptr)
throw FmtErrno("Error opening pipe \"{}\"", cmd);
throw FmtErrno("Error opening pipe {:?}", cmd);
}
std::size_t

View File

@@ -261,7 +261,7 @@ RecorderOutput::ReopenFormat(AllocatedPath &&new_path)
path = std::move(new_path);
file = new_file;
FmtDebug(recorder_domain, "Recording to \"{}\"", path);
FmtDebug(recorder_domain, "Recording to {:?}", path);
}
void

View File

@@ -88,7 +88,7 @@ require_block_string(const ConfigBlock &block, const char *name)
{
const char *value = block.GetBlockValue(name);
if (value == nullptr)
throw FmtRuntimeError("no \"{}\" defined for shout device defined "
throw FmtRuntimeError("no {:?} defined for shout device defined "
"at line {}\n", name, block.line);
return value;
@@ -123,7 +123,7 @@ ParseShoutTls(const char *value)
else if (StringIsEqual(value, "rfc2817"))
return SHOUT_TLS_RFC2817;
else
throw FmtRuntimeError("invalid shout TLS option \"{}\"",
throw FmtRuntimeError("invalid shout TLS option {:?}",
value);
}
@@ -146,7 +146,7 @@ ParseShoutProtocol(const char *value, const char *mime_type)
if (StringIsEqual(value, "shoutcast")) {
if (!StringIsEqual(mime_type, "audio/mpeg"))
throw FmtRuntimeError("you cannot stream \"{}\" to shoutcast, use mp3",
throw FmtRuntimeError("you cannot stream {:?} to shoutcast, use mp3",
mime_type);
return SHOUT_PROTOCOL_ICY;
} else if (StringIsEqual(value, "icecast1"))
@@ -154,7 +154,7 @@ ParseShoutProtocol(const char *value, const char *mime_type)
else if (StringIsEqual(value, "icecast2"))
return SHOUT_PROTOCOL_HTTP;
else
throw FmtRuntimeError("shout protocol \"{}\" is not \"shoutcast\" or "
throw FmtRuntimeError("shout protocol {:?} is not \"shoutcast\" or "
"\"icecast1\"or \"icecast2\"",
value);
}

View File

@@ -106,7 +106,7 @@ get_device_id(const char *device_name)
UINT id = strtoul(device_name, &endptr, 0);
if (endptr > device_name && *endptr == 0) {
if (id >= numdevs)
throw FmtRuntimeError("device \"{}\" is not found",
throw FmtRuntimeError("device {:?} is not found",
device_name);
return id;
@@ -127,7 +127,7 @@ get_device_id(const char *device_name)
return i;
}
throw FmtRuntimeError("device \"{}\" is not found", device_name);
throw FmtRuntimeError("device {:?} is not found", device_name);
}
WinmmOutput::WinmmOutput(const ConfigBlock &block)

View File

@@ -789,7 +789,7 @@ WasapiOutput::ChooseDevice()
if (!SafeSilenceTry([this, &id]() { id = std::stoul(device_config); })) {
device = SearchDevice(*enumerator, device_config);
if (!device)
throw FmtRuntimeError("Device '{}' not found",
throw FmtRuntimeError("Device {:?} not found",
device_config);
} else
device = GetDevice(*enumerator, id);
@@ -1007,7 +1007,7 @@ WasapiOutput::EnumerateDevices(IMMDeviceEnumerator &enumerator)
continue;
FmtNotice(wasapi_output_domain,
"Device \"{}\" \"{}\"", i, name.c_str());
"Device {:?} {:?}", i, name.c_str());
}
}