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
cfb350f4
Commit
cfb350f4
authored
Mar 02, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input: pass config_param to input_plugin.init()
Allow input plugins to configure with an "input" block in mpd.conf. Also allow the user to disable a plugin completely.
parent
9a350acf
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
7 deletions
+50
-7
conf.c
src/conf.c
+1
-0
conf.h
src/conf.h
+1
-0
archive_input_plugin.c
src/input/archive_input_plugin.c
+1
-0
curl_input_plugin.c
src/input/curl_input_plugin.c
+2
-1
file_input_plugin.c
src/input/file_input_plugin.c
+1
-0
mms_input_plugin.c
src/input/mms_input_plugin.c
+1
-0
input_plugin.h
src/input_plugin.h
+4
-1
input_stream.c
src/input_stream.c
+39
-5
No files found.
src/conf.c
View file @
cfb350f4
...
...
@@ -214,6 +214,7 @@ void config_global_init(void)
registerConfigParam
(
CONF_METADATA_TO_USE
,
0
,
0
);
registerConfigParam
(
CONF_SAVE_ABSOLUTE_PATHS
,
0
,
0
);
registerConfigParam
(
CONF_DECODER
,
true
,
true
);
registerConfigParam
(
CONF_INPUT
,
true
,
true
);
registerConfigParam
(
CONF_GAPLESS_MP3_PLAYBACK
,
0
,
0
);
}
...
...
src/conf.h
View file @
cfb350f4
...
...
@@ -65,6 +65,7 @@
#define CONF_METADATA_TO_USE "metadata_to_use"
#define CONF_SAVE_ABSOLUTE_PATHS "save_absolute_paths_in_playlists"
#define CONF_DECODER "decoder"
#define CONF_INPUT "input"
#define CONF_GAPLESS_MP3_PLAYBACK "gapless_mp3_playback"
#define CONF_BOOL_UNSET -1
...
...
src/input/archive_input_plugin.c
View file @
cfb350f4
...
...
@@ -73,5 +73,6 @@ input_archive_open(struct input_stream *is, const char *pathname)
}
const
struct
input_plugin
input_plugin_archive
=
{
.
name
=
"archive"
,
.
open
=
input_archive_open
,
};
src/input/curl_input_plugin.c
View file @
cfb350f4
...
...
@@ -92,7 +92,7 @@ struct input_curl {
static
struct
curl_slist
*
http_200_aliases
;
static
bool
input_curl_init
(
void
)
input_curl_init
(
G_GNUC_UNUSED
const
struct
config_param
*
param
)
{
CURLcode
code
=
curl_global_init
(
CURL_GLOBAL_ALL
);
if
(
code
!=
CURLE_OK
)
{
...
...
@@ -954,6 +954,7 @@ input_curl_open(struct input_stream *is, const char *url)
}
const
struct
input_plugin
input_plugin_curl
=
{
.
name
=
"curl"
,
.
init
=
input_curl_init
,
.
finish
=
input_curl_finish
,
...
...
src/input/file_input_plugin.c
View file @
cfb350f4
...
...
@@ -121,6 +121,7 @@ input_file_eof(struct input_stream *is)
}
const
struct
input_plugin
input_plugin_file
=
{
.
name
=
"file"
,
.
open
=
input_file_open
,
.
close
=
input_file_close
,
.
read
=
input_file_read
,
...
...
src/input/mms_input_plugin.c
View file @
cfb350f4
...
...
@@ -115,6 +115,7 @@ input_mms_seek(G_GNUC_UNUSED struct input_stream *is,
}
const
struct
input_plugin
input_plugin_mms
=
{
.
name
=
"mms"
,
.
open
=
input_mms_open
,
.
close
=
input_mms_close
,
.
buffer
=
input_mms_buffer
,
...
...
src/input_plugin.h
View file @
cfb350f4
...
...
@@ -25,16 +25,19 @@
#include <stdbool.h>
#include <sys/types.h>
struct
config_param
;
struct
input_stream
;
struct
input_plugin
{
const
char
*
name
;
/**
* Global initialization. This method is called when MPD starts.
*
* @return true on success, false if the plugin should be
* disabled
*/
bool
(
*
init
)(
void
);
bool
(
*
init
)(
const
struct
config_param
*
param
);
/**
* Global deinitialization. Called once before MPD shuts
...
...
src/input_stream.c
View file @
cfb350f4
...
...
@@ -18,6 +18,7 @@
#include "input_plugin.h"
#include "config.h"
#include "conf.h"
#include "input/file_input_plugin.h"
...
...
@@ -35,6 +36,7 @@
#include <glib.h>
#include <assert.h>
#include <string.h>
static
const
struct
input_plugin
*
const
input_plugins
[]
=
{
&
input_plugin_file
,
...
...
@@ -54,11 +56,45 @@ static bool input_plugins_enabled[G_N_ELEMENTS(input_plugins)];
static
const
unsigned
num_input_plugins
=
sizeof
(
input_plugins
)
/
sizeof
(
input_plugins
[
0
]);
/**
* Find the "input" configuration block for the specified plugin.
*
* @param plugin_name the name of the input plugin
* @return the configuration block, or NULL if none was configured
*/
static
const
struct
config_param
*
input_plugin_config
(
const
char
*
plugin_name
)
{
const
struct
config_param
*
param
=
NULL
;
while
((
param
=
config_get_next_param
(
CONF_INPUT
,
param
))
!=
NULL
)
{
const
char
*
name
=
config_get_block_string
(
param
,
"plugin"
,
NULL
);
if
(
name
==
NULL
)
g_error
(
"input configuration without 'plugin' name in line %d"
,
param
->
line
);
if
(
strcmp
(
name
,
plugin_name
)
==
0
)
return
param
;
}
return
NULL
;
}
void
input_stream_global_init
(
void
)
{
for
(
unsigned
i
=
0
;
i
<
num_input_plugins
;
++
i
)
if
(
input_plugins
[
i
]
->
init
==
NULL
||
input_plugins
[
i
]
->
init
())
for
(
unsigned
i
=
0
;
i
<
num_input_plugins
;
++
i
)
{
const
struct
input_plugin
*
plugin
=
input_plugins
[
i
];
const
struct
config_param
*
param
=
input_plugin_config
(
plugin
->
name
);
if
(
!
config_get_block_bool
(
param
,
"enabled"
,
true
))
/* the plugin is disabled in mpd.conf */
continue
;
if
(
plugin
->
init
==
NULL
||
plugin
->
init
(
param
))
input_plugins_enabled
[
i
]
=
true
;
}
}
void
input_stream_global_finish
(
void
)
...
...
@@ -82,10 +118,8 @@ input_stream_open(struct input_stream *is, const char *url)
for
(
unsigned
i
=
0
;
i
<
num_input_plugins
;
++
i
)
{
const
struct
input_plugin
*
plugin
=
input_plugins
[
i
];
if
(
plugin
->
open
(
is
,
url
))
{
if
(
input_plugins_enabled
[
i
]
&&
plugin
->
open
(
is
,
url
))
{
assert
(
is
->
plugin
!=
NULL
);
assert
(
is
->
plugin
->
open
==
NULL
||
is
->
plugin
==
plugin
);
assert
(
is
->
plugin
->
close
!=
NULL
);
assert
(
is
->
plugin
->
read
!=
NULL
);
assert
(
is
->
plugin
->
eof
!=
NULL
);
...
...
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