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
fea32653
Commit
fea32653
authored
Jun 10, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/gme: simplify LoadGmeAndM3u() by moving code to ReplaceSuffix()
parent
8925cc17
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
GmeDecoderPlugin.cxx
src/decoder/plugins/GmeDecoderPlugin.cxx
+18
-14
No files found.
src/decoder/plugins/GmeDecoderPlugin.cxx
View file @
fea32653
...
@@ -102,35 +102,39 @@ ParseContainerPath(Path path_fs)
...
@@ -102,35 +102,39 @@ ParseContainerPath(Path path_fs)
return
{
path_fs
.
GetDirectoryName
(),
track
-
1
};
return
{
path_fs
.
GetDirectoryName
(),
track
-
1
};
}
}
static
AllocatedPath
ReplaceSuffix
(
Path
src
,
const
PathTraitsFS
::
const_pointer_type
new_suffix
)
noexcept
{
const
auto
*
old_suffix
=
src
.
GetSuffix
();
if
(
old_suffix
==
nullptr
)
return
nullptr
;
PathTraitsFS
::
string
s
(
src
.
c_str
(),
old_suffix
);
s
+=
new_suffix
;
return
AllocatedPath
::
FromFS
(
std
::
move
(
s
));
}
static
Music_Emu
*
static
Music_Emu
*
LoadGmeAndM3u
(
GmeContainerPath
container
)
{
LoadGmeAndM3u
(
GmeContainerPath
container
)
{
const
char
*
path
=
container
.
path
.
c_str
();
const
auto
*
suffix
=
container
.
path
.
GetSuffix
();
Music_Emu
*
emu
;
Music_Emu
*
emu
;
const
char
*
gme_err
=
const
char
*
gme_err
=
gme_open_file
(
path
,
&
emu
,
GME_SAMPLE_RATE
);
gme_open_file
(
container
.
path
.
c_str
()
,
&
emu
,
GME_SAMPLE_RATE
);
if
(
gme_err
!=
nullptr
)
{
if
(
gme_err
!=
nullptr
)
{
LogWarning
(
gme_domain
,
gme_err
);
LogWarning
(
gme_domain
,
gme_err
);
return
nullptr
;
return
nullptr
;
}
}
if
(
suffix
==
nullptr
)
{
const
auto
m3u_path
=
ReplaceSuffix
(
container
.
path
,
"m3u"
);
return
emu
;
}
std
::
string
m3u_path
(
path
,
suffix
);
m3u_path
+=
"m3u"
;
/*
/*
* Some GME formats lose metadata if you attempt to
* Some GME formats lose metadata if you attempt to
* load a non-existant M3U file, so check that one
* load a non-existant M3U file, so check that one
* exists before loading.
* exists before loading.
*/
*/
if
(
FileExists
(
Path
::
FromFS
(
m3u_path
.
c_str
())))
{
if
(
!
m3u_path
.
IsNull
()
&&
FileExists
(
m3u_path
))
gme_load_m3u
(
emu
,
m3u_path
.
c_str
());
gme_load_m3u
(
emu
,
m3u_path
.
c_str
());
}
return
emu
;
return
emu
;
}
}
...
...
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