Playlist*: use nullptr instead of NULL
This commit is contained in:
parent
c2d3ed2acc
commit
0214baad5a
@ -77,7 +77,7 @@ playlist_queue_song_order(struct playlist *playlist, struct player_control *pc,
|
||||
static void
|
||||
playlist_song_started(struct playlist *playlist, struct player_control *pc)
|
||||
{
|
||||
assert(pc->next_song == NULL);
|
||||
assert(pc->next_song == nullptr);
|
||||
assert(playlist->queued >= -1);
|
||||
|
||||
/* queued song has started: copy queued to current,
|
||||
@ -108,7 +108,7 @@ playlist::UpdateQueuedSong(player_control &pc, const Song *prev)
|
||||
return;
|
||||
|
||||
assert(!queue.IsEmpty());
|
||||
assert((queued < 0) == (prev == NULL));
|
||||
assert((queued < 0) == (prev == nullptr));
|
||||
|
||||
const int next_order = current >= 0
|
||||
? queue.GetNextOrder(current)
|
||||
@ -133,7 +133,7 @@ playlist::UpdateQueuedSong(player_control &pc, const Song *prev)
|
||||
? queue.GetOrder(next_order)
|
||||
: nullptr;
|
||||
|
||||
if (prev != NULL && next_song != prev) {
|
||||
if (prev != nullptr && next_song != prev) {
|
||||
/* clear the currently queued song */
|
||||
pc.Cancel();
|
||||
queued = -1;
|
||||
|
@ -34,25 +34,25 @@ playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond,
|
||||
assert(uri_has_scheme(uri));
|
||||
|
||||
SongEnumerator *playlist = playlist_list_open_uri(uri, mutex, cond);
|
||||
if (playlist != NULL) {
|
||||
*is_r = NULL;
|
||||
if (playlist != nullptr) {
|
||||
*is_r = nullptr;
|
||||
return playlist;
|
||||
}
|
||||
|
||||
Error error;
|
||||
input_stream *is = input_stream::Open(uri, mutex, cond, error);
|
||||
if (is == NULL) {
|
||||
if (is == nullptr) {
|
||||
if (error.IsDefined())
|
||||
g_warning("Failed to open %s: %s",
|
||||
uri, error.GetMessage());
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
playlist = playlist_list_open_stream(is, uri);
|
||||
if (playlist == NULL) {
|
||||
if (playlist == nullptr) {
|
||||
is->Close();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*is_r = is;
|
||||
|
@ -226,7 +226,7 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
|
||||
}
|
||||
|
||||
queued = -1;
|
||||
UpdateQueuedSong(pc, NULL);
|
||||
UpdateQueuedSong(pc, nullptr);
|
||||
|
||||
return PLAYLIST_RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -49,10 +49,10 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name,
|
||||
char *line, *colon;
|
||||
const char *value;
|
||||
|
||||
while ((line = file.ReadLine()) != NULL &&
|
||||
while ((line = file.ReadLine()) != nullptr &&
|
||||
strcmp(line, "playlist_end") != 0) {
|
||||
colon = strchr(line, ':');
|
||||
if (colon == NULL || colon == line) {
|
||||
if (colon == nullptr || colon == line) {
|
||||
error.Format(playlist_database_domain,
|
||||
"unknown line in db: %s", line);
|
||||
return false;
|
||||
@ -62,7 +62,7 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name,
|
||||
value = strchug_fast_c(colon);
|
||||
|
||||
if (strcmp(line, "mtime") == 0)
|
||||
pm.mtime = strtol(value, NULL, 10);
|
||||
pm.mtime = strtol(value, nullptr, 10);
|
||||
else {
|
||||
error.Format(playlist_database_domain,
|
||||
"unknown line in db: %s", line);
|
||||
|
@ -59,7 +59,7 @@ playlist::AppendFile(struct player_control &pc,
|
||||
const char *path_utf8, unsigned *added_id)
|
||||
{
|
||||
Song *song = Song::LoadFile(path_utf8, nullptr);
|
||||
if (song == NULL)
|
||||
if (song == nullptr)
|
||||
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
||||
|
||||
return AppendSong(pc, song, added_id);
|
||||
@ -247,7 +247,7 @@ playlist::DeleteInternal(player_control &pc,
|
||||
completely */
|
||||
Stop(pc);
|
||||
|
||||
*queued_p = NULL;
|
||||
*queued_p = nullptr;
|
||||
} else if (current == (int)songOrder)
|
||||
/* there's a "current song" but we're not playing
|
||||
currently - clear "current" */
|
||||
|
@ -77,9 +77,9 @@ spl_valid_name(const char *name_utf8)
|
||||
* filenames isn't going to happen, either.
|
||||
*/
|
||||
|
||||
return strchr(name_utf8, '/') == NULL &&
|
||||
strchr(name_utf8, '\n') == NULL &&
|
||||
strchr(name_utf8, '\r') == NULL;
|
||||
return strchr(name_utf8, '/') == nullptr &&
|
||||
strchr(name_utf8, '\n') == nullptr &&
|
||||
strchr(name_utf8, '\r') == nullptr;
|
||||
}
|
||||
|
||||
static const Path &
|
||||
@ -144,7 +144,7 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
|
||||
size_t name_length = strlen(name_fs_str);
|
||||
|
||||
if (name_length < sizeof(PLAYLIST_FILE_SUFFIX) ||
|
||||
memchr(name_fs_str, '\n', name_length) != NULL)
|
||||
memchr(name_fs_str, '\n', name_length) != nullptr)
|
||||
return false;
|
||||
|
||||
if (!g_str_has_suffix(name_fs_str, PLAYLIST_FILE_SUFFIX))
|
||||
@ -196,7 +196,7 @@ static bool
|
||||
SavePlaylistFile(const PlaylistFileContents &contents, const char *utf8path,
|
||||
Error &error)
|
||||
{
|
||||
assert(utf8path != NULL);
|
||||
assert(utf8path != nullptr);
|
||||
|
||||
if (spl_map(error).IsNull())
|
||||
return false;
|
||||
@ -206,7 +206,7 @@ SavePlaylistFile(const PlaylistFileContents &contents, const char *utf8path,
|
||||
return false;
|
||||
|
||||
FILE *file = FOpen(path_fs, FOpenMode::WriteText);
|
||||
if (file == NULL) {
|
||||
if (file == nullptr) {
|
||||
playlist_errno(error);
|
||||
return false;
|
||||
}
|
||||
@ -237,7 +237,7 @@ LoadPlaylistFile(const char *utf8path, Error &error)
|
||||
}
|
||||
|
||||
char *s;
|
||||
while ((s = file.ReadLine()) != NULL) {
|
||||
while ((s = file.ReadLine()) != nullptr) {
|
||||
if (*s == 0 || *s == PLAYLIST_COMMENT)
|
||||
continue;
|
||||
|
||||
@ -245,7 +245,7 @@ LoadPlaylistFile(const char *utf8path, Error &error)
|
||||
char *path_utf8;
|
||||
|
||||
path_utf8 = map_fs_to_utf8(s);
|
||||
if (path_utf8 == NULL)
|
||||
if (path_utf8 == nullptr)
|
||||
continue;
|
||||
|
||||
s = path_utf8;
|
||||
@ -303,7 +303,7 @@ spl_clear(const char *utf8path, Error &error)
|
||||
return false;
|
||||
|
||||
FILE *file = FOpen(path_fs, FOpenMode::WriteText);
|
||||
if (file == NULL) {
|
||||
if (file == nullptr) {
|
||||
playlist_errno(error);
|
||||
return false;
|
||||
}
|
||||
@ -362,7 +362,7 @@ spl_append_song(const char *utf8path, Song *song, Error &error)
|
||||
return false;
|
||||
|
||||
FILE *file = FOpen(path_fs, FOpenMode::AppendText);
|
||||
if (file == NULL) {
|
||||
if (file == nullptr) {
|
||||
playlist_errno(error);
|
||||
return false;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ spl_valid_name(const char *name_utf8);
|
||||
|
||||
/**
|
||||
* Returns a list of stored_playlist_info struct pointers. Returns
|
||||
* NULL if an error occurred.
|
||||
* nullptr if an error occurred.
|
||||
*/
|
||||
PlaylistVector
|
||||
ListPlaylistFiles(Error &error);
|
||||
|
@ -32,8 +32,8 @@ playlist_open_path(const char *path_fs, Mutex &mutex, Cond &cond,
|
||||
struct input_stream **is_r)
|
||||
{
|
||||
auto playlist = playlist_list_open_uri(path_fs, mutex, cond);
|
||||
if (playlist != NULL)
|
||||
*is_r = NULL;
|
||||
if (playlist != nullptr)
|
||||
*is_r = nullptr;
|
||||
else
|
||||
playlist = playlist_list_open_path(path_fs, mutex, cond, is_r);
|
||||
|
||||
@ -47,15 +47,14 @@ static SongEnumerator *
|
||||
playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond,
|
||||
struct input_stream **is_r)
|
||||
{
|
||||
char *path_fs;
|
||||
|
||||
assert(spl_valid_name(uri));
|
||||
|
||||
const Path &playlist_directory_fs = map_spl_path();
|
||||
if (playlist_directory_fs.IsNull())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
path_fs = g_build_filename(playlist_directory_fs.c_str(), uri, NULL);
|
||||
char *path_fs = g_build_filename(playlist_directory_fs.c_str(), uri,
|
||||
nullptr);
|
||||
|
||||
auto playlist = playlist_open_path(path_fs, mutex, cond, is_r);
|
||||
g_free(path_fs);
|
||||
@ -74,7 +73,7 @@ playlist_open_in_music_dir(const char *uri, Mutex &mutex, Cond &cond,
|
||||
|
||||
Path path = map_uri_fs(uri);
|
||||
if (path.IsNull())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return playlist_open_path(path.c_str(), mutex, cond, is_r);
|
||||
}
|
||||
@ -86,16 +85,16 @@ playlist_mapper_open(const char *uri, Mutex &mutex, Cond &cond,
|
||||
if (spl_valid_name(uri)) {
|
||||
auto playlist = playlist_open_in_playlist_dir(uri, mutex, cond,
|
||||
is_r);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
return playlist;
|
||||
}
|
||||
|
||||
if (uri_safe_local(uri)) {
|
||||
auto playlist = playlist_open_in_music_dir(uri, mutex, cond,
|
||||
is_r);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
return playlist;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -149,11 +149,11 @@ playlist_provider_print(Client *client, const char *uri,
|
||||
SongEnumerator &e, bool detail)
|
||||
{
|
||||
Song *song;
|
||||
char *base_uri = uri != NULL ? g_path_get_dirname(uri) : NULL;
|
||||
char *base_uri = uri != nullptr ? g_path_get_dirname(uri) : nullptr;
|
||||
|
||||
while ((song = e.NextSong()) != nullptr) {
|
||||
song = playlist_check_translate_song(song, base_uri, false);
|
||||
if (song == NULL)
|
||||
if (song == nullptr)
|
||||
continue;
|
||||
|
||||
if (detail)
|
||||
@ -175,13 +175,13 @@ playlist_file_print(Client *client, const char *uri, bool detail)
|
||||
|
||||
struct input_stream *is;
|
||||
SongEnumerator *playlist = playlist_open_any(uri, mutex, cond, &is);
|
||||
if (playlist == NULL)
|
||||
if (playlist == nullptr)
|
||||
return false;
|
||||
|
||||
playlist_provider_print(client, uri, *playlist, detail);
|
||||
delete playlist;
|
||||
|
||||
if (is != NULL)
|
||||
if (is != nullptr)
|
||||
is->Close();
|
||||
|
||||
return true;
|
||||
|
@ -35,10 +35,10 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
|
||||
{
|
||||
enum playlist_result result;
|
||||
Song *song;
|
||||
char *base_uri = uri != NULL ? g_path_get_dirname(uri) : NULL;
|
||||
char *base_uri = uri != nullptr ? g_path_get_dirname(uri) : nullptr;
|
||||
|
||||
for (unsigned i = 0;
|
||||
i < end_index && (song = e.NextSong()) != NULL;
|
||||
i < end_index && (song = e.NextSong()) != nullptr;
|
||||
++i) {
|
||||
if (i < start_index) {
|
||||
/* skip songs before the start index */
|
||||
@ -47,7 +47,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
|
||||
}
|
||||
|
||||
song = playlist_check_translate_song(song, base_uri, secure);
|
||||
if (song == NULL)
|
||||
if (song == nullptr)
|
||||
continue;
|
||||
|
||||
result = dest->AppendSong(*pc, song);
|
||||
@ -74,7 +74,7 @@ playlist_open_into_queue(const char *uri,
|
||||
|
||||
struct input_stream *is;
|
||||
auto playlist = playlist_open_any(uri, mutex, cond, &is);
|
||||
if (playlist == NULL)
|
||||
if (playlist == nullptr)
|
||||
return PLAYLIST_RESULT_NO_SUCH_LIST;
|
||||
|
||||
enum playlist_result result =
|
||||
@ -83,7 +83,7 @@ playlist_open_into_queue(const char *uri,
|
||||
dest, pc, secure);
|
||||
delete playlist;
|
||||
|
||||
if (is != NULL)
|
||||
if (is != nullptr)
|
||||
is->Close();
|
||||
|
||||
return result;
|
||||
|
@ -57,7 +57,7 @@ const struct playlist_plugin *const playlist_plugins[] = {
|
||||
#endif
|
||||
&cue_playlist_plugin,
|
||||
&embcue_playlist_plugin,
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
|
||||
/** which plugins have been initialized successfully? */
|
||||
@ -71,18 +71,18 @@ static bool playlist_plugins_enabled[G_N_ELEMENTS(playlist_plugins)];
|
||||
* Find the "playlist" configuration block for the specified plugin.
|
||||
*
|
||||
* @param plugin_name the name of the playlist 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 *
|
||||
playlist_plugin_config(const char *plugin_name)
|
||||
{
|
||||
const struct config_param *param = NULL;
|
||||
const struct config_param *param = nullptr;
|
||||
|
||||
assert(plugin_name != NULL);
|
||||
assert(plugin_name != nullptr);
|
||||
|
||||
while ((param = config_get_next_param(CONF_PLAYLIST_PLUGIN, param)) != NULL) {
|
||||
while ((param = config_get_next_param(CONF_PLAYLIST_PLUGIN, param)) != nullptr) {
|
||||
const char *name = param->GetBlockValue("name");
|
||||
if (name == NULL)
|
||||
if (name == nullptr)
|
||||
FormatFatalError("playlist configuration without 'plugin' name in line %d",
|
||||
param->line);
|
||||
|
||||
@ -90,7 +90,7 @@ playlist_plugin_config(const char *plugin_name)
|
||||
return param;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
@ -98,7 +98,7 @@ playlist_list_global_init(void)
|
||||
{
|
||||
const config_param empty;
|
||||
|
||||
for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
|
||||
for (unsigned i = 0; playlist_plugins[i] != nullptr; ++i) {
|
||||
const struct playlist_plugin *plugin = playlist_plugins[i];
|
||||
const struct config_param *param =
|
||||
playlist_plugin_config(plugin->name);
|
||||
@ -127,23 +127,23 @@ playlist_list_open_uri_scheme(const char *uri, Mutex &mutex, Cond &cond,
|
||||
char *scheme;
|
||||
SongEnumerator *playlist = nullptr;
|
||||
|
||||
assert(uri != NULL);
|
||||
assert(uri != nullptr);
|
||||
|
||||
scheme = g_uri_parse_scheme(uri);
|
||||
if (scheme == NULL)
|
||||
return NULL;
|
||||
if (scheme == nullptr)
|
||||
return nullptr;
|
||||
|
||||
for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
|
||||
for (unsigned i = 0; playlist_plugins[i] != nullptr; ++i) {
|
||||
const struct playlist_plugin *plugin = playlist_plugins[i];
|
||||
|
||||
assert(!tried[i]);
|
||||
|
||||
if (playlist_plugins_enabled[i] && plugin->open_uri != NULL &&
|
||||
plugin->schemes != NULL &&
|
||||
if (playlist_plugins_enabled[i] && plugin->open_uri != nullptr &&
|
||||
plugin->schemes != nullptr &&
|
||||
string_array_contains(plugin->schemes, scheme)) {
|
||||
playlist = playlist_plugin_open_uri(plugin, uri,
|
||||
mutex, cond);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
break;
|
||||
|
||||
tried[i] = true;
|
||||
@ -161,21 +161,21 @@ playlist_list_open_uri_suffix(const char *uri, Mutex &mutex, Cond &cond,
|
||||
const char *suffix;
|
||||
SongEnumerator *playlist = nullptr;
|
||||
|
||||
assert(uri != NULL);
|
||||
assert(uri != nullptr);
|
||||
|
||||
suffix = uri_get_suffix(uri);
|
||||
if (suffix == NULL)
|
||||
return NULL;
|
||||
if (suffix == nullptr)
|
||||
return nullptr;
|
||||
|
||||
for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
|
||||
for (unsigned i = 0; playlist_plugins[i] != nullptr; ++i) {
|
||||
const struct playlist_plugin *plugin = playlist_plugins[i];
|
||||
|
||||
if (playlist_plugins_enabled[i] && !tried[i] &&
|
||||
plugin->open_uri != NULL && plugin->suffixes != NULL &&
|
||||
plugin->open_uri != nullptr && plugin->suffixes != nullptr &&
|
||||
string_array_contains(plugin->suffixes, suffix)) {
|
||||
playlist = playlist_plugin_open_uri(plugin, uri,
|
||||
mutex, cond);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -190,12 +190,12 @@ playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
||||
playlist_list_open_uri_scheme() */
|
||||
bool tried[G_N_ELEMENTS(playlist_plugins) - 1];
|
||||
|
||||
assert(uri != NULL);
|
||||
assert(uri != nullptr);
|
||||
|
||||
memset(tried, false, sizeof(tried));
|
||||
|
||||
auto playlist = playlist_list_open_uri_scheme(uri, mutex, cond, tried);
|
||||
if (playlist == NULL)
|
||||
if (playlist == nullptr)
|
||||
playlist = playlist_list_open_uri_suffix(uri, mutex, cond,
|
||||
tried);
|
||||
|
||||
@ -205,37 +205,37 @@ playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
||||
static SongEnumerator *
|
||||
playlist_list_open_stream_mime2(struct input_stream *is, const char *mime)
|
||||
{
|
||||
assert(is != NULL);
|
||||
assert(mime != NULL);
|
||||
assert(is != nullptr);
|
||||
assert(mime != nullptr);
|
||||
|
||||
playlist_plugins_for_each_enabled(plugin) {
|
||||
if (plugin->open_stream != NULL &&
|
||||
plugin->mime_types != NULL &&
|
||||
if (plugin->open_stream != nullptr &&
|
||||
plugin->mime_types != nullptr &&
|
||||
string_array_contains(plugin->mime_types, mime)) {
|
||||
/* rewind the stream, so each plugin gets a
|
||||
fresh start */
|
||||
is->Seek(0, SEEK_SET, IgnoreError());
|
||||
|
||||
auto playlist = playlist_plugin_open_stream(plugin, is);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
return playlist;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static SongEnumerator *
|
||||
playlist_list_open_stream_mime(struct input_stream *is, const char *full_mime)
|
||||
{
|
||||
assert(full_mime != NULL);
|
||||
assert(full_mime != nullptr);
|
||||
|
||||
const char *semicolon = strchr(full_mime, ';');
|
||||
if (semicolon == NULL)
|
||||
if (semicolon == nullptr)
|
||||
return playlist_list_open_stream_mime2(is, full_mime);
|
||||
|
||||
if (semicolon == full_mime)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* probe only the portion before the semicolon*/
|
||||
char *mime = g_strndup(full_mime, semicolon - full_mime);
|
||||
@ -247,24 +247,24 @@ playlist_list_open_stream_mime(struct input_stream *is, const char *full_mime)
|
||||
static SongEnumerator *
|
||||
playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix)
|
||||
{
|
||||
assert(is != NULL);
|
||||
assert(suffix != NULL);
|
||||
assert(is != nullptr);
|
||||
assert(suffix != nullptr);
|
||||
|
||||
playlist_plugins_for_each_enabled(plugin) {
|
||||
if (plugin->open_stream != NULL &&
|
||||
plugin->suffixes != NULL &&
|
||||
if (plugin->open_stream != nullptr &&
|
||||
plugin->suffixes != nullptr &&
|
||||
string_array_contains(plugin->suffixes, suffix)) {
|
||||
/* rewind the stream, so each plugin gets a
|
||||
fresh start */
|
||||
is->Seek(0, SEEK_SET, IgnoreError());
|
||||
|
||||
auto playlist = playlist_plugin_open_stream(plugin, is);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
return playlist;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SongEnumerator *
|
||||
@ -275,29 +275,29 @@ playlist_list_open_stream(struct input_stream *is, const char *uri)
|
||||
is->LockWaitReady();
|
||||
|
||||
const char *const mime = is->GetMimeType();
|
||||
if (mime != NULL) {
|
||||
if (mime != nullptr) {
|
||||
auto playlist = playlist_list_open_stream_mime(is, mime);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
return playlist;
|
||||
}
|
||||
|
||||
suffix = uri != NULL ? uri_get_suffix(uri) : NULL;
|
||||
if (suffix != NULL) {
|
||||
suffix = uri != nullptr ? uri_get_suffix(uri) : nullptr;
|
||||
if (suffix != nullptr) {
|
||||
auto playlist = playlist_list_open_stream_suffix(is, suffix);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
return playlist;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
playlist_suffix_supported(const char *suffix)
|
||||
{
|
||||
assert(suffix != NULL);
|
||||
assert(suffix != nullptr);
|
||||
|
||||
playlist_plugins_for_each_enabled(plugin) {
|
||||
if (plugin->suffixes != NULL &&
|
||||
if (plugin->suffixes != nullptr &&
|
||||
string_array_contains(plugin->suffixes, suffix))
|
||||
return true;
|
||||
}
|
||||
@ -311,25 +311,25 @@ playlist_list_open_path(const char *path_fs, Mutex &mutex, Cond &cond,
|
||||
{
|
||||
const char *suffix;
|
||||
|
||||
assert(path_fs != NULL);
|
||||
assert(path_fs != nullptr);
|
||||
|
||||
suffix = uri_get_suffix(path_fs);
|
||||
if (suffix == NULL || !playlist_suffix_supported(suffix))
|
||||
return NULL;
|
||||
if (suffix == nullptr || !playlist_suffix_supported(suffix))
|
||||
return nullptr;
|
||||
|
||||
Error error;
|
||||
input_stream *is = input_stream::Open(path_fs, mutex, cond, error);
|
||||
if (is == NULL) {
|
||||
if (is == nullptr) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
is->LockWaitReady();
|
||||
|
||||
auto playlist = playlist_list_open_stream_suffix(is, suffix);
|
||||
if (playlist != NULL)
|
||||
if (playlist != nullptr)
|
||||
*is_r = is;
|
||||
else
|
||||
is->Close();
|
||||
|
@ -31,7 +31,7 @@ extern const struct playlist_plugin *const playlist_plugins[];
|
||||
#define playlist_plugins_for_each(plugin) \
|
||||
for (const struct playlist_plugin *plugin, \
|
||||
*const*playlist_plugin_iterator = &playlist_plugins[0]; \
|
||||
(plugin = *playlist_plugin_iterator) != NULL; \
|
||||
(plugin = *playlist_plugin_iterator) != nullptr; \
|
||||
++playlist_plugin_iterator)
|
||||
|
||||
/**
|
||||
@ -75,7 +75,7 @@ playlist_suffix_supported(const char *suffix);
|
||||
* @param path_fs the path of the playlist file
|
||||
* @param is_r on success, an input_stream object is returned here,
|
||||
* which must be closed after the playlist_provider object is freed
|
||||
* @return a playlist, or NULL on error
|
||||
* @return a playlist, or nullptr on error
|
||||
*/
|
||||
SongEnumerator *
|
||||
playlist_list_open_path(const char *path_fs, Mutex &mutex, Cond &cond,
|
||||
|
@ -78,7 +78,7 @@ spl_save_queue(const char *name_utf8, const struct queue *queue)
|
||||
|
||||
FILE *file = FOpen(path_fs, FOpenMode::WriteText);
|
||||
|
||||
if (file == NULL)
|
||||
if (file == nullptr)
|
||||
return PLAYLIST_RESULT_ERRNO;
|
||||
|
||||
for (unsigned i = 0; i < queue->GetLength(); i++)
|
||||
|
@ -38,13 +38,13 @@ static void
|
||||
merge_song_metadata(Song *dest, const Song *base,
|
||||
const Song *add)
|
||||
{
|
||||
dest->tag = base->tag != NULL
|
||||
? (add->tag != NULL
|
||||
dest->tag = base->tag != nullptr
|
||||
? (add->tag != nullptr
|
||||
? Tag::Merge(*base->tag, *add->tag)
|
||||
: new Tag(*base->tag))
|
||||
: (add->tag != NULL
|
||||
: (add->tag != nullptr
|
||||
? new Tag(*add->tag)
|
||||
: NULL);
|
||||
: nullptr);
|
||||
|
||||
dest->mtime = base->mtime;
|
||||
dest->start_ms = add->start_ms;
|
||||
@ -56,10 +56,10 @@ apply_song_metadata(Song *dest, const Song *src)
|
||||
{
|
||||
Song *tmp;
|
||||
|
||||
assert(dest != NULL);
|
||||
assert(src != NULL);
|
||||
assert(dest != nullptr);
|
||||
assert(src != nullptr);
|
||||
|
||||
if (src->tag == NULL && src->start_ms == 0 && src->end_ms == 0)
|
||||
if (src->tag == nullptr && src->start_ms == 0 && src->end_ms == 0)
|
||||
return dest;
|
||||
|
||||
if (dest->IsInDatabase()) {
|
||||
@ -71,15 +71,15 @@ apply_song_metadata(Song *dest, const Song *src)
|
||||
if (path_utf8.empty())
|
||||
path_utf8 = path_fs.c_str();
|
||||
|
||||
tmp = Song::NewFile(path_utf8.c_str(), NULL);
|
||||
tmp = Song::NewFile(path_utf8.c_str(), nullptr);
|
||||
|
||||
merge_song_metadata(tmp, dest, src);
|
||||
} else {
|
||||
tmp = Song::NewFile(dest->uri, NULL);
|
||||
tmp = Song::NewFile(dest->uri, nullptr);
|
||||
merge_song_metadata(tmp, dest, src);
|
||||
}
|
||||
|
||||
if (dest->tag != NULL && dest->tag->time > 0 &&
|
||||
if (dest->tag != nullptr && dest->tag->time > 0 &&
|
||||
src->start_ms > 0 && src->end_ms == 0 &&
|
||||
src->start_ms / 1000 < (unsigned)dest->tag->time)
|
||||
/* the range is open-ended, and the playlist plugin
|
||||
@ -100,17 +100,17 @@ playlist_check_load_song(const Song *song, const char *uri, bool secure)
|
||||
dest = Song::NewRemote(uri);
|
||||
} else if (g_path_is_absolute(uri) && secure) {
|
||||
dest = Song::LoadFile(uri, nullptr);
|
||||
if (dest == NULL)
|
||||
return NULL;
|
||||
if (dest == nullptr)
|
||||
return nullptr;
|
||||
} else {
|
||||
const Database *db = GetDatabase(IgnoreError());
|
||||
if (db == nullptr)
|
||||
return nullptr;
|
||||
|
||||
Song *tmp = db->GetSong(uri, IgnoreError());
|
||||
if (tmp == NULL)
|
||||
if (tmp == nullptr)
|
||||
/* not found in database */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
dest = tmp->DupDetached();
|
||||
db->ReturnSong(tmp);
|
||||
@ -136,21 +136,21 @@ playlist_check_translate_song(Song *song, const char *base_uri,
|
||||
else {
|
||||
/* unsupported remote song */
|
||||
song->Free();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (base_uri != NULL && strcmp(base_uri, ".") == 0)
|
||||
if (base_uri != nullptr && strcmp(base_uri, ".") == 0)
|
||||
/* g_path_get_dirname() returns "." when there is no
|
||||
directory name in the given path; clear that now,
|
||||
because it would break the database lookup
|
||||
functions */
|
||||
base_uri = NULL;
|
||||
base_uri = nullptr;
|
||||
|
||||
if (g_path_is_absolute(uri)) {
|
||||
/* XXX fs_charset vs utf8? */
|
||||
const char *suffix = map_to_relative_path(uri);
|
||||
assert(suffix != NULL);
|
||||
assert(suffix != nullptr);
|
||||
|
||||
if (suffix != uri)
|
||||
uri = suffix;
|
||||
@ -158,15 +158,15 @@ playlist_check_translate_song(Song *song, const char *base_uri,
|
||||
/* local files must be relative to the music
|
||||
directory when "secure" is enabled */
|
||||
song->Free();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
base_uri = NULL;
|
||||
base_uri = nullptr;
|
||||
}
|
||||
|
||||
char *allocated = NULL;
|
||||
if (base_uri != NULL)
|
||||
uri = allocated = g_build_filename(base_uri, uri, NULL);
|
||||
char *allocated = nullptr;
|
||||
if (base_uri != nullptr)
|
||||
uri = allocated = g_build_filename(base_uri, uri, nullptr);
|
||||
|
||||
Song *dest = playlist_check_load_song(song, uri, secure);
|
||||
song->Free();
|
||||
|
@ -23,7 +23,7 @@
|
||||
struct Song;
|
||||
|
||||
/**
|
||||
* Verifies the song, returns NULL if it is unsafe. Translate the
|
||||
* Verifies the song, returns nullptr if it is unsafe. Translate the
|
||||
* song to a new song object within the database, if it is a local
|
||||
* file. The old song object is freed.
|
||||
*
|
||||
|
@ -101,7 +101,7 @@ static void
|
||||
playlist_state_load(TextFile &file, struct playlist *playlist)
|
||||
{
|
||||
const char *line = file.ReadLine();
|
||||
if (line == NULL) {
|
||||
if (line == nullptr) {
|
||||
g_warning("No playlist in state file");
|
||||
return;
|
||||
}
|
||||
@ -110,7 +110,7 @@ playlist_state_load(TextFile &file, struct playlist *playlist)
|
||||
queue_load_song(file, line, &playlist->queue);
|
||||
|
||||
line = file.ReadLine();
|
||||
if (line == NULL) {
|
||||
if (line == nullptr) {
|
||||
g_warning("'" PLAYLIST_STATE_FILE_PLAYLIST_END
|
||||
"' not found in state file");
|
||||
break;
|
||||
@ -141,7 +141,7 @@ playlist_state_restore(const char *line, TextFile &file,
|
||||
else
|
||||
state = PlayerState::STOP;
|
||||
|
||||
while ((line = file.ReadLine()) != NULL) {
|
||||
while ((line = file.ReadLine()) != nullptr) {
|
||||
if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_TIME)) {
|
||||
seek_time =
|
||||
atoi(&(line[strlen(PLAYLIST_STATE_FILE_TIME)]));
|
||||
|
@ -31,7 +31,7 @@ PlaylistVector::iterator
|
||||
PlaylistVector::find(const char *name)
|
||||
{
|
||||
assert(holding_db_lock());
|
||||
assert(name != NULL);
|
||||
assert(name != nullptr);
|
||||
|
||||
return std::find_if(begin(), end(),
|
||||
PlaylistInfo::CompareName(name));
|
||||
|
Loading…
Reference in New Issue
Block a user