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
9a350acf
Commit
9a350acf
authored
Mar 02, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input_plugin: added methods init(), finish()
Instead of hard-coding the plugin global initialization in input_stream_global_init(), make it walk the plugin list and initialize all plugins.
parent
36d24fb7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
13 deletions
+35
-13
curl_input_plugin.c
src/input/curl_input_plugin.c
+12
-3
curl_input_plugin.h
src/input/curl_input_plugin.h
+0
-4
input_plugin.h
src/input_plugin.h
+14
-0
input_stream.c
src/input_stream.c
+9
-6
No files found.
src/input/curl_input_plugin.c
View file @
9a350acf
...
...
@@ -91,17 +91,23 @@ struct input_curl {
/** libcurl should accept "ICY 200 OK" */
static
struct
curl_slist
*
http_200_aliases
;
void
input_curl_global_init
(
void
)
static
bool
input_curl_init
(
void
)
{
CURLcode
code
=
curl_global_init
(
CURL_GLOBAL_ALL
);
if
(
code
!=
CURLE_OK
)
if
(
code
!=
CURLE_OK
)
{
g_warning
(
"curl_global_init() failed: %s
\n
"
,
curl_easy_strerror
(
code
));
return
false
;
}
http_200_aliases
=
curl_slist_append
(
http_200_aliases
,
"ICY 200 OK"
);
return
true
;
}
void
input_curl_global_finish
(
void
)
static
void
input_curl_finish
(
void
)
{
curl_slist_free_all
(
http_200_aliases
);
...
...
@@ -948,6 +954,9 @@ input_curl_open(struct input_stream *is, const char *url)
}
const
struct
input_plugin
input_plugin_curl
=
{
.
init
=
input_curl_init
,
.
finish
=
input_curl_finish
,
.
open
=
input_curl_open
,
.
close
=
input_curl_close
,
.
tag
=
input_curl_tag
,
...
...
src/input/curl_input_plugin.h
View file @
9a350acf
...
...
@@ -21,8 +21,4 @@
extern
const
struct
input_plugin
input_plugin_curl
;
void
input_curl_global_init
(
void
);
void
input_curl_global_finish
(
void
);
#endif
src/input_plugin.h
View file @
9a350acf
...
...
@@ -28,6 +28,20 @@
struct
input_stream
;
struct
input_plugin
{
/**
* Global initialization. This method is called when MPD starts.
*
* @return true on success, false if the plugin should be
* disabled
*/
bool
(
*
init
)(
void
);
/**
* Global deinitialization. Called once before MPD shuts
* down (only if init() has returned true).
*/
void
(
*
finish
)(
void
);
bool
(
*
open
)(
struct
input_stream
*
is
,
const
char
*
url
);
void
(
*
close
)(
struct
input_stream
*
is
);
...
...
src/input_stream.c
View file @
9a350acf
...
...
@@ -49,21 +49,24 @@ static const struct input_plugin *const input_plugins[] = {
#endif
};
static
bool
input_plugins_enabled
[
G_N_ELEMENTS
(
input_plugins
)];
static
const
unsigned
num_input_plugins
=
sizeof
(
input_plugins
)
/
sizeof
(
input_plugins
[
0
]);
void
input_stream_global_init
(
void
)
{
#ifdef HAVE_CURL
input_curl_global_init
();
#endif
for
(
unsigned
i
=
0
;
i
<
num_input_plugins
;
++
i
)
if
(
input_plugins
[
i
]
->
init
==
NULL
||
input_plugins
[
i
]
->
init
())
input_plugins_enabled
[
i
]
=
true
;
}
void
input_stream_global_finish
(
void
)
{
#ifdef HAVE_CURL
input_curl_global_finish
();
#endif
for
(
unsigned
i
=
0
;
i
<
num_input_plugins
;
++
i
)
if
(
input_plugins_enabled
[
i
]
&&
input_plugins
[
i
]
->
finish
!=
NULL
)
input_plugins
[
i
]
->
finish
();
}
bool
...
...
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