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
decc4002
Commit
decc4002
authored
Dec 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecoderThread: use decoder_plugins_try()
.. instead of decoder_plugin_from_suffix(). This reduces overhead by walking the array only once.
parent
5bb563e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
32 deletions
+44
-32
DecoderThread.cxx
src/DecoderThread.cxx
+44
-32
No files found.
src/DecoderThread.cxx
View file @
decc4002
...
...
@@ -280,54 +280,66 @@ decoder_load_replay_gain(Decoder &decoder, const char *path_fs)
decoder_replay_gain
(
decoder
,
&
info
);
}
/**
* Try decoding a file.
*/
static
bool
decoder_run_file
(
Decoder
&
decoder
,
const
char
*
path_fs
)
TryDecoderFile
(
Decoder
&
decoder
,
const
char
*
path_fs
,
const
char
*
suffix
,
const
DecoderPlugin
&
plugin
)
{
if
(
!
plugin
.
SupportsSuffix
(
suffix
))
return
false
;
DecoderControl
&
dc
=
decoder
.
dc
;
const
char
*
suffix
=
uri_get_suffix
(
path_fs
);
const
struct
DecoderPlugin
*
plugin
=
nullptr
;
if
(
suffix
==
nullptr
)
return
false
;
if
(
plugin
.
file_decode
!=
nullptr
)
{
dc
.
Lock
()
;
dc
.
Unlock
();
if
(
decoder_file_decode
(
plugin
,
decoder
,
path_fs
))
return
true
;
decoder_load_replay_gain
(
decoder
,
path_fs
);
dc
.
Unlock
();
}
else
if
(
plugin
.
stream_decode
!=
nullptr
)
{
InputStream
*
input_stream
=
decoder_input_stream_open
(
dc
,
path_fs
);
if
(
input_stream
==
nullptr
)
return
false
;
while
((
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
))
!=
nullptr
)
{
if
(
plugin
->
file_decode
!=
nullptr
)
{
dc
.
Lock
();
dc
.
Lock
();
if
(
decoder_file_decode
(
*
plugin
,
decoder
,
path_fs
))
return
true
;
bool
success
=
decoder_stream_decode
(
plugin
,
decoder
,
*
input_stream
)
;
dc
.
Unlock
();
}
else
if
(
plugin
->
stream_decode
!=
nullptr
)
{
InputStream
*
input_stream
;
bool
success
;
dc
.
Unlock
();
input_stream
=
decoder_input_stream_open
(
dc
,
path_fs
);
if
(
input_stream
==
nullptr
)
continue
;
input_stream
->
Close
();
if
(
success
)
{
dc
.
Lock
();
return
true
;
}
}
success
=
decoder_stream_decode
(
*
plugin
,
decoder
,
*
input_stream
);
return
false
;
}
/**
* Try decoding a file.
*/
static
bool
decoder_run_file
(
Decoder
&
decoder
,
const
char
*
path_fs
)
{
const
char
*
suffix
=
uri_get_suffix
(
path_fs
);
if
(
suffix
==
nullptr
)
return
false
;
dc
.
Unlock
();
DecoderControl
&
dc
=
decoder
.
dc
;
dc
.
Unlock
();
input_stream
->
Close
(
);
decoder_load_replay_gain
(
decoder
,
path_fs
);
if
(
success
)
{
dc
.
Lock
();
return
true
;
}
}
}
if
(
decoder_plugins_try
([
&
decoder
,
path_fs
,
suffix
](
const
DecoderPlugin
&
plugin
){
return
TryDecoderFile
(
decoder
,
path_fs
,
suffix
,
plugin
);
}))
return
true
;
dc
.
Lock
();
return
false
;
...
...
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