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
13e9f184
Commit
13e9f184
authored
Oct 21, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecoderPlugin: move functions into the struct
parent
875821f2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
119 deletions
+90
-119
DecoderList.cxx
src/DecoderList.cxx
+4
-4
DecoderPlugin.cxx
src/DecoderPlugin.cxx
+5
-8
DecoderPlugin.hxx
src/DecoderPlugin.hxx
+69
-91
DecoderThread.cxx
src/DecoderThread.cxx
+2
-2
TagFile.cxx
src/TagFile.cxx
+4
-5
UpdateContainer.cxx
src/UpdateContainer.cxx
+2
-2
read_tags.cxx
test/read_tags.cxx
+2
-4
run_decoder.cxx
test/run_decoder.cxx
+2
-3
No files found.
src/DecoderList.cxx
View file @
13e9f184
...
...
@@ -148,7 +148,7 @@ decoder_plugin_from_suffix(const char *suffix,
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
plugin
=
decoder_plugins
[
i
];
if
(
decoder_plugins_enabled
[
i
]
&&
decoder_plugin_supports_suffix
(
*
plugin
,
suffix
))
plugin
->
SupportsSuffix
(
suffix
))
return
plugin
;
}
...
...
@@ -168,7 +168,7 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
for
(;
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
const
struct
DecoderPlugin
*
plugin
=
decoder_plugins
[
i
];
if
(
decoder_plugins_enabled
[
i
]
&&
decoder_plugin_supports_mime_type
(
*
plugin
,
mimeType
))
{
plugin
->
SupportsMimeType
(
mimeType
))
{
++
i
;
return
plugin
;
}
...
...
@@ -226,7 +226,7 @@ void decoder_plugin_init_all(void)
/* the plugin is disabled in mpd.conf */
continue
;
if
(
decoder_plugin_init
(
plugin
,
*
param
))
if
(
plugin
.
Init
(
*
param
))
decoder_plugins_enabled
[
i
]
=
true
;
}
}
...
...
@@ -234,5 +234,5 @@ void decoder_plugin_init_all(void)
void
decoder_plugin_deinit_all
(
void
)
{
decoder_plugins_for_each_enabled
(
plugin
)
decoder_plugin_finish
(
*
plugin
);
plugin
->
Finish
(
);
}
src/DecoderPlugin.cxx
View file @
13e9f184
...
...
@@ -24,22 +24,19 @@
#include <assert.h>
bool
decoder_plugin_supports_suffix
(
const
DecoderPlugin
&
plugin
,
const
char
*
suffix
)
DecoderPlugin
::
SupportsSuffix
(
const
char
*
suffix
)
const
{
assert
(
suffix
!=
nullptr
);
return
plugin
.
suffixes
!=
nullptr
&&
string_array_contains
(
plugin
.
suffixes
,
suffix
);
return
suffixes
!=
nullptr
&&
string_array_contains
(
suffixes
,
suffix
);
}
bool
decoder_plugin_supports_mime_type
(
const
DecoderPlugin
&
plugin
,
const
char
*
mime_type
)
DecoderPlugin
::
SupportsMimeType
(
const
char
*
mime_type
)
const
{
assert
(
mime_type
!=
nullptr
);
return
plugin
.
mime_types
!=
nullptr
&&
string_array_contains
(
plugin
.
mime_types
,
mime_type
);
return
mime_types
!=
nullptr
&&
string_array_contains
(
mime_types
,
mime_type
);
}
src/DecoderPlugin.hxx
View file @
13e9f184
...
...
@@ -20,6 +20,8 @@
#ifndef MPD_DECODER_PLUGIN_HXX
#define MPD_DECODER_PLUGIN_HXX
#include "Compiler.h"
struct
config_param
;
struct
input_stream
;
struct
Tag
;
...
...
@@ -100,105 +102,81 @@ struct DecoderPlugin {
/* last element in these arrays must always be a nullptr: */
const
char
*
const
*
suffixes
;
const
char
*
const
*
mime_types
;
};
/**
* Initialize a decoder plugin.
*
* @param param a configuration block for this plugin, or nullptr if none
* is configured
* @return true if the plugin was initialized successfully, false if
* the plugin is not available
*/
static
inline
bool
decoder_plugin_init
(
const
DecoderPlugin
&
plugin
,
const
config_param
&
param
)
{
return
plugin
.
init
!=
nullptr
?
plugin
.
init
(
param
)
:
true
;
}
/**
* Initialize a decoder plugin.
*
* @param param a configuration block for this plugin, or nullptr if none
* is configured
* @return true if the plugin was initialized successfully, false if
* the plugin is not available
*/
bool
Init
(
const
config_param
&
param
)
const
{
return
init
!=
nullptr
?
init
(
param
)
:
true
;
}
/**
* Deinitialize a decoder plugin which was initialized successfully.
*/
static
inline
void
decoder_plugin_finish
(
const
DecoderPlugin
&
plugin
)
{
if
(
plugin
.
finish
!=
nullptr
)
plugin
.
finish
();
}
/**
* Deinitialize a decoder plugin which was initialized successfully.
*/
void
Finish
()
const
{
if
(
finish
!=
nullptr
)
finish
();
}
/**
* Decode a stream.
*/
static
inline
void
decoder_plugin_stream_decode
(
const
DecoderPlugin
&
plugin
,
struct
decoder
*
decoder
,
struct
input_stream
*
is
)
{
plugin
.
stream_decode
(
decoder
,
is
);
}
/**
* Decode a stream.
*/
void
StreamDecode
(
decoder
&
decoder
,
input_stream
&
is
)
const
{
stream_decode
(
&
decoder
,
&
is
);
}
/**
* Decode a file.
*/
static
inline
void
decoder_plugin_file_decode
(
const
DecoderPlugin
&
plugin
,
struct
decoder
*
decoder
,
const
char
*
path_fs
)
{
plugin
.
file_decode
(
decoder
,
path_fs
);
}
/**
* Decode a file.
*/
void
FileDecode
(
decoder
&
decoder
,
const
char
*
path_fs
)
const
{
file_decode
(
&
decoder
,
path_fs
);
}
/**
* Read the tag of a file.
*/
static
inline
bool
decoder_plugin_scan_file
(
const
DecoderPlugin
&
plugin
,
const
char
*
path_fs
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
return
plugin
.
scan_file
!=
nullptr
?
plugin
.
scan_file
(
path_fs
,
handler
,
handler_ctx
)
:
false
;
}
/**
* Read the tag of a file.
*/
bool
ScanFile
(
const
char
*
path_fs
,
const
tag_handler
&
handler
,
void
*
handler_ctx
)
const
{
return
scan_file
!=
nullptr
?
scan_file
(
path_fs
,
&
handler
,
handler_ctx
)
:
false
;
}
/**
* Read the tag of a stream.
*/
static
inline
bool
decoder_plugin_scan_stream
(
const
DecoderPlugin
&
plugin
,
struct
input_stream
*
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
return
plugin
.
scan_stream
!=
nullptr
?
plugin
.
scan_stream
(
is
,
handler
,
handler_ctx
)
:
false
;
}
/**
* Read the tag of a stream.
*/
bool
ScanStream
(
input_stream
&
is
,
const
tag_handler
&
handler
,
void
*
handler_ctx
)
const
{
return
scan_stream
!=
nullptr
?
scan_stream
(
&
is
,
&
handler
,
handler_ctx
)
:
false
;
}
/**
* return "virtual" tracks in a container
*/
static
inline
char
*
decoder_plugin_container_scan
(
const
DecoderPlugin
&
plugin
,
const
char
*
pathname
,
const
unsigned
int
tnum
)
{
return
plugin
.
container_scan
(
pathname
,
tnum
);
}
/**
* return "virtual" tracks in a container
*/
char
*
ContainerScan
(
const
char
*
path
,
const
unsigned
int
tnum
)
const
{
return
container_scan
(
path
,
tnum
);
}
/**
* Does the plugin announce the specified file name suffix?
*/
bool
decoder_plugin_supports_suffix
(
const
DecoderPlugin
&
plugin
,
const
char
*
suffix
);
/**
* Does the plugin announce the specified file name suffix?
*/
gcc_pure
gcc_nonnull_all
bool
SupportsSuffix
(
const
char
*
suffix
)
const
;
/**
* Does the plugin announce the specified MIME type?
*/
boo
l
decoder_plugin_supports_mime_type
(
const
DecoderPlugin
&
plugin
,
const
char
*
mime_type
)
;
/**
* Does the plugin announce the specified MIME type?
*/
gcc_pure
gcc_nonnull_al
l
bool
SupportsMimeType
(
const
char
*
mime_type
)
const
;
}
;
#endif
src/DecoderThread.cxx
View file @
13e9f184
...
...
@@ -133,7 +133,7 @@ decoder_stream_decode(const DecoderPlugin &plugin,
decoder
->
dc
.
Unlock
();
decoder_plugin_stream_decode
(
plugin
,
decoder
,
input_stream
);
plugin
.
StreamDecode
(
*
decoder
,
*
input_stream
);
decoder
->
dc
.
Lock
();
...
...
@@ -162,7 +162,7 @@ decoder_file_decode(const DecoderPlugin &plugin,
decoder
->
dc
.
Unlock
();
decoder_plugin_file_decode
(
plugin
,
decoder
,
path
);
plugin
.
FileDecode
(
*
decoder
,
path
);
decoder
->
dc
.
Lock
();
...
...
src/TagFile.cxx
View file @
13e9f184
...
...
@@ -53,8 +53,8 @@ tag_file_scan(const char *path_fs,
do
{
/* load file tag */
if
(
decoder_plugin_scan_file
(
*
plugin
,
path_fs
,
handler
,
handler_ctx
))
if
(
plugin
->
ScanFile
(
path_fs
,
*
handler
,
handler_ctx
))
break
;
/* fall back to stream tag */
...
...
@@ -67,9 +67,8 @@ tag_file_scan(const char *path_fs,
/* now try the stream_tag() method */
if
(
is
!=
nullptr
)
{
if
(
decoder_plugin_scan_stream
(
*
plugin
,
is
,
handler
,
handler_ctx
))
if
(
plugin
->
ScanStream
(
*
is
,
*
handler
,
handler_ctx
))
break
;
is
->
LockSeek
(
0
,
SEEK_SET
,
IgnoreError
());
...
...
src/UpdateContainer.cxx
View file @
13e9f184
...
...
@@ -98,8 +98,8 @@ update_container_file(Directory &directory,
const
auto
child_path_fs
=
map_directory_child_fs
(
*
contdir
,
vtrack
);
decoder_plugin_scan_file
(
plugin
,
child_path_fs
.
c_str
(),
&
add_tag_handler
,
&
tag_builder
);
plugin
.
ScanFile
(
child_path_fs
.
c_str
(),
add_tag_handler
,
&
tag_builder
);
if
(
tag_builder
.
IsDefined
())
song
->
tag
=
tag_builder
.
Commit
();
...
...
test/read_tags.cxx
View file @
13e9f184
...
...
@@ -181,8 +181,7 @@ int main(int argc, char **argv)
return
1
;
}
bool
success
=
decoder_plugin_scan_file
(
*
plugin
,
path
,
&
print_handler
,
NULL
);
bool
success
=
plugin
->
ScanFile
(
path
,
print_handler
,
nullptr
);
if
(
!
success
&&
plugin
->
scan_stream
!=
NULL
)
{
Mutex
mutex
;
Cond
cond
;
...
...
@@ -209,8 +208,7 @@ int main(int argc, char **argv)
mutex
.
unlock
();
success
=
decoder_plugin_scan_stream
(
*
plugin
,
is
,
&
print_handler
,
NULL
);
success
=
plugin
->
ScanStream
(
*
is
,
print_handler
,
nullptr
);
is
->
Close
();
}
...
...
test/run_decoder.cxx
View file @
13e9f184
...
...
@@ -184,8 +184,7 @@ int main(int argc, char **argv)
decoder
.
initialized
=
false
;
if
(
decoder
.
plugin
->
file_decode
!=
NULL
)
{
decoder_plugin_file_decode
(
*
decoder
.
plugin
,
&
decoder
,
decoder
.
uri
);
decoder
.
plugin
->
FileDecode
(
decoder
,
decoder
.
uri
);
}
else
if
(
decoder
.
plugin
->
stream_decode
!=
NULL
)
{
Mutex
mutex
;
Cond
cond
;
...
...
@@ -201,7 +200,7 @@ int main(int argc, char **argv)
return
1
;
}
decoder
_plugin_stream_decode
(
*
decoder
.
plugin
,
&
decoder
,
is
);
decoder
.
plugin
->
StreamDecode
(
decoder
,
*
is
);
is
->
Close
();
}
else
{
...
...
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