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
3e3c5242
Commit
3e3c5242
authored
Feb 15, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder_plugin: added inline wrapper functions
Increase code readability, always use the wrapper functions instead of calling the plugin method pointers directly.
parent
a2828707
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
5 deletions
+62
-5
decoder_list.c
src/decoder_list.c
+5
-3
decoder_plugin.h
src/decoder_plugin.h
+55
-0
decoder_thread.c
src/decoder_thread.c
+2
-2
No files found.
src/decoder_list.c
View file @
3e3c5242
...
...
@@ -189,7 +189,8 @@ void decoder_plugin_init_all(void)
{
for
(
unsigned
i
=
0
;
i
<
num_decoder_plugins
;
++
i
)
{
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
if
(
plugin
->
init
==
NULL
||
decoder_plugins
[
i
]
->
init
())
if
(
decoder_plugin_init
(
plugin
))
decoder_plugins_enabled
[
i
]
=
true
;
}
}
...
...
@@ -198,7 +199,8 @@ void decoder_plugin_deinit_all(void)
{
for
(
unsigned
i
=
0
;
i
<
num_decoder_plugins
;
++
i
)
{
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
if
(
decoder_plugins_enabled
[
i
]
&&
plugin
->
finish
!=
NULL
)
decoder_plugins
[
i
]
->
finish
();
if
(
decoder_plugins_enabled
[
i
])
decoder_plugin_finish
(
plugin
);
}
}
src/decoder_plugin.h
View file @
3e3c5242
...
...
@@ -20,6 +20,7 @@
#define MPD_DECODER_PLUGIN_H
#include <stdbool.h>
#include <stddef.h>
struct
input_stream
;
struct
tag
;
...
...
@@ -77,4 +78,58 @@ struct decoder_plugin {
const
char
*
const
*
mime_types
;
};
/**
* Initialize a decoder plugin.
*
* @return true if the plugin was initialized successfully, false if
* the plugin is not available
*/
static
inline
bool
decoder_plugin_init
(
const
struct
decoder_plugin
*
plugin
)
{
return
plugin
->
init
!=
NULL
?
plugin
->
init
()
:
true
;
}
/**
* Deinitialize a decoder plugin which was initialized successfully.
*/
static
inline
void
decoder_plugin_finish
(
const
struct
decoder_plugin
*
plugin
)
{
if
(
plugin
->
finish
!=
NULL
)
plugin
->
finish
();
}
/**
* Decode a stream.
*/
static
inline
void
decoder_plugin_stream_decode
(
const
struct
decoder_plugin
*
plugin
,
struct
decoder
*
decoder
,
struct
input_stream
*
is
)
{
plugin
->
stream_decode
(
decoder
,
is
);
}
/**
* Decode a file.
*/
static
inline
void
decoder_plugin_file_decode
(
const
struct
decoder_plugin
*
plugin
,
struct
decoder
*
decoder
,
const
char
*
path_fs
)
{
plugin
->
file_decode
(
decoder
,
path_fs
);
}
/**
* Read the tag of a file.
*/
static
inline
struct
tag
*
decoder_plugin_tag_dup
(
const
struct
decoder_plugin
*
plugin
,
const
char
*
path_fs
)
{
return
plugin
->
tag_dup
(
path_fs
);
}
#endif
src/decoder_thread.c
View file @
3e3c5242
...
...
@@ -50,7 +50,7 @@ decoder_stream_decode(const struct decoder_plugin *plugin,
/* rewind the stream, so each plugin gets a fresh start */
input_stream_seek
(
input_stream
,
0
,
SEEK_SET
);
plugin
->
stream_decode
(
decoder
,
input_stream
);
decoder_plugin_stream_decode
(
plugin
,
decoder
,
input_stream
);
assert
(
dc
.
state
==
DECODE_STATE_START
||
dc
.
state
==
DECODE_STATE_DECODE
);
...
...
@@ -71,7 +71,7 @@ decoder_file_decode(const struct decoder_plugin *plugin,
assert
(
path
[
0
]
==
'/'
);
assert
(
dc
.
state
==
DECODE_STATE_START
);
plugin
->
file_decode
(
decoder
,
path
);
decoder_plugin_file_decode
(
plugin
,
decoder
,
path
);
assert
(
dc
.
state
==
DECODE_STATE_START
||
dc
.
state
==
DECODE_STATE_DECODE
);
...
...
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