*: use nullptr instead of NULL
This commit is contained in:
parent
5a7c931293
commit
59f8144c50
@ -245,7 +245,7 @@ command_lookup(const char *name)
|
|||||||
a = i + 1;
|
a = i + 1;
|
||||||
} while (a < b);
|
} while (a < b);
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -256,7 +256,7 @@ command_check_request(const struct command *cmd, Client *client,
|
|||||||
int max = cmd->max + 1;
|
int max = cmd->max + 1;
|
||||||
|
|
||||||
if (cmd->permission != (permission & cmd->permission)) {
|
if (cmd->permission != (permission & cmd->permission)) {
|
||||||
if (client != NULL)
|
if (client != nullptr)
|
||||||
command_error(client, ACK_ERROR_PERMISSION,
|
command_error(client, ACK_ERROR_PERMISSION,
|
||||||
"you don't have permission for \"%s\"",
|
"you don't have permission for \"%s\"",
|
||||||
cmd->cmd);
|
cmd->cmd);
|
||||||
@ -267,18 +267,18 @@ command_check_request(const struct command *cmd, Client *client,
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (min == max && max != argc) {
|
if (min == max && max != argc) {
|
||||||
if (client != NULL)
|
if (client != nullptr)
|
||||||
command_error(client, ACK_ERROR_ARG,
|
command_error(client, ACK_ERROR_ARG,
|
||||||
"wrong number of arguments for \"%s\"",
|
"wrong number of arguments for \"%s\"",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
return false;
|
return false;
|
||||||
} else if (argc < min) {
|
} else if (argc < min) {
|
||||||
if (client != NULL)
|
if (client != nullptr)
|
||||||
command_error(client, ACK_ERROR_ARG,
|
command_error(client, ACK_ERROR_ARG,
|
||||||
"too few arguments for \"%s\"", argv[0]);
|
"too few arguments for \"%s\"", argv[0]);
|
||||||
return false;
|
return false;
|
||||||
} else if (argc > max && max /* != 0 */ ) {
|
} else if (argc > max && max /* != 0 */ ) {
|
||||||
if (client != NULL)
|
if (client != nullptr)
|
||||||
command_error(client, ACK_ERROR_ARG,
|
command_error(client, ACK_ERROR_ARG,
|
||||||
"too many arguments for \"%s\"", argv[0]);
|
"too many arguments for \"%s\"", argv[0]);
|
||||||
return false;
|
return false;
|
||||||
@ -295,20 +295,20 @@ command_checked_lookup(Client *client, unsigned permission,
|
|||||||
current_command = "";
|
current_command = "";
|
||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
cmd = command_lookup(argv[0]);
|
cmd = command_lookup(argv[0]);
|
||||||
if (cmd == NULL) {
|
if (cmd == nullptr) {
|
||||||
if (client != NULL)
|
if (client != nullptr)
|
||||||
command_error(client, ACK_ERROR_UNKNOWN,
|
command_error(client, ACK_ERROR_UNKNOWN,
|
||||||
"unknown command \"%s\"", argv[0]);
|
"unknown command \"%s\"", argv[0]);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_command = cmd->cmd;
|
current_command = cmd->cmd;
|
||||||
|
|
||||||
if (!command_check_request(cmd, client, permission, argc, argv))
|
if (!command_check_request(cmd, client, permission, argc, argv))
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ enum command_return
|
|||||||
command_process(Client *client, unsigned num, char *line)
|
command_process(Client *client, unsigned num, char *line)
|
||||||
{
|
{
|
||||||
Error error;
|
Error error;
|
||||||
char *argv[COMMAND_ARGV_MAX] = { NULL };
|
char *argv[COMMAND_ARGV_MAX] = { nullptr };
|
||||||
const struct command *cmd;
|
const struct command *cmd;
|
||||||
enum command_return ret = COMMAND_RETURN_ERROR;
|
enum command_return ret = COMMAND_RETURN_ERROR;
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ command_process(Client *client, unsigned num, char *line)
|
|||||||
|
|
||||||
Tokenizer tokenizer(line);
|
Tokenizer tokenizer(line);
|
||||||
argv[0] = tokenizer.NextWord(error);
|
argv[0] = tokenizer.NextWord(error);
|
||||||
if (argv[0] == NULL) {
|
if (argv[0] == nullptr) {
|
||||||
current_command = "";
|
current_command = "";
|
||||||
if (tokenizer.IsEnd())
|
if (tokenizer.IsEnd())
|
||||||
command_error(client, ACK_ERROR_UNKNOWN,
|
command_error(client, ACK_ERROR_UNKNOWN,
|
||||||
@ -336,7 +336,7 @@ command_process(Client *client, unsigned num, char *line)
|
|||||||
command_error(client, ACK_ERROR_UNKNOWN,
|
command_error(client, ACK_ERROR_UNKNOWN,
|
||||||
"%s", error.GetMessage());
|
"%s", error.GetMessage());
|
||||||
|
|
||||||
current_command = NULL;
|
current_command = nullptr;
|
||||||
|
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ command_process(Client *client, unsigned num, char *line)
|
|||||||
|
|
||||||
while (argc < COMMAND_ARGV_MAX &&
|
while (argc < COMMAND_ARGV_MAX &&
|
||||||
(argv[argc] =
|
(argv[argc] =
|
||||||
tokenizer.NextParam(error)) != NULL)
|
tokenizer.NextParam(error)) != nullptr)
|
||||||
++argc;
|
++argc;
|
||||||
|
|
||||||
/* some error checks; we have to set current_command because
|
/* some error checks; we have to set current_command because
|
||||||
@ -357,13 +357,13 @@ command_process(Client *client, unsigned num, char *line)
|
|||||||
|
|
||||||
if (argc >= COMMAND_ARGV_MAX) {
|
if (argc >= COMMAND_ARGV_MAX) {
|
||||||
command_error(client, ACK_ERROR_ARG, "Too many arguments");
|
command_error(client, ACK_ERROR_ARG, "Too many arguments");
|
||||||
current_command = NULL;
|
current_command = nullptr;
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tokenizer.IsEnd()) {
|
if (!tokenizer.IsEnd()) {
|
||||||
command_error(client, ACK_ERROR_ARG, "%s", error.GetMessage());
|
command_error(client, ACK_ERROR_ARG, "%s", error.GetMessage());
|
||||||
current_command = NULL;
|
current_command = nullptr;
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ command_process(Client *client, unsigned num, char *line)
|
|||||||
if (cmd)
|
if (cmd)
|
||||||
ret = cmd->handler(client, argc, argv);
|
ret = cmd->handler(client, argc, argv);
|
||||||
|
|
||||||
current_command = NULL;
|
current_command = nullptr;
|
||||||
command_list_num = 0;
|
command_list_num = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -49,8 +49,6 @@ public:
|
|||||||
* Opens an input_stream of a file within the archive.
|
* Opens an input_stream of a file within the archive.
|
||||||
*
|
*
|
||||||
* @param path the path within the archive
|
* @param path the path within the archive
|
||||||
* @param error_r location to store the error occurring, or
|
|
||||||
* NULL to ignore errors
|
|
||||||
*/
|
*/
|
||||||
virtual input_stream *OpenStream(const char *path,
|
virtual input_stream *OpenStream(const char *path,
|
||||||
Mutex &mutex, Cond &cond,
|
Mutex &mutex, Cond &cond,
|
||||||
|
@ -38,7 +38,7 @@ const struct archive_plugin *const archive_plugins[] = {
|
|||||||
#ifdef HAVE_ISO9660
|
#ifdef HAVE_ISO9660
|
||||||
&iso9660_archive_plugin,
|
&iso9660_archive_plugin,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
/** which plugins have been initialized successfully? */
|
/** which plugins have been initialized successfully? */
|
||||||
@ -51,15 +51,15 @@ static bool archive_plugins_enabled[ARRAY_SIZE(archive_plugins) - 1];
|
|||||||
const struct archive_plugin *
|
const struct archive_plugin *
|
||||||
archive_plugin_from_suffix(const char *suffix)
|
archive_plugin_from_suffix(const char *suffix)
|
||||||
{
|
{
|
||||||
if (suffix == NULL)
|
if (suffix == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
archive_plugins_for_each_enabled(plugin)
|
archive_plugins_for_each_enabled(plugin)
|
||||||
if (plugin->suffixes != NULL &&
|
if (plugin->suffixes != nullptr &&
|
||||||
string_array_contains(plugin->suffixes, suffix))
|
string_array_contains(plugin->suffixes, suffix))
|
||||||
return plugin;
|
return plugin;
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct archive_plugin *
|
const struct archive_plugin *
|
||||||
@ -69,14 +69,14 @@ archive_plugin_from_name(const char *name)
|
|||||||
if (strcmp(plugin->name, name) == 0)
|
if (strcmp(plugin->name, name) == 0)
|
||||||
return plugin;
|
return plugin;
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void archive_plugin_init_all(void)
|
void archive_plugin_init_all(void)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; archive_plugins[i] != NULL; ++i) {
|
for (unsigned i = 0; archive_plugins[i] != nullptr; ++i) {
|
||||||
const struct archive_plugin *plugin = archive_plugins[i];
|
const struct archive_plugin *plugin = archive_plugins[i];
|
||||||
if (plugin->init == NULL || archive_plugins[i]->init())
|
if (plugin->init == nullptr || archive_plugins[i]->init())
|
||||||
archive_plugins_enabled[i] = true;
|
archive_plugins_enabled[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ void archive_plugin_init_all(void)
|
|||||||
void archive_plugin_deinit_all(void)
|
void archive_plugin_deinit_all(void)
|
||||||
{
|
{
|
||||||
archive_plugins_for_each_enabled(plugin)
|
archive_plugins_for_each_enabled(plugin)
|
||||||
if (plugin->finish != NULL)
|
if (plugin->finish != nullptr)
|
||||||
plugin->finish();
|
plugin->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ extern const struct archive_plugin *const archive_plugins[];
|
|||||||
#define archive_plugins_for_each(plugin) \
|
#define archive_plugins_for_each(plugin) \
|
||||||
for (const struct archive_plugin *plugin, \
|
for (const struct archive_plugin *plugin, \
|
||||||
*const*archive_plugin_iterator = &archive_plugins[0]; \
|
*const*archive_plugin_iterator = &archive_plugins[0]; \
|
||||||
(plugin = *archive_plugin_iterator) != NULL; \
|
(plugin = *archive_plugin_iterator) != nullptr; \
|
||||||
++archive_plugin_iterator)
|
++archive_plugin_iterator)
|
||||||
|
|
||||||
/* interface for using plugins */
|
/* interface for using plugins */
|
||||||
|
@ -28,9 +28,9 @@ ArchiveFile *
|
|||||||
archive_file_open(const struct archive_plugin *plugin, const char *path,
|
archive_file_open(const struct archive_plugin *plugin, const char *path,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
assert(plugin != NULL);
|
assert(plugin != nullptr);
|
||||||
assert(plugin->open != NULL);
|
assert(plugin->open != nullptr);
|
||||||
assert(path != NULL);
|
assert(path != nullptr);
|
||||||
|
|
||||||
ArchiveFile *file = plugin->open(path, error);
|
ArchiveFile *file = plugin->open(path, error);
|
||||||
assert((file == nullptr) == error.IsDefined());
|
assert((file == nullptr) == error.IsDefined());
|
||||||
|
@ -29,14 +29,14 @@ struct archive_plugin {
|
|||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* optional, set this to NULL if the archive plugin doesn't
|
* optional, set this to nullptr if the archive plugin doesn't
|
||||||
* have/need one this must false if there is an error and
|
* have/need one this must false if there is an error and
|
||||||
* true otherwise
|
* true otherwise
|
||||||
*/
|
*/
|
||||||
bool (*init)(void);
|
bool (*init)(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* optional, set this to NULL if the archive plugin doesn't
|
* optional, set this to nullptr if the archive plugin doesn't
|
||||||
* have/need one
|
* have/need one
|
||||||
*/
|
*/
|
||||||
void (*finish)(void);
|
void (*finish)(void);
|
||||||
@ -44,13 +44,13 @@ struct archive_plugin {
|
|||||||
/**
|
/**
|
||||||
* tryes to open archive file and associates handle with archive
|
* tryes to open archive file and associates handle with archive
|
||||||
* returns pointer to handle used is all operations with this archive
|
* returns pointer to handle used is all operations with this archive
|
||||||
* or NULL when opening fails
|
* or nullptr when opening fails
|
||||||
*/
|
*/
|
||||||
ArchiveFile *(*open)(const char *path_fs, Error &error);
|
ArchiveFile *(*open)(const char *path_fs, Error &error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* suffixes handled by this plugin.
|
* suffixes handled by this plugin.
|
||||||
* last element in these arrays must always be a NULL
|
* last element in these arrays must always be a nullptr
|
||||||
*/
|
*/
|
||||||
const char *const*suffixes;
|
const char *const*suffixes;
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,7 @@ Client::OnSocketInput(void *data, size_t length)
|
|||||||
{
|
{
|
||||||
char *p = (char *)data;
|
char *p = (char *)data;
|
||||||
char *newline = (char *)memchr(p, '\n', length);
|
char *newline = (char *)memchr(p, '\n', length);
|
||||||
if (newline == NULL)
|
if (newline == nullptr)
|
||||||
return InputResult::MORE;
|
return InputResult::MORE;
|
||||||
|
|
||||||
TimeoutMonitor::ScheduleSeconds(client_timeout);
|
TimeoutMonitor::ScheduleSeconds(client_timeout);
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
enum client_subscribe_result
|
enum client_subscribe_result
|
||||||
client_subscribe(Client *client, const char *channel)
|
client_subscribe(Client *client, const char *channel)
|
||||||
{
|
{
|
||||||
assert(client != NULL);
|
assert(client != nullptr);
|
||||||
assert(channel != NULL);
|
assert(channel != nullptr);
|
||||||
|
|
||||||
if (!client_message_valid_channel_name(channel))
|
if (!client_message_valid_channel_name(channel))
|
||||||
return CLIENT_SUBSCRIBE_INVALID;
|
return CLIENT_SUBSCRIBE_INVALID;
|
||||||
@ -78,7 +78,7 @@ client_unsubscribe_all(Client *client)
|
|||||||
bool
|
bool
|
||||||
client_push_message(Client *client, const ClientMessage &msg)
|
client_push_message(Client *client, const ClientMessage &msg)
|
||||||
{
|
{
|
||||||
assert(client != NULL);
|
assert(client != nullptr);
|
||||||
|
|
||||||
if (client->messages.size() >= CLIENT_MAX_MESSAGES ||
|
if (client->messages.size() >= CLIENT_MAX_MESSAGES ||
|
||||||
!client->IsSubscribed(msg.GetChannel()))
|
!client->IsSubscribed(msg.GetChannel()))
|
||||||
|
@ -79,8 +79,8 @@ static void version(void)
|
|||||||
printf(" [%s]", plugin->name);
|
printf(" [%s]", plugin->name);
|
||||||
|
|
||||||
const char *const*suffixes = plugin->suffixes;
|
const char *const*suffixes = plugin->suffixes;
|
||||||
if (suffixes != NULL)
|
if (suffixes != nullptr)
|
||||||
for (; *suffixes != NULL; ++suffixes)
|
for (; *suffixes != nullptr; ++suffixes)
|
||||||
printf(" %s", *suffixes);
|
printf(" %s", *suffixes);
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
@ -107,8 +107,8 @@ static void version(void)
|
|||||||
printf(" [%s]", plugin->name);
|
printf(" [%s]", plugin->name);
|
||||||
|
|
||||||
const char *const*suffixes = plugin->suffixes;
|
const char *const*suffixes = plugin->suffixes;
|
||||||
if (suffixes != NULL)
|
if (suffixes != nullptr)
|
||||||
for (; *suffixes != NULL; ++suffixes)
|
for (; *suffixes != nullptr; ++suffixes)
|
||||||
printf(" %s", *suffixes);
|
printf(" %s", *suffixes);
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
@ -156,19 +156,19 @@ parse_cmdline(int argc, char **argv, struct options *options,
|
|||||||
option_no_config;
|
option_no_config;
|
||||||
const GOptionEntry entries[] = {
|
const GOptionEntry entries[] = {
|
||||||
{ "kill", 0, 0, G_OPTION_ARG_NONE, &options->kill,
|
{ "kill", 0, 0, G_OPTION_ARG_NONE, &options->kill,
|
||||||
"kill the currently running mpd session", NULL },
|
"kill the currently running mpd session", nullptr },
|
||||||
{ "no-config", 0, 0, G_OPTION_ARG_NONE, &option_no_config,
|
{ "no-config", 0, 0, G_OPTION_ARG_NONE, &option_no_config,
|
||||||
"don't read from config", NULL },
|
"don't read from config", nullptr },
|
||||||
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &option_no_daemon,
|
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &option_no_daemon,
|
||||||
"don't detach from console", NULL },
|
"don't detach from console", nullptr },
|
||||||
{ "stdout", 0, 0, G_OPTION_ARG_NONE, &options->log_stderr,
|
{ "stdout", 0, 0, G_OPTION_ARG_NONE, &options->log_stderr,
|
||||||
NULL, NULL },
|
nullptr, nullptr },
|
||||||
{ "stderr", 0, 0, G_OPTION_ARG_NONE, &options->log_stderr,
|
{ "stderr", 0, 0, G_OPTION_ARG_NONE, &options->log_stderr,
|
||||||
"print messages to stderr", NULL },
|
"print messages to stderr", nullptr },
|
||||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &options->verbose,
|
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &options->verbose,
|
||||||
"verbose logging", NULL },
|
"verbose logging", nullptr },
|
||||||
{ "version", 'V', 0, G_OPTION_ARG_NONE, &option_version,
|
{ "version", 'V', 0, G_OPTION_ARG_NONE, &option_version,
|
||||||
"print version number", NULL },
|
"print version number", nullptr },
|
||||||
{ nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr }
|
{ nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ parse_cmdline(int argc, char **argv, struct options *options,
|
|||||||
options->verbose = false;
|
options->verbose = false;
|
||||||
|
|
||||||
context = g_option_context_new("[path/to/mpd.conf]");
|
context = g_option_context_new("[path/to/mpd.conf]");
|
||||||
g_option_context_add_main_entries(context, entries, NULL);
|
g_option_context_add_main_entries(context, entries, nullptr);
|
||||||
|
|
||||||
g_option_context_set_summary(context, summary);
|
g_option_context_set_summary(context, summary);
|
||||||
|
|
||||||
|
@ -49,13 +49,13 @@ config_read_name_value(struct config_param *param, char *input, unsigned line,
|
|||||||
Tokenizer tokenizer(input);
|
Tokenizer tokenizer(input);
|
||||||
|
|
||||||
const char *name = tokenizer.NextWord(error);
|
const char *name = tokenizer.NextWord(error);
|
||||||
if (name == NULL) {
|
if (name == nullptr) {
|
||||||
assert(!tokenizer.IsEnd());
|
assert(!tokenizer.IsEnd());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *value = tokenizer.NextString(error);
|
const char *value = tokenizer.NextString(error);
|
||||||
if (value == NULL) {
|
if (value == nullptr) {
|
||||||
if (tokenizer.IsEnd()) {
|
if (tokenizer.IsEnd()) {
|
||||||
error.Set(config_file_domain, "Value missing");
|
error.Set(config_file_domain, "Value missing");
|
||||||
} else {
|
} else {
|
||||||
@ -71,7 +71,7 @@ config_read_name_value(struct config_param *param, char *input, unsigned line,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const struct block_param *bp = param->GetBlockParam(name);
|
const struct block_param *bp = param->GetBlockParam(name);
|
||||||
if (bp != NULL) {
|
if (bp != nullptr) {
|
||||||
error.Format(config_file_domain,
|
error.Format(config_file_domain,
|
||||||
"\"%s\" is duplicate, first defined on line %i",
|
"\"%s\" is duplicate, first defined on line %i",
|
||||||
name, bp->line);
|
name, bp->line);
|
||||||
@ -91,11 +91,11 @@ config_read_block(FILE *fp, int *count, char *string, Error &error)
|
|||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
line = fgets(string, MAX_STRING_SIZE, fp);
|
line = fgets(string, MAX_STRING_SIZE, fp);
|
||||||
if (line == NULL) {
|
if (line == nullptr) {
|
||||||
delete ret;
|
delete ret;
|
||||||
error.Set(config_file_domain,
|
error.Set(config_file_domain,
|
||||||
"Expected '}' before end-of-file");
|
"Expected '}' before end-of-file");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
@ -125,7 +125,7 @@ config_read_block(FILE *fp, int *count, char *string, Error &error)
|
|||||||
assert(*line != 0);
|
assert(*line != 0);
|
||||||
delete ret;
|
delete ret;
|
||||||
error.FormatPrefix("line %i: ", *count);
|
error.FormatPrefix("line %i: ", *count);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error)
|
|||||||
|
|
||||||
Tokenizer tokenizer(line);
|
Tokenizer tokenizer(line);
|
||||||
name = tokenizer.NextWord(error);
|
name = tokenizer.NextWord(error);
|
||||||
if (name == NULL) {
|
if (name == nullptr) {
|
||||||
assert(!tokenizer.IsEnd());
|
assert(!tokenizer.IsEnd());
|
||||||
error.FormatPrefix("line %i: ", count);
|
error.FormatPrefix("line %i: ", count);
|
||||||
return false;
|
return false;
|
||||||
@ -217,14 +217,14 @@ ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
param = config_read_block(fp, &count, string, error);
|
param = config_read_block(fp, &count, string, error);
|
||||||
if (param == NULL) {
|
if (param == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* a string value */
|
/* a string value */
|
||||||
|
|
||||||
value = tokenizer.NextString(error);
|
value = tokenizer.NextString(error);
|
||||||
if (value == NULL) {
|
if (value == nullptr) {
|
||||||
if (tokenizer.IsEnd())
|
if (tokenizer.IsEnd())
|
||||||
error.Format(config_file_domain,
|
error.Format(config_file_domain,
|
||||||
"line %i: Value missing",
|
"line %i: Value missing",
|
||||||
|
@ -45,7 +45,7 @@ static bool is_simple;
|
|||||||
bool
|
bool
|
||||||
DatabaseGlobalInit(const config_param ¶m, Error &error)
|
DatabaseGlobalInit(const config_param ¶m, Error &error)
|
||||||
{
|
{
|
||||||
assert(db == NULL);
|
assert(db == nullptr);
|
||||||
assert(!db_is_open);
|
assert(!db_is_open);
|
||||||
|
|
||||||
const char *plugin_name =
|
const char *plugin_name =
|
||||||
@ -53,14 +53,14 @@ DatabaseGlobalInit(const config_param ¶m, Error &error)
|
|||||||
is_simple = strcmp(plugin_name, "simple") == 0;
|
is_simple = strcmp(plugin_name, "simple") == 0;
|
||||||
|
|
||||||
const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name);
|
const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name);
|
||||||
if (plugin == NULL) {
|
if (plugin == nullptr) {
|
||||||
error.Format(db_domain,
|
error.Format(db_domain,
|
||||||
"No such database plugin: %s", plugin_name);
|
"No such database plugin: %s", plugin_name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
db = plugin->create(param, error);
|
db = plugin->create(param, error);
|
||||||
return db != NULL;
|
return db != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -69,14 +69,14 @@ DatabaseGlobalDeinit(void)
|
|||||||
if (db_is_open)
|
if (db_is_open)
|
||||||
db->Close();
|
db->Close();
|
||||||
|
|
||||||
if (db != NULL)
|
if (db != nullptr)
|
||||||
delete db;
|
delete db;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Database *
|
const Database *
|
||||||
GetDatabase()
|
GetDatabase()
|
||||||
{
|
{
|
||||||
assert(db == NULL || db_is_open);
|
assert(db == nullptr || db_is_open);
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ GetDatabase(Error &error)
|
|||||||
bool
|
bool
|
||||||
db_is_simple(void)
|
db_is_simple(void)
|
||||||
{
|
{
|
||||||
assert(db == NULL || db_is_open);
|
assert(db == nullptr || db_is_open);
|
||||||
|
|
||||||
return is_simple;
|
return is_simple;
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ db_is_simple(void)
|
|||||||
Directory *
|
Directory *
|
||||||
db_get_root(void)
|
db_get_root(void)
|
||||||
{
|
{
|
||||||
assert(db != NULL);
|
assert(db != nullptr);
|
||||||
assert(db_is_simple());
|
assert(db_is_simple());
|
||||||
|
|
||||||
return ((SimpleDatabase *)db)->GetRoot();
|
return ((SimpleDatabase *)db)->GetRoot();
|
||||||
@ -112,11 +112,11 @@ db_get_root(void)
|
|||||||
Directory *
|
Directory *
|
||||||
db_get_directory(const char *name)
|
db_get_directory(const char *name)
|
||||||
{
|
{
|
||||||
if (db == NULL)
|
if (db == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
Directory *music_root = db_get_root();
|
Directory *music_root = db_get_root();
|
||||||
if (name == NULL)
|
if (name == nullptr)
|
||||||
return music_root;
|
return music_root;
|
||||||
|
|
||||||
return music_root->LookupDirectory(name);
|
return music_root->LookupDirectory(name);
|
||||||
@ -125,7 +125,7 @@ db_get_directory(const char *name)
|
|||||||
bool
|
bool
|
||||||
db_save(Error &error)
|
db_save(Error &error)
|
||||||
{
|
{
|
||||||
assert(db != NULL);
|
assert(db != nullptr);
|
||||||
assert(db_is_open);
|
assert(db_is_open);
|
||||||
assert(db_is_simple());
|
assert(db_is_simple());
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ db_save(Error &error)
|
|||||||
bool
|
bool
|
||||||
DatabaseGlobalOpen(Error &error)
|
DatabaseGlobalOpen(Error &error)
|
||||||
{
|
{
|
||||||
assert(db != NULL);
|
assert(db != nullptr);
|
||||||
assert(!db_is_open);
|
assert(!db_is_open);
|
||||||
|
|
||||||
if (!db->Open(error))
|
if (!db->Open(error))
|
||||||
@ -151,7 +151,7 @@ DatabaseGlobalOpen(Error &error)
|
|||||||
time_t
|
time_t
|
||||||
db_get_mtime(void)
|
db_get_mtime(void)
|
||||||
{
|
{
|
||||||
assert(db != NULL);
|
assert(db != nullptr);
|
||||||
assert(db_is_open);
|
assert(db_is_open);
|
||||||
assert(db_is_simple());
|
assert(db_is_simple());
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ bool
|
|||||||
DatabaseGlobalOpen(Error &error);
|
DatabaseGlobalOpen(Error &error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the global #Database instance. May return NULL if this MPD
|
* Returns the global #Database instance. May return nullptr if this MPD
|
||||||
* configuration has no database (no music_directory was configured).
|
* configuration has no database (no music_directory was configured).
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
@ -49,7 +49,7 @@ const Database *
|
|||||||
GetDatabase();
|
GetDatabase();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the global #Database instance. May return NULL if this MPD
|
* Returns the global #Database instance. May return nullptr if this MPD
|
||||||
* configuration has no database (no music_directory was configured).
|
* configuration has no database (no music_directory was configured).
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
|
@ -69,11 +69,11 @@ print_playlist_in_directory(Client *client,
|
|||||||
static bool
|
static bool
|
||||||
PrintSongBrief(Client *client, Song &song)
|
PrintSongBrief(Client *client, Song &song)
|
||||||
{
|
{
|
||||||
assert(song.parent != NULL);
|
assert(song.parent != nullptr);
|
||||||
|
|
||||||
song_print_uri(client, &song);
|
song_print_uri(client, &song);
|
||||||
|
|
||||||
if (song.tag != NULL && song.tag->has_playlist)
|
if (song.tag != nullptr && song.tag->has_playlist)
|
||||||
/* this song file has an embedded CUE sheet */
|
/* this song file has an embedded CUE sheet */
|
||||||
print_playlist_in_directory(client, *song.parent, song.uri);
|
print_playlist_in_directory(client, *song.parent, song.uri);
|
||||||
|
|
||||||
@ -83,11 +83,11 @@ PrintSongBrief(Client *client, Song &song)
|
|||||||
static bool
|
static bool
|
||||||
PrintSongFull(Client *client, Song &song)
|
PrintSongFull(Client *client, Song &song)
|
||||||
{
|
{
|
||||||
assert(song.parent != NULL);
|
assert(song.parent != nullptr);
|
||||||
|
|
||||||
song_print_info(client, &song);
|
song_print_info(client, &song);
|
||||||
|
|
||||||
if (song.tag != NULL && song.tag->has_playlist)
|
if (song.tag != nullptr && song.tag->has_playlist)
|
||||||
/* this song file has an embedded CUE sheet */
|
/* this song file has an embedded CUE sheet */
|
||||||
print_playlist_in_directory(client, *song.parent, song.uri);
|
print_playlist_in_directory(client, *song.parent, song.uri);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ const DatabasePlugin *const database_plugins[] = {
|
|||||||
#ifdef HAVE_LIBMPDCLIENT
|
#ifdef HAVE_LIBMPDCLIENT
|
||||||
&proxy_db_plugin,
|
&proxy_db_plugin,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const DatabasePlugin *
|
const DatabasePlugin *
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
struct DatabasePlugin;
|
struct DatabasePlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NULL terminated list of all database plugins which were enabled at
|
* nullptr terminated list of all database plugins which were enabled at
|
||||||
* compile time.
|
* compile time.
|
||||||
*/
|
*/
|
||||||
extern const DatabasePlugin *const database_plugins[];
|
extern const DatabasePlugin *const database_plugins[];
|
||||||
|
@ -51,7 +51,7 @@ enum {
|
|||||||
void
|
void
|
||||||
db_save_internal(FILE *fp, const Directory *music_root)
|
db_save_internal(FILE *fp, const Directory *music_root)
|
||||||
{
|
{
|
||||||
assert(music_root != NULL);
|
assert(music_root != nullptr);
|
||||||
|
|
||||||
fprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
|
fprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
|
||||||
fprintf(fp, DB_FORMAT_PREFIX "%u\n", DB_FORMAT);
|
fprintf(fp, DB_FORMAT_PREFIX "%u\n", DB_FORMAT);
|
||||||
@ -76,18 +76,18 @@ db_load_internal(TextFile &file, Directory *music_root, Error &error)
|
|||||||
bool success;
|
bool success;
|
||||||
bool tags[TAG_NUM_OF_ITEM_TYPES];
|
bool tags[TAG_NUM_OF_ITEM_TYPES];
|
||||||
|
|
||||||
assert(music_root != NULL);
|
assert(music_root != nullptr);
|
||||||
|
|
||||||
/* get initial info */
|
/* get initial info */
|
||||||
line = file.ReadLine();
|
line = file.ReadLine();
|
||||||
if (line == NULL || strcmp(DIRECTORY_INFO_BEGIN, line) != 0) {
|
if (line == nullptr || strcmp(DIRECTORY_INFO_BEGIN, line) != 0) {
|
||||||
error.Set(db_domain, "Database corrupted");
|
error.Set(db_domain, "Database corrupted");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(tags, false, sizeof(tags));
|
memset(tags, false, sizeof(tags));
|
||||||
|
|
||||||
while ((line = file.ReadLine()) != NULL &&
|
while ((line = file.ReadLine()) != nullptr &&
|
||||||
strcmp(line, DIRECTORY_INFO_END) != 0) {
|
strcmp(line, DIRECTORY_INFO_END) != 0) {
|
||||||
if (g_str_has_prefix(line, DB_FORMAT_PREFIX)) {
|
if (g_str_has_prefix(line, DB_FORMAT_PREFIX)) {
|
||||||
format = atoi(line + sizeof(DB_FORMAT_PREFIX) - 1);
|
format = atoi(line + sizeof(DB_FORMAT_PREFIX) - 1);
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
class SongFilter;
|
class SongFilter;
|
||||||
struct Song;
|
struct Song;
|
||||||
@ -31,7 +30,7 @@ struct Song;
|
|||||||
struct DatabaseSelection {
|
struct DatabaseSelection {
|
||||||
/**
|
/**
|
||||||
* The base URI of the search (UTF-8). Must not begin or end
|
* The base URI of the search (UTF-8). Must not begin or end
|
||||||
* with a slash. NULL or an empty string searches the whole
|
* with a slash. nullptr or an empty string searches the whole
|
||||||
* database.
|
* database.
|
||||||
*/
|
*/
|
||||||
const char *uri;
|
const char *uri;
|
||||||
@ -46,7 +45,7 @@ struct DatabaseSelection {
|
|||||||
DatabaseSelection(const char *_uri, bool _recursive,
|
DatabaseSelection(const char *_uri, bool _recursive,
|
||||||
const SongFilter *_filter=nullptr)
|
const SongFilter *_filter=nullptr)
|
||||||
:uri(_uri), recursive(_recursive), filter(_filter) {
|
:uri(_uri), recursive(_recursive), filter(_filter) {
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
|
@ -45,10 +45,10 @@ decoder_initialized(struct decoder *decoder,
|
|||||||
struct audio_format_string af_string;
|
struct audio_format_string af_string;
|
||||||
|
|
||||||
assert(dc->state == DecoderState::START);
|
assert(dc->state == DecoderState::START);
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != nullptr);
|
||||||
assert(decoder != NULL);
|
assert(decoder != nullptr);
|
||||||
assert(decoder->stream_tag == NULL);
|
assert(decoder->stream_tag == nullptr);
|
||||||
assert(decoder->decoder_tag == NULL);
|
assert(decoder->decoder_tag == nullptr);
|
||||||
assert(!decoder->seeking);
|
assert(!decoder->seeking);
|
||||||
assert(audio_format.IsDefined());
|
assert(audio_format.IsDefined());
|
||||||
assert(audio_format.IsValid());
|
assert(audio_format.IsValid());
|
||||||
@ -83,7 +83,7 @@ static bool
|
|||||||
decoder_prepare_initial_seek(struct decoder *decoder)
|
decoder_prepare_initial_seek(struct decoder *decoder)
|
||||||
{
|
{
|
||||||
const struct decoder_control *dc = decoder->dc;
|
const struct decoder_control *dc = decoder->dc;
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != nullptr);
|
||||||
|
|
||||||
if (dc->state != DecoderState::DECODE)
|
if (dc->state != DecoderState::DECODE)
|
||||||
/* wait until the decoder has finished initialisation
|
/* wait until the decoder has finished initialisation
|
||||||
@ -130,7 +130,7 @@ static DecoderCommand
|
|||||||
decoder_get_virtual_command(struct decoder *decoder)
|
decoder_get_virtual_command(struct decoder *decoder)
|
||||||
{
|
{
|
||||||
const struct decoder_control *dc = decoder->dc;
|
const struct decoder_control *dc = decoder->dc;
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != nullptr);
|
||||||
|
|
||||||
if (decoder_prepare_initial_seek(decoder))
|
if (decoder_prepare_initial_seek(decoder))
|
||||||
return DecoderCommand::SEEK;
|
return DecoderCommand::SEEK;
|
||||||
@ -156,11 +156,11 @@ decoder_command_finished(struct decoder *decoder)
|
|||||||
assert(dc->command != DecoderCommand::SEEK ||
|
assert(dc->command != DecoderCommand::SEEK ||
|
||||||
decoder->initial_seek_running ||
|
decoder->initial_seek_running ||
|
||||||
dc->seek_error || decoder->seeking);
|
dc->seek_error || decoder->seeking);
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != nullptr);
|
||||||
|
|
||||||
if (decoder->initial_seek_running) {
|
if (decoder->initial_seek_running) {
|
||||||
assert(!decoder->seeking);
|
assert(!decoder->seeking);
|
||||||
assert(decoder->chunk == NULL);
|
assert(decoder->chunk == nullptr);
|
||||||
assert(dc->pipe->IsEmpty());
|
assert(dc->pipe->IsEmpty());
|
||||||
|
|
||||||
decoder->initial_seek_running = false;
|
decoder->initial_seek_running = false;
|
||||||
@ -174,9 +174,9 @@ decoder_command_finished(struct decoder *decoder)
|
|||||||
|
|
||||||
/* delete frames from the old song position */
|
/* delete frames from the old song position */
|
||||||
|
|
||||||
if (decoder->chunk != NULL) {
|
if (decoder->chunk != nullptr) {
|
||||||
dc->buffer->Return(decoder->chunk);
|
dc->buffer->Return(decoder->chunk);
|
||||||
decoder->chunk = NULL;
|
decoder->chunk = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc->pipe->Clear(*dc->buffer);
|
dc->pipe->Clear(*dc->buffer);
|
||||||
@ -193,7 +193,7 @@ double decoder_seek_where(gcc_unused struct decoder * decoder)
|
|||||||
{
|
{
|
||||||
const struct decoder_control *dc = decoder->dc;
|
const struct decoder_control *dc = decoder->dc;
|
||||||
|
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != nullptr);
|
||||||
|
|
||||||
if (decoder->initial_seek_running)
|
if (decoder->initial_seek_running)
|
||||||
return dc->start_ms / 1000.;
|
return dc->start_ms / 1000.;
|
||||||
@ -209,7 +209,7 @@ void decoder_seek_error(struct decoder * decoder)
|
|||||||
{
|
{
|
||||||
struct decoder_control *dc = decoder->dc;
|
struct decoder_control *dc = decoder->dc;
|
||||||
|
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != nullptr);
|
||||||
|
|
||||||
if (decoder->initial_seek_running) {
|
if (decoder->initial_seek_running) {
|
||||||
/* d'oh, we can't seek to the sub-song start position,
|
/* d'oh, we can't seek to the sub-song start position,
|
||||||
@ -234,7 +234,7 @@ gcc_pure
|
|||||||
static inline bool
|
static inline bool
|
||||||
decoder_check_cancel_read(const struct decoder *decoder)
|
decoder_check_cancel_read(const struct decoder *decoder)
|
||||||
{
|
{
|
||||||
if (decoder == NULL)
|
if (decoder == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const struct decoder_control *dc = decoder->dc;
|
const struct decoder_control *dc = decoder->dc;
|
||||||
@ -254,13 +254,13 @@ size_t decoder_read(struct decoder *decoder,
|
|||||||
struct input_stream *is,
|
struct input_stream *is,
|
||||||
void *buffer, size_t length)
|
void *buffer, size_t length)
|
||||||
{
|
{
|
||||||
/* XXX don't allow decoder==NULL */
|
/* XXX don't allow decoder==nullptr */
|
||||||
|
|
||||||
assert(decoder == NULL ||
|
assert(decoder == nullptr ||
|
||||||
decoder->dc->state == DecoderState::START ||
|
decoder->dc->state == DecoderState::START ||
|
||||||
decoder->dc->state == DecoderState::DECODE);
|
decoder->dc->state == DecoderState::DECODE);
|
||||||
assert(is != NULL);
|
assert(is != nullptr);
|
||||||
assert(buffer != NULL);
|
assert(buffer != nullptr);
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -295,7 +295,7 @@ size_t decoder_read(struct decoder *decoder,
|
|||||||
void
|
void
|
||||||
decoder_timestamp(struct decoder *decoder, double t)
|
decoder_timestamp(struct decoder *decoder, double t)
|
||||||
{
|
{
|
||||||
assert(decoder != NULL);
|
assert(decoder != nullptr);
|
||||||
assert(t >= 0);
|
assert(t >= 0);
|
||||||
|
|
||||||
decoder->timestamp = t;
|
decoder->timestamp = t;
|
||||||
@ -310,17 +310,17 @@ do_send_tag(struct decoder *decoder, const Tag &tag)
|
|||||||
{
|
{
|
||||||
struct music_chunk *chunk;
|
struct music_chunk *chunk;
|
||||||
|
|
||||||
if (decoder->chunk != NULL) {
|
if (decoder->chunk != nullptr) {
|
||||||
/* there is a partial chunk - flush it, we want the
|
/* there is a partial chunk - flush it, we want the
|
||||||
tag in a new chunk */
|
tag in a new chunk */
|
||||||
decoder_flush_chunk(decoder);
|
decoder_flush_chunk(decoder);
|
||||||
decoder->dc->client_cond.signal();
|
decoder->dc->client_cond.signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(decoder->chunk == NULL);
|
assert(decoder->chunk == nullptr);
|
||||||
|
|
||||||
chunk = decoder_get_chunk(decoder);
|
chunk = decoder_get_chunk(decoder);
|
||||||
if (chunk == NULL) {
|
if (chunk == nullptr) {
|
||||||
assert(decoder->dc->command != DecoderCommand::NONE);
|
assert(decoder->dc->command != DecoderCommand::NONE);
|
||||||
return decoder->dc->command;
|
return decoder->dc->command;
|
||||||
}
|
}
|
||||||
@ -334,17 +334,17 @@ update_stream_tag(struct decoder *decoder, struct input_stream *is)
|
|||||||
{
|
{
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
|
|
||||||
tag = is != NULL
|
tag = is != nullptr
|
||||||
? is->LockReadTag()
|
? is->LockReadTag()
|
||||||
: NULL;
|
: nullptr;
|
||||||
if (tag == NULL) {
|
if (tag == nullptr) {
|
||||||
tag = decoder->song_tag;
|
tag = decoder->song_tag;
|
||||||
if (tag == NULL)
|
if (tag == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* no stream tag present - submit the song tag
|
/* no stream tag present - submit the song tag
|
||||||
instead */
|
instead */
|
||||||
decoder->song_tag = NULL;
|
decoder->song_tag = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete decoder->stream_tag;
|
delete decoder->stream_tag;
|
||||||
@ -362,7 +362,7 @@ decoder_data(struct decoder *decoder,
|
|||||||
DecoderCommand cmd;
|
DecoderCommand cmd;
|
||||||
|
|
||||||
assert(dc->state == DecoderState::DECODE);
|
assert(dc->state == DecoderState::DECODE);
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != nullptr);
|
||||||
assert(length % dc->in_audio_format.GetFrameSize() == 0);
|
assert(length % dc->in_audio_format.GetFrameSize() == 0);
|
||||||
|
|
||||||
dc->Lock();
|
dc->Lock();
|
||||||
@ -376,7 +376,7 @@ decoder_data(struct decoder *decoder,
|
|||||||
/* send stream tags */
|
/* send stream tags */
|
||||||
|
|
||||||
if (update_stream_tag(decoder, is)) {
|
if (update_stream_tag(decoder, is)) {
|
||||||
if (decoder->decoder_tag != NULL) {
|
if (decoder->decoder_tag != nullptr) {
|
||||||
/* merge with tag from decoder plugin */
|
/* merge with tag from decoder plugin */
|
||||||
Tag *tag = Tag::Merge(*decoder->decoder_tag,
|
Tag *tag = Tag::Merge(*decoder->decoder_tag,
|
||||||
*decoder->stream_tag);
|
*decoder->stream_tag);
|
||||||
@ -397,7 +397,7 @@ decoder_data(struct decoder *decoder,
|
|||||||
dc->out_audio_format,
|
dc->out_audio_format,
|
||||||
&length,
|
&length,
|
||||||
error);
|
error);
|
||||||
if (data == NULL) {
|
if (data == nullptr) {
|
||||||
/* the PCM conversion has failed - stop
|
/* the PCM conversion has failed - stop
|
||||||
playback, since we have no better way to
|
playback, since we have no better way to
|
||||||
bail out */
|
bail out */
|
||||||
@ -412,7 +412,7 @@ decoder_data(struct decoder *decoder,
|
|||||||
bool full;
|
bool full;
|
||||||
|
|
||||||
chunk = decoder_get_chunk(decoder);
|
chunk = decoder_get_chunk(decoder);
|
||||||
if (chunk == NULL) {
|
if (chunk == nullptr) {
|
||||||
assert(dc->command != DecoderCommand::NONE);
|
assert(dc->command != DecoderCommand::NONE);
|
||||||
return dc->command;
|
return dc->command;
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ decoder_data(struct decoder *decoder,
|
|||||||
decoder->timestamp -
|
decoder->timestamp -
|
||||||
dc->song->start_ms / 1000.0,
|
dc->song->start_ms / 1000.0,
|
||||||
kbit_rate, &nbytes);
|
kbit_rate, &nbytes);
|
||||||
if (dest == NULL) {
|
if (dest == nullptr) {
|
||||||
/* the chunk is full, flush it */
|
/* the chunk is full, flush it */
|
||||||
decoder_flush_chunk(decoder);
|
decoder_flush_chunk(decoder);
|
||||||
dc->client_cond.signal();
|
dc->client_cond.signal();
|
||||||
@ -470,7 +470,7 @@ decoder_tag(gcc_unused struct decoder *decoder, struct input_stream *is,
|
|||||||
DecoderCommand cmd;
|
DecoderCommand cmd;
|
||||||
|
|
||||||
assert(dc->state == DecoderState::DECODE);
|
assert(dc->state == DecoderState::DECODE);
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != nullptr);
|
||||||
|
|
||||||
/* save the tag */
|
/* save the tag */
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ decoder_tag(gcc_unused struct decoder *decoder, struct input_stream *is,
|
|||||||
|
|
||||||
/* send tag to music pipe */
|
/* send tag to music pipe */
|
||||||
|
|
||||||
if (decoder->stream_tag != NULL) {
|
if (decoder->stream_tag != nullptr) {
|
||||||
/* merge with tag from input stream */
|
/* merge with tag from input stream */
|
||||||
Tag *merged;
|
Tag *merged;
|
||||||
|
|
||||||
@ -510,9 +510,9 @@ void
|
|||||||
decoder_replay_gain(struct decoder *decoder,
|
decoder_replay_gain(struct decoder *decoder,
|
||||||
const struct replay_gain_info *replay_gain_info)
|
const struct replay_gain_info *replay_gain_info)
|
||||||
{
|
{
|
||||||
assert(decoder != NULL);
|
assert(decoder != nullptr);
|
||||||
|
|
||||||
if (replay_gain_info != NULL) {
|
if (replay_gain_info != nullptr) {
|
||||||
static unsigned serial;
|
static unsigned serial;
|
||||||
if (++serial == 0)
|
if (++serial == 0)
|
||||||
serial = 1;
|
serial = 1;
|
||||||
@ -532,7 +532,7 @@ decoder_replay_gain(struct decoder *decoder,
|
|||||||
decoder->replay_gain_info = *replay_gain_info;
|
decoder->replay_gain_info = *replay_gain_info;
|
||||||
decoder->replay_gain_serial = serial;
|
decoder->replay_gain_serial = serial;
|
||||||
|
|
||||||
if (decoder->chunk != NULL) {
|
if (decoder->chunk != nullptr) {
|
||||||
/* flush the current chunk because the new
|
/* flush the current chunk because the new
|
||||||
replay gain values affect the following
|
replay gain values affect the following
|
||||||
samples */
|
samples */
|
||||||
@ -547,9 +547,9 @@ void
|
|||||||
decoder_mixramp(struct decoder *decoder,
|
decoder_mixramp(struct decoder *decoder,
|
||||||
char *mixramp_start, char *mixramp_end)
|
char *mixramp_start, char *mixramp_end)
|
||||||
{
|
{
|
||||||
assert(decoder != NULL);
|
assert(decoder != nullptr);
|
||||||
struct decoder_control *dc = decoder->dc;
|
struct decoder_control *dc = decoder->dc;
|
||||||
assert(dc != NULL);
|
assert(dc != nullptr);
|
||||||
|
|
||||||
dc->MixRampStart(mixramp_start);
|
dc->MixRampStart(mixramp_start);
|
||||||
dc->MixRampEnd(mixramp_end);
|
dc->MixRampEnd(mixramp_end);
|
||||||
|
@ -146,7 +146,7 @@ decoder_tag(struct decoder *decoder, struct input_stream *is, Tag &&tag);
|
|||||||
* Set replay gain values for the following chunks.
|
* Set replay gain values for the following chunks.
|
||||||
*
|
*
|
||||||
* @param decoder the decoder object
|
* @param decoder the decoder object
|
||||||
* @param rgi the replay_gain_info object; may be NULL to invalidate
|
* @param rgi the replay_gain_info object; may be nullptr to invalidate
|
||||||
* the previous replay gain values
|
* the previous replay gain values
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -157,8 +157,8 @@ decoder_replay_gain(struct decoder *decoder,
|
|||||||
* Store MixRamp tags.
|
* Store MixRamp tags.
|
||||||
*
|
*
|
||||||
* @param decoder the decoder object
|
* @param decoder the decoder object
|
||||||
* @param mixramp_start the mixramp_start tag; may be NULL to invalidate
|
* @param mixramp_start the mixramp_start tag; may be nullptr to invalidate
|
||||||
* @param mixramp_end the mixramp_end tag; may be NULL to invalidate
|
* @param mixramp_end the mixramp_end tag; may be nullptr to invalidate
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
decoder_mixramp(struct decoder *decoder,
|
decoder_mixramp(struct decoder *decoder,
|
||||||
|
@ -35,7 +35,7 @@ struct input_stream;
|
|||||||
/**
|
/**
|
||||||
* Creates a new buffer.
|
* Creates a new buffer.
|
||||||
*
|
*
|
||||||
* @param decoder the decoder object, used for decoder_read(), may be NULL
|
* @param decoder the decoder object, used for decoder_read(), may be nullptr
|
||||||
* @param is the input stream object where we should read from
|
* @param is the input stream object where we should read from
|
||||||
* @param size the maximum size of the buffer
|
* @param size the maximum size of the buffer
|
||||||
* @return the new decoder_buffer object
|
* @return the new decoder_buffer object
|
||||||
@ -75,7 +75,7 @@ decoder_buffer_fill(DecoderBuffer *buffer);
|
|||||||
* @param buffer the decoder_buffer object
|
* @param buffer the decoder_buffer object
|
||||||
* @param length_r pointer to a size_t where you will receive the
|
* @param length_r pointer to a size_t where you will receive the
|
||||||
* number of bytes available
|
* number of bytes available
|
||||||
* @return a pointer to the read buffer, or NULL if there is no data
|
* @return a pointer to the read buffer, or nullptr if there is no data
|
||||||
* available
|
* available
|
||||||
*/
|
*/
|
||||||
const void *
|
const void *
|
||||||
|
@ -38,7 +38,7 @@ decoder_control::~decoder_control()
|
|||||||
{
|
{
|
||||||
ClearError();
|
ClearError();
|
||||||
|
|
||||||
if (song != NULL)
|
if (song != nullptr)
|
||||||
song->Free();
|
song->Free();
|
||||||
|
|
||||||
g_free(mixramp_start);
|
g_free(mixramp_start);
|
||||||
@ -49,7 +49,7 @@ decoder_control::~decoder_control()
|
|||||||
bool
|
bool
|
||||||
decoder_control::IsCurrentSong(const Song *_song) const
|
decoder_control::IsCurrentSong(const Song *_song) const
|
||||||
{
|
{
|
||||||
assert(_song != NULL);
|
assert(_song != nullptr);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case DecoderState::STOP:
|
case DecoderState::STOP:
|
||||||
@ -70,7 +70,7 @@ decoder_control::Start(Song *_song,
|
|||||||
unsigned _start_ms, unsigned _end_ms,
|
unsigned _start_ms, unsigned _end_ms,
|
||||||
MusicBuffer &_buffer, MusicPipe &_pipe)
|
MusicBuffer &_buffer, MusicPipe &_pipe)
|
||||||
{
|
{
|
||||||
assert(_song != NULL);
|
assert(_song != nullptr);
|
||||||
assert(_pipe.IsEmpty());
|
assert(_pipe.IsEmpty());
|
||||||
|
|
||||||
if (song != nullptr)
|
if (song != nullptr)
|
||||||
|
@ -64,14 +64,14 @@ decoder_get_chunk(struct decoder *decoder)
|
|||||||
struct decoder_control *dc = decoder->dc;
|
struct decoder_control *dc = decoder->dc;
|
||||||
DecoderCommand cmd;
|
DecoderCommand cmd;
|
||||||
|
|
||||||
assert(decoder != NULL);
|
assert(decoder != nullptr);
|
||||||
|
|
||||||
if (decoder->chunk != NULL)
|
if (decoder->chunk != nullptr)
|
||||||
return decoder->chunk;
|
return decoder->chunk;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
decoder->chunk = dc->buffer->Allocate();
|
decoder->chunk = dc->buffer->Allocate();
|
||||||
if (decoder->chunk != NULL) {
|
if (decoder->chunk != nullptr) {
|
||||||
decoder->chunk->replay_gain_serial =
|
decoder->chunk->replay_gain_serial =
|
||||||
decoder->replay_gain_serial;
|
decoder->replay_gain_serial;
|
||||||
if (decoder->replay_gain_serial != 0)
|
if (decoder->replay_gain_serial != 0)
|
||||||
@ -86,7 +86,7 @@ decoder_get_chunk(struct decoder *decoder)
|
|||||||
dc->Unlock();
|
dc->Unlock();
|
||||||
} while (cmd == DecoderCommand::NONE);
|
} while (cmd == DecoderCommand::NONE);
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -94,13 +94,13 @@ decoder_flush_chunk(struct decoder *decoder)
|
|||||||
{
|
{
|
||||||
struct decoder_control *dc = decoder->dc;
|
struct decoder_control *dc = decoder->dc;
|
||||||
|
|
||||||
assert(decoder != NULL);
|
assert(decoder != nullptr);
|
||||||
assert(decoder->chunk != NULL);
|
assert(decoder->chunk != nullptr);
|
||||||
|
|
||||||
if (decoder->chunk->IsEmpty())
|
if (decoder->chunk->IsEmpty())
|
||||||
dc->buffer->Return(decoder->chunk);
|
dc->buffer->Return(decoder->chunk);
|
||||||
else
|
else
|
||||||
dc->pipe->Push(decoder->chunk);
|
dc->pipe->Push(decoder->chunk);
|
||||||
|
|
||||||
decoder->chunk = NULL;
|
decoder->chunk = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ const struct decoder_plugin *const decoder_plugins[] = {
|
|||||||
&gme_decoder_plugin,
|
&gme_decoder_plugin,
|
||||||
#endif
|
#endif
|
||||||
&pcm_decoder_plugin,
|
&pcm_decoder_plugin,
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr unsigned num_decoder_plugins =
|
static constexpr unsigned num_decoder_plugins =
|
||||||
@ -142,18 +142,18 @@ const struct decoder_plugin *
|
|||||||
decoder_plugin_from_suffix(const char *suffix,
|
decoder_plugin_from_suffix(const char *suffix,
|
||||||
const struct decoder_plugin *plugin)
|
const struct decoder_plugin *plugin)
|
||||||
{
|
{
|
||||||
if (suffix == NULL)
|
if (suffix == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
for (unsigned i = decoder_plugin_next_index(plugin);
|
for (unsigned i = decoder_plugin_next_index(plugin);
|
||||||
decoder_plugins[i] != NULL; ++i) {
|
decoder_plugins[i] != nullptr; ++i) {
|
||||||
plugin = decoder_plugins[i];
|
plugin = decoder_plugins[i];
|
||||||
if (decoder_plugins_enabled[i] &&
|
if (decoder_plugins_enabled[i] &&
|
||||||
decoder_plugin_supports_suffix(plugin, suffix))
|
decoder_plugin_supports_suffix(plugin, suffix))
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct decoder_plugin *
|
const struct decoder_plugin *
|
||||||
@ -161,12 +161,12 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
|
|||||||
{
|
{
|
||||||
static unsigned i = num_decoder_plugins;
|
static unsigned i = num_decoder_plugins;
|
||||||
|
|
||||||
if (mimeType == NULL)
|
if (mimeType == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
if (!next)
|
if (!next)
|
||||||
i = 0;
|
i = 0;
|
||||||
for (; decoder_plugins[i] != NULL; ++i) {
|
for (; decoder_plugins[i] != nullptr; ++i) {
|
||||||
const struct decoder_plugin *plugin = decoder_plugins[i];
|
const struct decoder_plugin *plugin = decoder_plugins[i];
|
||||||
if (decoder_plugins_enabled[i] &&
|
if (decoder_plugins_enabled[i] &&
|
||||||
decoder_plugin_supports_mime_type(plugin, mimeType)) {
|
decoder_plugin_supports_mime_type(plugin, mimeType)) {
|
||||||
@ -175,7 +175,7 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct decoder_plugin *
|
const struct decoder_plugin *
|
||||||
@ -185,23 +185,23 @@ decoder_plugin_from_name(const char *name)
|
|||||||
if (strcmp(plugin->name, name) == 0)
|
if (strcmp(plugin->name, name) == 0)
|
||||||
return plugin;
|
return plugin;
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the "decoder" configuration block for the specified plugin.
|
* Find the "decoder" configuration block for the specified plugin.
|
||||||
*
|
*
|
||||||
* @param plugin_name the name of the decoder plugin
|
* @param plugin_name the name of the decoder plugin
|
||||||
* @return the configuration block, or NULL if none was configured
|
* @return the configuration block, or nullptr if none was configured
|
||||||
*/
|
*/
|
||||||
static const struct config_param *
|
static const struct config_param *
|
||||||
decoder_plugin_config(const char *plugin_name)
|
decoder_plugin_config(const char *plugin_name)
|
||||||
{
|
{
|
||||||
const struct config_param *param = NULL;
|
const struct config_param *param = nullptr;
|
||||||
|
|
||||||
while ((param = config_get_next_param(CONF_DECODER, param)) != NULL) {
|
while ((param = config_get_next_param(CONF_DECODER, param)) != nullptr) {
|
||||||
const char *name = param->GetBlockValue("plugin");
|
const char *name = param->GetBlockValue("plugin");
|
||||||
if (name == NULL)
|
if (name == nullptr)
|
||||||
FormatFatalError("decoder configuration without 'plugin' name in line %d",
|
FormatFatalError("decoder configuration without 'plugin' name in line %d",
|
||||||
param->line);
|
param->line);
|
||||||
|
|
||||||
@ -209,14 +209,14 @@ decoder_plugin_config(const char *plugin_name)
|
|||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void decoder_plugin_init_all(void)
|
void decoder_plugin_init_all(void)
|
||||||
{
|
{
|
||||||
struct config_param empty;
|
struct config_param empty;
|
||||||
|
|
||||||
for (unsigned i = 0; decoder_plugins[i] != NULL; ++i) {
|
for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i) {
|
||||||
const struct decoder_plugin *plugin = decoder_plugins[i];
|
const struct decoder_plugin *plugin = decoder_plugins[i];
|
||||||
const struct config_param *param =
|
const struct config_param *param =
|
||||||
decoder_plugin_config(plugin->name);
|
decoder_plugin_config(plugin->name);
|
||||||
|
@ -28,7 +28,7 @@ extern bool decoder_plugins_enabled[];
|
|||||||
#define decoder_plugins_for_each(plugin) \
|
#define decoder_plugins_for_each(plugin) \
|
||||||
for (const struct decoder_plugin *plugin, \
|
for (const struct decoder_plugin *plugin, \
|
||||||
*const*decoder_plugin_iterator = &decoder_plugins[0]; \
|
*const*decoder_plugin_iterator = &decoder_plugins[0]; \
|
||||||
(plugin = *decoder_plugin_iterator) != NULL; \
|
(plugin = *decoder_plugin_iterator) != nullptr; \
|
||||||
++decoder_plugin_iterator)
|
++decoder_plugin_iterator)
|
||||||
|
|
||||||
#define decoder_plugins_for_each_enabled(plugin) \
|
#define decoder_plugins_for_each_enabled(plugin) \
|
||||||
@ -41,8 +41,8 @@ extern bool decoder_plugins_enabled[];
|
|||||||
* Find the next enabled decoder plugin which supports the specified suffix.
|
* Find the next enabled decoder plugin which supports the specified suffix.
|
||||||
*
|
*
|
||||||
* @param suffix the file name suffix
|
* @param suffix the file name suffix
|
||||||
* @param plugin the previous plugin, or NULL to find the first plugin
|
* @param plugin the previous plugin, or nullptr to find the first plugin
|
||||||
* @return a plugin, or NULL if none matches
|
* @return a plugin, or nullptr if none matches
|
||||||
*/
|
*/
|
||||||
const struct decoder_plugin *
|
const struct decoder_plugin *
|
||||||
decoder_plugin_from_suffix(const char *suffix,
|
decoder_plugin_from_suffix(const char *suffix,
|
||||||
|
@ -31,17 +31,17 @@ decoder_plugin_print(Client *client,
|
|||||||
{
|
{
|
||||||
const char *const*p;
|
const char *const*p;
|
||||||
|
|
||||||
assert(plugin != NULL);
|
assert(plugin != nullptr);
|
||||||
assert(plugin->name != NULL);
|
assert(plugin->name != nullptr);
|
||||||
|
|
||||||
client_printf(client, "plugin: %s\n", plugin->name);
|
client_printf(client, "plugin: %s\n", plugin->name);
|
||||||
|
|
||||||
if (plugin->suffixes != NULL)
|
if (plugin->suffixes != nullptr)
|
||||||
for (p = plugin->suffixes; *p != NULL; ++p)
|
for (p = plugin->suffixes; *p != nullptr; ++p)
|
||||||
client_printf(client, "suffix: %s\n", *p);
|
client_printf(client, "suffix: %s\n", *p);
|
||||||
|
|
||||||
if (plugin->mime_types != NULL)
|
if (plugin->mime_types != nullptr)
|
||||||
for (p = plugin->mime_types; *p != NULL; ++p)
|
for (p = plugin->mime_types; *p != nullptr; ++p)
|
||||||
client_printf(client, "mime_type: %s\n", *p);
|
client_printf(client, "mime_type: %s\n", *p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ decoder_command_finished_locked(struct decoder_control *dc)
|
|||||||
* Unlock the decoder before calling this function.
|
* Unlock the decoder before calling this function.
|
||||||
*
|
*
|
||||||
* @return an input_stream on success or if #DecoderCommand::STOP is
|
* @return an input_stream on success or if #DecoderCommand::STOP is
|
||||||
* received, NULL on error
|
* received, nullptr on error
|
||||||
*/
|
*/
|
||||||
static struct input_stream *
|
static struct input_stream *
|
||||||
decoder_input_stream_open(struct decoder_control *dc, const char *uri)
|
decoder_input_stream_open(struct decoder_control *dc, const char *uri)
|
||||||
@ -78,11 +78,11 @@ decoder_input_stream_open(struct decoder_control *dc, const char *uri)
|
|||||||
Error error;
|
Error error;
|
||||||
|
|
||||||
input_stream *is = input_stream::Open(uri, dc->mutex, dc->cond, error);
|
input_stream *is = input_stream::Open(uri, dc->mutex, dc->cond, error);
|
||||||
if (is == NULL) {
|
if (is == nullptr) {
|
||||||
if (error.IsDefined())
|
if (error.IsDefined())
|
||||||
LogError(error);
|
LogError(error);
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait for the input stream to become ready; its metadata
|
/* wait for the input stream to become ready; its metadata
|
||||||
@ -102,7 +102,7 @@ decoder_input_stream_open(struct decoder_control *dc, const char *uri)
|
|||||||
dc->Unlock();
|
dc->Unlock();
|
||||||
|
|
||||||
LogError(error);
|
LogError(error);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc->Unlock();
|
dc->Unlock();
|
||||||
@ -115,12 +115,12 @@ decoder_stream_decode(const struct decoder_plugin *plugin,
|
|||||||
struct decoder *decoder,
|
struct decoder *decoder,
|
||||||
struct input_stream *input_stream)
|
struct input_stream *input_stream)
|
||||||
{
|
{
|
||||||
assert(plugin != NULL);
|
assert(plugin != nullptr);
|
||||||
assert(plugin->stream_decode != NULL);
|
assert(plugin->stream_decode != nullptr);
|
||||||
assert(decoder != NULL);
|
assert(decoder != nullptr);
|
||||||
assert(decoder->stream_tag == NULL);
|
assert(decoder->stream_tag == nullptr);
|
||||||
assert(decoder->decoder_tag == NULL);
|
assert(decoder->decoder_tag == nullptr);
|
||||||
assert(input_stream != NULL);
|
assert(input_stream != nullptr);
|
||||||
assert(input_stream->ready);
|
assert(input_stream->ready);
|
||||||
assert(decoder->dc->state == DecoderState::START);
|
assert(decoder->dc->state == DecoderState::START);
|
||||||
|
|
||||||
@ -148,12 +148,12 @@ static bool
|
|||||||
decoder_file_decode(const struct decoder_plugin *plugin,
|
decoder_file_decode(const struct decoder_plugin *plugin,
|
||||||
struct decoder *decoder, const char *path)
|
struct decoder *decoder, const char *path)
|
||||||
{
|
{
|
||||||
assert(plugin != NULL);
|
assert(plugin != nullptr);
|
||||||
assert(plugin->file_decode != NULL);
|
assert(plugin->file_decode != nullptr);
|
||||||
assert(decoder != NULL);
|
assert(decoder != nullptr);
|
||||||
assert(decoder->stream_tag == NULL);
|
assert(decoder->stream_tag == nullptr);
|
||||||
assert(decoder->decoder_tag == NULL);
|
assert(decoder->decoder_tag == nullptr);
|
||||||
assert(path != NULL);
|
assert(path != nullptr);
|
||||||
assert(PathTraits::IsAbsoluteFS(path));
|
assert(PathTraits::IsAbsoluteFS(path));
|
||||||
assert(decoder->dc->state == DecoderState::START);
|
assert(decoder->dc->state == DecoderState::START);
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ static bool
|
|||||||
decoder_run_stream_mime_type(struct decoder *decoder, struct input_stream *is,
|
decoder_run_stream_mime_type(struct decoder *decoder, struct input_stream *is,
|
||||||
GSList **tried_r)
|
GSList **tried_r)
|
||||||
{
|
{
|
||||||
assert(tried_r != NULL);
|
assert(tried_r != nullptr);
|
||||||
|
|
||||||
const struct decoder_plugin *plugin;
|
const struct decoder_plugin *plugin;
|
||||||
unsigned int next = 0;
|
unsigned int next = 0;
|
||||||
@ -202,10 +202,10 @@ decoder_run_stream_mime_type(struct decoder *decoder, struct input_stream *is,
|
|||||||
|
|
||||||
while ((plugin = decoder_plugin_from_mime_type(is->mime.c_str(),
|
while ((plugin = decoder_plugin_from_mime_type(is->mime.c_str(),
|
||||||
next++))) {
|
next++))) {
|
||||||
if (plugin->stream_decode == NULL)
|
if (plugin->stream_decode == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (g_slist_find(*tried_r, plugin) != NULL)
|
if (g_slist_find(*tried_r, plugin) != nullptr)
|
||||||
/* don't try a plugin twice */
|
/* don't try a plugin twice */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -228,19 +228,19 @@ static bool
|
|||||||
decoder_run_stream_suffix(struct decoder *decoder, struct input_stream *is,
|
decoder_run_stream_suffix(struct decoder *decoder, struct input_stream *is,
|
||||||
const char *uri, GSList **tried_r)
|
const char *uri, GSList **tried_r)
|
||||||
{
|
{
|
||||||
assert(tried_r != NULL);
|
assert(tried_r != nullptr);
|
||||||
|
|
||||||
const char *suffix = uri_get_suffix(uri);
|
const char *suffix = uri_get_suffix(uri);
|
||||||
const struct decoder_plugin *plugin = NULL;
|
const struct decoder_plugin *plugin = nullptr;
|
||||||
|
|
||||||
if (suffix == NULL)
|
if (suffix == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while ((plugin = decoder_plugin_from_suffix(suffix, plugin)) != NULL) {
|
while ((plugin = decoder_plugin_from_suffix(suffix, plugin)) != nullptr) {
|
||||||
if (plugin->stream_decode == NULL)
|
if (plugin->stream_decode == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (g_slist_find(*tried_r, plugin) != NULL)
|
if (g_slist_find(*tried_r, plugin) != nullptr)
|
||||||
/* don't try a plugin twice */
|
/* don't try a plugin twice */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ decoder_run_stream_fallback(struct decoder *decoder, struct input_stream *is)
|
|||||||
const struct decoder_plugin *plugin;
|
const struct decoder_plugin *plugin;
|
||||||
|
|
||||||
plugin = decoder_plugin_from_name("mad");
|
plugin = decoder_plugin_from_name("mad");
|
||||||
return plugin != NULL && plugin->stream_decode != NULL &&
|
return plugin != nullptr && plugin->stream_decode != nullptr &&
|
||||||
decoder_stream_decode(plugin, decoder, is);
|
decoder_stream_decode(plugin, decoder, is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,14 +279,14 @@ decoder_run_stream(struct decoder *decoder, const char *uri)
|
|||||||
dc->Unlock();
|
dc->Unlock();
|
||||||
|
|
||||||
input_stream = decoder_input_stream_open(dc, uri);
|
input_stream = decoder_input_stream_open(dc, uri);
|
||||||
if (input_stream == NULL) {
|
if (input_stream == nullptr) {
|
||||||
dc->Lock();
|
dc->Lock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc->Lock();
|
dc->Lock();
|
||||||
|
|
||||||
GSList *tried = NULL;
|
GSList *tried = nullptr;
|
||||||
|
|
||||||
success = dc->command == DecoderCommand::STOP ||
|
success = dc->command == DecoderCommand::STOP ||
|
||||||
/* first we try mime types: */
|
/* first we try mime types: */
|
||||||
@ -296,7 +296,7 @@ decoder_run_stream(struct decoder *decoder, const char *uri)
|
|||||||
&tried) ||
|
&tried) ||
|
||||||
/* fallback to mp3: this is needed for bastard streams
|
/* fallback to mp3: this is needed for bastard streams
|
||||||
that don't have a suffix or set the mimeType */
|
that don't have a suffix or set the mimeType */
|
||||||
(tried == NULL &&
|
(tried == nullptr &&
|
||||||
decoder_run_stream_fallback(decoder, input_stream));
|
decoder_run_stream_fallback(decoder, input_stream));
|
||||||
|
|
||||||
g_slist_free(tried);
|
g_slist_free(tried);
|
||||||
@ -328,29 +328,29 @@ decoder_run_file(struct decoder *decoder, const char *path_fs)
|
|||||||
{
|
{
|
||||||
struct decoder_control *dc = decoder->dc;
|
struct decoder_control *dc = decoder->dc;
|
||||||
const char *suffix = uri_get_suffix(path_fs);
|
const char *suffix = uri_get_suffix(path_fs);
|
||||||
const struct decoder_plugin *plugin = NULL;
|
const struct decoder_plugin *plugin = nullptr;
|
||||||
|
|
||||||
if (suffix == NULL)
|
if (suffix == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dc->Unlock();
|
dc->Unlock();
|
||||||
|
|
||||||
decoder_load_replay_gain(decoder, path_fs);
|
decoder_load_replay_gain(decoder, path_fs);
|
||||||
|
|
||||||
while ((plugin = decoder_plugin_from_suffix(suffix, plugin)) != NULL) {
|
while ((plugin = decoder_plugin_from_suffix(suffix, plugin)) != nullptr) {
|
||||||
if (plugin->file_decode != NULL) {
|
if (plugin->file_decode != nullptr) {
|
||||||
dc->Lock();
|
dc->Lock();
|
||||||
|
|
||||||
if (decoder_file_decode(plugin, decoder, path_fs))
|
if (decoder_file_decode(plugin, decoder, path_fs))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
dc->Unlock();
|
dc->Unlock();
|
||||||
} else if (plugin->stream_decode != NULL) {
|
} else if (plugin->stream_decode != nullptr) {
|
||||||
struct input_stream *input_stream;
|
struct input_stream *input_stream;
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
input_stream = decoder_input_stream_open(dc, path_fs);
|
input_stream = decoder_input_stream_open(dc, path_fs);
|
||||||
if (input_stream == NULL)
|
if (input_stream == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dc->Lock();
|
dc->Lock();
|
||||||
@ -378,7 +378,7 @@ decoder_run_song(struct decoder_control *dc,
|
|||||||
const Song *song, const char *uri)
|
const Song *song, const char *uri)
|
||||||
{
|
{
|
||||||
decoder decoder(dc, dc->start_ms > 0,
|
decoder decoder(dc, dc->start_ms > 0,
|
||||||
song->tag != NULL && song->IsFile()
|
song->tag != nullptr && song->IsFile()
|
||||||
? new Tag(*song->tag) : nullptr);
|
? new Tag(*song->tag) : nullptr);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -394,7 +394,7 @@ decoder_run_song(struct decoder_control *dc,
|
|||||||
|
|
||||||
/* flush the last chunk */
|
/* flush the last chunk */
|
||||||
|
|
||||||
if (decoder.chunk != NULL)
|
if (decoder.chunk != nullptr)
|
||||||
decoder_flush_chunk(&decoder);
|
decoder_flush_chunk(&decoder);
|
||||||
|
|
||||||
dc->Lock();
|
dc->Lock();
|
||||||
@ -406,7 +406,7 @@ decoder_run_song(struct decoder_control *dc,
|
|||||||
|
|
||||||
const char *error_uri = song->uri;
|
const char *error_uri = song->uri;
|
||||||
char *allocated = uri_remove_auth(error_uri);
|
char *allocated = uri_remove_auth(error_uri);
|
||||||
if (allocated != NULL)
|
if (allocated != nullptr)
|
||||||
error_uri = allocated;
|
error_uri = allocated;
|
||||||
|
|
||||||
dc->error.Format(decoder_domain,
|
dc->error.Format(decoder_domain,
|
||||||
@ -423,7 +423,7 @@ decoder_run(struct decoder_control *dc)
|
|||||||
dc->ClearError();
|
dc->ClearError();
|
||||||
|
|
||||||
const Song *song = dc->song;
|
const Song *song = dc->song;
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
|
|
||||||
const std::string uri = song->IsFile()
|
const std::string uri = song->IsFile()
|
||||||
? std::string(map_song_fs(song).c_str())
|
? std::string(map_song_fs(song).c_str())
|
||||||
@ -456,7 +456,7 @@ decoder_task(void *arg)
|
|||||||
case DecoderCommand::START:
|
case DecoderCommand::START:
|
||||||
dc->MixRampStart(nullptr);
|
dc->MixRampStart(nullptr);
|
||||||
dc->MixRampPrevEnd(dc->mixramp_end);
|
dc->MixRampPrevEnd(dc->mixramp_end);
|
||||||
dc->mixramp_end = NULL; /* Don't free, it's copied above. */
|
dc->mixramp_end = nullptr; /* Don't free, it's copied above. */
|
||||||
dc->replay_gain_prev_db = dc->replay_gain_db;
|
dc->replay_gain_prev_db = dc->replay_gain_db;
|
||||||
dc->replay_gain_db = 0;
|
dc->replay_gain_db = 0;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void mpd_despotify_unregister_callback(void (*cb)(struct despotify_session *, in
|
|||||||
for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
|
for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
|
||||||
|
|
||||||
if (registered_callbacks[i] == cb) {
|
if (registered_callbacks[i] == cb) {
|
||||||
registered_callbacks[i] = NULL;
|
registered_callbacks[i] = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,11 +118,11 @@ struct despotify_session *mpd_despotify_get_session(void)
|
|||||||
if (g_session)
|
if (g_session)
|
||||||
return g_session;
|
return g_session;
|
||||||
|
|
||||||
user = config_get_string(CONF_DESPOTIFY_USER, NULL);
|
user = config_get_string(CONF_DESPOTIFY_USER, nullptr);
|
||||||
passwd = config_get_string(CONF_DESPOTIFY_PASSWORD, NULL);
|
passwd = config_get_string(CONF_DESPOTIFY_PASSWORD, nullptr);
|
||||||
high_bitrate = config_get_bool(CONF_DESPOTIFY_HIGH_BITRATE, true);
|
high_bitrate = config_get_bool(CONF_DESPOTIFY_HIGH_BITRATE, true);
|
||||||
|
|
||||||
if (user == NULL || passwd == NULL) {
|
if (user == nullptr || passwd == nullptr) {
|
||||||
LogDebug(despotify_domain,
|
LogDebug(despotify_domain,
|
||||||
"disabling despotify because account is not configured");
|
"disabling despotify because account is not configured");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -133,7 +133,7 @@ struct despotify_session *mpd_despotify_get_session(void)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_session = despotify_init_client(callback, NULL,
|
g_session = despotify_init_client(callback, nullptr,
|
||||||
high_bitrate, true);
|
high_bitrate, true);
|
||||||
if (!g_session) {
|
if (!g_session) {
|
||||||
LogWarning(despotify_domain,
|
LogWarning(despotify_domain,
|
||||||
|
@ -32,7 +32,7 @@ extern const class Domain despotify_domain;
|
|||||||
* If the session isn't initialized, this function will initialize
|
* If the session isn't initialized, this function will initialize
|
||||||
* it and connect to Spotify.
|
* it and connect to Spotify.
|
||||||
*
|
*
|
||||||
* @return a pointer to the despotify session, or NULL if it can't
|
* @return a pointer to the despotify session, or nullptr if it can't
|
||||||
* be initialized (e.g., if the configuration isn't supplied)
|
* be initialized (e.g., if the configuration isn't supplied)
|
||||||
*/
|
*/
|
||||||
struct despotify_session *mpd_despotify_get_session(void);
|
struct despotify_session *mpd_despotify_get_session(void);
|
||||||
|
@ -39,7 +39,7 @@ extern "C" {
|
|||||||
inline Directory *
|
inline Directory *
|
||||||
Directory::Allocate(const char *path)
|
Directory::Allocate(const char *path)
|
||||||
{
|
{
|
||||||
assert(path != NULL);
|
assert(path != nullptr);
|
||||||
|
|
||||||
const size_t path_size = strlen(path) + 1;
|
const size_t path_size = strlen(path) + 1;
|
||||||
Directory *directory =
|
Directory *directory =
|
||||||
@ -81,8 +81,8 @@ Directory::~Directory()
|
|||||||
Directory *
|
Directory *
|
||||||
Directory::NewGeneric(const char *path, Directory *parent)
|
Directory::NewGeneric(const char *path, Directory *parent)
|
||||||
{
|
{
|
||||||
assert(path != NULL);
|
assert(path != nullptr);
|
||||||
assert((*path == 0) == (parent == NULL));
|
assert((*path == 0) == (parent == nullptr));
|
||||||
|
|
||||||
Directory *directory = Allocate(path);
|
Directory *directory = Allocate(path);
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ Directory::GetName() const
|
|||||||
const char *slash = strrchr(path, '/');
|
const char *slash = strrchr(path, '/');
|
||||||
assert((slash == nullptr) == parent->IsRoot());
|
assert((slash == nullptr) == parent->IsRoot());
|
||||||
|
|
||||||
return slash != NULL
|
return slash != nullptr
|
||||||
? slash + 1
|
? slash + 1
|
||||||
: path;
|
: path;
|
||||||
}
|
}
|
||||||
@ -126,17 +126,17 @@ Directory *
|
|||||||
Directory::CreateChild(const char *name_utf8)
|
Directory::CreateChild(const char *name_utf8)
|
||||||
{
|
{
|
||||||
assert(holding_db_lock());
|
assert(holding_db_lock());
|
||||||
assert(name_utf8 != NULL);
|
assert(name_utf8 != nullptr);
|
||||||
assert(*name_utf8 != 0);
|
assert(*name_utf8 != 0);
|
||||||
|
|
||||||
char *allocated;
|
char *allocated;
|
||||||
const char *path_utf8;
|
const char *path_utf8;
|
||||||
if (IsRoot()) {
|
if (IsRoot()) {
|
||||||
allocated = NULL;
|
allocated = nullptr;
|
||||||
path_utf8 = name_utf8;
|
path_utf8 = name_utf8;
|
||||||
} else {
|
} else {
|
||||||
allocated = g_strconcat(GetPath(),
|
allocated = g_strconcat(GetPath(),
|
||||||
"/", name_utf8, NULL);
|
"/", name_utf8, nullptr);
|
||||||
path_utf8 = allocated;
|
path_utf8 = allocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ Directory::FindChild(const char *name) const
|
|||||||
if (strcmp(child->GetName(), name) == 0)
|
if (strcmp(child->GetName(), name) == 0)
|
||||||
return child;
|
return child;
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -178,7 +178,7 @@ Directory *
|
|||||||
Directory::LookupDirectory(const char *uri)
|
Directory::LookupDirectory(const char *uri)
|
||||||
{
|
{
|
||||||
assert(holding_db_lock());
|
assert(holding_db_lock());
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
|
|
||||||
if (isRootDirectory(uri))
|
if (isRootDirectory(uri))
|
||||||
return this;
|
return this;
|
||||||
@ -189,15 +189,15 @@ Directory::LookupDirectory(const char *uri)
|
|||||||
while (1) {
|
while (1) {
|
||||||
char *slash = strchr(name, '/');
|
char *slash = strchr(name, '/');
|
||||||
if (slash == name) {
|
if (slash == name) {
|
||||||
d = NULL;
|
d = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slash != NULL)
|
if (slash != nullptr)
|
||||||
*slash = '\0';
|
*slash = '\0';
|
||||||
|
|
||||||
d = d->FindChild(name);
|
d = d->FindChild(name);
|
||||||
if (d == NULL || slash == NULL)
|
if (d == nullptr || slash == nullptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
name = slash + 1;
|
name = slash + 1;
|
||||||
@ -212,7 +212,7 @@ void
|
|||||||
Directory::AddSong(Song *song)
|
Directory::AddSong(Song *song)
|
||||||
{
|
{
|
||||||
assert(holding_db_lock());
|
assert(holding_db_lock());
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
assert(song->parent == this);
|
assert(song->parent == this);
|
||||||
|
|
||||||
list_add_tail(&song->siblings, &songs);
|
list_add_tail(&song->siblings, &songs);
|
||||||
@ -222,7 +222,7 @@ void
|
|||||||
Directory::RemoveSong(Song *song)
|
Directory::RemoveSong(Song *song)
|
||||||
{
|
{
|
||||||
assert(holding_db_lock());
|
assert(holding_db_lock());
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
assert(song->parent == this);
|
assert(song->parent == this);
|
||||||
|
|
||||||
list_del(&song->siblings);
|
list_del(&song->siblings);
|
||||||
@ -232,7 +232,7 @@ const Song *
|
|||||||
Directory::FindSong(const char *name_utf8) const
|
Directory::FindSong(const char *name_utf8) const
|
||||||
{
|
{
|
||||||
assert(holding_db_lock());
|
assert(holding_db_lock());
|
||||||
assert(name_utf8 != NULL);
|
assert(name_utf8 != nullptr);
|
||||||
|
|
||||||
Song *song;
|
Song *song;
|
||||||
directory_for_each_song(song, this) {
|
directory_for_each_song(song, this) {
|
||||||
@ -242,7 +242,7 @@ Directory::FindSong(const char *name_utf8) const
|
|||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Song *
|
Song *
|
||||||
@ -251,24 +251,24 @@ Directory::LookupSong(const char *uri)
|
|||||||
char *duplicated, *base;
|
char *duplicated, *base;
|
||||||
|
|
||||||
assert(holding_db_lock());
|
assert(holding_db_lock());
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
|
|
||||||
duplicated = g_strdup(uri);
|
duplicated = g_strdup(uri);
|
||||||
base = strrchr(duplicated, '/');
|
base = strrchr(duplicated, '/');
|
||||||
|
|
||||||
Directory *d = this;
|
Directory *d = this;
|
||||||
if (base != NULL) {
|
if (base != nullptr) {
|
||||||
*base++ = 0;
|
*base++ = 0;
|
||||||
d = d->LookupDirectory(duplicated);
|
d = d->LookupDirectory(duplicated);
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
g_free(duplicated);
|
g_free(duplicated);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
base = duplicated;
|
base = duplicated;
|
||||||
|
|
||||||
Song *song = d->FindSong(base);
|
Song *song = d->FindSong(base);
|
||||||
assert(song == NULL || song->parent == d);
|
assert(song == nullptr || song->parent == d);
|
||||||
|
|
||||||
g_free(duplicated);
|
g_free(duplicated);
|
||||||
return song;
|
return song;
|
||||||
@ -289,7 +289,7 @@ Directory::Sort()
|
|||||||
{
|
{
|
||||||
assert(holding_db_lock());
|
assert(holding_db_lock());
|
||||||
|
|
||||||
list_sort(NULL, &children, directory_cmp);
|
list_sort(nullptr, &children, directory_cmp);
|
||||||
song_list_sort(&songs);
|
song_list_sort(&songs);
|
||||||
|
|
||||||
Directory *child;
|
Directory *child;
|
||||||
|
@ -164,7 +164,7 @@ public:
|
|||||||
* Looks up a directory by its relative URI.
|
* Looks up a directory by its relative URI.
|
||||||
*
|
*
|
||||||
* @param uri the relative URI
|
* @param uri the relative URI
|
||||||
* @return the Directory, or NULL if none was found
|
* @return the Directory, or nullptr if none was found
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
Directory *LookupDirectory(const char *uri);
|
Directory *LookupDirectory(const char *uri);
|
||||||
@ -192,7 +192,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool IsRoot() const {
|
bool IsRoot() const {
|
||||||
return parent == NULL;
|
return parent == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,7 +215,7 @@ public:
|
|||||||
* Caller must lock the #db_mutex.
|
* Caller must lock the #db_mutex.
|
||||||
*
|
*
|
||||||
* @param uri the relative URI
|
* @param uri the relative URI
|
||||||
* @return the song, or NULL if none was found
|
* @return the song, or nullptr if none was found
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
Song *LookupSong(const char *uri);
|
Song *LookupSong(const char *uri);
|
||||||
|
@ -81,41 +81,41 @@ directory_load_subdir(TextFile &file, Directory *parent, const char *name,
|
|||||||
if (parent->FindChild(name) != nullptr) {
|
if (parent->FindChild(name) != nullptr) {
|
||||||
error.Format(directory_domain,
|
error.Format(directory_domain,
|
||||||
"Duplicate subdirectory '%s'", name);
|
"Duplicate subdirectory '%s'", name);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory *directory = parent->CreateChild(name);
|
Directory *directory = parent->CreateChild(name);
|
||||||
|
|
||||||
const char *line = file.ReadLine();
|
const char *line = file.ReadLine();
|
||||||
if (line == NULL) {
|
if (line == nullptr) {
|
||||||
error.Set(directory_domain, "Unexpected end of file");
|
error.Set(directory_domain, "Unexpected end of file");
|
||||||
directory->Delete();
|
directory->Delete();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_str_has_prefix(line, DIRECTORY_MTIME)) {
|
if (g_str_has_prefix(line, DIRECTORY_MTIME)) {
|
||||||
directory->mtime =
|
directory->mtime =
|
||||||
g_ascii_strtoull(line + sizeof(DIRECTORY_MTIME) - 1,
|
g_ascii_strtoull(line + sizeof(DIRECTORY_MTIME) - 1,
|
||||||
NULL, 10);
|
nullptr, 10);
|
||||||
|
|
||||||
line = file.ReadLine();
|
line = file.ReadLine();
|
||||||
if (line == NULL) {
|
if (line == nullptr) {
|
||||||
error.Set(directory_domain, "Unexpected end of file");
|
error.Set(directory_domain, "Unexpected end of file");
|
||||||
directory->Delete();
|
directory->Delete();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_str_has_prefix(line, DIRECTORY_BEGIN)) {
|
if (!g_str_has_prefix(line, DIRECTORY_BEGIN)) {
|
||||||
error.Format(directory_domain, "Malformed line: %s", line);
|
error.Format(directory_domain, "Malformed line: %s", line);
|
||||||
directory->Delete();
|
directory->Delete();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
success = directory_load(file, directory, error);
|
success = directory_load(file, directory, error);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
directory->Delete();
|
directory->Delete();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return directory;
|
return directory;
|
||||||
@ -126,14 +126,14 @@ directory_load(TextFile &file, Directory *directory, Error &error)
|
|||||||
{
|
{
|
||||||
const char *line;
|
const char *line;
|
||||||
|
|
||||||
while ((line = file.ReadLine()) != NULL &&
|
while ((line = file.ReadLine()) != nullptr &&
|
||||||
!g_str_has_prefix(line, DIRECTORY_END)) {
|
!g_str_has_prefix(line, DIRECTORY_END)) {
|
||||||
if (g_str_has_prefix(line, DIRECTORY_DIR)) {
|
if (g_str_has_prefix(line, DIRECTORY_DIR)) {
|
||||||
Directory *subdir =
|
Directory *subdir =
|
||||||
directory_load_subdir(file, directory,
|
directory_load_subdir(file, directory,
|
||||||
line + sizeof(DIRECTORY_DIR) - 1,
|
line + sizeof(DIRECTORY_DIR) - 1,
|
||||||
error);
|
error);
|
||||||
if (subdir == NULL)
|
if (subdir == nullptr)
|
||||||
return false;
|
return false;
|
||||||
} else if (g_str_has_prefix(line, SONG_BEGIN)) {
|
} else if (g_str_has_prefix(line, SONG_BEGIN)) {
|
||||||
const char *name = line + sizeof(SONG_BEGIN) - 1;
|
const char *name = line + sizeof(SONG_BEGIN) - 1;
|
||||||
@ -146,7 +146,7 @@ directory_load(TextFile &file, Directory *directory, Error &error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
song = song_load(file, directory, name, error);
|
song = song_load(file, directory, name, error);
|
||||||
if (song == NULL)
|
if (song == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
directory->AddSong(song);
|
directory->AddSong(song);
|
||||||
|
@ -50,7 +50,7 @@ const EncoderPlugin *const encoder_plugins[] = {
|
|||||||
#ifdef ENABLE_FLAC_ENCODER
|
#ifdef ENABLE_FLAC_ENCODER
|
||||||
&flac_encoder_plugin,
|
&flac_encoder_plugin,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const EncoderPlugin *
|
const EncoderPlugin *
|
||||||
@ -60,5 +60,5 @@ encoder_plugin_get(const char *name)
|
|||||||
if (strcmp(plugin->name, name) == 0)
|
if (strcmp(plugin->name, name) == 0)
|
||||||
return plugin;
|
return plugin;
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -27,14 +27,14 @@ extern const EncoderPlugin *const encoder_plugins[];
|
|||||||
#define encoder_plugins_for_each(plugin) \
|
#define encoder_plugins_for_each(plugin) \
|
||||||
for (const EncoderPlugin *plugin, \
|
for (const EncoderPlugin *plugin, \
|
||||||
*const*encoder_plugin_iterator = &encoder_plugins[0]; \
|
*const*encoder_plugin_iterator = &encoder_plugins[0]; \
|
||||||
(plugin = *encoder_plugin_iterator) != NULL; \
|
(plugin = *encoder_plugin_iterator) != nullptr; \
|
||||||
++encoder_plugin_iterator)
|
++encoder_plugin_iterator)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up an encoder plugin by its name.
|
* Looks up an encoder plugin by its name.
|
||||||
*
|
*
|
||||||
* @param name the encoder name to look for
|
* @param name the encoder name to look for
|
||||||
* @return the encoder plugin with the specified name, or NULL if none
|
* @return the encoder plugin with the specified name, or nullptr if none
|
||||||
* was found
|
* was found
|
||||||
*/
|
*/
|
||||||
const EncoderPlugin *
|
const EncoderPlugin *
|
||||||
|
@ -82,8 +82,8 @@ struct EncoderPlugin {
|
|||||||
*
|
*
|
||||||
* @param plugin the encoder plugin
|
* @param plugin the encoder plugin
|
||||||
* @param param optional configuration
|
* @param param optional configuration
|
||||||
* @param error location to store the error occurring, or NULL to ignore errors.
|
* @param error location to store the error occurring, or nullptr to ignore errors.
|
||||||
* @return an encoder object on success, NULL on failure
|
* @return an encoder object on success, nullptr on failure
|
||||||
*/
|
*/
|
||||||
static inline Encoder *
|
static inline Encoder *
|
||||||
encoder_init(const EncoderPlugin &plugin, const config_param ¶m,
|
encoder_init(const EncoderPlugin &plugin, const config_param ¶m,
|
||||||
@ -117,7 +117,6 @@ encoder_finish(Encoder *encoder)
|
|||||||
* @param encoder the encoder
|
* @param encoder the encoder
|
||||||
* @param audio_format the encoder's input audio format; the plugin
|
* @param audio_format the encoder's input audio format; the plugin
|
||||||
* may modify the struct to adapt it to its abilities
|
* may modify the struct to adapt it to its abilities
|
||||||
* @param error location to store the error occurring, or NULL to ignore errors.
|
|
||||||
* @return true on success
|
* @return true on success
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -145,7 +144,7 @@ encoder_close(Encoder *encoder)
|
|||||||
{
|
{
|
||||||
assert(encoder->open);
|
assert(encoder->open);
|
||||||
|
|
||||||
if (encoder->plugin.close != NULL)
|
if (encoder->plugin.close != nullptr)
|
||||||
encoder->plugin.close(encoder);
|
encoder->plugin.close(encoder);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -163,7 +162,6 @@ encoder_close(Encoder *encoder)
|
|||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param encoder the encoder
|
* @param encoder the encoder
|
||||||
* @param error location to store the error occuring, or NULL to ignore errors.
|
|
||||||
* @return true on success
|
* @return true on success
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -177,7 +175,7 @@ encoder_end(Encoder *encoder, Error &error)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this method is optional */
|
/* this method is optional */
|
||||||
return encoder->plugin.end != NULL
|
return encoder->plugin.end != nullptr
|
||||||
? encoder->plugin.end(encoder, error)
|
? encoder->plugin.end(encoder, error)
|
||||||
: true;
|
: true;
|
||||||
}
|
}
|
||||||
@ -187,7 +185,6 @@ encoder_end(Encoder *encoder, Error &error)
|
|||||||
* buffered available by encoder_read().
|
* buffered available by encoder_read().
|
||||||
*
|
*
|
||||||
* @param encoder the encoder
|
* @param encoder the encoder
|
||||||
* @param error location to store the error occurring, or NULL to ignore errors.
|
|
||||||
* @return true on success
|
* @return true on success
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -199,7 +196,7 @@ encoder_flush(Encoder *encoder, Error &error)
|
|||||||
assert(!encoder->end);
|
assert(!encoder->end);
|
||||||
|
|
||||||
/* this method is optional */
|
/* this method is optional */
|
||||||
return encoder->plugin.flush != NULL
|
return encoder->plugin.flush != nullptr
|
||||||
? encoder->plugin.flush(encoder, error)
|
? encoder->plugin.flush(encoder, error)
|
||||||
: true;
|
: true;
|
||||||
}
|
}
|
||||||
@ -211,7 +208,6 @@ encoder_flush(Encoder *encoder, Error &error)
|
|||||||
*
|
*
|
||||||
* @param encoder the encoder
|
* @param encoder the encoder
|
||||||
* @param tag the tag object
|
* @param tag the tag object
|
||||||
* @param error location to store the error occuring, or NULL to ignore errors.
|
|
||||||
* @return true on success
|
* @return true on success
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -223,7 +219,7 @@ encoder_pre_tag(Encoder *encoder, Error &error)
|
|||||||
assert(!encoder->end);
|
assert(!encoder->end);
|
||||||
|
|
||||||
/* this method is optional */
|
/* this method is optional */
|
||||||
bool success = encoder->plugin.pre_tag != NULL
|
bool success = encoder->plugin.pre_tag != nullptr
|
||||||
? encoder->plugin.pre_tag(encoder, error)
|
? encoder->plugin.pre_tag(encoder, error)
|
||||||
: true;
|
: true;
|
||||||
|
|
||||||
@ -241,7 +237,6 @@ encoder_pre_tag(Encoder *encoder, Error &error)
|
|||||||
*
|
*
|
||||||
* @param encoder the encoder
|
* @param encoder the encoder
|
||||||
* @param tag the tag object
|
* @param tag the tag object
|
||||||
* @param error location to store the error occurring, or NULL to ignore errors.
|
|
||||||
* @return true on success
|
* @return true on success
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -257,7 +252,7 @@ encoder_tag(Encoder *encoder, const Tag *tag, Error &error)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this method is optional */
|
/* this method is optional */
|
||||||
return encoder->plugin.tag != NULL
|
return encoder->plugin.tag != nullptr
|
||||||
? encoder->plugin.tag(encoder, tag, error)
|
? encoder->plugin.tag(encoder, tag, error)
|
||||||
: true;
|
: true;
|
||||||
}
|
}
|
||||||
@ -268,7 +263,6 @@ encoder_tag(Encoder *encoder, const Tag *tag, Error &error)
|
|||||||
* @param encoder the encoder
|
* @param encoder the encoder
|
||||||
* @param data the buffer containing PCM samples
|
* @param data the buffer containing PCM samples
|
||||||
* @param length the length of the buffer in bytes
|
* @param length the length of the buffer in bytes
|
||||||
* @param error location to store the error occurring, or NULL to ignore errors.
|
|
||||||
* @return true on success
|
* @return true on success
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -313,15 +307,15 @@ encoder_read(Encoder *encoder, void *dest, size_t length)
|
|||||||
* Get mime type of encoded content.
|
* Get mime type of encoded content.
|
||||||
*
|
*
|
||||||
* @param plugin the encoder plugin
|
* @param plugin the encoder plugin
|
||||||
* @return an constant string, NULL on failure
|
* @return an constant string, nullptr on failure
|
||||||
*/
|
*/
|
||||||
static inline const char *
|
static inline const char *
|
||||||
encoder_get_mime_type(Encoder *encoder)
|
encoder_get_mime_type(Encoder *encoder)
|
||||||
{
|
{
|
||||||
/* this method is optional */
|
/* this method is optional */
|
||||||
return encoder->plugin.get_mime_type != NULL
|
return encoder->plugin.get_mime_type != nullptr
|
||||||
? encoder->plugin.get_mime_type(encoder)
|
? encoder->plugin.get_mime_type(encoder)
|
||||||
: NULL;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,7 +40,7 @@ bool
|
|||||||
ExcludeList::LoadFile(Path path_fs)
|
ExcludeList::LoadFile(Path path_fs)
|
||||||
{
|
{
|
||||||
FILE *file = FOpen(path_fs, FOpenMode::ReadText);
|
FILE *file = FOpen(path_fs, FOpenMode::ReadText);
|
||||||
if (file == NULL) {
|
if (file == nullptr) {
|
||||||
const int e = errno;
|
const int e = errno;
|
||||||
if (e != ENOENT) {
|
if (e != ENOENT) {
|
||||||
const auto path_utf8 = path_fs.ToUTF8();
|
const auto path_utf8 = path_fs.ToUTF8();
|
||||||
@ -53,9 +53,9 @@ ExcludeList::LoadFile(Path path_fs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char line[1024];
|
char line[1024];
|
||||||
while (fgets(line, sizeof(line), file) != NULL) {
|
while (fgets(line, sizeof(line), file) != nullptr) {
|
||||||
char *p = strchr(line, '#');
|
char *p = strchr(line, '#');
|
||||||
if (p != NULL)
|
if (p != nullptr)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
p = g_strstrip(line);
|
p = g_strstrip(line);
|
||||||
|
@ -38,20 +38,20 @@
|
|||||||
*
|
*
|
||||||
* @param filter_template_name the name of the filter template
|
* @param filter_template_name the name of the filter template
|
||||||
* @param error space to return an error description
|
* @param error space to return an error description
|
||||||
* @return the configuration block, or NULL if none was configured
|
* @return the configuration block, or nullptr if none was configured
|
||||||
*/
|
*/
|
||||||
static const struct config_param *
|
static const struct config_param *
|
||||||
filter_plugin_config(const char *filter_template_name, Error &error)
|
filter_plugin_config(const char *filter_template_name, Error &error)
|
||||||
{
|
{
|
||||||
const struct config_param *param = NULL;
|
const struct config_param *param = nullptr;
|
||||||
|
|
||||||
while ((param = config_get_next_param(CONF_AUDIO_FILTER, param)) != NULL) {
|
while ((param = config_get_next_param(CONF_AUDIO_FILTER, param)) != nullptr) {
|
||||||
const char *name = param->GetBlockValue("name");
|
const char *name = param->GetBlockValue("name");
|
||||||
if (name == NULL) {
|
if (name == nullptr) {
|
||||||
error.Format(config_domain,
|
error.Format(config_domain,
|
||||||
"filter configuration without 'name' name in line %d",
|
"filter configuration without 'name' name in line %d",
|
||||||
param->line);
|
param->line);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(name, filter_template_name) == 0)
|
if (strcmp(name, filter_template_name) == 0)
|
||||||
@ -61,7 +61,7 @@ filter_plugin_config(const char *filter_template_name, Error &error)
|
|||||||
error.Format(config_domain,
|
error.Format(config_domain,
|
||||||
"filter template not found: %s",
|
"filter template not found: %s",
|
||||||
filter_template_name);
|
filter_template_name);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -31,7 +31,7 @@ Filter *
|
|||||||
filter_new(const struct filter_plugin *plugin,
|
filter_new(const struct filter_plugin *plugin,
|
||||||
const config_param ¶m, Error &error)
|
const config_param ¶m, Error &error)
|
||||||
{
|
{
|
||||||
assert(plugin != NULL);
|
assert(plugin != nullptr);
|
||||||
assert(!error.IsDefined());
|
assert(!error.IsDefined());
|
||||||
|
|
||||||
return plugin->init(param, error);
|
return plugin->init(param, error);
|
||||||
@ -43,16 +43,16 @@ filter_configured_new(const config_param ¶m, Error &error)
|
|||||||
assert(!error.IsDefined());
|
assert(!error.IsDefined());
|
||||||
|
|
||||||
const char *plugin_name = param.GetBlockValue("plugin");
|
const char *plugin_name = param.GetBlockValue("plugin");
|
||||||
if (plugin_name == NULL) {
|
if (plugin_name == nullptr) {
|
||||||
error.Set(config_domain, "No filter plugin specified");
|
error.Set(config_domain, "No filter plugin specified");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filter_plugin *plugin = filter_plugin_by_name(plugin_name);
|
const filter_plugin *plugin = filter_plugin_by_name(plugin_name);
|
||||||
if (plugin == NULL) {
|
if (plugin == nullptr) {
|
||||||
error.Format(config_domain,
|
error.Format(config_domain,
|
||||||
"No such filter plugin: %s", plugin_name);
|
"No such filter plugin: %s", plugin_name);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filter_new(plugin, param, error);
|
return filter_new(plugin, param, error);
|
||||||
|
@ -44,9 +44,9 @@ struct filter_plugin {
|
|||||||
*
|
*
|
||||||
* @param plugin the filter plugin
|
* @param plugin the filter plugin
|
||||||
* @param param optional configuration section
|
* @param param optional configuration section
|
||||||
* @param error location to store the error occurring, or NULL to
|
* @param error location to store the error occurring, or nullptr to
|
||||||
* ignore errors.
|
* ignore errors.
|
||||||
* @return a new filter object, or NULL on error
|
* @return a new filter object, or nullptr on error
|
||||||
*/
|
*/
|
||||||
Filter *
|
Filter *
|
||||||
filter_new(const struct filter_plugin *plugin,
|
filter_new(const struct filter_plugin *plugin,
|
||||||
@ -57,9 +57,9 @@ filter_new(const struct filter_plugin *plugin,
|
|||||||
* the specified configuration section.
|
* the specified configuration section.
|
||||||
*
|
*
|
||||||
* @param param the configuration section
|
* @param param the configuration section
|
||||||
* @param error location to store the error occurring, or NULL to
|
* @param error location to store the error occurring, or nullptr to
|
||||||
* ignore errors.
|
* ignore errors.
|
||||||
* @return a new filter object, or NULL on error
|
* @return a new filter object, or nullptr on error
|
||||||
*/
|
*/
|
||||||
Filter *
|
Filter *
|
||||||
filter_configured_new(const config_param ¶m, Error &error);
|
filter_configured_new(const config_param ¶m, Error &error);
|
||||||
|
@ -30,15 +30,15 @@ const struct filter_plugin *const filter_plugins[] = {
|
|||||||
&normalize_filter_plugin,
|
&normalize_filter_plugin,
|
||||||
&volume_filter_plugin,
|
&volume_filter_plugin,
|
||||||
&replay_gain_filter_plugin,
|
&replay_gain_filter_plugin,
|
||||||
NULL,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct filter_plugin *
|
const struct filter_plugin *
|
||||||
filter_plugin_by_name(const char *name)
|
filter_plugin_by_name(const char *name)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; filter_plugins[i] != NULL; ++i)
|
for (unsigned i = 0; filter_plugins[i] != nullptr; ++i)
|
||||||
if (strcmp(filter_plugins[i]->name, name) == 0)
|
if (strcmp(filter_plugins[i]->name, name) == 0)
|
||||||
return filter_plugins[i];
|
return filter_plugins[i];
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ static void
|
|||||||
InvokeGlobalEvent(GlobalEvents::Event event)
|
InvokeGlobalEvent(GlobalEvents::Event event)
|
||||||
{
|
{
|
||||||
assert((unsigned)event < GlobalEvents::MAX);
|
assert((unsigned)event < GlobalEvents::MAX);
|
||||||
assert(GlobalEvents::handlers[event] != NULL);
|
assert(GlobalEvents::handlers[event] != nullptr);
|
||||||
|
|
||||||
GlobalEvents::handlers[event]();
|
GlobalEvents::handlers[event]();
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void
|
|||||||
GlobalEvents::Register(Event event, Handler callback)
|
GlobalEvents::Register(Event event, Handler callback)
|
||||||
{
|
{
|
||||||
assert((unsigned)event < MAX);
|
assert((unsigned)event < MAX);
|
||||||
assert(handlers[event] == NULL);
|
assert(handlers[event] == nullptr);
|
||||||
|
|
||||||
handlers[event] = callback;
|
handlers[event] = callback;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ void
|
|||||||
io_thread_run(void)
|
io_thread_run(void)
|
||||||
{
|
{
|
||||||
assert(io_thread_inside());
|
assert(io_thread_inside());
|
||||||
assert(io.loop != NULL);
|
assert(io.loop != nullptr);
|
||||||
|
|
||||||
io.loop->Run();
|
io.loop->Run();
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ io_thread_func(gcc_unused void *arg)
|
|||||||
void
|
void
|
||||||
io_thread_init(void)
|
io_thread_init(void)
|
||||||
{
|
{
|
||||||
assert(io.loop == NULL);
|
assert(io.loop == nullptr);
|
||||||
assert(!io.thread.IsDefined());
|
assert(!io.thread.IsDefined());
|
||||||
|
|
||||||
io.loop = new EventLoop();
|
io.loop = new EventLoop();
|
||||||
@ -68,7 +68,7 @@ io_thread_init(void)
|
|||||||
void
|
void
|
||||||
io_thread_start()
|
io_thread_start()
|
||||||
{
|
{
|
||||||
assert(io.loop != NULL);
|
assert(io.loop != nullptr);
|
||||||
assert(!io.thread.IsDefined());
|
assert(!io.thread.IsDefined());
|
||||||
|
|
||||||
const ScopeLock protect(io.mutex);
|
const ScopeLock protect(io.mutex);
|
||||||
@ -81,7 +81,7 @@ io_thread_start()
|
|||||||
void
|
void
|
||||||
io_thread_quit(void)
|
io_thread_quit(void)
|
||||||
{
|
{
|
||||||
assert(io.loop != NULL);
|
assert(io.loop != nullptr);
|
||||||
|
|
||||||
io.loop->Break();
|
io.loop->Break();
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ icy_server_metadata_string(const char *stream_title, const char* stream_url)
|
|||||||
|
|
||||||
if (meta_length > 255) {
|
if (meta_length > 255) {
|
||||||
delete[] icy_metadata;
|
delete[] icy_metadata;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return icy_metadata;
|
return icy_metadata;
|
||||||
@ -124,8 +124,8 @@ icy_server_metadata_page(const Tag &tag, const enum tag_type *types)
|
|||||||
|
|
||||||
icy_string = icy_server_metadata_string(stream_title, "");
|
icy_string = icy_server_metadata_string(stream_title, "");
|
||||||
|
|
||||||
if (icy_string == NULL)
|
if (icy_string == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
Page *icy_metadata = Page::Copy(icy_string, (icy_string[0] * 16) + 1);
|
Page *icy_metadata = Page::Copy(icy_string, (icy_string[0] * 16) + 1);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ InotifySource::OnSocketReady(gcc_unused unsigned flags)
|
|||||||
if (event->len > 0 && event->name[event->len - 1] == 0)
|
if (event->len > 0 && event->name[event->len - 1] == 0)
|
||||||
name = event->name;
|
name = event->name;
|
||||||
else
|
else
|
||||||
name = NULL;
|
name = nullptr;
|
||||||
|
|
||||||
callback(event->wd, event->mask, name, callback_ctx);
|
callback(event->wd, event->mask, name, callback_ctx);
|
||||||
buffer.Consume(sizeof(*event) + event->len);
|
buffer.Consume(sizeof(*event) + event->len);
|
||||||
@ -85,7 +85,7 @@ InotifySource::Create(EventLoop &loop,
|
|||||||
int fd = inotify_init_cloexec();
|
int fd = inotify_init_cloexec();
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
error.SetErrno("inotify_init() has failed");
|
error.SetErrno("inotify_init() has failed");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new InotifySource(loop, callback, callback_ctx, fd);
|
return new InotifySource(loop, callback, callback_ctx, fd);
|
||||||
|
@ -112,9 +112,9 @@ disable_watch_directory(WatchDirectory &directory)
|
|||||||
static void
|
static void
|
||||||
remove_watch_directory(WatchDirectory *directory)
|
remove_watch_directory(WatchDirectory *directory)
|
||||||
{
|
{
|
||||||
assert(directory != NULL);
|
assert(directory != nullptr);
|
||||||
|
|
||||||
if (directory->parent == NULL) {
|
if (directory->parent == nullptr) {
|
||||||
LogWarning(inotify_domain,
|
LogWarning(inotify_domain,
|
||||||
"music directory was removed - "
|
"music directory was removed - "
|
||||||
"cannot continue to watch it");
|
"cannot continue to watch it");
|
||||||
@ -132,7 +132,7 @@ remove_watch_directory(WatchDirectory *directory)
|
|||||||
static AllocatedPath
|
static AllocatedPath
|
||||||
watch_directory_get_uri_fs(const WatchDirectory *directory)
|
watch_directory_get_uri_fs(const WatchDirectory *directory)
|
||||||
{
|
{
|
||||||
if (directory->parent == NULL)
|
if (directory->parent == nullptr)
|
||||||
return AllocatedPath::Null();
|
return AllocatedPath::Null();
|
||||||
|
|
||||||
const auto uri = watch_directory_get_uri_fs(directory->parent);
|
const auto uri = watch_directory_get_uri_fs(directory->parent);
|
||||||
@ -147,7 +147,7 @@ static bool skip_path(const char *path)
|
|||||||
{
|
{
|
||||||
return (path[0] == '.' && path[1] == 0) ||
|
return (path[0] == '.' && path[1] == 0) ||
|
||||||
(path[0] == '.' && path[1] == '.' && path[2] == 0) ||
|
(path[0] == '.' && path[1] == '.' && path[2] == 0) ||
|
||||||
strchr(path, '\n') != NULL;
|
strchr(path, '\n') != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -158,7 +158,7 @@ recursive_watch_subdirectories(WatchDirectory *directory,
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
|
|
||||||
assert(directory != NULL);
|
assert(directory != nullptr);
|
||||||
assert(depth <= inotify_max_depth);
|
assert(depth <= inotify_max_depth);
|
||||||
assert(!path_fs.IsNull());
|
assert(!path_fs.IsNull());
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ recursive_watch_subdirectories(WatchDirectory *directory,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
dir = opendir(path_fs.c_str());
|
dir = opendir(path_fs.c_str());
|
||||||
if (dir == NULL) {
|
if (dir == nullptr) {
|
||||||
FormatErrno(inotify_domain,
|
FormatErrno(inotify_domain,
|
||||||
"Failed to open directory %s", path_fs.c_str());
|
"Failed to open directory %s", path_fs.c_str());
|
||||||
return;
|
return;
|
||||||
@ -226,10 +226,10 @@ gcc_pure
|
|||||||
static unsigned
|
static unsigned
|
||||||
watch_directory_depth(const WatchDirectory *d)
|
watch_directory_depth(const WatchDirectory *d)
|
||||||
{
|
{
|
||||||
assert(d != NULL);
|
assert(d != nullptr);
|
||||||
|
|
||||||
unsigned depth = 0;
|
unsigned depth = 0;
|
||||||
while ((d = d->parent) != NULL)
|
while ((d = d->parent) != nullptr)
|
||||||
++depth;
|
++depth;
|
||||||
|
|
||||||
return depth;
|
return depth;
|
||||||
@ -244,7 +244,7 @@ mpd_inotify_callback(int wd, unsigned mask,
|
|||||||
/*FormatDebug(inotify_domain, "wd=%d mask=0x%x name='%s'", wd, mask, name);*/
|
/*FormatDebug(inotify_domain, "wd=%d mask=0x%x name='%s'", wd, mask, name);*/
|
||||||
|
|
||||||
directory = tree_find_watch_directory(wd);
|
directory = tree_find_watch_directory(wd);
|
||||||
if (directory == NULL)
|
if (directory == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto uri_fs = watch_directory_get_uri_fs(directory);
|
const auto uri_fs = watch_directory_get_uri_fs(directory);
|
||||||
@ -301,7 +301,7 @@ mpd_inotify_init(unsigned max_depth)
|
|||||||
inotify_source = InotifySource::Create(*main_loop,
|
inotify_source = InotifySource::Create(*main_loop,
|
||||||
mpd_inotify_callback, nullptr,
|
mpd_inotify_callback, nullptr,
|
||||||
error);
|
error);
|
||||||
if (inotify_source == NULL) {
|
if (inotify_source == nullptr) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ mpd_inotify_init(unsigned max_depth)
|
|||||||
if (descriptor < 0) {
|
if (descriptor < 0) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
delete inotify_source;
|
delete inotify_source;
|
||||||
inotify_source = NULL;
|
inotify_source = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ mpd_inotify_init(unsigned max_depth)
|
|||||||
void
|
void
|
||||||
mpd_inotify_finish(void)
|
mpd_inotify_finish(void)
|
||||||
{
|
{
|
||||||
if (inotify_source == NULL)
|
if (inotify_source == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
delete inotify_queue;
|
delete inotify_queue;
|
||||||
|
@ -36,27 +36,27 @@ extern constexpr Domain input_domain("input");
|
|||||||
* Find the "input" configuration block for the specified plugin.
|
* Find the "input" configuration block for the specified plugin.
|
||||||
*
|
*
|
||||||
* @param plugin_name the name of the input plugin
|
* @param plugin_name the name of the input plugin
|
||||||
* @return the configuration block, or NULL if none was configured
|
* @return the configuration block, or nullptr if none was configured
|
||||||
*/
|
*/
|
||||||
static const struct config_param *
|
static const struct config_param *
|
||||||
input_plugin_config(const char *plugin_name, Error &error)
|
input_plugin_config(const char *plugin_name, Error &error)
|
||||||
{
|
{
|
||||||
const struct config_param *param = NULL;
|
const struct config_param *param = nullptr;
|
||||||
|
|
||||||
while ((param = config_get_next_param(CONF_INPUT, param)) != NULL) {
|
while ((param = config_get_next_param(CONF_INPUT, param)) != nullptr) {
|
||||||
const char *name = param->GetBlockValue("plugin");
|
const char *name = param->GetBlockValue("plugin");
|
||||||
if (name == NULL) {
|
if (name == nullptr) {
|
||||||
error.Format(input_domain,
|
error.Format(input_domain,
|
||||||
"input configuration without 'plugin' name in line %d",
|
"input configuration without 'plugin' name in line %d",
|
||||||
param->line);
|
param->line);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(name, plugin_name) == 0)
|
if (strcmp(name, plugin_name) == 0)
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -64,12 +64,12 @@ input_stream_global_init(Error &error)
|
|||||||
{
|
{
|
||||||
const config_param empty;
|
const config_param empty;
|
||||||
|
|
||||||
for (unsigned i = 0; input_plugins[i] != NULL; ++i) {
|
for (unsigned i = 0; input_plugins[i] != nullptr; ++i) {
|
||||||
const InputPlugin *plugin = input_plugins[i];
|
const InputPlugin *plugin = input_plugins[i];
|
||||||
|
|
||||||
assert(plugin->name != NULL);
|
assert(plugin->name != nullptr);
|
||||||
assert(*plugin->name != 0);
|
assert(*plugin->name != 0);
|
||||||
assert(plugin->open != NULL);
|
assert(plugin->open != nullptr);
|
||||||
|
|
||||||
const struct config_param *param =
|
const struct config_param *param =
|
||||||
input_plugin_config(plugin->name, error);
|
input_plugin_config(plugin->name, error);
|
||||||
@ -82,7 +82,7 @@ input_stream_global_init(Error &error)
|
|||||||
/* the plugin is disabled in mpd.conf */
|
/* the plugin is disabled in mpd.conf */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (plugin->init == NULL || plugin->init(*param, error))
|
if (plugin->init == nullptr || plugin->init(*param, error))
|
||||||
input_plugins_enabled[i] = true;
|
input_plugins_enabled[i] = true;
|
||||||
else {
|
else {
|
||||||
error.FormatPrefix("Failed to initialize input plugin '%s': ",
|
error.FormatPrefix("Failed to initialize input plugin '%s': ",
|
||||||
@ -97,6 +97,6 @@ input_stream_global_init(Error &error)
|
|||||||
void input_stream_global_finish(void)
|
void input_stream_global_finish(void)
|
||||||
{
|
{
|
||||||
input_plugins_for_each_enabled(plugin)
|
input_plugins_for_each_enabled(plugin)
|
||||||
if (plugin->finish != NULL)
|
if (plugin->finish != nullptr)
|
||||||
plugin->finish();
|
plugin->finish();
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,6 @@ class Error;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this library and all input_stream implementations.
|
* Initializes this library and all input_stream implementations.
|
||||||
*
|
|
||||||
* @param error_r location to store the error occurring, or NULL to
|
|
||||||
* ignore errors
|
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
input_stream_global_init(Error &error);
|
input_stream_global_init(Error &error);
|
||||||
|
@ -39,8 +39,6 @@ struct InputPlugin {
|
|||||||
/**
|
/**
|
||||||
* Global initialization. This method is called when MPD starts.
|
* Global initialization. This method is called when MPD starts.
|
||||||
*
|
*
|
||||||
* @param error_r location to store the error occurring, or
|
|
||||||
* NULL to ignore errors
|
|
||||||
* @return true on success, false if the plugin should be
|
* @return true on success, false if the plugin should be
|
||||||
* disabled
|
* disabled
|
||||||
*/
|
*/
|
||||||
@ -67,7 +65,7 @@ struct InputPlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the public attributes. Call before access. Can be
|
* Update the public attributes. Call before access. Can be
|
||||||
* NULL if the plugin always keeps its attributes up to date.
|
* nullptr if the plugin always keeps its attributes up to date.
|
||||||
*/
|
*/
|
||||||
void (*update)(struct input_stream *is);
|
void (*update)(struct input_stream *is);
|
||||||
|
|
||||||
|
@ -39,21 +39,21 @@ input_stream::Open(const char *url,
|
|||||||
struct input_stream *is;
|
struct input_stream *is;
|
||||||
|
|
||||||
is = plugin->open(url, mutex, cond, error);
|
is = plugin->open(url, mutex, cond, error);
|
||||||
if (is != NULL) {
|
if (is != nullptr) {
|
||||||
assert(is->plugin.close != NULL);
|
assert(is->plugin.close != nullptr);
|
||||||
assert(is->plugin.read != NULL);
|
assert(is->plugin.read != nullptr);
|
||||||
assert(is->plugin.eof != NULL);
|
assert(is->plugin.eof != nullptr);
|
||||||
assert(!is->seekable || is->plugin.seek != NULL);
|
assert(!is->seekable || is->plugin.seek != nullptr);
|
||||||
|
|
||||||
is = input_rewind_open(is);
|
is = input_rewind_open(is);
|
||||||
|
|
||||||
return is;
|
return is;
|
||||||
} else if (error.IsDefined())
|
} else if (error.IsDefined())
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
error.Set(input_domain, "Unrecognized URI");
|
error.Set(input_domain, "Unrecognized URI");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -142,7 +142,7 @@ input_stream::IsAvailable()
|
|||||||
size_t
|
size_t
|
||||||
input_stream::Read(void *ptr, size_t _size, Error &error)
|
input_stream::Read(void *ptr, size_t _size, Error &error)
|
||||||
{
|
{
|
||||||
assert(ptr != NULL);
|
assert(ptr != nullptr);
|
||||||
assert(_size > 0);
|
assert(_size > 0);
|
||||||
|
|
||||||
return plugin.read(this, ptr, _size, error);
|
return plugin.read(this, ptr, _size, error);
|
||||||
@ -151,7 +151,7 @@ input_stream::Read(void *ptr, size_t _size, Error &error)
|
|||||||
size_t
|
size_t
|
||||||
input_stream::LockRead(void *ptr, size_t _size, Error &error)
|
input_stream::LockRead(void *ptr, size_t _size, Error &error)
|
||||||
{
|
{
|
||||||
assert(ptr != NULL);
|
assert(ptr != nullptr);
|
||||||
assert(_size > 0);
|
assert(_size > 0);
|
||||||
|
|
||||||
const ScopeLock protect(mutex);
|
const ScopeLock protect(mutex);
|
||||||
|
@ -60,7 +60,7 @@ struct input_stream {
|
|||||||
/**
|
/**
|
||||||
* A cond that gets signalled when the state of this object
|
* A cond that gets signalled when the state of this object
|
||||||
* changes from the I/O thread. The client of this object may
|
* changes from the I/O thread. The client of this object may
|
||||||
* wait on it. Optional, may be NULL.
|
* wait on it. Optional, may be nullptr.
|
||||||
*
|
*
|
||||||
* This object is allocated by the client, and the client is
|
* This object is allocated by the client, and the client is
|
||||||
* responsible for freeing it.
|
* responsible for freeing it.
|
||||||
@ -99,7 +99,7 @@ struct input_stream {
|
|||||||
mutex(_mutex), cond(_cond),
|
mutex(_mutex), cond(_cond),
|
||||||
ready(false), seekable(false),
|
ready(false), seekable(false),
|
||||||
size(-1), offset(0) {
|
size(-1), offset(0) {
|
||||||
assert(_uri != NULL);
|
assert(_uri != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,9 +109,9 @@ struct input_stream {
|
|||||||
* @param mutex a mutex that is used to protect this object; must be
|
* @param mutex a mutex that is used to protect this object; must be
|
||||||
* locked before calling any of the public methods
|
* locked before calling any of the public methods
|
||||||
* @param cond a cond that gets signalled when the state of
|
* @param cond a cond that gets signalled when the state of
|
||||||
* this object changes; may be NULL if the caller doesn't want to get
|
* this object changes; may be nullptr if the caller doesn't want to get
|
||||||
* notifications
|
* notifications
|
||||||
* @return an #input_stream object on success, NULL on error
|
* @return an #input_stream object on success, nullptr on error
|
||||||
*/
|
*/
|
||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
gcc_malloc
|
gcc_malloc
|
||||||
|
@ -62,7 +62,7 @@ listen_add_config_param(unsigned int port,
|
|||||||
const struct config_param *param,
|
const struct config_param *param,
|
||||||
Error &error_r)
|
Error &error_r)
|
||||||
{
|
{
|
||||||
assert(param != NULL);
|
assert(param != nullptr);
|
||||||
|
|
||||||
if (0 == strcmp(param->value.c_str(), "any")) {
|
if (0 == strcmp(param->value.c_str(), "any")) {
|
||||||
return listen_socket->AddPort(port, error_r);
|
return listen_socket->AddPort(port, error_r);
|
||||||
@ -107,7 +107,7 @@ listen_global_init(Error &error)
|
|||||||
|
|
||||||
int port = config_get_positive(CONF_PORT, DEFAULT_PORT);
|
int port = config_get_positive(CONF_PORT, DEFAULT_PORT);
|
||||||
const struct config_param *param =
|
const struct config_param *param =
|
||||||
config_get_next_param(CONF_BIND_TO_ADDRESS, NULL);
|
config_get_next_param(CONF_BIND_TO_ADDRESS, nullptr);
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
listen_socket = new ClientListener();
|
listen_socket = new ClientListener();
|
||||||
@ -118,7 +118,7 @@ listen_global_init(Error &error)
|
|||||||
if (error.IsDefined())
|
if (error.IsDefined())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (param != NULL) {
|
if (param != nullptr) {
|
||||||
/* "bind_to_address" is configured, create listeners
|
/* "bind_to_address" is configured, create listeners
|
||||||
for all values */
|
for all values */
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ listen_global_init(Error &error)
|
|||||||
|
|
||||||
param = config_get_next_param(CONF_BIND_TO_ADDRESS,
|
param = config_get_next_param(CONF_BIND_TO_ADDRESS,
|
||||||
param);
|
param);
|
||||||
} while (param != NULL);
|
} while (param != nullptr);
|
||||||
} else {
|
} else {
|
||||||
/* no "bind_to_address" configured, bind the
|
/* no "bind_to_address" configured, bind the
|
||||||
configured port on all interfaces */
|
configured port on all interfaces */
|
||||||
@ -159,7 +159,7 @@ void listen_global_finish(void)
|
|||||||
{
|
{
|
||||||
LogDebug(listen_domain, "listen_global_finish called");
|
LogDebug(listen_domain, "listen_global_finish called");
|
||||||
|
|
||||||
assert(listen_socket != NULL);
|
assert(listen_socket != nullptr);
|
||||||
|
|
||||||
delete listen_socket;
|
delete listen_socket;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ static void redirect_logs(int fd)
|
|||||||
static const char *log_date(void)
|
static const char *log_date(void)
|
||||||
{
|
{
|
||||||
static char buf[LOG_DATE_BUF_SIZE];
|
static char buf[LOG_DATE_BUF_SIZE];
|
||||||
time_t t = time(NULL);
|
time_t t = time(nullptr);
|
||||||
strftime(buf, LOG_DATE_BUF_SIZE, "%b %d %H:%M : ", localtime(&t));
|
strftime(buf, LOG_DATE_BUF_SIZE, "%b %d %H:%M : ", localtime(&t));
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -106,14 +106,15 @@ file_log_func(const gchar *domain,
|
|||||||
if (log_level > log_threshold)
|
if (log_level > log_threshold)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (log_charset != NULL) {
|
if (log_charset != nullptr) {
|
||||||
converted = g_convert_with_fallback(message, -1,
|
converted = g_convert_with_fallback(message, -1,
|
||||||
log_charset, "utf-8",
|
log_charset, "utf-8",
|
||||||
NULL, NULL, NULL, NULL);
|
nullptr, nullptr,
|
||||||
if (converted != NULL)
|
nullptr, nullptr);
|
||||||
|
if (converted != nullptr)
|
||||||
message = converted;
|
message = converted;
|
||||||
} else
|
} else
|
||||||
converted = NULL;
|
converted = nullptr;
|
||||||
|
|
||||||
if (domain == nullptr)
|
if (domain == nullptr)
|
||||||
domain = "";
|
domain = "";
|
||||||
@ -129,7 +130,7 @@ file_log_func(const gchar *domain,
|
|||||||
static void
|
static void
|
||||||
log_init_stdout(void)
|
log_init_stdout(void)
|
||||||
{
|
{
|
||||||
g_log_set_default_handler(file_log_func, NULL);
|
g_log_set_default_handler(file_log_func, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -153,7 +154,7 @@ log_init_file(unsigned line, Error &error)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_log_set_default_handler(file_log_func, NULL);
|
g_log_set_default_handler(file_log_func, nullptr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +215,7 @@ log_init_syslog(void)
|
|||||||
assert(out_path.IsNull());
|
assert(out_path.IsNull());
|
||||||
|
|
||||||
openlog(PACKAGE, 0, LOG_DAEMON);
|
openlog(PACKAGE, 0, LOG_DAEMON);
|
||||||
g_log_set_default_handler(syslog_log_func, NULL);
|
g_log_set_default_handler(syslog_log_func, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -253,7 +254,7 @@ log_init(bool verbose, bool use_stdout, Error &error)
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
log_threshold = G_LOG_LEVEL_DEBUG;
|
log_threshold = G_LOG_LEVEL_DEBUG;
|
||||||
else if ((param = config_get_param(CONF_LOG_LEVEL)) != NULL)
|
else if ((param = config_get_param(CONF_LOG_LEVEL)) != nullptr)
|
||||||
log_threshold = parse_log_level(param->value.c_str(),
|
log_threshold = parse_log_level(param->value.c_str(),
|
||||||
param->line);
|
param->line);
|
||||||
|
|
||||||
@ -262,7 +263,7 @@ log_init(bool verbose, bool use_stdout, Error &error)
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
param = config_get_param(CONF_LOG_FILE);
|
param = config_get_param(CONF_LOG_FILE);
|
||||||
if (param == NULL) {
|
if (param == nullptr) {
|
||||||
#ifdef HAVE_SYSLOG
|
#ifdef HAVE_SYSLOG
|
||||||
/* no configuration: default to syslog (if
|
/* no configuration: default to syslog (if
|
||||||
available) */
|
available) */
|
||||||
@ -308,7 +309,7 @@ log_deinit(void)
|
|||||||
|
|
||||||
void setup_log_output(bool use_stdout)
|
void setup_log_output(bool use_stdout)
|
||||||
{
|
{
|
||||||
fflush(NULL);
|
fflush(nullptr);
|
||||||
if (!use_stdout) {
|
if (!use_stdout) {
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
if (out_path.IsNull())
|
if (out_path.IsNull())
|
||||||
@ -321,7 +322,7 @@ void setup_log_output(bool use_stdout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stdout_mode = false;
|
stdout_mode = false;
|
||||||
log_charset = NULL;
|
log_charset = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ output_mixer_get_volume(unsigned i)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
Mixer *mixer = output->mixer;
|
Mixer *mixer = output->mixer;
|
||||||
if (mixer == NULL)
|
if (mixer == nullptr)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
@ -93,7 +93,7 @@ output_mixer_set_volume(unsigned i, unsigned volume)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
Mixer *mixer = output->mixer;
|
Mixer *mixer = output->mixer;
|
||||||
if (mixer == NULL)
|
if (mixer == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
@ -133,7 +133,7 @@ output_mixer_get_software_volume(unsigned i)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
Mixer *mixer = output->mixer;
|
Mixer *mixer = output->mixer;
|
||||||
if (mixer == NULL || !mixer->IsPlugin(software_mixer_plugin))
|
if (mixer == nullptr || !mixer->IsPlugin(software_mixer_plugin))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return mixer_get_volume(mixer, IgnoreError());
|
return mixer_get_volume(mixer, IgnoreError());
|
||||||
@ -168,7 +168,7 @@ mixer_all_set_software_volume(unsigned volume)
|
|||||||
|
|
||||||
for (unsigned i = 0; i < count; i++) {
|
for (unsigned i = 0; i < count; i++) {
|
||||||
struct audio_output *output = audio_output_get(i);
|
struct audio_output *output = audio_output_get(i);
|
||||||
if (output->mixer != NULL &&
|
if (output->mixer != nullptr &&
|
||||||
output->mixer->plugin == &software_mixer_plugin)
|
output->mixer->plugin == &software_mixer_plugin)
|
||||||
mixer_set_volume(output->mixer, volume, IgnoreError());
|
mixer_set_volume(output->mixer, volume, IgnoreError());
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ mixer_new(const struct mixer_plugin *plugin, void *ao,
|
|||||||
{
|
{
|
||||||
Mixer *mixer;
|
Mixer *mixer;
|
||||||
|
|
||||||
assert(plugin != NULL);
|
assert(plugin != nullptr);
|
||||||
|
|
||||||
mixer = plugin->init(ao, param, error);
|
mixer = plugin->init(ao, param, error);
|
||||||
|
|
||||||
assert(mixer == NULL || mixer->IsPlugin(*plugin));
|
assert(mixer == nullptr || mixer->IsPlugin(*plugin));
|
||||||
|
|
||||||
return mixer;
|
return mixer;
|
||||||
}
|
}
|
||||||
@ -44,8 +44,8 @@ mixer_new(const struct mixer_plugin *plugin, void *ao,
|
|||||||
void
|
void
|
||||||
mixer_free(Mixer *mixer)
|
mixer_free(Mixer *mixer)
|
||||||
{
|
{
|
||||||
assert(mixer != NULL);
|
assert(mixer != nullptr);
|
||||||
assert(mixer->plugin != NULL);
|
assert(mixer->plugin != nullptr);
|
||||||
|
|
||||||
/* mixers with the "global" flag set might still be open at
|
/* mixers with the "global" flag set might still be open at
|
||||||
this point (see mixer_auto_close()) */
|
this point (see mixer_auto_close()) */
|
||||||
@ -59,14 +59,14 @@ mixer_open(Mixer *mixer, Error &error)
|
|||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
assert(mixer != NULL);
|
assert(mixer != nullptr);
|
||||||
assert(mixer->plugin != NULL);
|
assert(mixer->plugin != nullptr);
|
||||||
|
|
||||||
const ScopeLock protect(mixer->mutex);
|
const ScopeLock protect(mixer->mutex);
|
||||||
|
|
||||||
if (mixer->open)
|
if (mixer->open)
|
||||||
success = true;
|
success = true;
|
||||||
else if (mixer->plugin->open == NULL)
|
else if (mixer->plugin->open == nullptr)
|
||||||
success = mixer->open = true;
|
success = mixer->open = true;
|
||||||
else
|
else
|
||||||
success = mixer->open = mixer->plugin->open(mixer, error);
|
success = mixer->open = mixer->plugin->open(mixer, error);
|
||||||
@ -79,11 +79,11 @@ mixer_open(Mixer *mixer, Error &error)
|
|||||||
static void
|
static void
|
||||||
mixer_close_internal(Mixer *mixer)
|
mixer_close_internal(Mixer *mixer)
|
||||||
{
|
{
|
||||||
assert(mixer != NULL);
|
assert(mixer != nullptr);
|
||||||
assert(mixer->plugin != NULL);
|
assert(mixer->plugin != nullptr);
|
||||||
assert(mixer->open);
|
assert(mixer->open);
|
||||||
|
|
||||||
if (mixer->plugin->close != NULL)
|
if (mixer->plugin->close != nullptr)
|
||||||
mixer->plugin->close(mixer);
|
mixer->plugin->close(mixer);
|
||||||
|
|
||||||
mixer->open = false;
|
mixer->open = false;
|
||||||
@ -92,8 +92,8 @@ mixer_close_internal(Mixer *mixer)
|
|||||||
void
|
void
|
||||||
mixer_close(Mixer *mixer)
|
mixer_close(Mixer *mixer)
|
||||||
{
|
{
|
||||||
assert(mixer != NULL);
|
assert(mixer != nullptr);
|
||||||
assert(mixer->plugin != NULL);
|
assert(mixer->plugin != nullptr);
|
||||||
|
|
||||||
const ScopeLock protect(mixer->mutex);
|
const ScopeLock protect(mixer->mutex);
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ mixer_get_volume(Mixer *mixer, Error &error)
|
|||||||
{
|
{
|
||||||
int volume;
|
int volume;
|
||||||
|
|
||||||
assert(mixer != NULL);
|
assert(mixer != nullptr);
|
||||||
|
|
||||||
if (mixer->plugin->global && !mixer->failed &&
|
if (mixer->plugin->global && !mixer->failed &&
|
||||||
!mixer_open(mixer, error))
|
!mixer_open(mixer, error))
|
||||||
@ -148,7 +148,7 @@ mixer_get_volume(Mixer *mixer, Error &error)
|
|||||||
bool
|
bool
|
||||||
mixer_set_volume(Mixer *mixer, unsigned volume, Error &error)
|
mixer_set_volume(Mixer *mixer, unsigned volume, Error &error)
|
||||||
{
|
{
|
||||||
assert(mixer != NULL);
|
assert(mixer != nullptr);
|
||||||
assert(volume <= 100);
|
assert(volume <= 100);
|
||||||
|
|
||||||
if (mixer->plugin->global && !mixer->failed &&
|
if (mixer->plugin->global && !mixer->failed &&
|
||||||
|
@ -38,8 +38,8 @@ struct mixer_plugin {
|
|||||||
* @param ao the pointer returned by audio_output_plugin.init
|
* @param ao the pointer returned by audio_output_plugin.init
|
||||||
* @param param the configuration section
|
* @param param the configuration section
|
||||||
* @param error_r location to store the error occurring, or
|
* @param error_r location to store the error occurring, or
|
||||||
* NULL to ignore errors
|
* nullptr to ignore errors
|
||||||
* @return a mixer object, or NULL on error
|
* @return a mixer object, or nullptr on error
|
||||||
*/
|
*/
|
||||||
Mixer *(*init)(void *ao, const config_param ¶m,
|
Mixer *(*init)(void *ao, const config_param ¶m,
|
||||||
Error &error);
|
Error &error);
|
||||||
@ -53,7 +53,7 @@ struct mixer_plugin {
|
|||||||
* Open mixer device
|
* Open mixer device
|
||||||
*
|
*
|
||||||
* @param error_r location to store the error occurring, or
|
* @param error_r location to store the error occurring, or
|
||||||
* NULL to ignore errors
|
* nullptr to ignore errors
|
||||||
* @return true on success, false on error
|
* @return true on success, false on error
|
||||||
*/
|
*/
|
||||||
bool (*open)(Mixer *data, Error &error);
|
bool (*open)(Mixer *data, Error &error);
|
||||||
@ -67,7 +67,7 @@ struct mixer_plugin {
|
|||||||
* Reads the current volume.
|
* Reads the current volume.
|
||||||
*
|
*
|
||||||
* @param error_r location to store the error occurring, or
|
* @param error_r location to store the error occurring, or
|
||||||
* NULL to ignore errors
|
* nullptr to ignore errors
|
||||||
* @return the current volume (0..100 including) or -1 if
|
* @return the current volume (0..100 including) or -1 if
|
||||||
* unavailable or on error (error set, mixer will be closed)
|
* unavailable or on error (error set, mixer will be closed)
|
||||||
*/
|
*/
|
||||||
@ -77,7 +77,7 @@ struct mixer_plugin {
|
|||||||
* Sets the volume.
|
* Sets the volume.
|
||||||
*
|
*
|
||||||
* @param error_r location to store the error occurring, or
|
* @param error_r location to store the error occurring, or
|
||||||
* NULL to ignore errors
|
* nullptr to ignore errors
|
||||||
* @param volume the new volume (0..100 including)
|
* @param volume the new volume (0..100 including)
|
||||||
* @return true on success, false on error
|
* @return true on success, false on error
|
||||||
*/
|
*/
|
||||||
|
@ -58,7 +58,7 @@ music_chunk::Write(const AudioFormat af,
|
|||||||
const size_t frame_size = af.GetFrameSize();
|
const size_t frame_size = af.GetFrameSize();
|
||||||
size_t num_frames = (sizeof(data) - length) / frame_size;
|
size_t num_frames = (sizeof(data) - length) / frame_size;
|
||||||
if (num_frames == 0)
|
if (num_frames == 0)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
audio_format = af;
|
audio_format = af;
|
||||||
|
@ -124,7 +124,7 @@ struct music_chunk {
|
|||||||
* @param bit_rate the current bit rate of the source file
|
* @param bit_rate the current bit rate of the source file
|
||||||
* @param max_length_r the maximum write length is returned
|
* @param max_length_r the maximum write length is returned
|
||||||
* here
|
* here
|
||||||
* @return a writable buffer, or NULL if the chunk is full
|
* @return a writable buffer, or nullptr if the chunk is full
|
||||||
*/
|
*/
|
||||||
void *Write(AudioFormat af,
|
void *Write(AudioFormat af,
|
||||||
float data_time, uint16_t bit_rate,
|
float data_time, uint16_t bit_rate,
|
||||||
|
@ -69,7 +69,7 @@ audio_output_get(unsigned i)
|
|||||||
{
|
{
|
||||||
assert(i < num_audio_outputs);
|
assert(i < num_audio_outputs);
|
||||||
|
|
||||||
assert(audio_outputs[i] != NULL);
|
assert(audio_outputs[i] != nullptr);
|
||||||
|
|
||||||
return audio_outputs[i];
|
return audio_outputs[i];
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ audio_output_find(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* name not found */
|
/* name not found */
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_const
|
gcc_const
|
||||||
@ -93,7 +93,7 @@ static unsigned
|
|||||||
audio_output_config_count(void)
|
audio_output_config_count(void)
|
||||||
{
|
{
|
||||||
unsigned int nr = 0;
|
unsigned int nr = 0;
|
||||||
const struct config_param *param = NULL;
|
const struct config_param *param = nullptr;
|
||||||
|
|
||||||
while ((param = config_get_next_param(CONF_AUDIO_OUTPUT, param)))
|
while ((param = config_get_next_param(CONF_AUDIO_OUTPUT, param)))
|
||||||
nr++;
|
nr++;
|
||||||
@ -105,7 +105,7 @@ audio_output_config_count(void)
|
|||||||
void
|
void
|
||||||
audio_output_all_init(struct player_control *pc)
|
audio_output_all_init(struct player_control *pc)
|
||||||
{
|
{
|
||||||
const struct config_param *param = NULL;
|
const struct config_param *param = nullptr;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
Error error;
|
Error error;
|
||||||
|
|
||||||
@ -129,8 +129,8 @@ audio_output_all_init(struct player_control *pc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio_output *output = audio_output_new(*param, pc, error);
|
audio_output *output = audio_output_new(*param, pc, error);
|
||||||
if (output == NULL) {
|
if (output == nullptr) {
|
||||||
if (param != NULL)
|
if (param != nullptr)
|
||||||
FormatFatalError("line %i: %s",
|
FormatFatalError("line %i: %s",
|
||||||
param->line,
|
param->line,
|
||||||
error.GetMessage());
|
error.GetMessage());
|
||||||
@ -161,7 +161,7 @@ audio_output_all_finish(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free(audio_outputs);
|
g_free(audio_outputs);
|
||||||
audio_outputs = NULL;
|
audio_outputs = nullptr;
|
||||||
num_audio_outputs = 0;
|
num_audio_outputs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,9 +225,9 @@ audio_output_reset_reopen(struct audio_output *ao)
|
|||||||
{
|
{
|
||||||
const ScopeLock protect(ao->mutex);
|
const ScopeLock protect(ao->mutex);
|
||||||
|
|
||||||
if (!ao->open && ao->fail_timer != NULL) {
|
if (!ao->open && ao->fail_timer != nullptr) {
|
||||||
g_timer_destroy(ao->fail_timer);
|
g_timer_destroy(ao->fail_timer);
|
||||||
ao->fail_timer = NULL;
|
ao->fail_timer = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,9 +280,9 @@ audio_output_all_play(struct music_chunk *chunk, Error &error)
|
|||||||
bool ret;
|
bool ret;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
assert(g_music_buffer != NULL);
|
assert(g_music_buffer != nullptr);
|
||||||
assert(g_mp != NULL);
|
assert(g_mp != nullptr);
|
||||||
assert(chunk != NULL);
|
assert(chunk != nullptr);
|
||||||
assert(chunk->CheckFormat(input_audio_format));
|
assert(chunk->CheckFormat(input_audio_format));
|
||||||
|
|
||||||
ret = audio_output_all_update();
|
ret = audio_output_all_update();
|
||||||
@ -308,16 +308,16 @@ audio_output_all_open(const AudioFormat audio_format,
|
|||||||
bool ret = false, enabled = false;
|
bool ret = false, enabled = false;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
assert(g_music_buffer == NULL || g_music_buffer == &buffer);
|
assert(g_music_buffer == nullptr || g_music_buffer == &buffer);
|
||||||
assert((g_mp == NULL) == (g_music_buffer == NULL));
|
assert((g_mp == nullptr) == (g_music_buffer == nullptr));
|
||||||
|
|
||||||
g_music_buffer = &buffer;
|
g_music_buffer = &buffer;
|
||||||
|
|
||||||
/* the audio format must be the same as existing chunks in the
|
/* the audio format must be the same as existing chunks in the
|
||||||
pipe */
|
pipe */
|
||||||
assert(g_mp == NULL || g_mp->CheckFormat(audio_format));
|
assert(g_mp == nullptr || g_mp->CheckFormat(audio_format));
|
||||||
|
|
||||||
if (g_mp == NULL)
|
if (g_mp == nullptr)
|
||||||
g_mp = new MusicPipe();
|
g_mp = new MusicPipe();
|
||||||
else
|
else
|
||||||
/* if the pipe hasn't been cleared, the the audio
|
/* if the pipe hasn't been cleared, the the audio
|
||||||
@ -361,17 +361,17 @@ chunk_is_consumed_in(const struct audio_output *ao,
|
|||||||
if (!ao->open)
|
if (!ao->open)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (ao->chunk == NULL)
|
if (ao->chunk == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
assert(chunk == ao->chunk || g_mp->Contains(ao->chunk));
|
assert(chunk == ao->chunk || g_mp->Contains(ao->chunk));
|
||||||
|
|
||||||
if (chunk != ao->chunk) {
|
if (chunk != ao->chunk) {
|
||||||
assert(chunk->next != NULL);
|
assert(chunk->next != nullptr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ao->chunk_finished && chunk->next == NULL;
|
return ao->chunk_finished && chunk->next == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -398,7 +398,7 @@ chunk_is_consumed(const struct music_chunk *chunk)
|
|||||||
static void
|
static void
|
||||||
clear_tail_chunk(gcc_unused const struct music_chunk *chunk, bool *locked)
|
clear_tail_chunk(gcc_unused const struct music_chunk *chunk, bool *locked)
|
||||||
{
|
{
|
||||||
assert(chunk->next == NULL);
|
assert(chunk->next == nullptr);
|
||||||
assert(g_mp->Contains(chunk));
|
assert(g_mp->Contains(chunk));
|
||||||
|
|
||||||
for (unsigned i = 0; i < num_audio_outputs; ++i) {
|
for (unsigned i = 0; i < num_audio_outputs; ++i) {
|
||||||
@ -416,7 +416,7 @@ clear_tail_chunk(gcc_unused const struct music_chunk *chunk, bool *locked)
|
|||||||
|
|
||||||
assert(ao->chunk == chunk);
|
assert(ao->chunk == chunk);
|
||||||
assert(ao->chunk_finished);
|
assert(ao->chunk_finished);
|
||||||
ao->chunk = NULL;
|
ao->chunk = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,8 +428,8 @@ audio_output_all_check(void)
|
|||||||
struct music_chunk *shifted;
|
struct music_chunk *shifted;
|
||||||
bool locked[num_audio_outputs];
|
bool locked[num_audio_outputs];
|
||||||
|
|
||||||
assert(g_music_buffer != NULL);
|
assert(g_music_buffer != nullptr);
|
||||||
assert(g_mp != NULL);
|
assert(g_mp != nullptr);
|
||||||
|
|
||||||
while ((chunk = g_mp->Peek()) != nullptr) {
|
while ((chunk = g_mp->Peek()) != nullptr) {
|
||||||
assert(!g_mp->IsEmpty());
|
assert(!g_mp->IsEmpty());
|
||||||
@ -444,7 +444,7 @@ audio_output_all_check(void)
|
|||||||
provides a defined value */
|
provides a defined value */
|
||||||
audio_output_all_elapsed_time = chunk->times;
|
audio_output_all_elapsed_time = chunk->times;
|
||||||
|
|
||||||
is_tail = chunk->next == NULL;
|
is_tail = chunk->next == nullptr;
|
||||||
if (is_tail)
|
if (is_tail)
|
||||||
/* this is the tail of the pipe - clear the
|
/* this is the tail of the pipe - clear the
|
||||||
chunk reference in all outputs */
|
chunk reference in all outputs */
|
||||||
@ -520,7 +520,7 @@ audio_output_all_cancel(void)
|
|||||||
|
|
||||||
/* clear the music pipe and return all chunks to the buffer */
|
/* clear the music pipe and return all chunks to the buffer */
|
||||||
|
|
||||||
if (g_mp != NULL)
|
if (g_mp != nullptr)
|
||||||
g_mp->Clear(*g_music_buffer);
|
g_mp->Clear(*g_music_buffer);
|
||||||
|
|
||||||
/* the audio outputs are now waiting for a signal, to
|
/* the audio outputs are now waiting for a signal, to
|
||||||
@ -541,15 +541,15 @@ audio_output_all_close(void)
|
|||||||
for (i = 0; i < num_audio_outputs; ++i)
|
for (i = 0; i < num_audio_outputs; ++i)
|
||||||
audio_output_close(audio_outputs[i]);
|
audio_output_close(audio_outputs[i]);
|
||||||
|
|
||||||
if (g_mp != NULL) {
|
if (g_mp != nullptr) {
|
||||||
assert(g_music_buffer != NULL);
|
assert(g_music_buffer != nullptr);
|
||||||
|
|
||||||
g_mp->Clear(*g_music_buffer);
|
g_mp->Clear(*g_music_buffer);
|
||||||
delete g_mp;
|
delete g_mp;
|
||||||
g_mp = NULL;
|
g_mp = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_music_buffer = NULL;
|
g_music_buffer = nullptr;
|
||||||
|
|
||||||
input_audio_format.Clear();
|
input_audio_format.Clear();
|
||||||
|
|
||||||
@ -564,15 +564,15 @@ audio_output_all_release(void)
|
|||||||
for (i = 0; i < num_audio_outputs; ++i)
|
for (i = 0; i < num_audio_outputs; ++i)
|
||||||
audio_output_release(audio_outputs[i]);
|
audio_output_release(audio_outputs[i]);
|
||||||
|
|
||||||
if (g_mp != NULL) {
|
if (g_mp != nullptr) {
|
||||||
assert(g_music_buffer != NULL);
|
assert(g_music_buffer != nullptr);
|
||||||
|
|
||||||
g_mp->Clear(*g_music_buffer);
|
g_mp->Clear(*g_music_buffer);
|
||||||
delete g_mp;
|
delete g_mp;
|
||||||
g_mp = NULL;
|
g_mp = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_music_buffer = NULL;
|
g_music_buffer = nullptr;
|
||||||
|
|
||||||
input_audio_format.Clear();
|
input_audio_format.Clear();
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ audio_output_disable_index(unsigned idx)
|
|||||||
idle_add(IDLE_OUTPUT);
|
idle_add(IDLE_OUTPUT);
|
||||||
|
|
||||||
Mixer *mixer = ao->mixer;
|
Mixer *mixer = ao->mixer;
|
||||||
if (mixer != NULL) {
|
if (mixer != nullptr) {
|
||||||
mixer_close(mixer);
|
mixer_close(mixer);
|
||||||
idle_add(IDLE_MIXER);
|
idle_add(IDLE_MIXER);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ void
|
|||||||
audio_output_set_replay_gain_mode(struct audio_output *ao,
|
audio_output_set_replay_gain_mode(struct audio_output *ao,
|
||||||
enum replay_gain_mode mode)
|
enum replay_gain_mode mode)
|
||||||
{
|
{
|
||||||
if (ao->replay_gain_filter != NULL)
|
if (ao->replay_gain_filter != nullptr)
|
||||||
replay_gain_filter_set_mode(ao->replay_gain_filter, mode);
|
replay_gain_filter_set_mode(ao->replay_gain_filter, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ void
|
|||||||
audio_output_enable(struct audio_output *ao)
|
audio_output_enable(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
if (!ao->thread.IsDefined()) {
|
if (!ao->thread.IsDefined()) {
|
||||||
if (ao->plugin->enable == NULL) {
|
if (ao->plugin->enable == nullptr) {
|
||||||
/* don't bother to start the thread now if the
|
/* don't bother to start the thread now if the
|
||||||
device doesn't even have a enable() method;
|
device doesn't even have a enable() method;
|
||||||
just assign the variable and we're done */
|
just assign the variable and we're done */
|
||||||
@ -126,7 +126,7 @@ void
|
|||||||
audio_output_disable(struct audio_output *ao)
|
audio_output_disable(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
if (!ao->thread.IsDefined()) {
|
if (!ao->thread.IsDefined()) {
|
||||||
if (ao->plugin->disable == NULL)
|
if (ao->plugin->disable == nullptr)
|
||||||
ao->really_enabled = false;
|
ao->really_enabled = false;
|
||||||
else
|
else
|
||||||
/* if there's no thread yet, the device cannot
|
/* if there's no thread yet, the device cannot
|
||||||
@ -149,13 +149,13 @@ audio_output_open(struct audio_output *ao,
|
|||||||
{
|
{
|
||||||
bool open;
|
bool open;
|
||||||
|
|
||||||
assert(ao != NULL);
|
assert(ao != nullptr);
|
||||||
assert(ao->allow_play);
|
assert(ao->allow_play);
|
||||||
assert(audio_format.IsValid());
|
assert(audio_format.IsValid());
|
||||||
|
|
||||||
if (ao->fail_timer != NULL) {
|
if (ao->fail_timer != nullptr) {
|
||||||
g_timer_destroy(ao->fail_timer);
|
g_timer_destroy(ao->fail_timer);
|
||||||
ao->fail_timer = NULL;
|
ao->fail_timer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ao->open && audio_format == ao->in_audio_format) {
|
if (ao->open && audio_format == ao->in_audio_format) {
|
||||||
@ -163,7 +163,7 @@ audio_output_open(struct audio_output *ao,
|
|||||||
(ao->always_on && ao->pause));
|
(ao->always_on && ao->pause));
|
||||||
|
|
||||||
if (ao->pause) {
|
if (ao->pause) {
|
||||||
ao->chunk = NULL;
|
ao->chunk = nullptr;
|
||||||
ao->pipe = ∓
|
ao->pipe = ∓
|
||||||
|
|
||||||
/* unpause with the CANCEL command; this is a
|
/* unpause with the CANCEL command; this is a
|
||||||
@ -180,7 +180,7 @@ audio_output_open(struct audio_output *ao,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ao->in_audio_format = audio_format;
|
ao->in_audio_format = audio_format;
|
||||||
ao->chunk = NULL;
|
ao->chunk = nullptr;
|
||||||
|
|
||||||
ao->pipe = ∓
|
ao->pipe = ∓
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ audio_output_open(struct audio_output *ao,
|
|||||||
ao_command(ao, ao->open ? AO_COMMAND_REOPEN : AO_COMMAND_OPEN);
|
ao_command(ao, ao->open ? AO_COMMAND_REOPEN : AO_COMMAND_OPEN);
|
||||||
open = ao->open;
|
open = ao->open;
|
||||||
|
|
||||||
if (open && ao->mixer != NULL) {
|
if (open && ao->mixer != nullptr) {
|
||||||
Error error;
|
Error error;
|
||||||
if (!mixer_open(ao->mixer, error))
|
if (!mixer_open(ao->mixer, error))
|
||||||
FormatWarning(output_domain,
|
FormatWarning(output_domain,
|
||||||
@ -208,19 +208,19 @@ audio_output_open(struct audio_output *ao,
|
|||||||
static void
|
static void
|
||||||
audio_output_close_locked(struct audio_output *ao)
|
audio_output_close_locked(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
assert(ao != NULL);
|
assert(ao != nullptr);
|
||||||
assert(ao->allow_play);
|
assert(ao->allow_play);
|
||||||
|
|
||||||
if (ao->mixer != NULL)
|
if (ao->mixer != nullptr)
|
||||||
mixer_auto_close(ao->mixer);
|
mixer_auto_close(ao->mixer);
|
||||||
|
|
||||||
assert(!ao->open || ao->fail_timer == NULL);
|
assert(!ao->open || ao->fail_timer == nullptr);
|
||||||
|
|
||||||
if (ao->open)
|
if (ao->open)
|
||||||
ao_command(ao, AO_COMMAND_CLOSE);
|
ao_command(ao, AO_COMMAND_CLOSE);
|
||||||
else if (ao->fail_timer != NULL) {
|
else if (ao->fail_timer != nullptr) {
|
||||||
g_timer_destroy(ao->fail_timer);
|
g_timer_destroy(ao->fail_timer);
|
||||||
ao->fail_timer = NULL;
|
ao->fail_timer = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,8 +232,8 @@ audio_output_update(struct audio_output *ao,
|
|||||||
const ScopeLock protect(ao->mutex);
|
const ScopeLock protect(ao->mutex);
|
||||||
|
|
||||||
if (ao->enabled && ao->really_enabled) {
|
if (ao->enabled && ao->really_enabled) {
|
||||||
if (ao->fail_timer == NULL ||
|
if (ao->fail_timer == nullptr ||
|
||||||
g_timer_elapsed(ao->fail_timer, NULL) > REOPEN_AFTER) {
|
g_timer_elapsed(ao->fail_timer, nullptr) > REOPEN_AFTER) {
|
||||||
return audio_output_open(ao, audio_format, mp);
|
return audio_output_open(ao, audio_format, mp);
|
||||||
}
|
}
|
||||||
} else if (audio_output_is_open(ao))
|
} else if (audio_output_is_open(ao))
|
||||||
@ -255,7 +255,7 @@ audio_output_play(struct audio_output *ao)
|
|||||||
|
|
||||||
void audio_output_pause(struct audio_output *ao)
|
void audio_output_pause(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
if (ao->mixer != NULL && ao->plugin->pause == NULL)
|
if (ao->mixer != nullptr && ao->plugin->pause == nullptr)
|
||||||
/* the device has no pause mode: close the mixer,
|
/* the device has no pause mode: close the mixer,
|
||||||
unless its "global" flag is set (checked by
|
unless its "global" flag is set (checked by
|
||||||
mixer_auto_close()) */
|
mixer_auto_close()) */
|
||||||
@ -309,8 +309,8 @@ audio_output_release(struct audio_output *ao)
|
|||||||
|
|
||||||
void audio_output_close(struct audio_output *ao)
|
void audio_output_close(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
assert(ao != NULL);
|
assert(ao != nullptr);
|
||||||
assert(!ao->open || ao->fail_timer == NULL);
|
assert(!ao->open || ao->fail_timer == nullptr);
|
||||||
|
|
||||||
const ScopeLock protect(ao->mutex);
|
const ScopeLock protect(ao->mutex);
|
||||||
audio_output_close_locked(ao);
|
audio_output_close_locked(ao);
|
||||||
@ -320,7 +320,7 @@ void audio_output_finish(struct audio_output *ao)
|
|||||||
{
|
{
|
||||||
audio_output_close(ao);
|
audio_output_close(ao);
|
||||||
|
|
||||||
assert(ao->fail_timer == NULL);
|
assert(ao->fail_timer == nullptr);
|
||||||
|
|
||||||
if (ao->thread.IsDefined()) {
|
if (ao->thread.IsDefined()) {
|
||||||
assert(ao->allow_play);
|
assert(ao->allow_play);
|
||||||
|
@ -29,10 +29,10 @@ void
|
|||||||
ao_base_finish(struct audio_output *ao)
|
ao_base_finish(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
assert(!ao->open);
|
assert(!ao->open);
|
||||||
assert(ao->fail_timer == NULL);
|
assert(ao->fail_timer == nullptr);
|
||||||
assert(!ao->thread.IsDefined());
|
assert(!ao->thread.IsDefined());
|
||||||
|
|
||||||
if (ao->mixer != NULL)
|
if (ao->mixer != nullptr)
|
||||||
mixer_free(ao->mixer);
|
mixer_free(ao->mixer);
|
||||||
|
|
||||||
delete ao->replay_gain_filter;
|
delete ao->replay_gain_filter;
|
||||||
@ -44,7 +44,7 @@ void
|
|||||||
audio_output_free(struct audio_output *ao)
|
audio_output_free(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
assert(!ao->open);
|
assert(!ao->open);
|
||||||
assert(ao->fail_timer == NULL);
|
assert(ao->fail_timer == nullptr);
|
||||||
assert(!ao->thread.IsDefined());
|
assert(!ao->thread.IsDefined());
|
||||||
|
|
||||||
ao_plugin_finish(ao);
|
ao_plugin_finish(ao);
|
||||||
|
@ -53,7 +53,7 @@ audio_output_detect(Error &error)
|
|||||||
LogInfo(output_domain, "Attempt to detect audio output device");
|
LogInfo(output_domain, "Attempt to detect audio output device");
|
||||||
|
|
||||||
audio_output_plugins_for_each(plugin) {
|
audio_output_plugins_for_each(plugin) {
|
||||||
if (plugin->test_default_device == NULL)
|
if (plugin->test_default_device == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FormatInfo(output_domain,
|
FormatInfo(output_domain,
|
||||||
@ -64,7 +64,7 @@ audio_output_detect(Error &error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
error.Set(output_domain, "Unable to detect an audio device");
|
error.Set(output_domain, "Unable to detect an audio device");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +80,7 @@ audio_output_mixer_type(const config_param ¶m)
|
|||||||
{
|
{
|
||||||
/* read the local "mixer_type" setting */
|
/* read the local "mixer_type" setting */
|
||||||
const char *p = param.GetBlockValue("mixer_type");
|
const char *p = param.GetBlockValue("mixer_type");
|
||||||
if (p != NULL)
|
if (p != nullptr)
|
||||||
return mixer_type_parse(p);
|
return mixer_type_parse(p);
|
||||||
|
|
||||||
/* try the local "mixer_enabled" setting next (deprecated) */
|
/* try the local "mixer_enabled" setting next (deprecated) */
|
||||||
@ -105,11 +105,11 @@ audio_output_load_mixer(struct audio_output *ao,
|
|||||||
switch (audio_output_mixer_type(param)) {
|
switch (audio_output_mixer_type(param)) {
|
||||||
case MIXER_TYPE_NONE:
|
case MIXER_TYPE_NONE:
|
||||||
case MIXER_TYPE_UNKNOWN:
|
case MIXER_TYPE_UNKNOWN:
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
case MIXER_TYPE_HARDWARE:
|
case MIXER_TYPE_HARDWARE:
|
||||||
if (plugin == NULL)
|
if (plugin == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
return mixer_new(plugin, ao, param, error);
|
return mixer_new(plugin, ao, param, error);
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ audio_output_load_mixer(struct audio_output *ao,
|
|||||||
mixer = mixer_new(&software_mixer_plugin, nullptr,
|
mixer = mixer_new(&software_mixer_plugin, nullptr,
|
||||||
config_param(),
|
config_param(),
|
||||||
IgnoreError());
|
IgnoreError());
|
||||||
assert(mixer != NULL);
|
assert(mixer != nullptr);
|
||||||
|
|
||||||
filter_chain_append(filter_chain, "software_mixer",
|
filter_chain_append(filter_chain, "software_mixer",
|
||||||
software_mixer_get_filter(mixer));
|
software_mixer_get_filter(mixer));
|
||||||
@ -133,23 +133,23 @@ ao_base_init(struct audio_output *ao,
|
|||||||
const struct audio_output_plugin *plugin,
|
const struct audio_output_plugin *plugin,
|
||||||
const config_param ¶m, Error &error)
|
const config_param ¶m, Error &error)
|
||||||
{
|
{
|
||||||
assert(ao != NULL);
|
assert(ao != nullptr);
|
||||||
assert(plugin != NULL);
|
assert(plugin != nullptr);
|
||||||
assert(plugin->finish != NULL);
|
assert(plugin->finish != nullptr);
|
||||||
assert(plugin->open != NULL);
|
assert(plugin->open != nullptr);
|
||||||
assert(plugin->close != NULL);
|
assert(plugin->close != nullptr);
|
||||||
assert(plugin->play != NULL);
|
assert(plugin->play != nullptr);
|
||||||
|
|
||||||
if (!param.IsNull()) {
|
if (!param.IsNull()) {
|
||||||
ao->name = param.GetBlockValue(AUDIO_OUTPUT_NAME);
|
ao->name = param.GetBlockValue(AUDIO_OUTPUT_NAME);
|
||||||
if (ao->name == NULL) {
|
if (ao->name == nullptr) {
|
||||||
error.Set(config_domain,
|
error.Set(config_domain,
|
||||||
"Missing \"name\" configuration");
|
"Missing \"name\" configuration");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *p = param.GetBlockValue(AUDIO_OUTPUT_FORMAT);
|
const char *p = param.GetBlockValue(AUDIO_OUTPUT_FORMAT);
|
||||||
if (p != NULL) {
|
if (p != nullptr) {
|
||||||
bool success =
|
bool success =
|
||||||
audio_format_parse(ao->config_audio_format,
|
audio_format_parse(ao->config_audio_format,
|
||||||
p, true, error);
|
p, true, error);
|
||||||
@ -171,12 +171,12 @@ ao_base_init(struct audio_output *ao,
|
|||||||
ao->open = false;
|
ao->open = false;
|
||||||
ao->pause = false;
|
ao->pause = false;
|
||||||
ao->allow_play = true;
|
ao->allow_play = true;
|
||||||
ao->fail_timer = NULL;
|
ao->fail_timer = nullptr;
|
||||||
|
|
||||||
/* set up the filter chain */
|
/* set up the filter chain */
|
||||||
|
|
||||||
ao->filter = filter_chain_new();
|
ao->filter = filter_chain_new();
|
||||||
assert(ao->filter != NULL);
|
assert(ao->filter != nullptr);
|
||||||
|
|
||||||
/* create the normalization filter (if configured) */
|
/* create the normalization filter (if configured) */
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ ao_base_init(struct audio_output *ao,
|
|||||||
Filter *normalize_filter =
|
Filter *normalize_filter =
|
||||||
filter_new(&normalize_filter_plugin, config_param(),
|
filter_new(&normalize_filter_plugin, config_param(),
|
||||||
IgnoreError());
|
IgnoreError());
|
||||||
assert(normalize_filter != NULL);
|
assert(normalize_filter != nullptr);
|
||||||
|
|
||||||
filter_chain_append(*ao->filter, "normalize",
|
filter_chain_append(*ao->filter, "normalize",
|
||||||
autoconvert_filter_new(normalize_filter));
|
autoconvert_filter_new(normalize_filter));
|
||||||
@ -204,9 +204,9 @@ ao_base_init(struct audio_output *ao,
|
|||||||
|
|
||||||
ao->command = AO_COMMAND_NONE;
|
ao->command = AO_COMMAND_NONE;
|
||||||
|
|
||||||
ao->mixer = NULL;
|
ao->mixer = nullptr;
|
||||||
ao->replay_gain_filter = NULL;
|
ao->replay_gain_filter = nullptr;
|
||||||
ao->other_replay_gain_filter = NULL;
|
ao->other_replay_gain_filter = nullptr;
|
||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
|
|
||||||
@ -226,19 +226,19 @@ audio_output_setup(struct audio_output *ao, const config_param ¶m,
|
|||||||
if (strcmp(replay_gain_handler, "none") != 0) {
|
if (strcmp(replay_gain_handler, "none") != 0) {
|
||||||
ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
||||||
param, IgnoreError());
|
param, IgnoreError());
|
||||||
assert(ao->replay_gain_filter != NULL);
|
assert(ao->replay_gain_filter != nullptr);
|
||||||
|
|
||||||
ao->replay_gain_serial = 0;
|
ao->replay_gain_serial = 0;
|
||||||
|
|
||||||
ao->other_replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
ao->other_replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
||||||
param,
|
param,
|
||||||
IgnoreError());
|
IgnoreError());
|
||||||
assert(ao->other_replay_gain_filter != NULL);
|
assert(ao->other_replay_gain_filter != nullptr);
|
||||||
|
|
||||||
ao->other_replay_gain_serial = 0;
|
ao->other_replay_gain_serial = 0;
|
||||||
} else {
|
} else {
|
||||||
ao->replay_gain_filter = NULL;
|
ao->replay_gain_filter = nullptr;
|
||||||
ao->other_replay_gain_filter = NULL;
|
ao->other_replay_gain_filter = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set up the mixer */
|
/* set up the mixer */
|
||||||
@ -247,7 +247,7 @@ audio_output_setup(struct audio_output *ao, const config_param ¶m,
|
|||||||
ao->mixer = audio_output_load_mixer(ao, param,
|
ao->mixer = audio_output_load_mixer(ao, param,
|
||||||
ao->plugin->mixer_plugin,
|
ao->plugin->mixer_plugin,
|
||||||
*ao->filter, mixer_error);
|
*ao->filter, mixer_error);
|
||||||
if (ao->mixer == NULL && mixer_error.IsDefined())
|
if (ao->mixer == nullptr && mixer_error.IsDefined())
|
||||||
FormatError(mixer_error,
|
FormatError(mixer_error,
|
||||||
"Failed to initialize hardware mixer for '%s'",
|
"Failed to initialize hardware mixer for '%s'",
|
||||||
ao->name);
|
ao->name);
|
||||||
@ -255,14 +255,14 @@ audio_output_setup(struct audio_output *ao, const config_param ¶m,
|
|||||||
/* use the hardware mixer for replay gain? */
|
/* use the hardware mixer for replay gain? */
|
||||||
|
|
||||||
if (strcmp(replay_gain_handler, "mixer") == 0) {
|
if (strcmp(replay_gain_handler, "mixer") == 0) {
|
||||||
if (ao->mixer != NULL)
|
if (ao->mixer != nullptr)
|
||||||
replay_gain_filter_set_mixer(ao->replay_gain_filter,
|
replay_gain_filter_set_mixer(ao->replay_gain_filter,
|
||||||
ao->mixer, 100);
|
ao->mixer, 100);
|
||||||
else
|
else
|
||||||
FormatError(output_domain,
|
FormatError(output_domain,
|
||||||
"No such mixer for output '%s'", ao->name);
|
"No such mixer for output '%s'", ao->name);
|
||||||
} else if (strcmp(replay_gain_handler, "software") != 0 &&
|
} else if (strcmp(replay_gain_handler, "software") != 0 &&
|
||||||
ao->replay_gain_filter != NULL) {
|
ao->replay_gain_filter != nullptr) {
|
||||||
error.Set(config_domain,
|
error.Set(config_domain,
|
||||||
"Invalid \"replay_gain_handler\" value");
|
"Invalid \"replay_gain_handler\" value");
|
||||||
return false;
|
return false;
|
||||||
@ -272,7 +272,7 @@ audio_output_setup(struct audio_output *ao, const config_param ¶m,
|
|||||||
|
|
||||||
ao->convert_filter = filter_new(&convert_filter_plugin, config_param(),
|
ao->convert_filter = filter_new(&convert_filter_plugin, config_param(),
|
||||||
IgnoreError());
|
IgnoreError());
|
||||||
assert(ao->convert_filter != NULL);
|
assert(ao->convert_filter != nullptr);
|
||||||
|
|
||||||
filter_chain_append(*ao->filter, "convert", ao->convert_filter);
|
filter_chain_append(*ao->filter, "convert", ao->convert_filter);
|
||||||
|
|
||||||
@ -290,14 +290,14 @@ audio_output_new(const config_param ¶m,
|
|||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
p = param.GetBlockValue(AUDIO_OUTPUT_TYPE);
|
p = param.GetBlockValue(AUDIO_OUTPUT_TYPE);
|
||||||
if (p == NULL) {
|
if (p == nullptr) {
|
||||||
error.Set(config_domain,
|
error.Set(config_domain,
|
||||||
"Missing \"type\" configuration");
|
"Missing \"type\" configuration");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin = audio_output_plugin_get(p);
|
plugin = audio_output_plugin_get(p);
|
||||||
if (plugin == NULL) {
|
if (plugin == nullptr) {
|
||||||
error.Format(config_domain,
|
error.Format(config_domain,
|
||||||
"No such audio output plugin: %s", p);
|
"No such audio output plugin: %s", p);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -307,7 +307,7 @@ audio_output_new(const config_param ¶m,
|
|||||||
"No 'audio_output' defined in config file");
|
"No 'audio_output' defined in config file");
|
||||||
|
|
||||||
plugin = audio_output_detect(error);
|
plugin = audio_output_detect(error);
|
||||||
if (plugin == NULL)
|
if (plugin == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
FormatInfo(output_domain,
|
FormatInfo(output_domain,
|
||||||
@ -316,12 +316,12 @@ audio_output_new(const config_param ¶m,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct audio_output *ao = ao_plugin_init(plugin, param, error);
|
struct audio_output *ao = ao_plugin_init(plugin, param, error);
|
||||||
if (ao == NULL)
|
if (ao == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
if (!audio_output_setup(ao, param, error)) {
|
if (!audio_output_setup(ao, param, error)) {
|
||||||
ao_plugin_finish(ao);
|
ao_plugin_finish(ao);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ao->player_control = pc;
|
ao->player_control = pc;
|
||||||
|
@ -72,7 +72,7 @@ struct audio_output {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The #mixer object associated with this audio output device.
|
* The #mixer object associated with this audio output device.
|
||||||
* May be NULL if none is available, or if software volume is
|
* May be nullptr if none is available, or if software volume is
|
||||||
* configured.
|
* configured.
|
||||||
*/
|
*/
|
||||||
class Mixer *mixer;
|
class Mixer *mixer;
|
||||||
@ -127,7 +127,7 @@ struct audio_output {
|
|||||||
bool allow_play;
|
bool allow_play;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If not NULL, the device has failed, and this timer is used
|
* If not nullptr, the device has failed, and this timer is used
|
||||||
* to estimate how long it should stay disabled (unless
|
* to estimate how long it should stay disabled (unless
|
||||||
* explicitly reopened with "play").
|
* explicitly reopened with "play").
|
||||||
*/
|
*/
|
||||||
@ -197,7 +197,7 @@ struct audio_output {
|
|||||||
Filter *convert_filter;
|
Filter *convert_filter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The thread handle, or NULL if the output thread isn't
|
* The thread handle, or nullptr if the output thread isn't
|
||||||
* running.
|
* running.
|
||||||
*/
|
*/
|
||||||
Thread thread;
|
Thread thread;
|
||||||
|
@ -26,8 +26,8 @@ ao_plugin_init(const struct audio_output_plugin *plugin,
|
|||||||
const config_param ¶m,
|
const config_param ¶m,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
assert(plugin != NULL);
|
assert(plugin != nullptr);
|
||||||
assert(plugin->init != NULL);
|
assert(plugin->init != nullptr);
|
||||||
|
|
||||||
return plugin->init(param, error);
|
return plugin->init(param, error);
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ ao_plugin_finish(struct audio_output *ao)
|
|||||||
bool
|
bool
|
||||||
ao_plugin_enable(struct audio_output *ao, Error &error_r)
|
ao_plugin_enable(struct audio_output *ao, Error &error_r)
|
||||||
{
|
{
|
||||||
return ao->plugin->enable != NULL
|
return ao->plugin->enable != nullptr
|
||||||
? ao->plugin->enable(ao, error_r)
|
? ao->plugin->enable(ao, error_r)
|
||||||
: true;
|
: true;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ ao_plugin_enable(struct audio_output *ao, Error &error_r)
|
|||||||
void
|
void
|
||||||
ao_plugin_disable(struct audio_output *ao)
|
ao_plugin_disable(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
if (ao->plugin->disable != NULL)
|
if (ao->plugin->disable != nullptr)
|
||||||
ao->plugin->disable(ao);
|
ao->plugin->disable(ao);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ ao_plugin_close(struct audio_output *ao)
|
|||||||
unsigned
|
unsigned
|
||||||
ao_plugin_delay(struct audio_output *ao)
|
ao_plugin_delay(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
return ao->plugin->delay != NULL
|
return ao->plugin->delay != nullptr
|
||||||
? ao->plugin->delay(ao)
|
? ao->plugin->delay(ao)
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ ao_plugin_delay(struct audio_output *ao)
|
|||||||
void
|
void
|
||||||
ao_plugin_send_tag(struct audio_output *ao, const Tag *tag)
|
ao_plugin_send_tag(struct audio_output *ao, const Tag *tag)
|
||||||
{
|
{
|
||||||
if (ao->plugin->send_tag != NULL)
|
if (ao->plugin->send_tag != nullptr)
|
||||||
ao->plugin->send_tag(ao, tag);
|
ao->plugin->send_tag(ao, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,19 +91,19 @@ ao_plugin_play(struct audio_output *ao, const void *chunk, size_t size,
|
|||||||
void
|
void
|
||||||
ao_plugin_drain(struct audio_output *ao)
|
ao_plugin_drain(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
if (ao->plugin->drain != NULL)
|
if (ao->plugin->drain != nullptr)
|
||||||
ao->plugin->drain(ao);
|
ao->plugin->drain(ao);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ao_plugin_cancel(struct audio_output *ao)
|
ao_plugin_cancel(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
if (ao->plugin->cancel != NULL)
|
if (ao->plugin->cancel != nullptr)
|
||||||
ao->plugin->cancel(ao);
|
ao->plugin->cancel(ao);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ao_plugin_pause(struct audio_output *ao)
|
ao_plugin_pause(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
return ao->plugin->pause != NULL && ao->plugin->pause(ao);
|
return ao->plugin->pause != nullptr && ao->plugin->pause(ao);
|
||||||
}
|
}
|
||||||
|
@ -48,11 +48,9 @@ struct audio_output_plugin {
|
|||||||
* Configure and initialize the device, but do not open it
|
* Configure and initialize the device, but do not open it
|
||||||
* yet.
|
* yet.
|
||||||
*
|
*
|
||||||
* @param param the configuration section, or NULL if there is
|
* @param param the configuration section, or nullptr if there is
|
||||||
* no configuration
|
* no configuration
|
||||||
* @param error location to store the error occurring, or NULL
|
* @return nullptr on error, or an opaque pointer to the plugin's
|
||||||
* to ignore errors
|
|
||||||
* @return NULL on error, or an opaque pointer to the plugin's
|
|
||||||
* data
|
* data
|
||||||
*/
|
*/
|
||||||
struct audio_output *(*init)(const config_param ¶m,
|
struct audio_output *(*init)(const config_param ¶m,
|
||||||
@ -69,8 +67,6 @@ struct audio_output_plugin {
|
|||||||
* fail: if an error occurs during that, it should be reported
|
* fail: if an error occurs during that, it should be reported
|
||||||
* by the open() method.
|
* by the open() method.
|
||||||
*
|
*
|
||||||
* @param error_r location to store the error occurring, or
|
|
||||||
* NULL to ignore errors
|
|
||||||
* @return true on success, false on error
|
* @return true on success, false on error
|
||||||
*/
|
*/
|
||||||
bool (*enable)(struct audio_output *data, Error &error);
|
bool (*enable)(struct audio_output *data, Error &error);
|
||||||
@ -86,8 +82,6 @@ struct audio_output_plugin {
|
|||||||
*
|
*
|
||||||
* @param audio_format the audio format in which data is going
|
* @param audio_format the audio format in which data is going
|
||||||
* to be delivered; may be modified by the plugin
|
* to be delivered; may be modified by the plugin
|
||||||
* @param error location to store the error occurring, or NULL
|
|
||||||
* to ignore errors
|
|
||||||
*/
|
*/
|
||||||
bool (*open)(struct audio_output *data, AudioFormat &audio_format,
|
bool (*open)(struct audio_output *data, AudioFormat &audio_format,
|
||||||
Error &error);
|
Error &error);
|
||||||
@ -116,8 +110,6 @@ struct audio_output_plugin {
|
|||||||
/**
|
/**
|
||||||
* Play a chunk of audio data.
|
* Play a chunk of audio data.
|
||||||
*
|
*
|
||||||
* @param error location to store the error occurring, or NULL
|
|
||||||
* to ignore errors
|
|
||||||
* @return the number of bytes played, or 0 on error
|
* @return the number of bytes played, or 0 on error
|
||||||
*/
|
*/
|
||||||
size_t (*play)(struct audio_output *data,
|
size_t (*play)(struct audio_output *data,
|
||||||
@ -150,7 +142,7 @@ struct audio_output_plugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The mixer plugin associated with this output plugin. This
|
* The mixer plugin associated with this output plugin. This
|
||||||
* may be NULL if no mixer plugin is implemented. When
|
* may be nullptr if no mixer plugin is implemented. When
|
||||||
* created, this mixer plugin gets the same #config_param as
|
* created, this mixer plugin gets the same #config_param as
|
||||||
* this audio output device.
|
* this audio output device.
|
||||||
*/
|
*/
|
||||||
@ -160,7 +152,7 @@ struct audio_output_plugin {
|
|||||||
static inline bool
|
static inline bool
|
||||||
ao_plugin_test_default_device(const struct audio_output_plugin *plugin)
|
ao_plugin_test_default_device(const struct audio_output_plugin *plugin)
|
||||||
{
|
{
|
||||||
return plugin->test_default_device != NULL
|
return plugin->test_default_device != nullptr
|
||||||
? plugin->test_default_device()
|
? plugin->test_default_device()
|
||||||
: false;
|
: false;
|
||||||
}
|
}
|
||||||
|
@ -98,16 +98,16 @@ ao_filter_open(struct audio_output *ao, AudioFormat &format,
|
|||||||
assert(format.IsValid());
|
assert(format.IsValid());
|
||||||
|
|
||||||
/* the replay_gain filter cannot fail here */
|
/* the replay_gain filter cannot fail here */
|
||||||
if (ao->replay_gain_filter != NULL)
|
if (ao->replay_gain_filter != nullptr)
|
||||||
ao->replay_gain_filter->Open(format, error_r);
|
ao->replay_gain_filter->Open(format, error_r);
|
||||||
if (ao->other_replay_gain_filter != NULL)
|
if (ao->other_replay_gain_filter != nullptr)
|
||||||
ao->other_replay_gain_filter->Open(format, error_r);
|
ao->other_replay_gain_filter->Open(format, error_r);
|
||||||
|
|
||||||
const AudioFormat af = ao->filter->Open(format, error_r);
|
const AudioFormat af = ao->filter->Open(format, error_r);
|
||||||
if (!af.IsDefined()) {
|
if (!af.IsDefined()) {
|
||||||
if (ao->replay_gain_filter != NULL)
|
if (ao->replay_gain_filter != nullptr)
|
||||||
ao->replay_gain_filter->Close();
|
ao->replay_gain_filter->Close();
|
||||||
if (ao->other_replay_gain_filter != NULL)
|
if (ao->other_replay_gain_filter != nullptr)
|
||||||
ao->other_replay_gain_filter->Close();
|
ao->other_replay_gain_filter->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,9 +117,9 @@ ao_filter_open(struct audio_output *ao, AudioFormat &format,
|
|||||||
static void
|
static void
|
||||||
ao_filter_close(struct audio_output *ao)
|
ao_filter_close(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
if (ao->replay_gain_filter != NULL)
|
if (ao->replay_gain_filter != nullptr)
|
||||||
ao->replay_gain_filter->Close();
|
ao->replay_gain_filter->Close();
|
||||||
if (ao->other_replay_gain_filter != NULL)
|
if (ao->other_replay_gain_filter != nullptr)
|
||||||
ao->other_replay_gain_filter->Close();
|
ao->other_replay_gain_filter->Close();
|
||||||
|
|
||||||
ao->filter->Close();
|
ao->filter->Close();
|
||||||
@ -133,17 +133,17 @@ ao_open(struct audio_output *ao)
|
|||||||
struct audio_format_string af_string;
|
struct audio_format_string af_string;
|
||||||
|
|
||||||
assert(!ao->open);
|
assert(!ao->open);
|
||||||
assert(ao->pipe != NULL);
|
assert(ao->pipe != nullptr);
|
||||||
assert(ao->chunk == NULL);
|
assert(ao->chunk == nullptr);
|
||||||
assert(ao->in_audio_format.IsValid());
|
assert(ao->in_audio_format.IsValid());
|
||||||
|
|
||||||
if (ao->fail_timer != NULL) {
|
if (ao->fail_timer != nullptr) {
|
||||||
/* this can only happen when this
|
/* this can only happen when this
|
||||||
output thread fails while
|
output thread fails while
|
||||||
audio_output_open() is run in the
|
audio_output_open() is run in the
|
||||||
player thread */
|
player thread */
|
||||||
g_timer_destroy(ao->fail_timer);
|
g_timer_destroy(ao->fail_timer);
|
||||||
ao->fail_timer = NULL;
|
ao->fail_timer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable the device (just in case the last enable has failed) */
|
/* enable the device (just in case the last enable has failed) */
|
||||||
@ -204,9 +204,9 @@ ao_close(struct audio_output *ao, bool drain)
|
|||||||
{
|
{
|
||||||
assert(ao->open);
|
assert(ao->open);
|
||||||
|
|
||||||
ao->pipe = NULL;
|
ao->pipe = nullptr;
|
||||||
|
|
||||||
ao->chunk = NULL;
|
ao->chunk = nullptr;
|
||||||
ao->open = false;
|
ao->open = false;
|
||||||
|
|
||||||
ao->mutex.unlock();
|
ao->mutex.unlock();
|
||||||
@ -242,9 +242,9 @@ ao_reopen_filter(struct audio_output *ao)
|
|||||||
but we cannot call this function because we must
|
but we cannot call this function because we must
|
||||||
not call filter_close(ao->filter) again */
|
not call filter_close(ao->filter) again */
|
||||||
|
|
||||||
ao->pipe = NULL;
|
ao->pipe = nullptr;
|
||||||
|
|
||||||
ao->chunk = NULL;
|
ao->chunk = nullptr;
|
||||||
ao->open = false;
|
ao->open = false;
|
||||||
ao->fail_timer = g_timer_new();
|
ao->fail_timer = g_timer_new();
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk,
|
|||||||
unsigned *replay_gain_serial_p,
|
unsigned *replay_gain_serial_p,
|
||||||
size_t *length_r)
|
size_t *length_r)
|
||||||
{
|
{
|
||||||
assert(chunk != NULL);
|
assert(chunk != nullptr);
|
||||||
assert(!chunk->IsEmpty());
|
assert(!chunk->IsEmpty());
|
||||||
assert(chunk->CheckFormat(ao->in_audio_format));
|
assert(chunk->CheckFormat(ao->in_audio_format));
|
||||||
|
|
||||||
@ -321,22 +321,22 @@ ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk,
|
|||||||
|
|
||||||
assert(length % ao->in_audio_format.GetFrameSize() == 0);
|
assert(length % ao->in_audio_format.GetFrameSize() == 0);
|
||||||
|
|
||||||
if (length > 0 && replay_gain_filter != NULL) {
|
if (length > 0 && replay_gain_filter != nullptr) {
|
||||||
if (chunk->replay_gain_serial != *replay_gain_serial_p) {
|
if (chunk->replay_gain_serial != *replay_gain_serial_p) {
|
||||||
replay_gain_filter_set_info(replay_gain_filter,
|
replay_gain_filter_set_info(replay_gain_filter,
|
||||||
chunk->replay_gain_serial != 0
|
chunk->replay_gain_serial != 0
|
||||||
? &chunk->replay_gain_info
|
? &chunk->replay_gain_info
|
||||||
: NULL);
|
: nullptr);
|
||||||
*replay_gain_serial_p = chunk->replay_gain_serial;
|
*replay_gain_serial_p = chunk->replay_gain_serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
data = replay_gain_filter->FilterPCM(data, length,
|
data = replay_gain_filter->FilterPCM(data, length,
|
||||||
&length, error);
|
&length, error);
|
||||||
if (data == NULL) {
|
if (data == nullptr) {
|
||||||
FormatError(error, "\"%s\" [%s] failed to filter",
|
FormatError(error, "\"%s\" [%s] failed to filter",
|
||||||
ao->name, ao->plugin->name);
|
ao->name, ao->plugin->name);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,8 +351,8 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
|
|||||||
size_t length;
|
size_t length;
|
||||||
const void *data = ao_chunk_data(ao, chunk, ao->replay_gain_filter,
|
const void *data = ao_chunk_data(ao, chunk, ao->replay_gain_filter,
|
||||||
&ao->replay_gain_serial, &length);
|
&ao->replay_gain_serial, &length);
|
||||||
if (data == NULL)
|
if (data == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
/* empty chunk, nothing to do */
|
/* empty chunk, nothing to do */
|
||||||
@ -362,15 +362,15 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
|
|||||||
|
|
||||||
/* cross-fade */
|
/* cross-fade */
|
||||||
|
|
||||||
if (chunk->other != NULL) {
|
if (chunk->other != nullptr) {
|
||||||
size_t other_length;
|
size_t other_length;
|
||||||
const void *other_data =
|
const void *other_data =
|
||||||
ao_chunk_data(ao, chunk->other,
|
ao_chunk_data(ao, chunk->other,
|
||||||
ao->other_replay_gain_filter,
|
ao->other_replay_gain_filter,
|
||||||
&ao->other_replay_gain_serial,
|
&ao->other_replay_gain_serial,
|
||||||
&other_length);
|
&other_length);
|
||||||
if (other_data == NULL)
|
if (other_data == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
if (other_length == 0) {
|
if (other_length == 0) {
|
||||||
*length_r = 0;
|
*length_r = 0;
|
||||||
@ -393,7 +393,7 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
|
|||||||
FormatError(output_domain,
|
FormatError(output_domain,
|
||||||
"Cannot cross-fade format %s",
|
"Cannot cross-fade format %s",
|
||||||
sample_format_to_string(ao->in_audio_format.format));
|
sample_format_to_string(ao->in_audio_format.format));
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = dest;
|
data = dest;
|
||||||
@ -404,10 +404,10 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
|
|||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
data = ao->filter->FilterPCM(data, length, &length, error);
|
data = ao->filter->FilterPCM(data, length, &length, error);
|
||||||
if (data == NULL) {
|
if (data == nullptr) {
|
||||||
FormatError(error, "\"%s\" [%s] failed to filter",
|
FormatError(error, "\"%s\" [%s] failed to filter",
|
||||||
ao->name, ao->plugin->name);
|
ao->name, ao->plugin->name);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
*length_r = length;
|
*length_r = length;
|
||||||
@ -417,10 +417,10 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
|
|||||||
static bool
|
static bool
|
||||||
ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
|
ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
|
||||||
{
|
{
|
||||||
assert(ao != NULL);
|
assert(ao != nullptr);
|
||||||
assert(ao->filter != NULL);
|
assert(ao->filter != nullptr);
|
||||||
|
|
||||||
if (ao->tags && gcc_unlikely(chunk->tag != NULL)) {
|
if (ao->tags && gcc_unlikely(chunk->tag != nullptr)) {
|
||||||
ao->mutex.unlock();
|
ao->mutex.unlock();
|
||||||
ao_plugin_send_tag(ao, chunk->tag);
|
ao_plugin_send_tag(ao, chunk->tag);
|
||||||
ao->mutex.lock();
|
ao->mutex.lock();
|
||||||
@ -432,7 +432,7 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
|
|||||||
size = 0;
|
size = 0;
|
||||||
#endif
|
#endif
|
||||||
const char *data = (const char *)ao_filter_chunk(ao, chunk, &size);
|
const char *data = (const char *)ao_filter_chunk(ao, chunk, &size);
|
||||||
if (data == NULL) {
|
if (data == nullptr) {
|
||||||
ao_close(ao, false);
|
ao_close(ao, false);
|
||||||
|
|
||||||
/* don't automatically reopen this device for 10
|
/* don't automatically reopen this device for 10
|
||||||
@ -461,7 +461,7 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
|
|||||||
|
|
||||||
/* don't automatically reopen this device for
|
/* don't automatically reopen this device for
|
||||||
10 seconds */
|
10 seconds */
|
||||||
assert(ao->fail_timer == NULL);
|
assert(ao->fail_timer == nullptr);
|
||||||
ao->fail_timer = g_timer_new();
|
ao->fail_timer = g_timer_new();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -480,7 +480,7 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
|
|||||||
static const struct music_chunk *
|
static const struct music_chunk *
|
||||||
ao_next_chunk(struct audio_output *ao)
|
ao_next_chunk(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
return ao->chunk != NULL
|
return ao->chunk != nullptr
|
||||||
/* continue the previous play() call */
|
/* continue the previous play() call */
|
||||||
? ao->chunk->next
|
? ao->chunk->next
|
||||||
/* get the first chunk from the pipe */
|
/* get the first chunk from the pipe */
|
||||||
@ -501,23 +501,23 @@ ao_play(struct audio_output *ao)
|
|||||||
bool success;
|
bool success;
|
||||||
const struct music_chunk *chunk;
|
const struct music_chunk *chunk;
|
||||||
|
|
||||||
assert(ao->pipe != NULL);
|
assert(ao->pipe != nullptr);
|
||||||
|
|
||||||
chunk = ao_next_chunk(ao);
|
chunk = ao_next_chunk(ao);
|
||||||
if (chunk == NULL)
|
if (chunk == nullptr)
|
||||||
/* no chunk available */
|
/* no chunk available */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ao->chunk_finished = false;
|
ao->chunk_finished = false;
|
||||||
|
|
||||||
while (chunk != NULL && ao->command == AO_COMMAND_NONE) {
|
while (chunk != nullptr && ao->command == AO_COMMAND_NONE) {
|
||||||
assert(!ao->chunk_finished);
|
assert(!ao->chunk_finished);
|
||||||
|
|
||||||
ao->chunk = chunk;
|
ao->chunk = chunk;
|
||||||
|
|
||||||
success = ao_play_chunk(ao, chunk);
|
success = ao_play_chunk(ao, chunk);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
assert(ao->chunk == NULL);
|
assert(ao->chunk == nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ audio_output_task(void *arg)
|
|||||||
|
|
||||||
case AO_COMMAND_CLOSE:
|
case AO_COMMAND_CLOSE:
|
||||||
assert(ao->open);
|
assert(ao->open);
|
||||||
assert(ao->pipe != NULL);
|
assert(ao->pipe != nullptr);
|
||||||
|
|
||||||
ao_close(ao, false);
|
ao_close(ao, false);
|
||||||
ao_command_finished(ao);
|
ao_command_finished(ao);
|
||||||
@ -621,7 +621,7 @@ audio_output_task(void *arg)
|
|||||||
|
|
||||||
case AO_COMMAND_DRAIN:
|
case AO_COMMAND_DRAIN:
|
||||||
if (ao->open) {
|
if (ao->open) {
|
||||||
assert(ao->chunk == NULL);
|
assert(ao->chunk == nullptr);
|
||||||
assert(ao->pipe->Peek() == nullptr);
|
assert(ao->pipe->Peek() == nullptr);
|
||||||
|
|
||||||
ao->mutex.unlock();
|
ao->mutex.unlock();
|
||||||
@ -633,7 +633,7 @@ audio_output_task(void *arg)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case AO_COMMAND_CANCEL:
|
case AO_COMMAND_CANCEL:
|
||||||
ao->chunk = NULL;
|
ao->chunk = nullptr;
|
||||||
|
|
||||||
if (ao->open) {
|
if (ao->open) {
|
||||||
ao->mutex.unlock();
|
ao->mutex.unlock();
|
||||||
@ -645,7 +645,7 @@ audio_output_task(void *arg)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case AO_COMMAND_KILL:
|
case AO_COMMAND_KILL:
|
||||||
ao->chunk = NULL;
|
ao->chunk = nullptr;
|
||||||
ao_command_finished(ao);
|
ao_command_finished(ao);
|
||||||
ao->mutex.unlock();
|
ao->mutex.unlock();
|
||||||
return;
|
return;
|
||||||
|
@ -58,7 +58,7 @@ player_control::~player_control()
|
|||||||
void
|
void
|
||||||
player_control::Play(Song *song)
|
player_control::Play(Song *song)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ void
|
|||||||
player_control::Cancel()
|
player_control::Cancel()
|
||||||
{
|
{
|
||||||
LockSynchronousCommand(PlayerCommand::CANCEL);
|
LockSynchronousCommand(PlayerCommand::CANCEL);
|
||||||
assert(next_song == NULL);
|
assert(next_song == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -203,7 +203,7 @@ player_control::ClearError()
|
|||||||
void
|
void
|
||||||
player_control::EnqueueSong(Song *song)
|
player_control::EnqueueSong(Song *song)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
EnqueueSongLocked(song);
|
EnqueueSongLocked(song);
|
||||||
@ -213,7 +213,7 @@ player_control::EnqueueSong(Song *song)
|
|||||||
bool
|
bool
|
||||||
player_control::Seek(Song *song, float seek_time)
|
player_control::Seek(Song *song, float seek_time)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ queue::Clear()
|
|||||||
static void
|
static void
|
||||||
queue_sort_order_by_priority(struct queue *queue, unsigned start, unsigned end)
|
queue_sort_order_by_priority(struct queue *queue, unsigned start, unsigned end)
|
||||||
{
|
{
|
||||||
assert(queue != NULL);
|
assert(queue != nullptr);
|
||||||
assert(queue->random);
|
assert(queue->random);
|
||||||
assert(start <= end);
|
assert(start <= end);
|
||||||
assert(end <= queue->length);
|
assert(end <= queue->length);
|
||||||
|
@ -79,10 +79,10 @@ queue_load_song(TextFile &file, const char *line, queue *queue)
|
|||||||
|
|
||||||
uint8_t priority = 0;
|
uint8_t priority = 0;
|
||||||
if (g_str_has_prefix(line, PRIO_LABEL)) {
|
if (g_str_has_prefix(line, PRIO_LABEL)) {
|
||||||
priority = strtoul(line + sizeof(PRIO_LABEL) - 1, NULL, 10);
|
priority = strtoul(line + sizeof(PRIO_LABEL) - 1, nullptr, 10);
|
||||||
|
|
||||||
line = file.ReadLine();
|
line = file.ReadLine();
|
||||||
if (line == NULL)
|
if (line == nullptr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,8 +95,8 @@ queue_load_song(TextFile &file, const char *line, queue *queue)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
song = song_load(file, NULL, uri, error);
|
song = song_load(file, nullptr, uri, error);
|
||||||
if (song == NULL) {
|
if (song == nullptr) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ Song *
|
|||||||
song_load(TextFile &file, Directory *parent, const char *uri,
|
song_load(TextFile &file, Directory *parent, const char *uri,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
Song *song = parent != NULL
|
Song *song = parent != nullptr
|
||||||
? Song::NewFile(uri, parent)
|
? Song::NewFile(uri, parent)
|
||||||
: Song::NewRemote(uri);
|
: Song::NewRemote(uri);
|
||||||
char *line, *colon;
|
char *line, *colon;
|
||||||
@ -66,15 +66,15 @@ song_load(TextFile &file, Directory *parent, const char *uri,
|
|||||||
|
|
||||||
TagBuilder tag;
|
TagBuilder tag;
|
||||||
|
|
||||||
while ((line = file.ReadLine()) != NULL &&
|
while ((line = file.ReadLine()) != nullptr &&
|
||||||
strcmp(line, SONG_END) != 0) {
|
strcmp(line, SONG_END) != 0) {
|
||||||
colon = strchr(line, ':');
|
colon = strchr(line, ':');
|
||||||
if (colon == NULL || colon == line) {
|
if (colon == nullptr || colon == line) {
|
||||||
song->Free();
|
song->Free();
|
||||||
|
|
||||||
error.Format(song_save_domain,
|
error.Format(song_save_domain,
|
||||||
"unknown line in db: %s", line);
|
"unknown line in db: %s", line);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
*colon++ = 0;
|
*colon++ = 0;
|
||||||
@ -93,13 +93,13 @@ song_load(TextFile &file, Directory *parent, const char *uri,
|
|||||||
|
|
||||||
song->start_ms = strtoul(value, &endptr, 10);
|
song->start_ms = strtoul(value, &endptr, 10);
|
||||||
if (*endptr == '-')
|
if (*endptr == '-')
|
||||||
song->end_ms = strtoul(endptr + 1, NULL, 10);
|
song->end_ms = strtoul(endptr + 1, nullptr, 10);
|
||||||
} else {
|
} else {
|
||||||
song->Free();
|
song->Free();
|
||||||
|
|
||||||
error.Format(song_save_domain,
|
error.Format(song_save_domain,
|
||||||
"unknown line in db: %s", line);
|
"unknown line in db: %s", line);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,18 +35,18 @@ extern "C" {
|
|||||||
static const char *
|
static const char *
|
||||||
tag_get_value_checked(const Tag *tag, enum tag_type type)
|
tag_get_value_checked(const Tag *tag, enum tag_type type)
|
||||||
{
|
{
|
||||||
return tag != NULL
|
return tag != nullptr
|
||||||
? tag->GetValue(type)
|
? tag->GetValue(type)
|
||||||
: NULL;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
compare_utf8_string(const char *a, const char *b)
|
compare_utf8_string(const char *a, const char *b)
|
||||||
{
|
{
|
||||||
if (a == NULL)
|
if (a == nullptr)
|
||||||
return b == NULL ? 0 : -1;
|
return b == nullptr ? 0 : -1;
|
||||||
|
|
||||||
if (b == NULL)
|
if (b == nullptr)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return g_utf8_collate(a, b);
|
return g_utf8_collate(a, b);
|
||||||
@ -54,7 +54,7 @@ compare_utf8_string(const char *a, const char *b)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two string tag values, ignoring case. Either one may be
|
* Compare two string tag values, ignoring case. Either one may be
|
||||||
* NULL.
|
* nullptr.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
compare_string_tag_item(const Tag *a, const Tag *b,
|
compare_string_tag_item(const Tag *a, const Tag *b,
|
||||||
@ -66,13 +66,13 @@ compare_string_tag_item(const Tag *a, const Tag *b,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two tag values which should contain an integer value
|
* Compare two tag values which should contain an integer value
|
||||||
* (e.g. disc or track number). Either one may be NULL.
|
* (e.g. disc or track number). Either one may be nullptr.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
compare_number_string(const char *a, const char *b)
|
compare_number_string(const char *a, const char *b)
|
||||||
{
|
{
|
||||||
long ai = a == NULL ? 0 : strtol(a, NULL, 10);
|
long ai = a == nullptr ? 0 : strtol(a, nullptr, 10);
|
||||||
long bi = b == NULL ? 0 : strtol(b, NULL, 10);
|
long bi = b == nullptr ? 0 : strtol(b, nullptr, 10);
|
||||||
|
|
||||||
if (ai <= 0)
|
if (ai <= 0)
|
||||||
return bi <= 0 ? 0 : -1;
|
return bi <= 0 ? 0 : -1;
|
||||||
@ -120,5 +120,5 @@ song_cmp(gcc_unused void *priv, struct list_head *_a, struct list_head *_b)
|
|||||||
void
|
void
|
||||||
song_list_sort(struct list_head *songs)
|
song_list_sort(struct list_head *songs)
|
||||||
{
|
{
|
||||||
list_sort(NULL, songs, song_cmp);
|
list_sort(nullptr, songs, song_cmp);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
std::string
|
std::string
|
||||||
sticker_song_get_value(const Song *song, const char *name)
|
sticker_song_get_value(const Song *song, const char *name)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
assert(song->IsInDatabase());
|
assert(song->IsInDatabase());
|
||||||
|
|
||||||
const auto uri = song->GetURI();
|
const auto uri = song->GetURI();
|
||||||
@ -42,7 +42,7 @@ bool
|
|||||||
sticker_song_set_value(const Song *song,
|
sticker_song_set_value(const Song *song,
|
||||||
const char *name, const char *value)
|
const char *name, const char *value)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
assert(song->IsInDatabase());
|
assert(song->IsInDatabase());
|
||||||
|
|
||||||
const auto uri = song->GetURI();
|
const auto uri = song->GetURI();
|
||||||
@ -52,7 +52,7 @@ sticker_song_set_value(const Song *song,
|
|||||||
bool
|
bool
|
||||||
sticker_song_delete(const Song *song)
|
sticker_song_delete(const Song *song)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
assert(song->IsInDatabase());
|
assert(song->IsInDatabase());
|
||||||
|
|
||||||
const auto uri = song->GetURI();
|
const auto uri = song->GetURI();
|
||||||
@ -62,7 +62,7 @@ sticker_song_delete(const Song *song)
|
|||||||
bool
|
bool
|
||||||
sticker_song_delete_value(const Song *song, const char *name)
|
sticker_song_delete_value(const Song *song, const char *name)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
assert(song->IsInDatabase());
|
assert(song->IsInDatabase());
|
||||||
|
|
||||||
const auto uri = song->GetURI();
|
const auto uri = song->GetURI();
|
||||||
@ -72,7 +72,7 @@ sticker_song_delete_value(const Song *song, const char *name)
|
|||||||
struct sticker *
|
struct sticker *
|
||||||
sticker_song_get(const Song *song)
|
sticker_song_get(const Song *song)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != nullptr);
|
||||||
assert(song->IsInDatabase());
|
assert(song->IsInDatabase());
|
||||||
|
|
||||||
const auto uri = song->GetURI();
|
const auto uri = song->GetURI();
|
||||||
@ -100,7 +100,7 @@ sticker_song_find_cb(const char *uri, const char *value, void *user_data)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Song *song = data->directory->LookupSong(uri + data->base_uri_length);
|
Song *song = data->directory->LookupSong(uri + data->base_uri_length);
|
||||||
if (song != NULL)
|
if (song != nullptr)
|
||||||
data->func(song, value, data->user_data);
|
data->func(song, value, data->user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,10 +120,10 @@ sticker_song_find(Directory *directory, const char *name,
|
|||||||
if (*data.base_uri != 0)
|
if (*data.base_uri != 0)
|
||||||
/* append slash to base_uri */
|
/* append slash to base_uri */
|
||||||
data.base_uri = allocated =
|
data.base_uri = allocated =
|
||||||
g_strconcat(data.base_uri, "/", NULL);
|
g_strconcat(data.base_uri, "/", nullptr);
|
||||||
else
|
else
|
||||||
/* searching in root directory - no trailing slash */
|
/* searching in root directory - no trailing slash */
|
||||||
allocated = NULL;
|
allocated = nullptr;
|
||||||
|
|
||||||
data.base_uri_length = strlen(data.base_uri);
|
data.base_uri_length = strlen(data.base_uri);
|
||||||
|
|
||||||
|
@ -48,21 +48,21 @@ Song::LoadFile(const char *path_utf8, Directory *parent)
|
|||||||
Song *song;
|
Song *song;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
assert((parent == NULL) == PathTraits::IsAbsoluteUTF8(path_utf8));
|
assert((parent == nullptr) == PathTraits::IsAbsoluteUTF8(path_utf8));
|
||||||
assert(!uri_has_scheme(path_utf8));
|
assert(!uri_has_scheme(path_utf8));
|
||||||
assert(strchr(path_utf8, '\n') == NULL);
|
assert(strchr(path_utf8, '\n') == nullptr);
|
||||||
|
|
||||||
song = NewFile(path_utf8, parent);
|
song = NewFile(path_utf8, parent);
|
||||||
|
|
||||||
//in archive ?
|
//in archive ?
|
||||||
if (parent != NULL && parent->device == DEVICE_INARCHIVE) {
|
if (parent != nullptr && parent->device == DEVICE_INARCHIVE) {
|
||||||
ret = song->UpdateFileInArchive();
|
ret = song->UpdateFileInArchive();
|
||||||
} else {
|
} else {
|
||||||
ret = song->UpdateFile();
|
ret = song->UpdateFile();
|
||||||
}
|
}
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
song->Free();
|
song->Free();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
@ -85,18 +85,18 @@ Song::UpdateFile()
|
|||||||
const char *suffix;
|
const char *suffix;
|
||||||
const struct decoder_plugin *plugin;
|
const struct decoder_plugin *plugin;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct input_stream *is = NULL;
|
struct input_stream *is = nullptr;
|
||||||
|
|
||||||
assert(IsFile());
|
assert(IsFile());
|
||||||
|
|
||||||
/* check if there's a suffix and a plugin */
|
/* check if there's a suffix and a plugin */
|
||||||
|
|
||||||
suffix = uri_get_suffix(uri);
|
suffix = uri_get_suffix(uri);
|
||||||
if (suffix == NULL)
|
if (suffix == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
plugin = decoder_plugin_from_suffix(suffix, NULL);
|
plugin = decoder_plugin_from_suffix(suffix, nullptr);
|
||||||
if (plugin == NULL)
|
if (plugin == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto path_fs = map_song_fs(this);
|
const auto path_fs = map_song_fs(this);
|
||||||
@ -126,16 +126,16 @@ Song::UpdateFile()
|
|||||||
tag_builder.Clear();
|
tag_builder.Clear();
|
||||||
|
|
||||||
/* fall back to stream tag */
|
/* fall back to stream tag */
|
||||||
if (plugin->scan_stream != NULL) {
|
if (plugin->scan_stream != nullptr) {
|
||||||
/* open the input_stream (if not already
|
/* open the input_stream (if not already
|
||||||
open) */
|
open) */
|
||||||
if (is == NULL)
|
if (is == nullptr)
|
||||||
is = input_stream::Open(path_fs.c_str(),
|
is = input_stream::Open(path_fs.c_str(),
|
||||||
mutex, cond,
|
mutex, cond,
|
||||||
IgnoreError());
|
IgnoreError());
|
||||||
|
|
||||||
/* now try the stream_tag() method */
|
/* now try the stream_tag() method */
|
||||||
if (is != NULL) {
|
if (is != nullptr) {
|
||||||
if (decoder_plugin_scan_stream(plugin, is,
|
if (decoder_plugin_scan_stream(plugin, is,
|
||||||
&full_tag_handler,
|
&full_tag_handler,
|
||||||
&tag_builder))
|
&tag_builder))
|
||||||
@ -148,9 +148,9 @@ Song::UpdateFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin = decoder_plugin_from_suffix(suffix, plugin);
|
plugin = decoder_plugin_from_suffix(suffix, plugin);
|
||||||
} while (plugin != NULL);
|
} while (plugin != nullptr);
|
||||||
|
|
||||||
if (is != NULL)
|
if (is != nullptr)
|
||||||
is->Close();
|
is->Close();
|
||||||
|
|
||||||
if (!tag_builder.IsDefined())
|
if (!tag_builder.IsDefined())
|
||||||
@ -175,11 +175,11 @@ Song::UpdateFileInArchive()
|
|||||||
/* check if there's a suffix and a plugin */
|
/* check if there's a suffix and a plugin */
|
||||||
|
|
||||||
suffix = uri_get_suffix(uri);
|
suffix = uri_get_suffix(uri);
|
||||||
if (suffix == NULL)
|
if (suffix == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
plugin = decoder_plugin_from_suffix(suffix, NULL);
|
plugin = decoder_plugin_from_suffix(suffix, nullptr);
|
||||||
if (plugin == NULL)
|
if (plugin == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
delete tag;
|
delete tag;
|
||||||
|
@ -134,7 +134,7 @@ handle_sticker_song(Client *client, int argc, char *argv[])
|
|||||||
|
|
||||||
db_lock();
|
db_lock();
|
||||||
Directory *directory = db_get_directory(argv[3]);
|
Directory *directory = db_get_directory(argv[3]);
|
||||||
if (directory == NULL) {
|
if (directory == nullptr) {
|
||||||
db_unlock();
|
db_unlock();
|
||||||
command_error(client, ACK_ERROR_NO_EXIST,
|
command_error(client, ACK_ERROR_NO_EXIST,
|
||||||
"no such directory");
|
"no such directory");
|
||||||
|
@ -95,12 +95,12 @@ sticker_prepare(const char *sql, Error &error)
|
|||||||
int ret;
|
int ret;
|
||||||
sqlite3_stmt *stmt;
|
sqlite3_stmt *stmt;
|
||||||
|
|
||||||
ret = sqlite3_prepare_v2(sticker_db, sql, -1, &stmt, NULL);
|
ret = sqlite3_prepare_v2(sticker_db, sql, -1, &stmt, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
error.Format(sticker_domain, ret,
|
error.Format(sticker_domain, ret,
|
||||||
"sqlite3_prepare_v2() failed: %s",
|
"sqlite3_prepare_v2() failed: %s",
|
||||||
sqlite3_errmsg(sticker_db));
|
sqlite3_errmsg(sticker_db));
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stmt;
|
return stmt;
|
||||||
@ -126,7 +126,8 @@ sticker_global_init(Path path, Error &error)
|
|||||||
|
|
||||||
/* create the table and index */
|
/* create the table and index */
|
||||||
|
|
||||||
ret = sqlite3_exec(sticker_db, sticker_sql_create, NULL, NULL, NULL);
|
ret = sqlite3_exec(sticker_db, sticker_sql_create,
|
||||||
|
nullptr, nullptr, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
error.Format(sticker_domain, ret,
|
error.Format(sticker_domain, ret,
|
||||||
"Failed to create sticker table: %s",
|
"Failed to create sticker table: %s",
|
||||||
@ -137,10 +138,10 @@ sticker_global_init(Path path, Error &error)
|
|||||||
/* prepare the statements we're going to use */
|
/* prepare the statements we're going to use */
|
||||||
|
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(sticker_sql); ++i) {
|
for (unsigned i = 0; i < ARRAY_SIZE(sticker_sql); ++i) {
|
||||||
assert(sticker_sql[i] != NULL);
|
assert(sticker_sql[i] != nullptr);
|
||||||
|
|
||||||
sticker_stmt[i] = sticker_prepare(sticker_sql[i], error);
|
sticker_stmt[i] = sticker_prepare(sticker_sql[i], error);
|
||||||
if (sticker_stmt[i] == NULL)
|
if (sticker_stmt[i] == nullptr)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,12 +151,12 @@ sticker_global_init(Path path, Error &error)
|
|||||||
void
|
void
|
||||||
sticker_global_finish(void)
|
sticker_global_finish(void)
|
||||||
{
|
{
|
||||||
if (sticker_db == NULL)
|
if (sticker_db == nullptr)
|
||||||
/* not configured */
|
/* not configured */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(sticker_stmt); ++i) {
|
for (unsigned i = 0; i < ARRAY_SIZE(sticker_stmt); ++i) {
|
||||||
assert(sticker_stmt[i] != NULL);
|
assert(sticker_stmt[i] != nullptr);
|
||||||
|
|
||||||
sqlite3_finalize(sticker_stmt[i]);
|
sqlite3_finalize(sticker_stmt[i]);
|
||||||
}
|
}
|
||||||
@ -166,7 +167,7 @@ sticker_global_finish(void)
|
|||||||
bool
|
bool
|
||||||
sticker_enabled(void)
|
sticker_enabled(void)
|
||||||
{
|
{
|
||||||
return sticker_db != NULL;
|
return sticker_db != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
@ -176,28 +177,28 @@ sticker_load_value(const char *type, const char *uri, const char *name)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(sticker_enabled());
|
assert(sticker_enabled());
|
||||||
assert(type != NULL);
|
assert(type != nullptr);
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
assert(name != NULL);
|
assert(name != nullptr);
|
||||||
|
|
||||||
if (*name == 0)
|
if (*name == 0)
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 1, type, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 1, type, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 2, uri, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 2, uri, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 3, name, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 3, name, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return std::string();
|
return std::string();
|
||||||
@ -231,19 +232,19 @@ sticker_list_values(std::map<std::string, std::string> &table,
|
|||||||
sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_LIST];
|
sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_LIST];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(type != NULL);
|
assert(type != nullptr);
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
assert(sticker_enabled());
|
assert(sticker_enabled());
|
||||||
|
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 1, type, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 1, type, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 2, uri, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 2, uri, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
@ -284,35 +285,35 @@ sticker_update_value(const char *type, const char *uri,
|
|||||||
sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_UPDATE];
|
sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_UPDATE];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(type != NULL);
|
assert(type != nullptr);
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
assert(name != NULL);
|
assert(name != nullptr);
|
||||||
assert(*name != 0);
|
assert(*name != 0);
|
||||||
assert(value != NULL);
|
assert(value != nullptr);
|
||||||
|
|
||||||
assert(sticker_enabled());
|
assert(sticker_enabled());
|
||||||
|
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 1, value, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 1, value, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 2, type, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 2, type, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 3, uri, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 3, uri, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 4, name, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 4, name, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
@ -343,35 +344,35 @@ sticker_insert_value(const char *type, const char *uri,
|
|||||||
sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_INSERT];
|
sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_INSERT];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(type != NULL);
|
assert(type != nullptr);
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
assert(name != NULL);
|
assert(name != nullptr);
|
||||||
assert(*name != 0);
|
assert(*name != 0);
|
||||||
assert(value != NULL);
|
assert(value != nullptr);
|
||||||
|
|
||||||
assert(sticker_enabled());
|
assert(sticker_enabled());
|
||||||
|
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 1, type, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 1, type, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 2, uri, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 2, uri, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 3, name, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 3, name, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 4, value, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 4, value, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
@ -399,10 +400,10 @@ sticker_store_value(const char *type, const char *uri,
|
|||||||
const char *name, const char *value)
|
const char *name, const char *value)
|
||||||
{
|
{
|
||||||
assert(sticker_enabled());
|
assert(sticker_enabled());
|
||||||
assert(type != NULL);
|
assert(type != nullptr);
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
assert(name != NULL);
|
assert(name != nullptr);
|
||||||
assert(value != NULL);
|
assert(value != nullptr);
|
||||||
|
|
||||||
if (*name == 0)
|
if (*name == 0)
|
||||||
return false;
|
return false;
|
||||||
@ -418,18 +419,18 @@ sticker_delete(const char *type, const char *uri)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(sticker_enabled());
|
assert(sticker_enabled());
|
||||||
assert(type != NULL);
|
assert(type != nullptr);
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
|
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 1, type, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 1, type, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 2, uri, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 2, uri, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
@ -458,24 +459,24 @@ sticker_delete_value(const char *type, const char *uri, const char *name)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(sticker_enabled());
|
assert(sticker_enabled());
|
||||||
assert(type != NULL);
|
assert(type != nullptr);
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
|
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 1, type, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 1, type, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 2, uri, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 2, uri, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 3, name, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 3, name, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
@ -531,11 +532,11 @@ sticker_load(const char *type, const char *uri)
|
|||||||
sticker s;
|
sticker s;
|
||||||
|
|
||||||
if (!sticker_list_values(s.table, type, uri))
|
if (!sticker_list_values(s.table, type, uri))
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
if (s.table.empty())
|
if (s.table.empty())
|
||||||
/* don't return empty sticker objects */
|
/* don't return empty sticker objects */
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
return new sticker(std::move(s));
|
return new sticker(std::move(s));
|
||||||
}
|
}
|
||||||
@ -549,29 +550,29 @@ sticker_find(const char *type, const char *base_uri, const char *name,
|
|||||||
sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_FIND];
|
sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_FIND];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(type != NULL);
|
assert(type != nullptr);
|
||||||
assert(name != NULL);
|
assert(name != nullptr);
|
||||||
assert(func != NULL);
|
assert(func != nullptr);
|
||||||
assert(sticker_enabled());
|
assert(sticker_enabled());
|
||||||
|
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 1, type, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 1, type, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base_uri == NULL)
|
if (base_uri == nullptr)
|
||||||
base_uri = "";
|
base_uri = "";
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 2, base_uri, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 2, base_uri, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sqlite3_bind_text(stmt, 3, name, -1, NULL);
|
ret = sqlite3_bind_text(stmt, 3, name, -1, nullptr);
|
||||||
if (ret != SQLITE_OK) {
|
if (ret != SQLITE_OK) {
|
||||||
LogError(sticker_db, "sqlite3_bind_text() failed");
|
LogError(sticker_db, "sqlite3_bind_text() failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -51,10 +51,8 @@ class Path;
|
|||||||
struct sticker;
|
struct sticker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the sticker database (if path is not NULL).
|
* Opens the sticker database.
|
||||||
*
|
*
|
||||||
* @param error_r location to store the error occurring, or NULL to
|
|
||||||
* ignore errors
|
|
||||||
* @return true on success, false on error
|
* @return true on success, false on error
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
@ -115,7 +113,7 @@ sticker_free(struct sticker *sticker);
|
|||||||
*
|
*
|
||||||
* @param sticker the sticker object
|
* @param sticker the sticker object
|
||||||
* @param name the name of the sticker
|
* @param name the name of the sticker
|
||||||
* @return the sticker value, or NULL if none was found
|
* @return the sticker value, or nullptr if none was found
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const char *
|
const char *
|
||||||
@ -139,7 +137,7 @@ sticker_foreach(const struct sticker *sticker,
|
|||||||
*
|
*
|
||||||
* @param type the resource type, e.g. "song"
|
* @param type the resource type, e.g. "song"
|
||||||
* @param uri the URI of the resource, e.g. the song path
|
* @param uri the URI of the resource, e.g. the song path
|
||||||
* @return a sticker object, or NULL on error or if there is no sticker
|
* @return a sticker object, or nullptr on error or if there is no sticker
|
||||||
*/
|
*/
|
||||||
struct sticker *
|
struct sticker *
|
||||||
sticker_load(const char *type, const char *uri);
|
sticker_load(const char *type, const char *uri);
|
||||||
@ -148,7 +146,7 @@ sticker_load(const char *type, const char *uri);
|
|||||||
* Finds stickers with the specified name below the specified URI.
|
* Finds stickers with the specified name below the specified URI.
|
||||||
*
|
*
|
||||||
* @param type the resource type, e.g. "song"
|
* @param type the resource type, e.g. "song"
|
||||||
* @param base_uri the URI prefix of the resources, or NULL if all
|
* @param base_uri the URI prefix of the resources, or nullptr if all
|
||||||
* resources should be searched
|
* resources should be searched
|
||||||
* @param name the name of the sticker
|
* @param name the name of the sticker
|
||||||
* @return true on success (even if no sticker was found), false on
|
* @return true on success (even if no sticker was found), false on
|
||||||
|
@ -33,21 +33,21 @@ bool
|
|||||||
tag_file_scan(const char *path_fs,
|
tag_file_scan(const char *path_fs,
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
assert(path_fs != NULL);
|
assert(path_fs != nullptr);
|
||||||
assert(handler != NULL);
|
assert(handler != nullptr);
|
||||||
|
|
||||||
/* check if there's a suffix and a plugin */
|
/* check if there's a suffix and a plugin */
|
||||||
|
|
||||||
const char *suffix = uri_get_suffix(path_fs);
|
const char *suffix = uri_get_suffix(path_fs);
|
||||||
if (suffix == NULL)
|
if (suffix == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const struct decoder_plugin *plugin =
|
const struct decoder_plugin *plugin =
|
||||||
decoder_plugin_from_suffix(suffix, NULL);
|
decoder_plugin_from_suffix(suffix, nullptr);
|
||||||
if (plugin == NULL)
|
if (plugin == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct input_stream *is = NULL;
|
struct input_stream *is = nullptr;
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
Cond cond;
|
Cond cond;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ tag_file_scan(const char *path_fs,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* fall back to stream tag */
|
/* fall back to stream tag */
|
||||||
if (plugin->scan_stream != NULL) {
|
if (plugin->scan_stream != nullptr) {
|
||||||
/* open the input_stream (if not already
|
/* open the input_stream (if not already
|
||||||
open) */
|
open) */
|
||||||
if (is == nullptr) {
|
if (is == nullptr) {
|
||||||
@ -68,7 +68,7 @@ tag_file_scan(const char *path_fs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now try the stream_tag() method */
|
/* now try the stream_tag() method */
|
||||||
if (is != NULL) {
|
if (is != nullptr) {
|
||||||
if (decoder_plugin_scan_stream(plugin, is,
|
if (decoder_plugin_scan_stream(plugin, is,
|
||||||
handler,
|
handler,
|
||||||
handler_ctx))
|
handler_ctx))
|
||||||
@ -79,10 +79,10 @@ tag_file_scan(const char *path_fs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin = decoder_plugin_from_suffix(suffix, plugin);
|
plugin = decoder_plugin_from_suffix(suffix, plugin);
|
||||||
} while (plugin != NULL);
|
} while (plugin != nullptr);
|
||||||
|
|
||||||
if (is != NULL)
|
if (is != nullptr)
|
||||||
is->Close();
|
is->Close();
|
||||||
|
|
||||||
return plugin != NULL;
|
return plugin != nullptr;
|
||||||
}
|
}
|
||||||
|
@ -45,16 +45,16 @@ TextFile::ReadLine()
|
|||||||
gsize length = 0, i;
|
gsize length = 0, i;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
assert(file != NULL);
|
assert(file != nullptr);
|
||||||
assert(buffer != NULL);
|
assert(buffer != nullptr);
|
||||||
assert(buffer->allocated_len >= step);
|
assert(buffer->allocated_len >= step);
|
||||||
|
|
||||||
while (buffer->len < max_length) {
|
while (buffer->len < max_length) {
|
||||||
p = fgets(buffer->str + length,
|
p = fgets(buffer->str + length,
|
||||||
buffer->allocated_len - length, file);
|
buffer->allocated_len - length, file);
|
||||||
if (p == NULL) {
|
if (p == nullptr) {
|
||||||
if (length == 0 || ferror(file))
|
if (length == 0 || ferror(file))
|
||||||
return NULL;
|
return nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @param file the source file, opened in text mode
|
* @param file the source file, opened in text mode
|
||||||
* @param buffer an allocator for the buffer
|
* @param buffer an allocator for the buffer
|
||||||
* @return a pointer to the line, or NULL on end-of-file or error
|
* @return a pointer to the line, or nullptr on end-of-file or error
|
||||||
*/
|
*/
|
||||||
char *ReadLine();
|
char *ReadLine();
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,7 @@ time_print(Client *client, const char *name, time_t t)
|
|||||||
struct tm tm;
|
struct tm tm;
|
||||||
const struct tm *tm2 = gmtime_r(&t, &tm);
|
const struct tm *tm2 = gmtime_r(&t, &tm);
|
||||||
#endif
|
#endif
|
||||||
if (tm2 == NULL)
|
if (tm2 == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
@ -63,9 +63,9 @@ update_archive_tree(Directory *directory, const char *name)
|
|||||||
db_lock();
|
db_lock();
|
||||||
Song *song = directory->FindSong(name);
|
Song *song = directory->FindSong(name);
|
||||||
db_unlock();
|
db_unlock();
|
||||||
if (song == NULL) {
|
if (song == nullptr) {
|
||||||
song = Song::LoadFile(name, directory);
|
song = Song::LoadFile(name, directory);
|
||||||
if (song != NULL) {
|
if (song != nullptr) {
|
||||||
db_lock();
|
db_lock();
|
||||||
directory->AddSong(song);
|
directory->AddSong(song);
|
||||||
db_unlock();
|
db_unlock();
|
||||||
@ -95,7 +95,7 @@ update_archive_file2(Directory *parent, const char *name,
|
|||||||
Directory *directory = parent->FindChild(name);
|
Directory *directory = parent->FindChild(name);
|
||||||
db_unlock();
|
db_unlock();
|
||||||
|
|
||||||
if (directory != NULL && directory->mtime == st->st_mtime &&
|
if (directory != nullptr && directory->mtime == st->st_mtime &&
|
||||||
!walk_discard)
|
!walk_discard)
|
||||||
/* MPD has already scanned the archive, and it hasn't
|
/* MPD has already scanned the archive, and it hasn't
|
||||||
changed since - don't consider updating it */
|
changed since - don't consider updating it */
|
||||||
@ -106,14 +106,14 @@ update_archive_file2(Directory *parent, const char *name,
|
|||||||
/* open archive */
|
/* open archive */
|
||||||
Error error;
|
Error error;
|
||||||
ArchiveFile *file = archive_file_open(plugin, path_fs.c_str(), error);
|
ArchiveFile *file = archive_file_open(plugin, path_fs.c_str(), error);
|
||||||
if (file == NULL) {
|
if (file == nullptr) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FormatDebug(update_domain, "archive %s opened", path_fs.c_str());
|
FormatDebug(update_domain, "archive %s opened", path_fs.c_str());
|
||||||
|
|
||||||
if (directory == NULL) {
|
if (directory == nullptr) {
|
||||||
FormatDebug(update_domain,
|
FormatDebug(update_domain,
|
||||||
"creating archive directory: %s", name);
|
"creating archive directory: %s", name);
|
||||||
db_lock();
|
db_lock();
|
||||||
@ -153,7 +153,7 @@ update_archive_file(Directory *directory,
|
|||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
const struct archive_plugin *plugin =
|
const struct archive_plugin *plugin =
|
||||||
archive_plugin_from_suffix(suffix);
|
archive_plugin_from_suffix(suffix);
|
||||||
if (plugin == NULL)
|
if (plugin == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
update_archive_file2(directory, name, st, plugin);
|
update_archive_file2(directory, name, st, plugin);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
/**
|
/**
|
||||||
* Create the specified directory object if it does not exist already
|
* Create the specified directory object if it does not exist already
|
||||||
* or if the #stat object indicates that it has been modified since
|
* or if the #stat object indicates that it has been modified since
|
||||||
* the last update. Returns NULL when it exists already and is
|
* the last update. Returns nullptr when it exists already and is
|
||||||
* unmodified.
|
* unmodified.
|
||||||
*
|
*
|
||||||
* The caller must lock the database.
|
* The caller must lock the database.
|
||||||
@ -49,10 +49,10 @@ make_directory_if_modified(Directory *parent, const char *name,
|
|||||||
Directory *directory = parent->FindChild(name);
|
Directory *directory = parent->FindChild(name);
|
||||||
|
|
||||||
// directory exists already
|
// directory exists already
|
||||||
if (directory != NULL) {
|
if (directory != nullptr) {
|
||||||
if (directory->mtime == st->st_mtime && !walk_discard) {
|
if (directory->mtime == st->st_mtime && !walk_discard) {
|
||||||
/* not modified */
|
/* not modified */
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_directory(directory);
|
delete_directory(directory);
|
||||||
@ -70,12 +70,12 @@ update_container_file(Directory *directory,
|
|||||||
const struct stat *st,
|
const struct stat *st,
|
||||||
const struct decoder_plugin *plugin)
|
const struct decoder_plugin *plugin)
|
||||||
{
|
{
|
||||||
if (plugin->container_scan == NULL)
|
if (plugin->container_scan == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
db_lock();
|
db_lock();
|
||||||
Directory *contdir = make_directory_if_modified(directory, name, st);
|
Directory *contdir = make_directory_if_modified(directory, name, st);
|
||||||
if (contdir == NULL) {
|
if (contdir == nullptr) {
|
||||||
/* not modified */
|
/* not modified */
|
||||||
db_unlock();
|
db_unlock();
|
||||||
return true;
|
return true;
|
||||||
@ -89,7 +89,7 @@ update_container_file(Directory *directory,
|
|||||||
char *vtrack;
|
char *vtrack;
|
||||||
unsigned int tnum = 0;
|
unsigned int tnum = 0;
|
||||||
TagBuilder tag_builder;
|
TagBuilder tag_builder;
|
||||||
while ((vtrack = plugin->container_scan(pathname.c_str(), ++tnum)) != NULL) {
|
while ((vtrack = plugin->container_scan(pathname.c_str(), ++tnum)) != nullptr) {
|
||||||
Song *song = Song::NewFile(vtrack, contdir);
|
Song *song = Song::NewFile(vtrack, contdir);
|
||||||
|
|
||||||
// shouldn't be necessary but it's there..
|
// shouldn't be necessary but it's there..
|
||||||
|
@ -70,7 +70,7 @@ clear_directory(Directory *directory)
|
|||||||
void
|
void
|
||||||
delete_directory(Directory *directory)
|
delete_directory(Directory *directory)
|
||||||
{
|
{
|
||||||
assert(directory->parent != NULL);
|
assert(directory->parent != nullptr);
|
||||||
|
|
||||||
clear_directory(directory);
|
clear_directory(directory);
|
||||||
|
|
||||||
@ -85,13 +85,13 @@ delete_name_in(Directory *parent, const char *name)
|
|||||||
db_lock();
|
db_lock();
|
||||||
Directory *directory = parent->FindChild(name);
|
Directory *directory = parent->FindChild(name);
|
||||||
|
|
||||||
if (directory != NULL) {
|
if (directory != nullptr) {
|
||||||
delete_directory(directory);
|
delete_directory(directory);
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Song *song = parent->FindSong(name);
|
Song *song = parent->FindSong(name);
|
||||||
if (song != NULL) {
|
if (song != nullptr) {
|
||||||
delete_song(parent, song);
|
delete_song(parent, song);
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ static Cond remove_cond;
|
|||||||
static void
|
static void
|
||||||
song_remove_event(void)
|
song_remove_event(void)
|
||||||
{
|
{
|
||||||
assert(removed_song != NULL);
|
assert(removed_song != nullptr);
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto uri = removed_song->GetURI();
|
const auto uri = removed_song->GetURI();
|
||||||
@ -67,7 +67,7 @@ song_remove_event(void)
|
|||||||
|
|
||||||
/* clear "removed_song" and send signal to update thread */
|
/* clear "removed_song" and send signal to update thread */
|
||||||
remove_mutex.lock();
|
remove_mutex.lock();
|
||||||
removed_song = NULL;
|
removed_song = nullptr;
|
||||||
remove_cond.signal();
|
remove_cond.signal();
|
||||||
remove_mutex.unlock();
|
remove_mutex.unlock();
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ update_remove_global_init(void)
|
|||||||
void
|
void
|
||||||
update_remove_song(const Song *song)
|
update_remove_song(const Song *song)
|
||||||
{
|
{
|
||||||
assert(removed_song == NULL);
|
assert(removed_song == nullptr);
|
||||||
|
|
||||||
removed_song = song;
|
removed_song = song;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ update_remove_song(const Song *song)
|
|||||||
|
|
||||||
remove_mutex.lock();
|
remove_mutex.lock();
|
||||||
|
|
||||||
while (removed_song != NULL)
|
while (removed_song != nullptr)
|
||||||
remove_cond.wait(remove_mutex);
|
remove_cond.wait(remove_mutex);
|
||||||
|
|
||||||
remove_mutex.unlock();
|
remove_mutex.unlock();
|
||||||
|
@ -46,7 +46,7 @@ update_song_file2(Directory *directory,
|
|||||||
FormatError(update_domain,
|
FormatError(update_domain,
|
||||||
"no read permissions on %s/%s",
|
"no read permissions on %s/%s",
|
||||||
directory->GetPath(), name);
|
directory->GetPath(), name);
|
||||||
if (song != NULL) {
|
if (song != nullptr) {
|
||||||
db_lock();
|
db_lock();
|
||||||
delete_song(directory, song);
|
delete_song(directory, song);
|
||||||
db_unlock();
|
db_unlock();
|
||||||
@ -55,10 +55,10 @@ update_song_file2(Directory *directory,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(song != NULL && st->st_mtime == song->mtime &&
|
if (!(song != nullptr && st->st_mtime == song->mtime &&
|
||||||
!walk_discard) &&
|
!walk_discard) &&
|
||||||
update_container_file(directory, name, st, plugin)) {
|
update_container_file(directory, name, st, plugin)) {
|
||||||
if (song != NULL) {
|
if (song != nullptr) {
|
||||||
db_lock();
|
db_lock();
|
||||||
delete_song(directory, song);
|
delete_song(directory, song);
|
||||||
db_unlock();
|
db_unlock();
|
||||||
@ -67,11 +67,11 @@ update_song_file2(Directory *directory,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (song == NULL) {
|
if (song == nullptr) {
|
||||||
FormatDebug(update_domain, "reading %s/%s",
|
FormatDebug(update_domain, "reading %s/%s",
|
||||||
directory->GetPath(), name);
|
directory->GetPath(), name);
|
||||||
song = Song::LoadFile(name, directory);
|
song = Song::LoadFile(name, directory);
|
||||||
if (song == NULL) {
|
if (song == nullptr) {
|
||||||
FormatDebug(update_domain,
|
FormatDebug(update_domain,
|
||||||
"ignoring unrecognized file %s/%s",
|
"ignoring unrecognized file %s/%s",
|
||||||
directory->GetPath(), name);
|
directory->GetPath(), name);
|
||||||
@ -108,7 +108,7 @@ update_song_file(Directory *directory,
|
|||||||
{
|
{
|
||||||
const struct decoder_plugin *plugin =
|
const struct decoder_plugin *plugin =
|
||||||
decoder_plugin_from_suffix(suffix, nullptr);
|
decoder_plugin_from_suffix(suffix, nullptr);
|
||||||
if (plugin == NULL)
|
if (plugin == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
update_song_file2(directory, name, st, plugin);
|
update_song_file2(directory, name, st, plugin);
|
||||||
|
@ -222,7 +222,7 @@ update_regular_file(Directory *directory,
|
|||||||
const char *name, const struct stat *st)
|
const char *name, const struct stat *st)
|
||||||
{
|
{
|
||||||
const char *suffix = uri_get_suffix(name);
|
const char *suffix = uri_get_suffix(name);
|
||||||
if (suffix == NULL)
|
if (suffix == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return update_song_file(directory, name, suffix, st) ||
|
return update_song_file(directory, name, suffix, st) ||
|
||||||
@ -237,7 +237,7 @@ static void
|
|||||||
update_directory_child(Directory *directory,
|
update_directory_child(Directory *directory,
|
||||||
const char *name, const struct stat *st)
|
const char *name, const struct stat *st)
|
||||||
{
|
{
|
||||||
assert(strchr(name, '/') == NULL);
|
assert(strchr(name, '/') == nullptr);
|
||||||
|
|
||||||
if (S_ISREG(st->st_mode)) {
|
if (S_ISREG(st->st_mode)) {
|
||||||
update_regular_file(directory, name, st);
|
update_regular_file(directory, name, st);
|
||||||
@ -269,7 +269,7 @@ static bool skip_path(Path path_fs)
|
|||||||
const char *path = path_fs.c_str();
|
const char *path = path_fs.c_str();
|
||||||
return (path[0] == '.' && path[1] == 0) ||
|
return (path[0] == '.' && path[1] == 0) ||
|
||||||
(path[0] == '.' && path[1] == '.' && path[2] == 0) ||
|
(path[0] == '.' && path[1] == '.' && path[2] == 0) ||
|
||||||
strchr(path, '\n') != NULL;
|
strchr(path, '\n') != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
@ -310,7 +310,7 @@ skip_symlink(const Directory *directory, const char *utf8_name)
|
|||||||
if (p[1] == '.' && PathTraits::IsSeparatorFS(p[2])) {
|
if (p[1] == '.' && PathTraits::IsSeparatorFS(p[2])) {
|
||||||
/* "../" moves to parent directory */
|
/* "../" moves to parent directory */
|
||||||
directory = directory->parent;
|
directory = directory->parent;
|
||||||
if (directory == NULL) {
|
if (directory == nullptr) {
|
||||||
/* we have moved outside the music
|
/* we have moved outside the music
|
||||||
directory - skip this symlink
|
directory - skip this symlink
|
||||||
if such symlinks are not allowed */
|
if such symlinks are not allowed */
|
||||||
@ -403,16 +403,16 @@ directory_make_child_checked(Directory *parent, const char *name_utf8)
|
|||||||
Directory *directory = parent->FindChild(name_utf8);
|
Directory *directory = parent->FindChild(name_utf8);
|
||||||
db_unlock();
|
db_unlock();
|
||||||
|
|
||||||
if (directory != NULL)
|
if (directory != nullptr)
|
||||||
return directory;
|
return directory;
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat_directory_child(parent, name_utf8, &st) < 0 ||
|
if (stat_directory_child(parent, name_utf8, &st) < 0 ||
|
||||||
find_inode_ancestor(parent, st.st_ino, st.st_dev))
|
find_inode_ancestor(parent, st.st_ino, st.st_dev))
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
if (skip_symlink(parent, name_utf8))
|
if (skip_symlink(parent, name_utf8))
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
/* if we're adding directory paths, make sure to delete filenames
|
/* if we're adding directory paths, make sure to delete filenames
|
||||||
with potentially the same name */
|
with potentially the same name */
|
||||||
@ -435,14 +435,14 @@ directory_make_uri_parent_checked(const char *uri)
|
|||||||
char *duplicated = g_strdup(uri);
|
char *duplicated = g_strdup(uri);
|
||||||
char *name_utf8 = duplicated, *slash;
|
char *name_utf8 = duplicated, *slash;
|
||||||
|
|
||||||
while ((slash = strchr(name_utf8, '/')) != NULL) {
|
while ((slash = strchr(name_utf8, '/')) != nullptr) {
|
||||||
*slash = 0;
|
*slash = 0;
|
||||||
|
|
||||||
if (*name_utf8 == 0)
|
if (*name_utf8 == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
directory = directory_make_child_checked(directory, name_utf8);
|
directory = directory_make_child_checked(directory, name_utf8);
|
||||||
if (directory == NULL)
|
if (directory == nullptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
name_utf8 = slash + 1;
|
name_utf8 = slash + 1;
|
||||||
@ -456,7 +456,7 @@ static void
|
|||||||
update_uri(const char *uri)
|
update_uri(const char *uri)
|
||||||
{
|
{
|
||||||
Directory *parent = directory_make_uri_parent_checked(uri);
|
Directory *parent = directory_make_uri_parent_checked(uri);
|
||||||
if (parent == NULL)
|
if (parent == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char *name = g_path_get_basename(uri);
|
char *name = g_path_get_basename(uri);
|
||||||
@ -477,7 +477,7 @@ update_walk(const char *path, bool discard)
|
|||||||
walk_discard = discard;
|
walk_discard = discard;
|
||||||
modified = false;
|
modified = false;
|
||||||
|
|
||||||
if (path != NULL && !isRootDirectory(path)) {
|
if (path != nullptr && !isRootDirectory(path)) {
|
||||||
update_uri(path);
|
update_uri(path);
|
||||||
} else {
|
} else {
|
||||||
Directory *directory = db_get_root();
|
Directory *directory = db_get_root();
|
||||||
|
@ -68,10 +68,10 @@ void volume_init(void)
|
|||||||
|
|
||||||
int volume_level_get(void)
|
int volume_level_get(void)
|
||||||
{
|
{
|
||||||
assert(hardware_volume_timer != NULL);
|
assert(hardware_volume_timer != nullptr);
|
||||||
|
|
||||||
if (last_hardware_volume >= 0 &&
|
if (last_hardware_volume >= 0 &&
|
||||||
g_timer_elapsed(hardware_volume_timer, NULL) < 1.0)
|
g_timer_elapsed(hardware_volume_timer, nullptr) < 1.0)
|
||||||
/* throttle access to hardware mixers */
|
/* throttle access to hardware mixers */
|
||||||
return last_hardware_volume;
|
return last_hardware_volume;
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ bool volume_level_change(unsigned volume)
|
|||||||
bool
|
bool
|
||||||
read_sw_volume_state(const char *line)
|
read_sw_volume_state(const char *line)
|
||||||
{
|
{
|
||||||
char *end = NULL;
|
char *end = nullptr;
|
||||||
long int sv;
|
long int sv;
|
||||||
|
|
||||||
if (!g_str_has_prefix(line, SW_VOLUME_STATE))
|
if (!g_str_has_prefix(line, SW_VOLUME_STATE))
|
||||||
|
@ -44,7 +44,7 @@ service_main(DWORD argc, CHAR *argv[]);
|
|||||||
|
|
||||||
static SERVICE_TABLE_ENTRY service_registry[] = {
|
static SERVICE_TABLE_ENTRY service_registry[] = {
|
||||||
{service_name, service_main},
|
{service_name, service_main},
|
||||||
{NULL, NULL}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -87,7 +87,7 @@ service_main(gcc_unused DWORD argc, gcc_unused CHAR *argv[])
|
|||||||
|
|
||||||
service_handle =
|
service_handle =
|
||||||
RegisterServiceCtrlHandlerEx(service_name,
|
RegisterServiceCtrlHandlerEx(service_name,
|
||||||
service_dispatcher, NULL);
|
service_dispatcher, nullptr);
|
||||||
|
|
||||||
if (service_handle == 0) {
|
if (service_handle == 0) {
|
||||||
error_code = GetLastError();
|
error_code = GetLastError();
|
||||||
|
@ -109,7 +109,7 @@ static void avahiRegisterService(AvahiClient * c)
|
|||||||
/* If this is the first time we're called,
|
/* If this is the first time we're called,
|
||||||
* let's create a new entry group */
|
* let's create a new entry group */
|
||||||
if (!avahiGroup) {
|
if (!avahiGroup) {
|
||||||
avahiGroup = avahi_entry_group_new(c, avahiGroupCallback, NULL);
|
avahiGroup = avahi_entry_group_new(c, avahiGroupCallback, nullptr);
|
||||||
if (!avahiGroup) {
|
if (!avahiGroup) {
|
||||||
FormatError(avahi_domain,
|
FormatError(avahi_domain,
|
||||||
"Failed to create avahi EntryGroup: %s",
|
"Failed to create avahi EntryGroup: %s",
|
||||||
@ -125,8 +125,8 @@ static void avahiRegisterService(AvahiClient * c)
|
|||||||
ret = avahi_entry_group_add_service(avahiGroup,
|
ret = avahi_entry_group_add_service(avahiGroup,
|
||||||
AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
|
AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
|
||||||
AvahiPublishFlags(0),
|
AvahiPublishFlags(0),
|
||||||
avahiName, SERVICE_TYPE, NULL,
|
avahiName, SERVICE_TYPE, nullptr,
|
||||||
NULL, listen_port, NULL);
|
nullptr, listen_port, nullptr);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
FormatError(avahi_domain, "Failed to add service %s: %s",
|
FormatError(avahi_domain, "Failed to add service %s: %s",
|
||||||
SERVICE_TYPE, avahi_strerror(ret));
|
SERVICE_TYPE, avahi_strerror(ret));
|
||||||
@ -173,14 +173,14 @@ static void avahiClientCallback(AvahiClient * c, AvahiClientState state,
|
|||||||
"Client Disconnected, will reconnect shortly");
|
"Client Disconnected, will reconnect shortly");
|
||||||
if (avahiGroup) {
|
if (avahiGroup) {
|
||||||
avahi_entry_group_free(avahiGroup);
|
avahi_entry_group_free(avahiGroup);
|
||||||
avahiGroup = NULL;
|
avahiGroup = nullptr;
|
||||||
}
|
}
|
||||||
if (avahiClient)
|
if (avahiClient)
|
||||||
avahi_client_free(avahiClient);
|
avahi_client_free(avahiClient);
|
||||||
avahiClient =
|
avahiClient =
|
||||||
avahi_client_new(avahi_poll,
|
avahi_client_new(avahi_poll,
|
||||||
AVAHI_CLIENT_NO_FAIL,
|
AVAHI_CLIENT_NO_FAIL,
|
||||||
avahiClientCallback, NULL,
|
avahiClientCallback, nullptr,
|
||||||
&reason);
|
&reason);
|
||||||
if (!avahiClient) {
|
if (!avahiClient) {
|
||||||
FormatWarning(avahi_domain,
|
FormatWarning(avahi_domain,
|
||||||
@ -246,7 +246,7 @@ AvahiInit(EventLoop &loop, const char *serviceName)
|
|||||||
|
|
||||||
int error;
|
int error;
|
||||||
avahiClient = avahi_client_new(avahi_poll, AVAHI_CLIENT_NO_FAIL,
|
avahiClient = avahi_client_new(avahi_poll, AVAHI_CLIENT_NO_FAIL,
|
||||||
avahiClientCallback, NULL, &error);
|
avahiClientCallback, nullptr, &error);
|
||||||
|
|
||||||
if (!avahiClient) {
|
if (!avahiClient) {
|
||||||
FormatError(avahi_domain, "Failed to create client: %s",
|
FormatError(avahi_domain, "Failed to create client: %s",
|
||||||
@ -262,17 +262,17 @@ AvahiDeinit(void)
|
|||||||
|
|
||||||
if (avahiGroup) {
|
if (avahiGroup) {
|
||||||
avahi_entry_group_free(avahiGroup);
|
avahi_entry_group_free(avahiGroup);
|
||||||
avahiGroup = NULL;
|
avahiGroup = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avahiClient) {
|
if (avahiClient) {
|
||||||
avahi_client_free(avahiClient);
|
avahi_client_free(avahiClient);
|
||||||
avahiClient = NULL;
|
avahiClient = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete avahi_poll;
|
delete avahi_poll;
|
||||||
avahi_poll = nullptr;
|
avahi_poll = nullptr;
|
||||||
|
|
||||||
avahi_free(avahiName);
|
avahi_free(avahiName);
|
||||||
avahiName = NULL;
|
avahiName = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -82,11 +82,11 @@ BonjourInit(EventLoop &loop, const char *service_name)
|
|||||||
DNSServiceRef dnsReference;
|
DNSServiceRef dnsReference;
|
||||||
DNSServiceErrorType error = DNSServiceRegister(&dnsReference,
|
DNSServiceErrorType error = DNSServiceRegister(&dnsReference,
|
||||||
0, 0, service_name,
|
0, 0, service_name,
|
||||||
SERVICE_TYPE, NULL, NULL,
|
SERVICE_TYPE, nullptr, nullptr,
|
||||||
g_htons(listen_port), 0,
|
g_htons(listen_port), 0,
|
||||||
NULL,
|
nullptr,
|
||||||
dnsRegisterCallback,
|
dnsRegisterCallback,
|
||||||
NULL);
|
nullptr);
|
||||||
|
|
||||||
if (error != kDNSServiceErr_NoError) {
|
if (error != kDNSServiceErr_NoError) {
|
||||||
LogError(bonjour_domain,
|
LogError(bonjour_domain,
|
||||||
@ -94,7 +94,7 @@ BonjourInit(EventLoop &loop, const char *service_name)
|
|||||||
|
|
||||||
if (dnsReference) {
|
if (dnsReference) {
|
||||||
DNSServiceRefDeallocate(dnsReference);
|
DNSServiceRefDeallocate(dnsReference);
|
||||||
dnsReference = NULL;
|
dnsReference = nullptr;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ Bzip2ArchiveFile::OpenStream(const char *path,
|
|||||||
Bzip2InputStream *bis = new Bzip2InputStream(*this, path, mutex, cond);
|
Bzip2InputStream *bis = new Bzip2InputStream(*this, path, mutex, cond);
|
||||||
if (!bis->Open(error)) {
|
if (!bis->Open(error)) {
|
||||||
delete bis;
|
delete bis;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return &bis->base;
|
return &bis->base;
|
||||||
@ -273,7 +273,7 @@ bz2_is_eof(struct input_stream *is)
|
|||||||
|
|
||||||
static const char *const bz2_extensions[] = {
|
static const char *const bz2_extensions[] = {
|
||||||
"bz2",
|
"bz2",
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const InputPlugin bz2_inputplugin = {
|
const InputPlugin bz2_inputplugin = {
|
||||||
|
@ -118,7 +118,7 @@ iso9660_archive_open(const char *pathname, Error &error)
|
|||||||
if (iso == nullptr) {
|
if (iso == nullptr) {
|
||||||
error.Format(iso9660_domain,
|
error.Format(iso9660_domain,
|
||||||
"Failed to open ISO9660 file %s", pathname);
|
"Failed to open ISO9660 file %s", pathname);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Iso9660ArchiveFile(iso);
|
return new Iso9660ArchiveFile(iso);
|
||||||
@ -168,7 +168,7 @@ Iso9660ArchiveFile::OpenStream(const char *pathname,
|
|||||||
if (statbuf == nullptr) {
|
if (statbuf == nullptr) {
|
||||||
error.Format(iso9660_domain,
|
error.Format(iso9660_domain,
|
||||||
"not found in the ISO file: %s", pathname);
|
"not found in the ISO file: %s", pathname);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iso9660InputStream *iis =
|
Iso9660InputStream *iis =
|
||||||
@ -236,7 +236,7 @@ iso9660_input_eof(struct input_stream *is)
|
|||||||
|
|
||||||
static const char *const iso9660_archive_extensions[] = {
|
static const char *const iso9660_archive_extensions[] = {
|
||||||
"iso",
|
"iso",
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const InputPlugin iso9660_input_plugin = {
|
const InputPlugin iso9660_input_plugin = {
|
||||||
|
@ -75,11 +75,11 @@ static constexpr Domain zzip_domain("zzip");
|
|||||||
static ArchiveFile *
|
static ArchiveFile *
|
||||||
zzip_archive_open(const char *pathname, Error &error)
|
zzip_archive_open(const char *pathname, Error &error)
|
||||||
{
|
{
|
||||||
ZZIP_DIR *dir = zzip_dir_open(pathname, NULL);
|
ZZIP_DIR *dir = zzip_dir_open(pathname, nullptr);
|
||||||
if (dir == nullptr) {
|
if (dir == nullptr) {
|
||||||
error.Format(zzip_domain, "Failed to open ZIP file %s",
|
error.Format(zzip_domain, "Failed to open ZIP file %s",
|
||||||
pathname);
|
pathname);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ZzipArchiveFile(dir);
|
return new ZzipArchiveFile(dir);
|
||||||
@ -137,7 +137,7 @@ ZzipArchiveFile::OpenStream(const char *pathname,
|
|||||||
if (_file == nullptr) {
|
if (_file == nullptr) {
|
||||||
error.Format(zzip_domain, "not found in the ZIP file: %s",
|
error.Format(zzip_domain, "not found in the ZIP file: %s",
|
||||||
pathname);
|
pathname);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZzipInputStream *zis =
|
ZzipInputStream *zis =
|
||||||
@ -199,7 +199,7 @@ zzip_input_seek(struct input_stream *is, InputPlugin::offset_type offset,
|
|||||||
|
|
||||||
static const char *const zzip_archive_extensions[] = {
|
static const char *const zzip_archive_extensions[] = {
|
||||||
"zip",
|
"zip",
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const InputPlugin zzip_input_plugin = {
|
const InputPlugin zzip_input_plugin = {
|
||||||
|
@ -44,7 +44,7 @@ SimpleDatabase::Create(const config_param ¶m, Error &error)
|
|||||||
SimpleDatabase *db = new SimpleDatabase();
|
SimpleDatabase *db = new SimpleDatabase();
|
||||||
if (!db->Configure(param, error)) {
|
if (!db->Configure(param, error)) {
|
||||||
delete db;
|
delete db;
|
||||||
db = NULL;
|
db = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
@ -136,7 +136,7 @@ bool
|
|||||||
SimpleDatabase::Load(Error &error)
|
SimpleDatabase::Load(Error &error)
|
||||||
{
|
{
|
||||||
assert(!path.IsNull());
|
assert(!path.IsNull());
|
||||||
assert(root != NULL);
|
assert(root != nullptr);
|
||||||
|
|
||||||
TextFile file(path);
|
TextFile file(path);
|
||||||
if (file.HasFailed()) {
|
if (file.HasFailed()) {
|
||||||
@ -183,7 +183,7 @@ SimpleDatabase::Open(Error &error)
|
|||||||
void
|
void
|
||||||
SimpleDatabase::Close()
|
SimpleDatabase::Close()
|
||||||
{
|
{
|
||||||
assert(root != NULL);
|
assert(root != nullptr);
|
||||||
assert(borrowed_song_count == 0);
|
assert(borrowed_song_count == 0);
|
||||||
|
|
||||||
root->Free();
|
root->Free();
|
||||||
@ -192,12 +192,12 @@ SimpleDatabase::Close()
|
|||||||
Song *
|
Song *
|
||||||
SimpleDatabase::GetSong(const char *uri, Error &error) const
|
SimpleDatabase::GetSong(const char *uri, Error &error) const
|
||||||
{
|
{
|
||||||
assert(root != NULL);
|
assert(root != nullptr);
|
||||||
|
|
||||||
db_lock();
|
db_lock();
|
||||||
Song *song = root->LookupSong(uri);
|
Song *song = root->LookupSong(uri);
|
||||||
db_unlock();
|
db_unlock();
|
||||||
if (song == NULL)
|
if (song == nullptr)
|
||||||
error.Format(db_domain, DB_NOT_FOUND,
|
error.Format(db_domain, DB_NOT_FOUND,
|
||||||
"No such song: %s", uri);
|
"No such song: %s", uri);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -223,8 +223,8 @@ gcc_pure
|
|||||||
const Directory *
|
const Directory *
|
||||||
SimpleDatabase::LookupDirectory(const char *uri) const
|
SimpleDatabase::LookupDirectory(const char *uri) const
|
||||||
{
|
{
|
||||||
assert(root != NULL);
|
assert(root != nullptr);
|
||||||
assert(uri != NULL);
|
assert(uri != nullptr);
|
||||||
|
|
||||||
ScopeDatabaseLock protect;
|
ScopeDatabaseLock protect;
|
||||||
return root->LookupDirectory(uri);
|
return root->LookupDirectory(uri);
|
||||||
@ -240,7 +240,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
|
|||||||
ScopeDatabaseLock protect;
|
ScopeDatabaseLock protect;
|
||||||
|
|
||||||
const Directory *directory = root->LookupDirectory(selection.uri);
|
const Directory *directory = root->LookupDirectory(selection.uri);
|
||||||
if (directory == NULL) {
|
if (directory == nullptr) {
|
||||||
if (visit_song) {
|
if (visit_song) {
|
||||||
Song *song = root->LookupSong(selection.uri);
|
Song *song = root->LookupSong(selection.uri);
|
||||||
if (song != nullptr)
|
if (song != nullptr)
|
||||||
|
@ -76,12 +76,12 @@ static void
|
|||||||
mpd_ffmpeg_log_callback(gcc_unused void *ptr, int level,
|
mpd_ffmpeg_log_callback(gcc_unused void *ptr, int level,
|
||||||
const char *fmt, va_list vl)
|
const char *fmt, va_list vl)
|
||||||
{
|
{
|
||||||
const AVClass * cls = NULL;
|
const AVClass * cls = nullptr;
|
||||||
|
|
||||||
if (ptr != NULL)
|
if (ptr != nullptr)
|
||||||
cls = *(const AVClass *const*)ptr;
|
cls = *(const AVClass *const*)ptr;
|
||||||
|
|
||||||
if (cls != NULL) {
|
if (cls != nullptr) {
|
||||||
char domain[64];
|
char domain[64];
|
||||||
snprintf(domain, sizeof(domain), "%s/%s",
|
snprintf(domain, sizeof(domain), "%s/%s",
|
||||||
ffmpeg_domain.GetName(), cls->item_name(ptr));
|
ffmpeg_domain.GetName(), cls->item_name(ptr));
|
||||||
@ -155,12 +155,12 @@ mpd_ffmpeg_open_input(AVFormatContext **ic_ptr,
|
|||||||
AVInputFormat *fmt)
|
AVInputFormat *fmt)
|
||||||
{
|
{
|
||||||
AVFormatContext *context = avformat_alloc_context();
|
AVFormatContext *context = avformat_alloc_context();
|
||||||
if (context == NULL)
|
if (context == nullptr)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
context->pb = pb;
|
context->pb = pb;
|
||||||
*ic_ptr = context;
|
*ic_ptr = context;
|
||||||
return avformat_open_input(ic_ptr, filename, fmt, NULL);
|
return avformat_open_input(ic_ptr, filename, fmt, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -329,7 +329,7 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
|
|||||||
char buffer[64];
|
char buffer[64];
|
||||||
const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),
|
const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),
|
||||||
sample_fmt);
|
sample_fmt);
|
||||||
if (name != NULL)
|
if (name != nullptr)
|
||||||
FormatError(ffmpeg_domain,
|
FormatError(ffmpeg_domain,
|
||||||
"Unsupported libavcodec SampleFormat value: %s (%d)",
|
"Unsupported libavcodec SampleFormat value: %s (%d)",
|
||||||
name, sample_fmt);
|
name, sample_fmt);
|
||||||
@ -373,7 +373,7 @@ static void
|
|||||||
ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
||||||
{
|
{
|
||||||
AVInputFormat *input_format = ffmpeg_probe(decoder, input);
|
AVInputFormat *input_format = ffmpeg_probe(decoder, input);
|
||||||
if (input_format == NULL)
|
if (input_format == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)",
|
FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)",
|
||||||
@ -386,7 +386,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//ffmpeg works with ours "fileops" helper
|
//ffmpeg works with ours "fileops" helper
|
||||||
AVFormatContext *format_context = NULL;
|
AVFormatContext *format_context = nullptr;
|
||||||
if (mpd_ffmpeg_open_input(&format_context, stream.io,
|
if (mpd_ffmpeg_open_input(&format_context, stream.io,
|
||||||
input->uri.c_str(),
|
input->uri.c_str(),
|
||||||
input_format) != 0) {
|
input_format) != 0) {
|
||||||
@ -395,7 +395,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int find_result =
|
const int find_result =
|
||||||
avformat_find_stream_info(format_context, NULL);
|
avformat_find_stream_info(format_context, nullptr);
|
||||||
if (find_result < 0) {
|
if (find_result < 0) {
|
||||||
LogError(ffmpeg_domain, "Couldn't find stream info");
|
LogError(ffmpeg_domain, "Couldn't find stream info");
|
||||||
avformat_close_input(&format_context);
|
avformat_close_input(&format_context);
|
||||||
@ -445,7 +445,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
|||||||
values into AVCodecContext.channels - a change that will be
|
values into AVCodecContext.channels - a change that will be
|
||||||
reverted later by avcodec_decode_audio3() */
|
reverted later by avcodec_decode_audio3() */
|
||||||
|
|
||||||
const int open_result = avcodec_open2(codec_context, codec, NULL);
|
const int open_result = avcodec_open2(codec_context, codec, nullptr);
|
||||||
if (open_result < 0) {
|
if (open_result < 0) {
|
||||||
LogError(ffmpeg_domain, "Could not open codec");
|
LogError(ffmpeg_domain, "Could not open codec");
|
||||||
avformat_close_input(&format_context);
|
avformat_close_input(&format_context);
|
||||||
@ -466,7 +466,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *interleaved_buffer = NULL;
|
uint8_t *interleaved_buffer = nullptr;
|
||||||
int interleaved_buffer_size = 0;
|
int interleaved_buffer_size = 0;
|
||||||
|
|
||||||
DecoderCommand cmd;
|
DecoderCommand cmd;
|
||||||
@ -518,21 +518,21 @@ static bool
|
|||||||
ffmpeg_scan_stream(struct input_stream *is,
|
ffmpeg_scan_stream(struct input_stream *is,
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
AVInputFormat *input_format = ffmpeg_probe(NULL, is);
|
AVInputFormat *input_format = ffmpeg_probe(nullptr, is);
|
||||||
if (input_format == NULL)
|
if (input_format == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AvioStream stream(nullptr, is);
|
AvioStream stream(nullptr, is);
|
||||||
if (!stream.Open())
|
if (!stream.Open())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AVFormatContext *f = NULL;
|
AVFormatContext *f = nullptr;
|
||||||
if (mpd_ffmpeg_open_input(&f, stream.io, is->uri.c_str(),
|
if (mpd_ffmpeg_open_input(&f, stream.io, is->uri.c_str(),
|
||||||
input_format) != 0)
|
input_format) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const int find_result =
|
const int find_result =
|
||||||
avformat_find_stream_info(f, NULL);
|
avformat_find_stream_info(f, nullptr);
|
||||||
if (find_result < 0) {
|
if (find_result < 0) {
|
||||||
avformat_close_input(&f);
|
avformat_close_input(&f);
|
||||||
return false;
|
return false;
|
||||||
@ -576,7 +576,7 @@ static const char *const ffmpeg_suffixes[] = {
|
|||||||
"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
|
"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
|
||||||
"vp6", "vmd", "wav", "webm", "wma", "wmv", "wsaud", "wsvga", "wv",
|
"vp6", "vmd", "wav", "webm", "wma", "wmv", "wsaud", "wsvga", "wv",
|
||||||
"wve",
|
"wve",
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const ffmpeg_mime_types[] = {
|
static const char *const ffmpeg_mime_types[] = {
|
||||||
@ -664,7 +664,7 @@ static const char *const ffmpeg_mime_types[] = {
|
|||||||
plugin */
|
plugin */
|
||||||
"audio/x-mpd-ffmpeg",
|
"audio/x-mpd-ffmpeg",
|
||||||
|
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct decoder_plugin ffmpeg_decoder_plugin = {
|
const struct decoder_plugin ffmpeg_decoder_plugin = {
|
||||||
|
@ -206,7 +206,7 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
|
|||||||
format_samples(bytes_per_sample, chunk,
|
format_samples(bytes_per_sample, chunk,
|
||||||
samples_got * audio_format.channels);
|
samples_got * audio_format.channels);
|
||||||
|
|
||||||
cmd = decoder_data(decoder, NULL, chunk,
|
cmd = decoder_data(decoder, nullptr, chunk,
|
||||||
samples_got * output_sample_size,
|
samples_got * output_sample_size,
|
||||||
bitrate);
|
bitrate);
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ wavpack_scan_file(const char *fname,
|
|||||||
char error[ERRORLEN];
|
char error[ERRORLEN];
|
||||||
|
|
||||||
wpc = WavpackOpenFileInput(fname, error, OPEN_TAGS, 0);
|
wpc = WavpackOpenFileInput(fname, error, OPEN_TAGS, 0);
|
||||||
if (wpc == NULL) {
|
if (wpc == nullptr) {
|
||||||
FormatError(wavpack_domain,
|
FormatError(wavpack_domain,
|
||||||
"failed to open WavPack file \"%s\": %s",
|
"failed to open WavPack file \"%s\": %s",
|
||||||
fname, error);
|
fname, error);
|
||||||
@ -311,16 +311,16 @@ wavpack_scan_file(const char *fname,
|
|||||||
|
|
||||||
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) {
|
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) {
|
||||||
const char *name = tag_item_names[i];
|
const char *name = tag_item_names[i];
|
||||||
if (name != NULL)
|
if (name != nullptr)
|
||||||
wavpack_scan_tag_item(wpc, name, (enum tag_type)i,
|
wavpack_scan_tag_item(wpc, name, (enum tag_type)i,
|
||||||
handler, handler_ctx);
|
handler, handler_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const struct tag_table *i = ape_tags; i->name != NULL; ++i)
|
for (const struct tag_table *i = ape_tags; i->name != nullptr; ++i)
|
||||||
wavpack_scan_tag_item(wpc, i->name, i->type,
|
wavpack_scan_tag_item(wpc, i->name, i->type,
|
||||||
handler, handler_ctx);
|
handler, handler_ctx);
|
||||||
|
|
||||||
if (handler->pair != NULL) {
|
if (handler->pair != nullptr) {
|
||||||
char name[64];
|
char name[64];
|
||||||
|
|
||||||
for (int i = 0, n = WavpackGetNumTagItems(wpc);
|
for (int i = 0, n = WavpackGetNumTagItems(wpc);
|
||||||
@ -463,7 +463,7 @@ wavpack_open_wvc(struct decoder *decoder, const char *uri,
|
|||||||
struct wavpack_input *wpi)
|
struct wavpack_input *wpi)
|
||||||
{
|
{
|
||||||
struct input_stream *is_wvc;
|
struct input_stream *is_wvc;
|
||||||
char *wvc_url = NULL;
|
char *wvc_url = nullptr;
|
||||||
char first_byte;
|
char first_byte;
|
||||||
size_t nbytes;
|
size_t nbytes;
|
||||||
|
|
||||||
@ -471,16 +471,16 @@ wavpack_open_wvc(struct decoder *decoder, const char *uri,
|
|||||||
* As we use dc->utf8url, this function will be bad for
|
* As we use dc->utf8url, this function will be bad for
|
||||||
* single files. utf8url is not absolute file path :/
|
* single files. utf8url is not absolute file path :/
|
||||||
*/
|
*/
|
||||||
if (uri == NULL)
|
if (uri == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
wvc_url = g_strconcat(uri, "c", NULL);
|
wvc_url = g_strconcat(uri, "c", nullptr);
|
||||||
|
|
||||||
is_wvc = input_stream::Open(wvc_url, mutex, cond, IgnoreError());
|
is_wvc = input_stream::Open(wvc_url, mutex, cond, IgnoreError());
|
||||||
g_free(wvc_url);
|
g_free(wvc_url);
|
||||||
|
|
||||||
if (is_wvc == NULL)
|
if (is_wvc == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* And we try to buffer in order to get know
|
* And we try to buffer in order to get know
|
||||||
@ -491,7 +491,7 @@ wavpack_open_wvc(struct decoder *decoder, const char *uri,
|
|||||||
);
|
);
|
||||||
if (nbytes == 0) {
|
if (nbytes == 0) {
|
||||||
is_wvc->Close();
|
is_wvc->Close();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* push it back */
|
/* push it back */
|
||||||
@ -516,7 +516,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
|
|||||||
is_wvc = wavpack_open_wvc(decoder, is->uri.c_str(),
|
is_wvc = wavpack_open_wvc(decoder, is->uri.c_str(),
|
||||||
is->mutex, is->cond,
|
is->mutex, is->cond,
|
||||||
&isp_wvc);
|
&isp_wvc);
|
||||||
if (is_wvc != NULL) {
|
if (is_wvc != nullptr) {
|
||||||
open_flags |= OPEN_WVC;
|
open_flags |= OPEN_WVC;
|
||||||
can_seek &= is_wvc->seekable;
|
can_seek &= is_wvc->seekable;
|
||||||
}
|
}
|
||||||
@ -528,11 +528,11 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
|
|||||||
wavpack_input_init(&isp, decoder, is);
|
wavpack_input_init(&isp, decoder, is);
|
||||||
wpc = WavpackOpenFileInputEx(
|
wpc = WavpackOpenFileInputEx(
|
||||||
&mpd_is_reader, &isp,
|
&mpd_is_reader, &isp,
|
||||||
open_flags & OPEN_WVC ? &isp_wvc : NULL,
|
open_flags & OPEN_WVC ? &isp_wvc : nullptr,
|
||||||
error, open_flags, 23
|
error, open_flags, 23
|
||||||
);
|
);
|
||||||
|
|
||||||
if (wpc == NULL) {
|
if (wpc == nullptr) {
|
||||||
FormatError(wavpack_domain,
|
FormatError(wavpack_domain,
|
||||||
"failed to open WavPack stream: %s", error);
|
"failed to open WavPack stream: %s", error);
|
||||||
return;
|
return;
|
||||||
@ -559,7 +559,7 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
|
|||||||
fname, error,
|
fname, error,
|
||||||
OPEN_TAGS | OPEN_WVC | OPEN_NORMALIZE, 23
|
OPEN_TAGS | OPEN_WVC | OPEN_NORMALIZE, 23
|
||||||
);
|
);
|
||||||
if (wpc == NULL) {
|
if (wpc == nullptr) {
|
||||||
FormatWarning(wavpack_domain,
|
FormatWarning(wavpack_domain,
|
||||||
"failed to open WavPack file \"%s\": %s",
|
"failed to open WavPack file \"%s\": %s",
|
||||||
fname, error);
|
fname, error);
|
||||||
@ -577,12 +577,12 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
|
|||||||
|
|
||||||
static char const *const wavpack_suffixes[] = {
|
static char const *const wavpack_suffixes[] = {
|
||||||
"wv",
|
"wv",
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
static char const *const wavpack_mime_types[] = {
|
static char const *const wavpack_mime_types[] = {
|
||||||
"audio/x-wavpack",
|
"audio/x-wavpack",
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct decoder_plugin wavpack_decoder_plugin = {
|
const struct decoder_plugin wavpack_decoder_plugin = {
|
||||||
|
@ -49,7 +49,7 @@ static bool filter_setting;
|
|||||||
static GKeyFile *
|
static GKeyFile *
|
||||||
sidplay_load_songlength_db(const char *path)
|
sidplay_load_songlength_db(const char *path)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = nullptr;
|
||||||
gchar *data;
|
gchar *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ sidplay_load_songlength_db(const char *path)
|
|||||||
"unable to read songlengths file %s: %s",
|
"unable to read songlengths file %s: %s",
|
||||||
path, error->message);
|
path, error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* replace any ; comment characters with # */
|
/* replace any ; comment characters with # */
|
||||||
@ -76,7 +76,7 @@ sidplay_load_songlength_db(const char *path)
|
|||||||
path, error->message);
|
path, error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
g_key_file_free(db);
|
g_key_file_free(db);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_key_file_set_list_separator(db, ' ');
|
g_key_file_set_list_separator(db, ' ');
|
||||||
@ -88,7 +88,7 @@ sidplay_init(const config_param ¶m)
|
|||||||
{
|
{
|
||||||
/* read the songlengths database file */
|
/* read the songlengths database file */
|
||||||
songlength_file = param.GetBlockValue("songlength_database");
|
songlength_file = param.GetBlockValue("songlength_database");
|
||||||
if (songlength_file != NULL)
|
if (songlength_file != nullptr)
|
||||||
songlength_database = sidplay_load_songlength_db(songlength_file);
|
songlength_database = sidplay_load_songlength_db(songlength_file);
|
||||||
|
|
||||||
default_songlength = param.GetBlockValue("default_songlength", 0u);
|
default_songlength = param.GetBlockValue("default_songlength", 0u);
|
||||||
@ -123,7 +123,7 @@ get_container_name(const char *path_fs)
|
|||||||
char *path_container=g_strdup(path_fs);
|
char *path_container=g_strdup(path_fs);
|
||||||
|
|
||||||
if(!g_pattern_match(path_with_subtune,
|
if(!g_pattern_match(path_with_subtune,
|
||||||
strlen(path_container), path_container, NULL))
|
strlen(path_container), path_container, nullptr))
|
||||||
return path_container;
|
return path_container;
|
||||||
|
|
||||||
char *ptr=g_strrstr(path_container, "/" SUBTUNE_PREFIX);
|
char *ptr=g_strrstr(path_container, "/" SUBTUNE_PREFIX);
|
||||||
@ -140,12 +140,12 @@ static unsigned
|
|||||||
get_song_num(const char *path_fs)
|
get_song_num(const char *path_fs)
|
||||||
{
|
{
|
||||||
if(g_pattern_match(path_with_subtune,
|
if(g_pattern_match(path_with_subtune,
|
||||||
strlen(path_fs), path_fs, NULL)) {
|
strlen(path_fs), path_fs, nullptr)) {
|
||||||
char *sub=g_strrstr(path_fs, "/" SUBTUNE_PREFIX);
|
char *sub=g_strrstr(path_fs, "/" SUBTUNE_PREFIX);
|
||||||
if(!sub) return 1;
|
if(!sub) return 1;
|
||||||
|
|
||||||
sub+=strlen("/" SUBTUNE_PREFIX);
|
sub+=strlen("/" SUBTUNE_PREFIX);
|
||||||
int song_num=strtol(sub, NULL, 10);
|
int song_num=strtol(sub, nullptr, 10);
|
||||||
|
|
||||||
if (errno == EINVAL)
|
if (errno == EINVAL)
|
||||||
return 1;
|
return 1;
|
||||||
@ -159,7 +159,7 @@ get_song_num(const char *path_fs)
|
|||||||
static int
|
static int
|
||||||
get_song_length(const char *path_fs)
|
get_song_length(const char *path_fs)
|
||||||
{
|
{
|
||||||
if (songlength_database == NULL)
|
if (songlength_database == nullptr)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
gchar *sid_file=get_container_name(path_fs);
|
gchar *sid_file=get_container_name(path_fs);
|
||||||
@ -177,19 +177,19 @@ get_song_length(const char *path_fs)
|
|||||||
|
|
||||||
gsize num_items;
|
gsize num_items;
|
||||||
gchar **values=g_key_file_get_string_list(songlength_database,
|
gchar **values=g_key_file_get_string_list(songlength_database,
|
||||||
"Database", md5sum, &num_items, NULL);
|
"Database", md5sum, &num_items, nullptr);
|
||||||
if(!values || song_num>num_items) {
|
if(!values || song_num>num_items) {
|
||||||
g_strfreev(values);
|
g_strfreev(values);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int minutes=strtol(values[song_num-1], NULL, 10);
|
int minutes=strtol(values[song_num-1], nullptr, 10);
|
||||||
if(errno==EINVAL) minutes=0;
|
if(errno==EINVAL) minutes=0;
|
||||||
|
|
||||||
int seconds;
|
int seconds;
|
||||||
char *ptr=strchr(values[song_num-1], ':');
|
char *ptr=strchr(values[song_num-1], ':');
|
||||||
if(ptr) {
|
if(ptr) {
|
||||||
seconds=strtol(ptr+1, NULL, 10);
|
seconds=strtol(ptr+1, nullptr, 10);
|
||||||
if(errno==EINVAL) seconds=0;
|
if(errno==EINVAL) seconds=0;
|
||||||
} else
|
} else
|
||||||
seconds=0;
|
seconds=0;
|
||||||
@ -207,7 +207,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
|||||||
/* load the tune */
|
/* load the tune */
|
||||||
|
|
||||||
char *path_container=get_container_name(path_fs);
|
char *path_container=get_container_name(path_fs);
|
||||||
SidTune tune(path_container, NULL, true);
|
SidTune tune(path_container, nullptr, true);
|
||||||
g_free(path_container);
|
g_free(path_container);
|
||||||
if (!tune) {
|
if (!tune) {
|
||||||
LogWarning(sidplay_domain, "failed to load file");
|
LogWarning(sidplay_domain, "failed to load file");
|
||||||
@ -307,7 +307,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
|||||||
|
|
||||||
decoder_timestamp(decoder, (double)player.time() / timebase);
|
decoder_timestamp(decoder, (double)player.time() / timebase);
|
||||||
|
|
||||||
cmd = decoder_data(decoder, NULL, buffer, nbytes, 0);
|
cmd = decoder_data(decoder, nullptr, buffer, nbytes, 0);
|
||||||
|
|
||||||
if (cmd == DecoderCommand::SEEK) {
|
if (cmd == DecoderCommand::SEEK) {
|
||||||
unsigned data_time = player.time();
|
unsigned data_time = player.time();
|
||||||
@ -344,7 +344,7 @@ sidplay_scan_file(const char *path_fs,
|
|||||||
int song_num=get_song_num(path_fs);
|
int song_num=get_song_num(path_fs);
|
||||||
char *path_container=get_container_name(path_fs);
|
char *path_container=get_container_name(path_fs);
|
||||||
|
|
||||||
SidTune tune(path_container, NULL, true);
|
SidTune tune(path_container, nullptr, true);
|
||||||
g_free(path_container);
|
g_free(path_container);
|
||||||
if (!tune)
|
if (!tune)
|
||||||
return false;
|
return false;
|
||||||
@ -353,7 +353,7 @@ sidplay_scan_file(const char *path_fs,
|
|||||||
|
|
||||||
/* title */
|
/* title */
|
||||||
const char *title;
|
const char *title;
|
||||||
if (info.numberOfInfoStrings > 0 && info.infoString[0] != NULL)
|
if (info.numberOfInfoStrings > 0 && info.infoString[0] != nullptr)
|
||||||
title=info.infoString[0];
|
title=info.infoString[0];
|
||||||
else
|
else
|
||||||
title="";
|
title="";
|
||||||
@ -369,7 +369,7 @@ sidplay_scan_file(const char *path_fs,
|
|||||||
tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, title);
|
tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, title);
|
||||||
|
|
||||||
/* artist */
|
/* artist */
|
||||||
if (info.numberOfInfoStrings > 1 && info.infoString[1] != NULL)
|
if (info.numberOfInfoStrings > 1 && info.infoString[1] != nullptr)
|
||||||
tag_handler_invoke_tag(handler, handler_ctx, TAG_ARTIST,
|
tag_handler_invoke_tag(handler, handler_ctx, TAG_ARTIST,
|
||||||
info.infoString[1]);
|
info.infoString[1]);
|
||||||
|
|
||||||
@ -389,16 +389,16 @@ sidplay_scan_file(const char *path_fs,
|
|||||||
static char *
|
static char *
|
||||||
sidplay_container_scan(const char *path_fs, const unsigned int tnum)
|
sidplay_container_scan(const char *path_fs, const unsigned int tnum)
|
||||||
{
|
{
|
||||||
SidTune tune(path_fs, NULL, true);
|
SidTune tune(path_fs, nullptr, true);
|
||||||
if (!tune)
|
if (!tune)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
const SidTuneInfo &info=tune.getInfo();
|
const SidTuneInfo &info=tune.getInfo();
|
||||||
|
|
||||||
/* Don't treat sids containing a single tune
|
/* Don't treat sids containing a single tune
|
||||||
as containers */
|
as containers */
|
||||||
if(!all_files_are_containers && info.songs<2)
|
if(!all_files_are_containers && info.songs<2)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
/* Construct container/tune path names, eg.
|
/* Construct container/tune path names, eg.
|
||||||
Delta.sid/tune_001.sid */
|
Delta.sid/tune_001.sid */
|
||||||
@ -407,7 +407,7 @@ sidplay_container_scan(const char *path_fs, const unsigned int tnum)
|
|||||||
SUBTUNE_PREFIX "%03u.sid", tnum);
|
SUBTUNE_PREFIX "%03u.sid", tnum);
|
||||||
return subtune;
|
return subtune;
|
||||||
} else
|
} else
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const sidplay_suffixes[] = {
|
static const char *const sidplay_suffixes[] = {
|
||||||
@ -416,7 +416,7 @@ static const char *const sidplay_suffixes[] = {
|
|||||||
"str",
|
"str",
|
||||||
"prg",
|
"prg",
|
||||||
"P00",
|
"P00",
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct decoder_plugin sidplay_decoder_plugin;
|
extern const struct decoder_plugin sidplay_decoder_plugin;
|
||||||
@ -424,11 +424,11 @@ const struct decoder_plugin sidplay_decoder_plugin = {
|
|||||||
"sidplay",
|
"sidplay",
|
||||||
sidplay_init,
|
sidplay_init,
|
||||||
sidplay_finish,
|
sidplay_finish,
|
||||||
NULL, /* stream_decode() */
|
nullptr, /* stream_decode() */
|
||||||
sidplay_file_decode,
|
sidplay_file_decode,
|
||||||
sidplay_scan_file,
|
sidplay_scan_file,
|
||||||
NULL, /* stream_tag() */
|
nullptr, /* stream_tag() */
|
||||||
sidplay_container_scan,
|
sidplay_container_scan,
|
||||||
sidplay_suffixes,
|
sidplay_suffixes,
|
||||||
NULL, /* mime_types */
|
nullptr, /* mime_types */
|
||||||
};
|
};
|
||||||
|
@ -232,7 +232,7 @@ input_curl_find_request(CURL *easy)
|
|||||||
if (c->easy == easy)
|
if (c->easy == easy)
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -323,9 +323,9 @@ static bool
|
|||||||
input_curl_easy_add(struct input_curl *c, Error &error)
|
input_curl_easy_add(struct input_curl *c, Error &error)
|
||||||
{
|
{
|
||||||
assert(io_thread_inside());
|
assert(io_thread_inside());
|
||||||
assert(c != NULL);
|
assert(c != nullptr);
|
||||||
assert(c->easy != NULL);
|
assert(c->easy != nullptr);
|
||||||
assert(input_curl_find_request(c->easy) == NULL);
|
assert(input_curl_find_request(c->easy) == nullptr);
|
||||||
|
|
||||||
curl.requests.push_front(c);
|
curl.requests.push_front(c);
|
||||||
|
|
||||||
@ -349,8 +349,8 @@ input_curl_easy_add(struct input_curl *c, Error &error)
|
|||||||
static bool
|
static bool
|
||||||
input_curl_easy_add_indirect(struct input_curl *c, Error &error)
|
input_curl_easy_add_indirect(struct input_curl *c, Error &error)
|
||||||
{
|
{
|
||||||
assert(c != NULL);
|
assert(c != nullptr);
|
||||||
assert(c->easy != NULL);
|
assert(c->easy != nullptr);
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
BlockingCall(io_thread_get(), [c, &error, &result](){
|
BlockingCall(io_thread_get(), [c, &error, &result](){
|
||||||
@ -369,19 +369,19 @@ static void
|
|||||||
input_curl_easy_free(struct input_curl *c)
|
input_curl_easy_free(struct input_curl *c)
|
||||||
{
|
{
|
||||||
assert(io_thread_inside());
|
assert(io_thread_inside());
|
||||||
assert(c != NULL);
|
assert(c != nullptr);
|
||||||
|
|
||||||
if (c->easy == NULL)
|
if (c->easy == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
curl.requests.remove(c);
|
curl.requests.remove(c);
|
||||||
|
|
||||||
curl_multi_remove_handle(curl.multi, c->easy);
|
curl_multi_remove_handle(curl.multi, c->easy);
|
||||||
curl_easy_cleanup(c->easy);
|
curl_easy_cleanup(c->easy);
|
||||||
c->easy = NULL;
|
c->easy = nullptr;
|
||||||
|
|
||||||
curl_slist_free_all(c->request_headers);
|
curl_slist_free_all(c->request_headers);
|
||||||
c->request_headers = NULL;
|
c->request_headers = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -398,7 +398,7 @@ input_curl_easy_free_indirect(struct input_curl *c)
|
|||||||
curl.sockets->InvalidateSockets();
|
curl.sockets->InvalidateSockets();
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(c->easy == NULL);
|
assert(c->easy == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -437,8 +437,8 @@ static void
|
|||||||
input_curl_request_done(struct input_curl *c, CURLcode result, long status)
|
input_curl_request_done(struct input_curl *c, CURLcode result, long status)
|
||||||
{
|
{
|
||||||
assert(io_thread_inside());
|
assert(io_thread_inside());
|
||||||
assert(c != NULL);
|
assert(c != nullptr);
|
||||||
assert(c->easy == NULL);
|
assert(c->easy == nullptr);
|
||||||
assert(!c->postponed_error.IsDefined());
|
assert(!c->postponed_error.IsDefined());
|
||||||
|
|
||||||
const ScopeLock protect(c->base.mutex);
|
const ScopeLock protect(c->base.mutex);
|
||||||
@ -461,7 +461,7 @@ static void
|
|||||||
input_curl_handle_done(CURL *easy_handle, CURLcode result)
|
input_curl_handle_done(CURL *easy_handle, CURLcode result)
|
||||||
{
|
{
|
||||||
struct input_curl *c = input_curl_find_request(easy_handle);
|
struct input_curl *c = input_curl_find_request(easy_handle);
|
||||||
assert(c != NULL);
|
assert(c != nullptr);
|
||||||
|
|
||||||
long status = 0;
|
long status = 0;
|
||||||
curl_easy_getinfo(easy_handle, CURLINFO_RESPONSE_CODE, &status);
|
curl_easy_getinfo(easy_handle, CURLINFO_RESPONSE_CODE, &status);
|
||||||
@ -484,7 +484,7 @@ input_curl_info_read(void)
|
|||||||
int msgs_in_queue;
|
int msgs_in_queue;
|
||||||
|
|
||||||
while ((msg = curl_multi_info_read(curl.multi,
|
while ((msg = curl_multi_info_read(curl.multi,
|
||||||
&msgs_in_queue)) != NULL) {
|
&msgs_in_queue)) != nullptr) {
|
||||||
if (msg->msg == CURLMSG_DONE)
|
if (msg->msg == CURLMSG_DONE)
|
||||||
input_curl_handle_done(msg->easy_handle, msg->data.result);
|
input_curl_handle_done(msg->easy_handle, msg->data.result);
|
||||||
}
|
}
|
||||||
@ -573,17 +573,17 @@ input_curl_init(const config_param ¶m, Error &error)
|
|||||||
proxy_user = param.GetBlockValue("proxy_user");
|
proxy_user = param.GetBlockValue("proxy_user");
|
||||||
proxy_password = param.GetBlockValue("proxy_password");
|
proxy_password = param.GetBlockValue("proxy_password");
|
||||||
|
|
||||||
if (proxy == NULL) {
|
if (proxy == nullptr) {
|
||||||
/* deprecated proxy configuration */
|
/* deprecated proxy configuration */
|
||||||
proxy = config_get_string(CONF_HTTP_PROXY_HOST, NULL);
|
proxy = config_get_string(CONF_HTTP_PROXY_HOST, nullptr);
|
||||||
proxy_port = config_get_positive(CONF_HTTP_PROXY_PORT, 0);
|
proxy_port = config_get_positive(CONF_HTTP_PROXY_PORT, 0);
|
||||||
proxy_user = config_get_string(CONF_HTTP_PROXY_USER, NULL);
|
proxy_user = config_get_string(CONF_HTTP_PROXY_USER, nullptr);
|
||||||
proxy_password = config_get_string(CONF_HTTP_PROXY_PASSWORD,
|
proxy_password = config_get_string(CONF_HTTP_PROXY_PASSWORD,
|
||||||
"");
|
"");
|
||||||
}
|
}
|
||||||
|
|
||||||
curl.multi = curl_multi_init();
|
curl.multi = curl_multi_init();
|
||||||
if (curl.multi == NULL) {
|
if (curl.multi == nullptr) {
|
||||||
error.Set(curl_domain, 0, "curl_multi_init() failed");
|
error.Set(curl_domain, 0, "curl_multi_init() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -654,14 +654,14 @@ input_curl_tag(struct input_stream *is)
|
|||||||
struct input_curl *c = (struct input_curl *)is;
|
struct input_curl *c = (struct input_curl *)is;
|
||||||
Tag *tag = c->tag;
|
Tag *tag = c->tag;
|
||||||
|
|
||||||
c->tag = NULL;
|
c->tag = nullptr;
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
fill_buffer(struct input_curl *c, Error &error)
|
fill_buffer(struct input_curl *c, Error &error)
|
||||||
{
|
{
|
||||||
while (c->easy != NULL && c->buffers.empty())
|
while (c->easy != nullptr && c->buffers.empty())
|
||||||
c->base.cond.wait(c->base.mutex);
|
c->base.cond.wait(c->base.mutex);
|
||||||
|
|
||||||
if (c->postponed_error.IsDefined()) {
|
if (c->postponed_error.IsDefined()) {
|
||||||
@ -728,7 +728,7 @@ copy_icy_tag(struct input_curl *c)
|
|||||||
{
|
{
|
||||||
Tag *tag = c->icy.ReadTag();
|
Tag *tag = c->icy.ReadTag();
|
||||||
|
|
||||||
if (tag == NULL)
|
if (tag == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
delete c->tag;
|
delete c->tag;
|
||||||
@ -744,7 +744,7 @@ input_curl_available(struct input_stream *is)
|
|||||||
{
|
{
|
||||||
struct input_curl *c = (struct input_curl *)is;
|
struct input_curl *c = (struct input_curl *)is;
|
||||||
|
|
||||||
return c->postponed_error.IsDefined() || c->easy == NULL ||
|
return c->postponed_error.IsDefined() || c->easy == nullptr ||
|
||||||
!c->buffers.empty();
|
!c->buffers.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -806,7 +806,7 @@ input_curl_eof(gcc_unused struct input_stream *is)
|
|||||||
{
|
{
|
||||||
struct input_curl *c = (struct input_curl *)is;
|
struct input_curl *c = (struct input_curl *)is;
|
||||||
|
|
||||||
return c->easy == NULL && c->buffers.empty();
|
return c->easy == nullptr && c->buffers.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** called by curl when new data is available */
|
/** called by curl when new data is available */
|
||||||
@ -822,7 +822,7 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||||||
const char *end = header + size;
|
const char *end = header + size;
|
||||||
|
|
||||||
const char *value = (const char *)memchr(header, ':', size);
|
const char *value = (const char *)memchr(header, ':', size);
|
||||||
if (value == NULL || (size_t)(value - header) >= sizeof(name))
|
if (value == nullptr || (size_t)(value - header) >= sizeof(name))
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
memcpy(name, header, value - header);
|
memcpy(name, header, value - header);
|
||||||
@ -853,7 +853,7 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||||||
memcpy(buffer, value, end - value);
|
memcpy(buffer, value, end - value);
|
||||||
buffer[end - value] = 0;
|
buffer[end - value] = 0;
|
||||||
|
|
||||||
c->base.size = c->base.offset + g_ascii_strtoull(buffer, NULL, 10);
|
c->base.size = c->base.offset + g_ascii_strtoull(buffer, nullptr, 10);
|
||||||
} else if (g_ascii_strcasecmp(name, "content-type") == 0) {
|
} else if (g_ascii_strcasecmp(name, "content-type") == 0) {
|
||||||
c->base.mime.assign(value, end);
|
c->base.mime.assign(value, end);
|
||||||
} else if (g_ascii_strcasecmp(name, "icy-name") == 0 ||
|
} else if (g_ascii_strcasecmp(name, "icy-name") == 0 ||
|
||||||
@ -876,7 +876,7 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||||||
memcpy(buffer, value, end - value);
|
memcpy(buffer, value, end - value);
|
||||||
buffer[end - value] = 0;
|
buffer[end - value] = 0;
|
||||||
|
|
||||||
icy_metaint = g_ascii_strtoull(buffer, NULL, 10);
|
icy_metaint = g_ascii_strtoull(buffer, nullptr, 10);
|
||||||
FormatDebug(curl_domain, "icy-metaint=%zu", icy_metaint);
|
FormatDebug(curl_domain, "icy-metaint=%zu", icy_metaint);
|
||||||
|
|
||||||
if (icy_metaint > 0) {
|
if (icy_metaint > 0) {
|
||||||
@ -921,7 +921,7 @@ input_curl_easy_init(struct input_curl *c, Error &error)
|
|||||||
CURLcode code;
|
CURLcode code;
|
||||||
|
|
||||||
c->easy = curl_easy_init();
|
c->easy = curl_easy_init();
|
||||||
if (c->easy == NULL) {
|
if (c->easy == nullptr) {
|
||||||
error.Set(curl_domain, "curl_easy_init() failed");
|
error.Set(curl_domain, "curl_easy_init() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -944,13 +944,13 @@ input_curl_easy_init(struct input_curl *c, Error &error)
|
|||||||
curl_easy_setopt(c->easy, CURLOPT_NOSIGNAL, 1l);
|
curl_easy_setopt(c->easy, CURLOPT_NOSIGNAL, 1l);
|
||||||
curl_easy_setopt(c->easy, CURLOPT_CONNECTTIMEOUT, 10l);
|
curl_easy_setopt(c->easy, CURLOPT_CONNECTTIMEOUT, 10l);
|
||||||
|
|
||||||
if (proxy != NULL)
|
if (proxy != nullptr)
|
||||||
curl_easy_setopt(c->easy, CURLOPT_PROXY, proxy);
|
curl_easy_setopt(c->easy, CURLOPT_PROXY, proxy);
|
||||||
|
|
||||||
if (proxy_port > 0)
|
if (proxy_port > 0)
|
||||||
curl_easy_setopt(c->easy, CURLOPT_PROXYPORT, (long)proxy_port);
|
curl_easy_setopt(c->easy, CURLOPT_PROXYPORT, (long)proxy_port);
|
||||||
|
|
||||||
if (proxy_user != NULL && proxy_password != NULL) {
|
if (proxy_user != nullptr && proxy_password != nullptr) {
|
||||||
char proxy_auth_str[1024];
|
char proxy_auth_str[1024];
|
||||||
snprintf(proxy_auth_str, sizeof(proxy_auth_str),
|
snprintf(proxy_auth_str, sizeof(proxy_auth_str),
|
||||||
"%s:%s",
|
"%s:%s",
|
||||||
@ -966,7 +966,7 @@ input_curl_easy_init(struct input_curl *c, Error &error)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->request_headers = NULL;
|
c->request_headers = nullptr;
|
||||||
c->request_headers = curl_slist_append(c->request_headers,
|
c->request_headers = curl_slist_append(c->request_headers,
|
||||||
"Icy-Metadata: 1");
|
"Icy-Metadata: 1");
|
||||||
curl_easy_setopt(c->easy, CURLOPT_HTTPHEADER, c->request_headers);
|
curl_easy_setopt(c->easy, CURLOPT_HTTPHEADER, c->request_headers);
|
||||||
@ -1085,18 +1085,18 @@ input_curl_open(const char *url, Mutex &mutex, Cond &cond,
|
|||||||
{
|
{
|
||||||
if (memcmp(url, "http://", 7) != 0 &&
|
if (memcmp(url, "http://", 7) != 0 &&
|
||||||
memcmp(url, "https://", 8) != 0)
|
memcmp(url, "https://", 8) != 0)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
struct input_curl *c = new input_curl(url, mutex, cond);
|
struct input_curl *c = new input_curl(url, mutex, cond);
|
||||||
|
|
||||||
if (!input_curl_easy_init(c, error)) {
|
if (!input_curl_easy_init(c, error)) {
|
||||||
delete c;
|
delete c;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!input_curl_easy_add_indirect(c, error)) {
|
if (!input_curl_easy_add_indirect(c, error)) {
|
||||||
delete c;
|
delete c;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return &c->base;
|
return &c->base;
|
||||||
|
Loading…
Reference in New Issue
Block a user