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
df4db509
Commit
df4db509
authored
Dec 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecoderList: add function decoder_plugins_supports_suffix()
Replaces decoder_plugin_from_suffix().
parent
decc4002
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
54 deletions
+20
-54
DecoderList.cxx
src/DecoderList.cxx
+8
-37
DecoderList.hxx
src/DecoderList.hxx
+10
-11
SongUpdate.cxx
src/SongUpdate.cxx
+1
-3
UpdateSong.cxx
src/UpdateSong.cxx
+1
-3
No files found.
src/DecoderList.cxx
View file @
df4db509
...
@@ -118,43 +118,6 @@ static constexpr unsigned num_decoder_plugins =
...
@@ -118,43 +118,6 @@ static constexpr unsigned num_decoder_plugins =
/** which plugins have been initialized successfully? */
/** which plugins have been initialized successfully? */
bool
decoder_plugins_enabled
[
num_decoder_plugins
];
bool
decoder_plugins_enabled
[
num_decoder_plugins
];
static
unsigned
decoder_plugin_index
(
const
struct
DecoderPlugin
*
plugin
)
{
unsigned
i
=
0
;
while
(
decoder_plugins
[
i
]
!=
plugin
)
++
i
;
return
i
;
}
static
unsigned
decoder_plugin_next_index
(
const
struct
DecoderPlugin
*
plugin
)
{
return
plugin
==
0
?
0
/* start with first plugin */
:
decoder_plugin_index
(
plugin
)
+
1
;
}
const
struct
DecoderPlugin
*
decoder_plugin_from_suffix
(
const
char
*
suffix
,
const
struct
DecoderPlugin
*
plugin
)
{
if
(
suffix
==
nullptr
)
return
nullptr
;
for
(
unsigned
i
=
decoder_plugin_next_index
(
plugin
);
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
plugin
=
decoder_plugins
[
i
];
if
(
decoder_plugins_enabled
[
i
]
&&
plugin
->
SupportsSuffix
(
suffix
))
return
plugin
;
}
return
nullptr
;
}
const
struct
DecoderPlugin
*
const
struct
DecoderPlugin
*
decoder_plugin_from_name
(
const
char
*
name
)
decoder_plugin_from_name
(
const
char
*
name
)
{
{
...
@@ -213,3 +176,11 @@ void decoder_plugin_deinit_all(void)
...
@@ -213,3 +176,11 @@ void decoder_plugin_deinit_all(void)
plugin
.
Finish
();
plugin
.
Finish
();
});
});
}
}
bool
decoder_plugins_supports_suffix
(
const
char
*
suffix
)
{
return
decoder_plugins_try
([
suffix
](
const
DecoderPlugin
&
plugin
){
return
plugin
.
SupportsSuffix
(
suffix
);
});
}
src/DecoderList.hxx
View file @
df4db509
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
#ifndef MPD_DECODER_LIST_HXX
#ifndef MPD_DECODER_LIST_HXX
#define MPD_DECODER_LIST_HXX
#define MPD_DECODER_LIST_HXX
#include "Compiler.h"
struct
DecoderPlugin
;
struct
DecoderPlugin
;
extern
const
struct
DecoderPlugin
*
const
decoder_plugins
[];
extern
const
struct
DecoderPlugin
*
const
decoder_plugins
[];
...
@@ -27,17 +29,6 @@ extern bool decoder_plugins_enabled[];
...
@@ -27,17 +29,6 @@ extern bool decoder_plugins_enabled[];
/* interface for using plugins */
/* interface for using plugins */
/**
* Find the next enabled decoder plugin which supports the specified suffix.
*
* @param suffix the file name suffix
* @param plugin the previous plugin, or nullptr to find the first plugin
* @return a plugin, or nullptr if none matches
*/
const
struct
DecoderPlugin
*
decoder_plugin_from_suffix
(
const
char
*
suffix
,
const
struct
DecoderPlugin
*
plugin
);
const
struct
DecoderPlugin
*
const
struct
DecoderPlugin
*
decoder_plugin_from_name
(
const
char
*
name
);
decoder_plugin_from_name
(
const
char
*
name
);
...
@@ -86,4 +77,12 @@ decoder_plugins_for_each_enabled(F f)
...
@@ -86,4 +77,12 @@ decoder_plugins_for_each_enabled(F f)
f
(
*
decoder_plugins
[
i
]);
f
(
*
decoder_plugins
[
i
]);
}
}
/**
* Is there at least once #DecoderPlugin that supports the specified
* file name suffix?
*/
gcc_pure
gcc_nonnull_all
bool
decoder_plugins_supports_suffix
(
const
char
*
suffix
);
#endif
#endif
src/SongUpdate.cxx
View file @
df4db509
...
@@ -107,7 +107,6 @@ bool
...
@@ -107,7 +107,6 @@ bool
Song
::
UpdateFileInArchive
()
Song
::
UpdateFileInArchive
()
{
{
const
char
*
suffix
;
const
char
*
suffix
;
const
struct
DecoderPlugin
*
plugin
;
assert
(
IsFile
());
assert
(
IsFile
());
...
@@ -117,8 +116,7 @@ Song::UpdateFileInArchive()
...
@@ -117,8 +116,7 @@ Song::UpdateFileInArchive()
if
(
suffix
==
nullptr
)
if
(
suffix
==
nullptr
)
return
false
;
return
false
;
plugin
=
decoder_plugin_from_suffix
(
suffix
,
nullptr
);
if
(
!
decoder_plugins_supports_suffix
(
suffix
))
if
(
plugin
==
nullptr
)
return
false
;
return
false
;
delete
tag
;
delete
tag
;
...
...
src/UpdateSong.cxx
View file @
df4db509
...
@@ -105,9 +105,7 @@ update_song_file(Directory &directory,
...
@@ -105,9 +105,7 @@ update_song_file(Directory &directory,
const
char
*
name
,
const
char
*
suffix
,
const
char
*
name
,
const
char
*
suffix
,
const
struct
stat
*
st
)
const
struct
stat
*
st
)
{
{
const
struct
DecoderPlugin
*
plugin
=
if
(
!
decoder_plugins_supports_suffix
(
suffix
))
decoder_plugin_from_suffix
(
suffix
,
nullptr
);
if
(
plugin
==
nullptr
)
return
false
;
return
false
;
update_song_file2
(
directory
,
name
,
st
,
suffix
);
update_song_file2
(
directory
,
name
,
st
,
suffix
);
...
...
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