Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
4d117451
Commit
4d117451
authored
Sep 02, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/Plugin: add SupportsSuffix(), SupportsMimeType()
parent
2038620b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
11 deletions
+70
-11
PlaylistPlugin.cxx
src/playlist/PlaylistPlugin.cxx
+43
-0
PlaylistPlugin.hxx
src/playlist/PlaylistPlugin.hxx
+20
-0
PlaylistRegistry.cxx
src/playlist/PlaylistRegistry.cxx
+6
-11
meson.build
src/playlist/meson.build
+1
-0
No files found.
src/playlist/PlaylistPlugin.cxx
0 → 100644
View file @
4d117451
/*
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "PlaylistPlugin.hxx"
#include "util/StringUtil.hxx"
#include "util/StringView.hxx"
bool
PlaylistPlugin
::
SupportsScheme
(
StringView
scheme
)
const
noexcept
{
return
schemes
!=
nullptr
&&
StringArrayContainsCase
(
schemes
,
scheme
);
}
bool
PlaylistPlugin
::
SupportsSuffix
(
const
char
*
suffix
)
const
noexcept
{
return
suffixes
!=
nullptr
&&
StringArrayContainsCase
(
suffixes
,
suffix
);
}
bool
PlaylistPlugin
::
SupportsMimeType
(
StringView
mime_type
)
const
noexcept
{
return
mime_types
!=
nullptr
&&
StringArrayContainsCase
(
mime_types
,
mime_type
);
}
src/playlist/PlaylistPlugin.hxx
View file @
4d117451
...
...
@@ -22,9 +22,11 @@
#include "input/Ptr.hxx"
#include "thread/Mutex.hxx"
#include "util/Compiler.h"
struct
ConfigBlock
;
struct
Tag
;
struct
StringView
;
class
SongEnumerator
;
struct
PlaylistPlugin
{
...
...
@@ -101,6 +103,24 @@ struct PlaylistPlugin {
copy
.
mime_types
=
_mime_types
;
return
copy
;
}
/**
* Does the plugin announce the specified URI scheme?
*/
gcc_pure
gcc_nonnull_all
bool
SupportsScheme
(
StringView
scheme
)
const
noexcept
;
/**
* Does the plugin announce the specified file name suffix?
*/
gcc_pure
gcc_nonnull_all
bool
SupportsSuffix
(
const
char
*
suffix
)
const
noexcept
;
/**
* Does the plugin announce the specified MIME type?
*/
gcc_pure
gcc_nonnull_all
bool
SupportsMimeType
(
StringView
mime_type
)
const
noexcept
;
};
/**
...
...
src/playlist/PlaylistRegistry.cxx
View file @
4d117451
...
...
@@ -33,7 +33,6 @@
#include "plugins/EmbeddedCuePlaylistPlugin.hxx"
#include "input/InputStream.hxx"
#include "util/MimeType.hxx"
#include "util/StringUtil.hxx"
#include "util/StringView.hxx"
#include "util/UriExtract.hxx"
#include "config/Data.hxx"
...
...
@@ -122,8 +121,7 @@ playlist_list_open_uri_scheme(const char *uri, Mutex &mutex,
assert
(
!
tried
[
i
]);
if
(
playlist_plugins_enabled
[
i
]
&&
plugin
->
open_uri
!=
nullptr
&&
plugin
->
schemes
!=
nullptr
&&
StringArrayContainsCase
(
plugin
->
schemes
,
scheme
))
{
plugin
->
SupportsScheme
(
scheme
))
{
auto
playlist
=
plugin
->
open_uri
(
uri
,
mutex
);
if
(
playlist
)
return
playlist
;
...
...
@@ -150,8 +148,8 @@ playlist_list_open_uri_suffix(const char *uri, Mutex &mutex,
const
auto
*
plugin
=
playlist_plugins
[
i
];
if
(
playlist_plugins_enabled
[
i
]
&&
!
tried
[
i
]
&&
plugin
->
open_uri
!=
nullptr
&&
plugin
->
suffixes
!=
nullptr
&&
StringArrayContainsCase
(
plugin
->
suffixes
,
suffix
))
{
plugin
->
open_uri
!=
nullptr
&&
plugin
->
SupportsSuffix
(
suffix
))
{
auto
playlist
=
plugin
->
open_uri
(
uri
,
mutex
);
if
(
playlist
!=
nullptr
)
return
playlist
;
...
...
@@ -183,8 +181,7 @@ playlist_list_open_stream_mime2(InputStreamPtr &&is, StringView mime)
{
playlist_plugins_for_each_enabled
(
plugin
)
{
if
(
plugin
->
open_stream
!=
nullptr
&&
plugin
->
mime_types
!=
nullptr
&&
StringArrayContainsCase
(
plugin
->
mime_types
,
mime
))
{
plugin
->
SupportsMimeType
(
mime
))
{
/* rewind the stream, so each plugin gets a
fresh start */
try
{
...
...
@@ -233,8 +230,7 @@ playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix)
playlist_plugins_for_each_enabled
(
plugin
)
{
if
(
plugin
->
open_stream
!=
nullptr
&&
plugin
->
suffixes
!=
nullptr
&&
StringArrayContainsCase
(
plugin
->
suffixes
,
suffix
))
{
plugin
->
SupportsSuffix
(
suffix
))
{
/* rewind the stream, so each plugin gets a
fresh start */
try
{
...
...
@@ -284,8 +280,7 @@ playlist_suffix_supported(const char *suffix) noexcept
assert
(
suffix
!=
nullptr
);
playlist_plugins_for_each_enabled
(
plugin
)
{
if
(
plugin
->
suffixes
!=
nullptr
&&
StringArrayContainsCase
(
plugin
->
suffixes
,
suffix
))
if
(
plugin
->
SupportsSuffix
(
suffix
))
return
true
;
}
...
...
src/playlist/meson.build
View file @
4d117451
playlist_api = static_library(
'playlist_api',
'PlaylistPlugin.cxx',
'MemorySongEnumerator.cxx',
include_directories: inc,
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment