Commit f2c3d866 authored by Max Kellermann's avatar Max Kellermann

output: use StringIsEqual()

parent d7dbf47a
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "filter/plugins/VolumeFilterPlugin.hxx" #include "filter/plugins/VolumeFilterPlugin.hxx"
#include "filter/plugins/NormalizeFilterPlugin.hxx" #include "filter/plugins/NormalizeFilterPlugin.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "util/StringAPI.hxx"
#include "util/StringFormat.hxx" #include "util/StringFormat.hxx"
#include "Log.hxx" #include "Log.hxx"
...@@ -212,7 +213,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop, ...@@ -212,7 +213,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
const char *replay_gain_handler = const char *replay_gain_handler =
block.GetBlockValue("replay_gain_handler", "software"); block.GetBlockValue("replay_gain_handler", "software");
if (strcmp(replay_gain_handler, "none") != 0) { if (!StringIsEqual(replay_gain_handler, "none")) {
/* when using software volume, we lose quality by /* when using software volume, we lose quality by
invoking PcmVolume::Apply() twice; to avoid losing invoking PcmVolume::Apply() twice; to avoid losing
too much precision, we allow the ReplayGainFilter too much precision, we allow the ReplayGainFilter
...@@ -244,14 +245,14 @@ FilteredAudioOutput::Setup(EventLoop &event_loop, ...@@ -244,14 +245,14 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
/* use the hardware mixer for replay gain? */ /* use the hardware mixer for replay gain? */
if (strcmp(replay_gain_handler, "mixer") == 0) { if (StringIsEqual(replay_gain_handler, "mixer")) {
if (mixer != nullptr) if (mixer != nullptr)
replay_gain_filter_set_mixer(*prepared_replay_gain_filter, replay_gain_filter_set_mixer(*prepared_replay_gain_filter,
mixer, 100); mixer, 100);
else else
FormatError(output_domain, FormatError(output_domain,
"No such mixer for output '%s'", name); "No such mixer for output '%s'", name);
} else if (strcmp(replay_gain_handler, "software") != 0 && } else if (!StringIsEqual(replay_gain_handler, "software") &&
prepared_replay_gain_filter != nullptr) { prepared_replay_gain_filter != nullptr) {
throw std::runtime_error("Invalid \"replay_gain_handler\" value"); throw std::runtime_error("Invalid \"replay_gain_handler\" value");
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "config/Data.hxx" #include "config/Data.hxx"
#include "config/Option.hxx" #include "config/Option.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "util/StringAPI.hxx"
#include <stdexcept> #include <stdexcept>
...@@ -135,7 +136,7 @@ AudioOutputControl * ...@@ -135,7 +136,7 @@ AudioOutputControl *
MultipleOutputs::FindByName(const char *name) noexcept MultipleOutputs::FindByName(const char *name) noexcept
{ {
for (const auto &i : outputs) for (const auto &i : outputs)
if (strcmp(i->GetName(), name) == 0) if (StringIsEqual(i->GetName(), name))
return i.get(); return i.get();
return nullptr; return nullptr;
......
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
#include "plugins/sles/SlesOutputPlugin.hxx" #include "plugins/sles/SlesOutputPlugin.hxx"
#include "plugins/SolarisOutputPlugin.hxx" #include "plugins/SolarisOutputPlugin.hxx"
#include "plugins/WinmmOutputPlugin.hxx" #include "plugins/WinmmOutputPlugin.hxx"
#include "util/StringAPI.hxx"
#include <string.h>
const AudioOutputPlugin *const audio_output_plugins[] = { const AudioOutputPlugin *const audio_output_plugins[] = {
#ifdef HAVE_SHOUT #ifdef HAVE_SHOUT
...@@ -101,7 +100,7 @@ const AudioOutputPlugin * ...@@ -101,7 +100,7 @@ const AudioOutputPlugin *
AudioOutputPlugin_get(const char *name) AudioOutputPlugin_get(const char *name)
{ {
audio_output_plugins_for_each(plugin) audio_output_plugins_for_each(plugin)
if (strcmp(plugin->name, name) == 0) if (StringIsEqual(plugin->name, name))
return plugin; return plugin;
return nullptr; return nullptr;
......
...@@ -25,12 +25,11 @@ ...@@ -25,12 +25,11 @@
#include "util/SplitString.hxx" #include "util/SplitString.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "util/StringAPI.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <ao/ao.h> #include <ao/ao.h>
#include <string.h>
/* An ao_sample_format, with all fields set to zero: */ /* An ao_sample_format, with all fields set to zero: */
static ao_sample_format OUR_AO_FORMAT_INITIALIZER; static ao_sample_format OUR_AO_FORMAT_INITIALIZER;
...@@ -105,7 +104,7 @@ AoOutput::AoOutput(const ConfigBlock &block) ...@@ -105,7 +104,7 @@ AoOutput::AoOutput(const ConfigBlock &block)
write_size(block.GetPositiveValue("write_size", 1024u)) write_size(block.GetPositiveValue("write_size", 1024u))
{ {
const char *value = block.GetBlockValue("driver", "default"); const char *value = block.GetBlockValue("driver", "default");
if (0 == strcmp(value, "default")) if (StringIsEqual(value, "default"))
driver = ao_default_driver_id(); driver = ao_default_driver_id();
else else
driver = ao_driver_id(value); driver = ao_driver_id(value);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "thread/Mutex.hxx" #include "thread/Mutex.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include "util/ByteOrder.hxx" #include "util/ByteOrder.hxx"
#include "util/StringAPI.hxx"
#include "util/StringBuffer.hxx" #include "util/StringBuffer.hxx"
#include "util/StringFormat.hxx" #include "util/StringFormat.hxx"
#include "Log.hxx" #include "Log.hxx"
...@@ -135,11 +136,11 @@ OSXOutput::OSXOutput(const ConfigBlock &block) ...@@ -135,11 +136,11 @@ OSXOutput::OSXOutput(const ConfigBlock &block)
{ {
const char *device = block.GetBlockValue("device"); const char *device = block.GetBlockValue("device");
if (device == nullptr || 0 == strcmp(device, "default")) { if (device == nullptr || StringIsEqual(device, "default")) {
component_subtype = kAudioUnitSubType_DefaultOutput; component_subtype = kAudioUnitSubType_DefaultOutput;
device_name = nullptr; device_name = nullptr;
} }
else if (0 == strcmp(device, "system")) { else if (StringIsEqual(device, "system")) {
component_subtype = kAudioUnitSubType_SystemOutput; component_subtype = kAudioUnitSubType_SystemOutput;
device_name = nullptr; device_name = nullptr;
} }
...@@ -666,7 +667,7 @@ osx_output_set_device(OSXOutput *oo) ...@@ -666,7 +667,7 @@ osx_output_set_device(OSXOutput *oo)
kCFStringEncodingUTF8)) kCFStringEncodingUTF8))
throw std::runtime_error("Unable to convert device name from CFStringRef to char*"); throw std::runtime_error("Unable to convert device name from CFStringRef to char*");
if (strcmp(oo->device_name, name) == 0) { if (StringIsEqual(oo->device_name, name)) {
FormatDebug(osx_output_domain, FormatDebug(osx_output_domain,
"found matching device: ID=%u, name=%s", "found matching device: ID=%u, name=%s",
(unsigned)deviceids[i], name); (unsigned)deviceids[i], name);
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <memory> #include <memory>
#include <assert.h> #include <assert.h>
#include <string.h>
#include <stdio.h> #include <stdio.h>
static constexpr unsigned DEFAULT_CONN_TIMEOUT = 2; static constexpr unsigned DEFAULT_CONN_TIMEOUT = 2;
...@@ -122,15 +121,15 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) ...@@ -122,15 +121,15 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block)
unsigned protocol; unsigned protocol;
const char *value = block.GetBlockValue("protocol"); const char *value = block.GetBlockValue("protocol");
if (value != nullptr) { if (value != nullptr) {
if (0 == strcmp(value, "shoutcast") && if (StringIsEqual(value, "shoutcast") &&
!StringIsEqual(mime_type, "audio/mpeg")) !StringIsEqual(mime_type, "audio/mpeg"))
throw FormatRuntimeError("you cannot stream \"%s\" to shoutcast, use mp3", throw FormatRuntimeError("you cannot stream \"%s\" to shoutcast, use mp3",
mime_type); mime_type);
else if (0 == strcmp(value, "shoutcast")) else if (StringIsEqual(value, "shoutcast"))
protocol = SHOUT_PROTOCOL_ICY; protocol = SHOUT_PROTOCOL_ICY;
else if (0 == strcmp(value, "icecast1")) else if (StringIsEqual(value, "icecast1"))
protocol = SHOUT_PROTOCOL_XAUDIOCAST; protocol = SHOUT_PROTOCOL_XAUDIOCAST;
else if (0 == strcmp(value, "icecast2")) else if (StringIsEqual(value, "icecast2"))
protocol = SHOUT_PROTOCOL_HTTP; protocol = SHOUT_PROTOCOL_HTTP;
else else
throw FormatRuntimeError("shout protocol \"%s\" is not \"shoutcast\" or " throw FormatRuntimeError("shout protocol \"%s\" is not \"shoutcast\" or "
...@@ -144,15 +143,15 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) ...@@ -144,15 +143,15 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block)
unsigned tls; unsigned tls;
value = block.GetBlockValue("tls"); value = block.GetBlockValue("tls");
if (value != nullptr) { if (value != nullptr) {
if (0 == strcmp(value, "disabled")) if (StringIsEqual(value, "disabled"))
tls = SHOUT_TLS_DISABLED; tls = SHOUT_TLS_DISABLED;
else if(0 == strcmp(value, "auto")) else if (StringIsEqual(value, "auto"))
tls = SHOUT_TLS_AUTO; tls = SHOUT_TLS_AUTO;
else if(0 == strcmp(value, "auto_no_plain")) else if (StringIsEqual(value, "auto_no_plain"))
tls = SHOUT_TLS_AUTO_NO_PLAIN; tls = SHOUT_TLS_AUTO_NO_PLAIN;
else if(0 == strcmp(value, "rfc2818")) else if (StringIsEqual(value, "rfc2818"))
tls = SHOUT_TLS_RFC2818; tls = SHOUT_TLS_RFC2818;
else if(0 == strcmp(value, "rfc2817")) else if (StringIsEqual(value, "rfc2817"))
tls = SHOUT_TLS_RFC2817; tls = SHOUT_TLS_RFC2817;
else else
throw FormatRuntimeError("invalid shout TLS option \"%s\"", value); throw FormatRuntimeError("invalid shout TLS option \"%s\"", value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment