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
5d55b456
Commit
5d55b456
authored
Nov 07, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder_list: pass previous plugin pointer to lookup functions
Remove the static integer hack, that's not thread safe and sucks.
parent
e3da174f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
19 deletions
+40
-19
decoder_list.c
src/decoder_list.c
+25
-10
decoder_list.h
src/decoder_list.h
+9
-1
decoder_thread.c
src/decoder_thread.c
+4
-6
song_update.c
src/song_update.c
+2
-2
No files found.
src/decoder_list.c
View file @
5d55b456
...
...
@@ -107,23 +107,38 @@ enum {
/** which plugins have been initialized successfully? */
static
bool
decoder_plugins_enabled
[
num_decoder_plugins
];
const
struct
decoder_plugin
*
decoder_plugin_
from_suffix
(
const
char
*
suffix
,
unsigned
int
next
)
static
unsigned
decoder_plugin_
index
(
const
struct
decoder_plugin
*
plugin
)
{
static
unsigned
i
=
num_decoder_plugins
;
unsigned
i
=
0
;
while
(
decoder_plugins
[
i
]
!=
plugin
)
++
i
;
return
i
;
}
static
unsigned
decoder_plugin_next_index
(
const
struct
decoder_plugin
*
plugin
)
{
return
plugin
==
0
?
0
/* start with first plugin */
:
decoder_plugin_index
(
plugin
)
+
1
;
}
const
struct
decoder_plugin
*
decoder_plugin_from_suffix
(
const
char
*
suffix
,
const
struct
decoder_plugin
*
plugin
)
{
if
(
suffix
==
NULL
)
return
NULL
;
if
(
!
next
)
i
=
0
;
for
(;
decoder_plugins
[
i
]
!=
NULL
;
++
i
)
{
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
for
(
unsigned
i
=
decoder_plugin_next_index
(
plugin
);
decoder_plugins
[
i
]
!=
NULL
;
++
i
)
{
plugin
=
decoder_plugins
[
i
];
if
(
decoder_plugins_enabled
[
i
]
&&
decoder_plugin_supports_suffix
(
plugin
,
suffix
))
{
++
i
;
decoder_plugin_supports_suffix
(
plugin
,
suffix
))
return
plugin
;
}
}
return
NULL
;
...
...
src/decoder_list.h
View file @
5d55b456
...
...
@@ -26,8 +26,16 @@ struct decoder_plugin;
/* 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 NULL to find the first plugin
* @return a plugin, or NULL if none matches
*/
const
struct
decoder_plugin
*
decoder_plugin_from_suffix
(
const
char
*
suffix
,
unsigned
int
next
);
decoder_plugin_from_suffix
(
const
char
*
suffix
,
const
struct
decoder_plugin
*
plugin
);
const
struct
decoder_plugin
*
decoder_plugin_from_mime_type
(
const
char
*
mimeType
,
unsigned
int
next
);
...
...
src/decoder_thread.c
View file @
5d55b456
...
...
@@ -118,13 +118,12 @@ decoder_run_stream_suffix(struct decoder *decoder, struct input_stream *is,
const
char
*
uri
)
{
const
char
*
suffix
=
uri_get_suffix
(
uri
);
const
struct
decoder_plugin
*
plugin
;
unsigned
int
next
=
0
;
const
struct
decoder_plugin
*
plugin
=
NULL
;
if
(
suffix
==
NULL
)
return
false
;
while
((
plugin
=
decoder_plugin_from_suffix
(
suffix
,
next
++
))
)
while
((
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
))
!=
NULL
)
if
(
plugin
->
stream_decode
!=
NULL
&&
decoder_stream_decode
(
plugin
,
decoder
,
is
))
return
true
;
...
...
@@ -212,15 +211,14 @@ static bool
decoder_run_file
(
struct
decoder
*
decoder
,
const
char
*
path_fs
)
{
const
char
*
suffix
=
uri_get_suffix
(
path_fs
);
const
struct
decoder_plugin
*
plugin
;
unsigned
int
next
=
0
;
const
struct
decoder_plugin
*
plugin
=
NULL
;
if
(
suffix
==
NULL
)
return
false
;
decoder_unlock
(
decoder
->
dc
);
while
((
plugin
=
decoder_plugin_from_suffix
(
suffix
,
next
++
))
)
{
while
((
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
))
!=
NULL
)
{
if
(
plugin
->
file_decode
!=
NULL
)
{
decoder_lock
(
decoder
->
dc
);
...
...
src/song_update.c
View file @
5d55b456
...
...
@@ -107,7 +107,7 @@ song_file_update(struct song *song)
if
(
suffix
==
NULL
)
return
false
;
plugin
=
decoder_plugin_from_suffix
(
suffix
,
false
);
plugin
=
decoder_plugin_from_suffix
(
suffix
,
NULL
);
if
(
plugin
==
NULL
)
return
false
;
...
...
@@ -132,7 +132,7 @@ song_file_update(struct song *song)
if
(
song
->
tag
!=
NULL
)
break
;
plugin
=
decoder_plugin_from_suffix
(
suffix
,
true
);
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
);
}
while
(
plugin
!=
NULL
);
if
(
song
->
tag
!=
NULL
&&
tag_is_empty
(
song
->
tag
))
...
...
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