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
9b69d22d
Commit
9b69d22d
authored
Feb 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecoderThread: pass Path object around for local song files
parent
4ab4cf85
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
21 deletions
+27
-21
DecoderThread.cxx
src/decoder/DecoderThread.cxx
+27
-21
No files found.
src/decoder/DecoderThread.cxx
View file @
9b69d22d
...
@@ -282,15 +282,15 @@ decoder_run_stream(Decoder &decoder, const char *uri)
...
@@ -282,15 +282,15 @@ decoder_run_stream(Decoder &decoder, const char *uri)
* decoder_replay_gain().
* decoder_replay_gain().
*/
*/
static
void
static
void
decoder_load_replay_gain
(
Decoder
&
decoder
,
const
char
*
path_fs
)
decoder_load_replay_gain
(
Decoder
&
decoder
,
Path
path_fs
)
{
{
ReplayGainInfo
info
;
ReplayGainInfo
info
;
if
(
replay_gain_ape_read
(
Path
::
FromFS
(
path_fs
)
,
info
))
if
(
replay_gain_ape_read
(
path_fs
,
info
))
decoder_replay_gain
(
decoder
,
&
info
);
decoder_replay_gain
(
decoder
,
&
info
);
}
}
static
bool
static
bool
TryDecoderFile
(
Decoder
&
decoder
,
const
char
*
path_fs
,
const
char
*
suffix
,
TryDecoderFile
(
Decoder
&
decoder
,
Path
path_fs
,
const
char
*
suffix
,
const
DecoderPlugin
&
plugin
)
const
DecoderPlugin
&
plugin
)
{
{
if
(
!
plugin
.
SupportsSuffix
(
suffix
))
if
(
!
plugin
.
SupportsSuffix
(
suffix
))
...
@@ -301,13 +301,13 @@ TryDecoderFile(Decoder &decoder, const char *path_fs, const char *suffix,
...
@@ -301,13 +301,13 @@ TryDecoderFile(Decoder &decoder, const char *path_fs, const char *suffix,
if
(
plugin
.
file_decode
!=
nullptr
)
{
if
(
plugin
.
file_decode
!=
nullptr
)
{
dc
.
Lock
();
dc
.
Lock
();
if
(
decoder_file_decode
(
plugin
,
decoder
,
path_fs
))
if
(
decoder_file_decode
(
plugin
,
decoder
,
path_fs
.
c_str
()
))
return
true
;
return
true
;
dc
.
Unlock
();
dc
.
Unlock
();
}
else
if
(
plugin
.
stream_decode
!=
nullptr
)
{
}
else
if
(
plugin
.
stream_decode
!=
nullptr
)
{
InputStream
*
input_stream
=
InputStream
*
input_stream
=
decoder_input_stream_open
(
dc
,
path_fs
);
decoder_input_stream_open
(
dc
,
path_fs
.
c_str
()
);
if
(
input_stream
==
nullptr
)
if
(
input_stream
==
nullptr
)
return
false
;
return
false
;
...
@@ -333,9 +333,9 @@ TryDecoderFile(Decoder &decoder, const char *path_fs, const char *suffix,
...
@@ -333,9 +333,9 @@ TryDecoderFile(Decoder &decoder, const char *path_fs, const char *suffix,
* Try decoding a file.
* Try decoding a file.
*/
*/
static
bool
static
bool
decoder_run_file
(
Decoder
&
decoder
,
const
char
*
path_fs
)
decoder_run_file
(
Decoder
&
decoder
,
const
char
*
uri_utf8
,
Path
path_fs
)
{
{
const
char
*
suffix
=
uri_get_suffix
(
path_fs
);
const
char
*
suffix
=
uri_get_suffix
(
uri_utf8
);
if
(
suffix
==
nullptr
)
if
(
suffix
==
nullptr
)
return
false
;
return
false
;
...
@@ -344,8 +344,10 @@ decoder_run_file(Decoder &decoder, const char *path_fs)
...
@@ -344,8 +344,10 @@ decoder_run_file(Decoder &decoder, const char *path_fs)
decoder_load_replay_gain
(
decoder
,
path_fs
);
decoder_load_replay_gain
(
decoder
,
path_fs
);
if
(
decoder_plugins_try
([
&
decoder
,
path_fs
,
suffix
](
const
DecoderPlugin
&
plugin
){
if
(
decoder_plugins_try
([
&
decoder
,
path_fs
,
return
TryDecoderFile
(
decoder
,
path_fs
,
suffix
,
suffix
](
const
DecoderPlugin
&
plugin
){
return
TryDecoderFile
(
decoder
,
path_fs
,
suffix
,
plugin
);
plugin
);
}))
}))
return
true
;
return
true
;
...
@@ -356,7 +358,7 @@ decoder_run_file(Decoder &decoder, const char *path_fs)
...
@@ -356,7 +358,7 @@ decoder_run_file(Decoder &decoder, const char *path_fs)
static
void
static
void
decoder_run_song
(
DecoderControl
&
dc
,
decoder_run_song
(
DecoderControl
&
dc
,
const
DetachedSong
&
song
,
const
char
*
uri
)
const
DetachedSong
&
song
,
const
char
*
uri
,
Path
path_fs
)
{
{
Decoder
decoder
(
dc
,
dc
.
start_ms
>
0
,
Decoder
decoder
(
dc
,
dc
.
start_ms
>
0
,
new
Tag
(
song
.
GetTag
()));
new
Tag
(
song
.
GetTag
()));
...
@@ -366,8 +368,8 @@ decoder_run_song(DecoderControl &dc,
...
@@ -366,8 +368,8 @@ decoder_run_song(DecoderControl &dc,
decoder_command_finished_locked
(
dc
);
decoder_command_finished_locked
(
dc
);
ret
=
song
.
IsFile
()
ret
=
!
path_fs
.
IsNull
()
?
decoder_run_file
(
decoder
,
uri
)
?
decoder_run_file
(
decoder
,
uri
,
path_fs
)
:
decoder_run_stream
(
decoder
,
uri
);
:
decoder_run_stream
(
decoder
,
uri
);
dc
.
Unlock
();
dc
.
Unlock
();
...
@@ -409,19 +411,23 @@ decoder_run(DecoderControl &dc)
...
@@ -409,19 +411,23 @@ decoder_run(DecoderControl &dc)
assert
(
dc
.
song
!=
nullptr
);
assert
(
dc
.
song
!=
nullptr
);
const
DetachedSong
&
song
=
*
dc
.
song
;
const
DetachedSong
&
song
=
*
dc
.
song
;
const
std
::
string
uri
=
song
.
IsFile
()
const
char
*
const
uri_utf8
=
song
.
GetRealURI
();
?
map_song_fs
(
song
).
c_str
()
:
song
.
GetRealURI
();
if
(
uri
.
empty
())
{
Path
path_fs
=
Path
::
Null
();
dc
.
state
=
DecoderState
::
ERROR
;
AllocatedPath
path_buffer
=
AllocatedPath
::
Null
();
dc
.
error
.
Set
(
decoder_domain
,
"Failed to map song"
);
if
(
song
.
IsFile
())
{
path_buffer
=
map_song_fs
(
song
);
if
(
path_buffer
.
IsNull
())
{
dc
.
state
=
DecoderState
::
ERROR
;
dc
.
error
.
Set
(
decoder_domain
,
"Failed to map song"
);
decoder_command_finished_locked
(
dc
);
return
;
}
decoder_command_finished_locked
(
dc
);
path_fs
=
path_buffer
;
return
;
}
}
decoder_run_song
(
dc
,
song
,
uri
.
c_str
()
);
decoder_run_song
(
dc
,
song
,
uri
_utf8
,
path_fs
);
}
}
...
...
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