playlist/Plugin: use std::unique_ptr<SongEnumerator>
This commit is contained in:
parent
147f64e1fc
commit
0095e2d7d8
|
@ -21,9 +21,10 @@
|
||||||
#include "PlaylistAny.hxx"
|
#include "PlaylistAny.hxx"
|
||||||
#include "PlaylistStream.hxx"
|
#include "PlaylistStream.hxx"
|
||||||
#include "PlaylistMapper.hxx"
|
#include "PlaylistMapper.hxx"
|
||||||
|
#include "SongEnumerator.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
|
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_any(const char *uri,
|
playlist_open_any(const char *uri,
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
const Storage *storage,
|
const Storage *storage,
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef MPD_PLAYLIST_ANY_HXX
|
#ifndef MPD_PLAYLIST_ANY_HXX
|
||||||
#define MPD_PLAYLIST_ANY_HXX
|
#define MPD_PLAYLIST_ANY_HXX
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class Mutex;
|
class Mutex;
|
||||||
class Cond;
|
class Cond;
|
||||||
class SongEnumerator;
|
class SongEnumerator;
|
||||||
|
@ -30,7 +32,7 @@ class Storage;
|
||||||
* absolute remote URI (with a scheme) or a relative path to the
|
* absolute remote URI (with a scheme) or a relative path to the
|
||||||
* music or playlist directory.
|
* music or playlist directory.
|
||||||
*/
|
*/
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_any(const char *uri,
|
playlist_open_any(const char *uri,
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
const Storage *storage,
|
const Storage *storage,
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "PlaylistMapper.hxx"
|
#include "PlaylistMapper.hxx"
|
||||||
#include "PlaylistFile.hxx"
|
#include "PlaylistFile.hxx"
|
||||||
#include "PlaylistStream.hxx"
|
#include "PlaylistStream.hxx"
|
||||||
|
#include "SongEnumerator.hxx"
|
||||||
#include "Mapper.hxx"
|
#include "Mapper.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "storage/StorageInterface.hxx"
|
#include "storage/StorageInterface.hxx"
|
||||||
|
@ -31,7 +32,7 @@
|
||||||
/**
|
/**
|
||||||
* Load a playlist from the configured playlist directory.
|
* Load a playlist from the configured playlist directory.
|
||||||
*/
|
*/
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond)
|
playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
assert(spl_valid_name(uri));
|
assert(spl_valid_name(uri));
|
||||||
|
@ -48,7 +49,7 @@ playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond)
|
||||||
/**
|
/**
|
||||||
* Load a playlist from the configured music directory.
|
* Load a playlist from the configured music directory.
|
||||||
*/
|
*/
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_in_storage(const char *uri, const Storage *storage,
|
playlist_open_in_storage(const char *uri, const Storage *storage,
|
||||||
Mutex &mutex, Cond &cond)
|
Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +70,7 @@ playlist_open_in_storage(const char *uri, const Storage *storage,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_mapper_open(const char *uri,
|
playlist_mapper_open(const char *uri,
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
const Storage *storage,
|
const Storage *storage,
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class Mutex;
|
class Mutex;
|
||||||
class Cond;
|
class Cond;
|
||||||
class SongEnumerator;
|
class SongEnumerator;
|
||||||
|
@ -31,7 +33,7 @@ class Storage;
|
||||||
* Opens a playlist from an URI relative to the playlist or music
|
* Opens a playlist from an URI relative to the playlist or music
|
||||||
* directory.
|
* directory.
|
||||||
*/
|
*/
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_mapper_open(const char *uri,
|
playlist_mapper_open(const char *uri,
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
const Storage *storage,
|
const Storage *storage,
|
||||||
|
|
|
@ -51,8 +51,8 @@ struct playlist_plugin {
|
||||||
* Opens the playlist on the specified URI. This URI has
|
* Opens the playlist on the specified URI. This URI has
|
||||||
* either matched one of the schemes or one of the suffixes.
|
* either matched one of the schemes or one of the suffixes.
|
||||||
*/
|
*/
|
||||||
SongEnumerator *(*open_uri)(const char *uri,
|
std::unique_ptr<SongEnumerator> (*open_uri)(const char *uri,
|
||||||
Mutex &mutex, Cond &cond);
|
Mutex &mutex, Cond &cond);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the playlist in the specified input stream. It has
|
* Opens the playlist in the specified input stream. It has
|
||||||
|
@ -62,7 +62,7 @@ struct playlist_plugin {
|
||||||
* @parm is the input stream; the pointer will not be
|
* @parm is the input stream; the pointer will not be
|
||||||
* invalidated when the function returns nullptr
|
* invalidated when the function returns nullptr
|
||||||
*/
|
*/
|
||||||
SongEnumerator *(*open_stream)(InputStreamPtr &&is);
|
std::unique_ptr<SongEnumerator> (*open_stream)(InputStreamPtr &&is);
|
||||||
|
|
||||||
const char *const*schemes;
|
const char *const*schemes;
|
||||||
const char *const*suffixes;
|
const char *const*suffixes;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "PlaylistRegistry.hxx"
|
#include "PlaylistRegistry.hxx"
|
||||||
#include "PlaylistPlugin.hxx"
|
#include "PlaylistPlugin.hxx"
|
||||||
|
#include "SongEnumerator.hxx"
|
||||||
#include "plugins/ExtM3uPlaylistPlugin.hxx"
|
#include "plugins/ExtM3uPlaylistPlugin.hxx"
|
||||||
#include "plugins/M3uPlaylistPlugin.hxx"
|
#include "plugins/M3uPlaylistPlugin.hxx"
|
||||||
#include "plugins/XspfPlaylistPlugin.hxx"
|
#include "plugins/XspfPlaylistPlugin.hxx"
|
||||||
|
@ -101,12 +102,10 @@ playlist_list_global_finish(void)
|
||||||
playlist_plugin_finish(plugin);
|
playlist_plugin_finish(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_uri_scheme(const char *uri, Mutex &mutex, Cond &cond,
|
playlist_list_open_uri_scheme(const char *uri, Mutex &mutex, Cond &cond,
|
||||||
bool *tried)
|
bool *tried)
|
||||||
{
|
{
|
||||||
SongEnumerator *playlist = nullptr;
|
|
||||||
|
|
||||||
assert(uri != nullptr);
|
assert(uri != nullptr);
|
||||||
|
|
||||||
const auto scheme = uri_get_scheme(uri);
|
const auto scheme = uri_get_scheme(uri);
|
||||||
|
@ -121,23 +120,21 @@ playlist_list_open_uri_scheme(const char *uri, Mutex &mutex, Cond &cond,
|
||||||
if (playlist_plugins_enabled[i] && plugin->open_uri != nullptr &&
|
if (playlist_plugins_enabled[i] && plugin->open_uri != nullptr &&
|
||||||
plugin->schemes != nullptr &&
|
plugin->schemes != nullptr &&
|
||||||
StringArrayContainsCase(plugin->schemes, scheme.c_str())) {
|
StringArrayContainsCase(plugin->schemes, scheme.c_str())) {
|
||||||
playlist = plugin->open_uri(uri, mutex, cond);
|
auto playlist = plugin->open_uri(uri, mutex, cond);
|
||||||
if (playlist != nullptr)
|
if (playlist)
|
||||||
break;
|
return playlist;
|
||||||
|
|
||||||
tried[i] = true;
|
tried[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return playlist;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_uri_suffix(const char *uri, Mutex &mutex, Cond &cond,
|
playlist_list_open_uri_suffix(const char *uri, Mutex &mutex, Cond &cond,
|
||||||
const bool *tried)
|
const bool *tried)
|
||||||
{
|
{
|
||||||
SongEnumerator *playlist = nullptr;
|
|
||||||
|
|
||||||
assert(uri != nullptr);
|
assert(uri != nullptr);
|
||||||
|
|
||||||
UriSuffixBuffer suffix_buffer;
|
UriSuffixBuffer suffix_buffer;
|
||||||
|
@ -151,16 +148,16 @@ playlist_list_open_uri_suffix(const char *uri, Mutex &mutex, Cond &cond,
|
||||||
if (playlist_plugins_enabled[i] && !tried[i] &&
|
if (playlist_plugins_enabled[i] && !tried[i] &&
|
||||||
plugin->open_uri != nullptr && plugin->suffixes != nullptr &&
|
plugin->open_uri != nullptr && plugin->suffixes != nullptr &&
|
||||||
StringArrayContainsCase(plugin->suffixes, suffix)) {
|
StringArrayContainsCase(plugin->suffixes, suffix)) {
|
||||||
playlist = plugin->open_uri(uri, mutex, cond);
|
auto playlist = plugin->open_uri(uri, mutex, cond);
|
||||||
if (playlist != nullptr)
|
if (playlist != nullptr)
|
||||||
break;
|
return playlist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return playlist;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
/** this array tracks which plugins have already been tried by
|
/** this array tracks which plugins have already been tried by
|
||||||
|
@ -179,7 +176,7 @@ playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
||||||
return playlist;
|
return playlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_stream_mime2(InputStreamPtr &&is, const char *mime)
|
playlist_list_open_stream_mime2(InputStreamPtr &&is, const char *mime)
|
||||||
{
|
{
|
||||||
assert(mime != nullptr);
|
assert(mime != nullptr);
|
||||||
|
@ -204,7 +201,7 @@ playlist_list_open_stream_mime2(InputStreamPtr &&is, const char *mime)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_stream_mime(InputStreamPtr &&is, const char *full_mime)
|
playlist_list_open_stream_mime(InputStreamPtr &&is, const char *full_mime)
|
||||||
{
|
{
|
||||||
assert(full_mime != nullptr);
|
assert(full_mime != nullptr);
|
||||||
|
@ -222,7 +219,7 @@ playlist_list_open_stream_mime(InputStreamPtr &&is, const char *full_mime)
|
||||||
return playlist_list_open_stream_mime2(std::move(is), mime.c_str());
|
return playlist_list_open_stream_mime2(std::move(is), mime.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix)
|
playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix)
|
||||||
{
|
{
|
||||||
assert(suffix != nullptr);
|
assert(suffix != nullptr);
|
||||||
|
@ -247,7 +244,7 @@ playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_stream(InputStreamPtr &&is, const char *uri)
|
playlist_list_open_stream(InputStreamPtr &&is, const char *uri)
|
||||||
{
|
{
|
||||||
assert(is->IsReady());
|
assert(is->IsReady());
|
||||||
|
|
|
@ -49,10 +49,10 @@ playlist_list_global_finish();
|
||||||
/**
|
/**
|
||||||
* Opens a playlist by its URI.
|
* Opens a playlist by its URI.
|
||||||
*/
|
*/
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond);
|
playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond);
|
||||||
|
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix);
|
playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +62,7 @@ playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix);
|
||||||
* @param uri optional URI which was used to open the stream; may be
|
* @param uri optional URI which was used to open the stream; may be
|
||||||
* used to select the appropriate playlist plugin
|
* used to select the appropriate playlist plugin
|
||||||
*/
|
*/
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_stream(InputStreamPtr &&is, const char *uri);
|
playlist_list_open_stream(InputStreamPtr &&is, const char *uri);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "PlaylistStream.hxx"
|
#include "PlaylistStream.hxx"
|
||||||
#include "PlaylistRegistry.hxx"
|
#include "PlaylistRegistry.hxx"
|
||||||
|
#include "SongEnumerator.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "input/LocalOpen.hxx"
|
#include "input/LocalOpen.hxx"
|
||||||
|
@ -30,7 +31,7 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_path_suffix(Path path, Mutex &mutex, Cond &cond)
|
playlist_open_path_suffix(Path path, Mutex &mutex, Cond &cond)
|
||||||
try {
|
try {
|
||||||
assert(!path.IsNull());
|
assert(!path.IsNull());
|
||||||
|
@ -51,7 +52,7 @@ try {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_path(Path path, Mutex &mutex, Cond &cond)
|
playlist_open_path(Path path, Mutex &mutex, Cond &cond)
|
||||||
try {
|
try {
|
||||||
assert(!path.IsNull());
|
assert(!path.IsNull());
|
||||||
|
@ -69,12 +70,12 @@ try {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond)
|
playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond)
|
||||||
try {
|
try {
|
||||||
assert(uri_has_scheme(uri));
|
assert(uri_has_scheme(uri));
|
||||||
|
|
||||||
SongEnumerator *playlist = playlist_list_open_uri(uri, mutex, cond);
|
auto playlist = playlist_list_open_uri(uri, mutex, cond);
|
||||||
if (playlist != nullptr)
|
if (playlist != nullptr)
|
||||||
return playlist;
|
return playlist;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class Mutex;
|
class Mutex;
|
||||||
class Cond;
|
class Cond;
|
||||||
class SongEnumerator;
|
class SongEnumerator;
|
||||||
|
@ -34,11 +36,11 @@ class Path;
|
||||||
* @return a playlist, or nullptr on error
|
* @return a playlist, or nullptr on error
|
||||||
*/
|
*/
|
||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_path(Path path, Mutex &mutex, Cond &cond);
|
playlist_open_path(Path path, Mutex &mutex, Cond &cond);
|
||||||
|
|
||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
SongEnumerator *
|
std::unique_ptr<SongEnumerator>
|
||||||
playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond);
|
playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -65,15 +65,14 @@ playlist_file_print(Response &r, Partition &partition,
|
||||||
(void)partition;
|
(void)partition;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SongEnumerator *playlist = playlist_open_any(uri,
|
auto playlist = playlist_open_any(uri,
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
partition.instance.storage,
|
partition.instance.storage,
|
||||||
#endif
|
#endif
|
||||||
mutex, cond);
|
mutex, cond);
|
||||||
if (playlist == nullptr)
|
if (playlist == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
playlist_provider_print(r, loader, uri, *playlist, detail);
|
playlist_provider_print(r, loader, uri, *playlist, detail);
|
||||||
delete playlist;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ asx_char_data(void *user_data, const XML_Char *s, int len)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
asx_open_stream(InputStreamPtr &&is)
|
asx_open_stream(InputStreamPtr &&is)
|
||||||
{
|
{
|
||||||
AsxParser parser;
|
AsxParser parser;
|
||||||
|
@ -155,7 +155,7 @@ asx_open_stream(InputStreamPtr &&is)
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.songs.reverse();
|
parser.songs.reverse();
|
||||||
return new MemorySongEnumerator(std::move(parser.songs));
|
return std::make_unique<MemorySongEnumerator>(std::move(parser.songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const asx_suffixes[] = {
|
static const char *const asx_suffixes[] = {
|
||||||
|
|
|
@ -36,10 +36,10 @@ class CuePlaylist final : public SongEnumerator {
|
||||||
virtual std::unique_ptr<DetachedSong> NextSong() override;
|
virtual std::unique_ptr<DetachedSong> NextSong() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
cue_playlist_open_stream(InputStreamPtr &&is)
|
cue_playlist_open_stream(InputStreamPtr &&is)
|
||||||
{
|
{
|
||||||
return new CuePlaylist(std::move(is));
|
return std::make_unique<CuePlaylist>(std::move(is));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<DetachedSong>
|
std::unique_ptr<DetachedSong>
|
||||||
|
|
|
@ -87,7 +87,7 @@ static constexpr TagHandler embcue_tag_handler = {
|
||||||
embcue_tag_pair,
|
embcue_tag_pair,
|
||||||
};
|
};
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
embcue_playlist_open_uri(const char *uri,
|
embcue_playlist_open_uri(const char *uri,
|
||||||
gcc_unused Mutex &mutex,
|
gcc_unused Mutex &mutex,
|
||||||
gcc_unused Cond &cond)
|
gcc_unused Cond &cond)
|
||||||
|
@ -98,17 +98,15 @@ embcue_playlist_open_uri(const char *uri,
|
||||||
|
|
||||||
const auto path_fs = AllocatedPath::FromUTF8Throw(uri);
|
const auto path_fs = AllocatedPath::FromUTF8Throw(uri);
|
||||||
|
|
||||||
const auto playlist = new EmbeddedCuePlaylist();
|
auto playlist = std::make_unique<EmbeddedCuePlaylist>();
|
||||||
|
|
||||||
tag_file_scan(path_fs, embcue_tag_handler, playlist);
|
tag_file_scan(path_fs, embcue_tag_handler, playlist.get());
|
||||||
if (playlist->cuesheet.empty())
|
if (playlist->cuesheet.empty())
|
||||||
ScanGenericTags(path_fs, embcue_tag_handler, playlist);
|
ScanGenericTags(path_fs, embcue_tag_handler, playlist.get());
|
||||||
|
|
||||||
if (playlist->cuesheet.empty()) {
|
if (playlist->cuesheet.empty())
|
||||||
/* no "CUESHEET" tag found */
|
/* no "CUESHEET" tag found */
|
||||||
delete playlist;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
playlist->filename = PathTraitsUTF8::GetBase(uri);
|
playlist->filename = PathTraitsUTF8::GetBase(uri);
|
||||||
|
|
||||||
|
|
|
@ -59,18 +59,16 @@ public:
|
||||||
virtual std::unique_ptr<DetachedSong> NextSong() override;
|
virtual std::unique_ptr<DetachedSong> NextSong() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
extm3u_open_stream(InputStreamPtr &&is)
|
extm3u_open_stream(InputStreamPtr &&is)
|
||||||
{
|
{
|
||||||
ExtM3uPlaylist *playlist = new ExtM3uPlaylist(std::move(is));
|
auto playlist = std::make_unique<ExtM3uPlaylist>(std::move(is));
|
||||||
|
|
||||||
is = playlist->CheckFirstLine();
|
is = playlist->CheckFirstLine();
|
||||||
if (is) {
|
if (is)
|
||||||
/* no EXTM3U header: fall back to the plain m3u
|
/* no EXTM3U header: fall back to the plain m3u
|
||||||
plugin */
|
plugin */
|
||||||
delete playlist;
|
playlist.reset();
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return playlist;
|
return playlist;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ FlacPlaylist::NextSong()
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
flac_playlist_open_uri(const char *uri,
|
flac_playlist_open_uri(const char *uri,
|
||||||
gcc_unused Mutex &mutex, gcc_unused Cond &cond)
|
gcc_unused Mutex &mutex, gcc_unused Cond &cond)
|
||||||
{
|
{
|
||||||
|
@ -109,7 +109,7 @@ flac_playlist_open_uri(const char *uri,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FlacPlaylist(uri, cuesheet, streaminfo);
|
return std::make_unique<FlacPlaylist>(uri, cuesheet, streaminfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const flac_playlist_suffixes[] = {
|
static const char *const flac_playlist_suffixes[] = {
|
||||||
|
|
|
@ -36,10 +36,10 @@ public:
|
||||||
virtual std::unique_ptr<DetachedSong> NextSong() override;
|
virtual std::unique_ptr<DetachedSong> NextSong() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
m3u_open_stream(InputStreamPtr &&is)
|
m3u_open_stream(InputStreamPtr &&is)
|
||||||
{
|
{
|
||||||
return new M3uPlaylist(std::move(is));
|
return std::make_unique<M3uPlaylist>(std::move(is));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<DetachedSong>
|
std::unique_ptr<DetachedSong>
|
||||||
|
|
|
@ -153,14 +153,14 @@ ParsePls(InputStreamPtr &&is, std::forward_list<DetachedSong> &songs)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
pls_open_stream(InputStreamPtr &&is)
|
pls_open_stream(InputStreamPtr &&is)
|
||||||
{
|
{
|
||||||
std::forward_list<DetachedSong> songs;
|
std::forward_list<DetachedSong> songs;
|
||||||
if (!ParsePls(std::move(is), songs))
|
if (!ParsePls(std::move(is), songs))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return new MemorySongEnumerator(std::move(songs));
|
return std::make_unique<MemorySongEnumerator>(std::move(songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const pls_suffixes[] = {
|
static const char *const pls_suffixes[] = {
|
||||||
|
|
|
@ -140,7 +140,7 @@ rss_char_data(void *user_data, const XML_Char *s, int len)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
rss_open_stream(InputStreamPtr &&is)
|
rss_open_stream(InputStreamPtr &&is)
|
||||||
{
|
{
|
||||||
RssParser parser;
|
RssParser parser;
|
||||||
|
@ -153,7 +153,7 @@ rss_open_stream(InputStreamPtr &&is)
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.songs.reverse();
|
parser.songs.reverse();
|
||||||
return new MemorySongEnumerator(std::move(parser.songs));
|
return std::make_unique<MemorySongEnumerator>(std::move(parser.songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const rss_suffixes[] = {
|
static const char *const rss_suffixes[] = {
|
||||||
|
|
|
@ -234,7 +234,7 @@ soundcloud_parse_json(const char *url, Yajl::Handle &handle,
|
||||||
* soundcloud://playlist/<playlist-id>
|
* soundcloud://playlist/<playlist-id>
|
||||||
* soundcloud://url/<url or path of soundcloud page>
|
* soundcloud://url/<url or path of soundcloud page>
|
||||||
*/
|
*/
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
assert(strncmp(uri, "soundcloud://", 13) == 0);
|
assert(strncmp(uri, "soundcloud://", 13) == 0);
|
||||||
|
@ -280,7 +280,7 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
||||||
soundcloud_parse_json(u, handle, mutex, cond);
|
soundcloud_parse_json(u, handle, mutex, cond);
|
||||||
|
|
||||||
data.songs.reverse();
|
data.songs.reverse();
|
||||||
return new MemorySongEnumerator(std::move(data.songs));
|
return std::make_unique<MemorySongEnumerator>(std::move(data.songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const soundcloud_schemes[] = {
|
static const char *const soundcloud_schemes[] = {
|
||||||
|
|
|
@ -187,7 +187,7 @@ xspf_char_data(void *user_data, const XML_Char *s, int len)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static SongEnumerator *
|
static std::unique_ptr<SongEnumerator>
|
||||||
xspf_open_stream(InputStreamPtr &&is)
|
xspf_open_stream(InputStreamPtr &&is)
|
||||||
{
|
{
|
||||||
XspfParser parser;
|
XspfParser parser;
|
||||||
|
@ -200,7 +200,7 @@ xspf_open_stream(InputStreamPtr &&is)
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.songs.reverse();
|
parser.songs.reverse();
|
||||||
return new MemorySongEnumerator(std::move(parser.songs));
|
return std::make_unique<MemorySongEnumerator>(std::move(parser.songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const xspf_suffixes[] = {
|
static const char *const xspf_suffixes[] = {
|
||||||
|
|
|
@ -117,7 +117,7 @@ try {
|
||||||
|
|
||||||
/* deinitialize everything */
|
/* deinitialize everything */
|
||||||
|
|
||||||
delete playlist;
|
playlist.reset();
|
||||||
is.reset();
|
is.reset();
|
||||||
|
|
||||||
decoder_plugin_deinit_all();
|
decoder_plugin_deinit_all();
|
||||||
|
|
Loading…
Reference in New Issue