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
95e2bec2
Commit
95e2bec2
authored
Nov 22, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/DecoderPlugin: container_scan() returns forward_list<DetachedSong>
Speed up container_scan() again, by eliminating the need to call scan_file() for each item.
parent
72c96052
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
35 deletions
+47
-35
Makefile.am
Makefile.am
+4
-0
Container.cxx
src/db/update/Container.cxx
+7
-24
DecoderPlugin.hxx
src/decoder/DecoderPlugin.hxx
+2
-2
GmeDecoderPlugin.cxx
src/decoder/plugins/GmeDecoderPlugin.cxx
+13
-4
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+18
-4
ContainerScan.cxx
test/ContainerScan.cxx
+3
-1
No files found.
Makefile.am
View file @
95e2bec2
...
...
@@ -1894,6 +1894,7 @@ test_run_decoder_LDADD = \
test_run_decoder_SOURCES
=
test
/run_decoder.cxx
\
test
/FakeDecoderAPI.cxx
test
/FakeDecoderAPI.hxx
\
test
/ScopeIOThread.hxx
\
src/DetachedSong.cxx
\
src/Log.cxx src/LogBackend.cxx
\
src/IOThread.cxx
\
src/ReplayGainInfo.cxx
...
...
@@ -1915,6 +1916,7 @@ test_read_tags_LDADD = \
test_read_tags_SOURCES
=
test
/read_tags.cxx
\
test
/FakeDecoderAPI.cxx
test
/FakeDecoderAPI.hxx
\
test
/ScopeIOThread.hxx
\
src/DetachedSong.cxx
\
src/Log.cxx src/LogBackend.cxx
\
src/IOThread.cxx
\
src/ReplayGainInfo.cxx
...
...
@@ -1946,6 +1948,8 @@ test_ContainerScan_LDADD = \
libsystem.a
\
libutil.a
test_ContainerScan_SOURCES
=
test
/ContainerScan.cxx
\
src/DetachedSong.cxx
\
src/SongSave.cxx src/TagSave.cxx
\
src/Log.cxx src/LogBackend.cxx
\
src/ReplayGainInfo.cxx
\
$(DECODER_SRC)
...
...
src/db/update/Container.cxx
View file @
95e2bec2
...
...
@@ -20,6 +20,7 @@
#include "config.h"
/* must be first for large file support */
#include "Walk.hxx"
#include "UpdateDomain.hxx"
#include "DetachedSong.hxx"
#include "db/DatabaseLock.hxx"
#include "db/plugins/simple/Directory.hxx"
#include "db/plugins/simple/Song.hxx"
...
...
@@ -28,8 +29,6 @@
#include "decoder/DecoderList.hxx"
#include "fs/AllocatedPath.hxx"
#include "storage/FileInfo.hxx"
#include "tag/TagHandler.hxx"
#include "tag/TagBuilder.hxx"
#include "Log.hxx"
#include "util/AllocatedString.hxx"
...
...
@@ -97,34 +96,21 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
}
try
{
const
auto
v
=
plugin
.
container_scan
(
pathname
);
auto
v
=
plugin
.
container_scan
(
pathname
);
if
(
v
.
empty
())
{
editor
.
LockDeleteDirectory
(
contdir
);
return
false
;
}
TagBuilder
tag_builder
;
for
(
const
auto
&
vtrack
:
v
)
{
Song
*
song
=
Song
::
NewFile
(
vtrack
.
c_str
(),
*
contdir
);
for
(
auto
&
vtrack
:
v
)
{
Song
*
song
=
Song
::
NewFrom
(
std
::
move
(
vtrack
),
*
contdir
);
// shouldn't be necessary but it's there..
song
->
mtime
=
info
.
mtime
;
try
{
const
auto
vtrack_fs
=
AllocatedPath
::
FromUTF8Throw
(
vtrack
.
c_str
());
const
auto
child_path_fs
=
AllocatedPath
::
Build
(
pathname
,
vtrack_fs
);
plugin
.
ScanFile
(
child_path_fs
,
add_tag_handler
,
&
tag_builder
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
song
->
Free
();
LogError
(
e
);
continue
;
}
tag_builder
.
Commit
(
song
->
tag
);
FormatDefault
(
update_domain
,
"added %s/%s"
,
contdir
->
GetPath
(),
song
->
uri
);
{
const
ScopeDatabaseLock
protect
;
...
...
@@ -132,9 +118,6 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
}
modified
=
true
;
FormatDefault
(
update_domain
,
"added %s/%s"
,
directory
.
GetPath
(),
vtrack
.
c_str
());
}
}
catch
(
const
std
::
runtime_error
&
e
)
{
editor
.
LockDeleteDirectory
(
contdir
);
...
...
src/decoder/DecoderPlugin.hxx
View file @
95e2bec2
...
...
@@ -23,13 +23,13 @@
#include "Compiler.h"
#include <forward_list>
#include <string>
struct
ConfigBlock
;
class
InputStream
;
struct
TagHandler
;
class
Path
;
class
DecoderClient
;
class
DetachedSong
;
struct
DecoderPlugin
{
const
char
*
name
;
...
...
@@ -93,7 +93,7 @@ struct DecoderPlugin {
* a filename for every single track;
* do not include full pathname here, just the "virtual" file
*/
std
::
forward_list
<
std
::
stri
ng
>
(
*
container_scan
)(
Path
path_fs
);
std
::
forward_list
<
DetachedSo
ng
>
(
*
container_scan
)(
Path
path_fs
);
/* last element in these arrays must always be a nullptr: */
const
char
*
const
*
suffixes
;
...
...
src/decoder/plugins/GmeDecoderPlugin.cxx
View file @
95e2bec2
...
...
@@ -22,7 +22,9 @@
#include "../DecoderAPI.hxx"
#include "config/Block.cxx"
#include "CheckAudioFormat.hxx"
#include "DetachedSong.hxx"
#include "tag/TagHandler.hxx"
#include "tag/TagBuilder.hxx"
#include "fs/Path.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/ScopeExit.hxx"
...
...
@@ -266,10 +268,10 @@ gme_scan_file(Path path_fs,
return
ScanMusicEmu
(
emu
,
container
.
track
,
handler
,
handler_ctx
);
}
static
std
::
forward_list
<
std
::
stri
ng
>
static
std
::
forward_list
<
DetachedSo
ng
>
gme_container_scan
(
Path
path_fs
)
{
std
::
forward_list
<
std
::
stri
ng
>
list
;
std
::
forward_list
<
DetachedSo
ng
>
list
;
Music_Emu
*
emu
;
const
char
*
gme_err
=
gme_open_file
(
path_fs
.
c_str
(),
&
emu
,
...
...
@@ -279,20 +281,27 @@ gme_container_scan(Path path_fs)
return
list
;
}
AtScopeExit
(
emu
)
{
gme_delete
(
emu
);
};
const
unsigned
num_songs
=
gme_track_count
(
emu
);
gme_delete
(
emu
);
/* if it only contains a single tune, don't treat as container */
if
(
num_songs
<
2
)
return
list
;
const
char
*
subtune_suffix
=
uri_get_suffix
(
path_fs
.
c_str
());
TagBuilder
tag_builder
;
auto
tail
=
list
.
before_begin
();
for
(
unsigned
i
=
1
;
i
<=
num_songs
;
++
i
)
{
ScanMusicEmu
(
emu
,
i
,
add_tag_handler
,
&
tag_builder
);
char
track_name
[
64
];
snprintf
(
track_name
,
sizeof
(
track_name
),
SUBTUNE_PREFIX
"%03u.%s"
,
i
,
subtune_suffix
);
tail
=
list
.
emplace_after
(
tail
,
track_name
);
tail
=
list
.
emplace_after
(
tail
,
track_name
,
tag_builder
.
Commit
());
}
return
list
;
...
...
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
95e2bec2
...
...
@@ -21,6 +21,8 @@
#include "SidplayDecoderPlugin.hxx"
#include "../DecoderAPI.hxx"
#include "tag/TagHandler.hxx"
#include "tag/TagBuilder.hxx"
#include "DetachedSong.hxx"
#include "fs/Path.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/Macros.hxx"
...
...
@@ -467,12 +469,16 @@ sidplay_scan_file(Path path_fs,
return
true
;
}
static
std
::
forward_list
<
std
::
stri
ng
>
static
std
::
forward_list
<
DetachedSo
ng
>
sidplay_container_scan
(
Path
path_fs
)
{
std
::
forward_list
<
std
::
stri
ng
>
list
;
std
::
forward_list
<
DetachedSo
ng
>
list
;
SidTune
tune
(
path_fs
.
c_str
(),
nullptr
,
true
);
#ifdef HAVE_SIDPLAYFP
SidTune
tune
(
path_fs
.
c_str
());
#else
SidTuneMod
tune
(
path_fs
.
c_str
());
#endif
if
(
!
tune
.
getStatus
())
return
list
;
...
...
@@ -489,13 +495,21 @@ sidplay_container_scan(Path path_fs)
if
(
!
all_files_are_containers
&&
n_tracks
<
2
)
return
list
;
TagBuilder
tag_builder
;
auto
tail
=
list
.
before_begin
();
for
(
unsigned
i
=
1
;
i
<=
n_tracks
;
++
i
)
{
tune
.
selectSong
(
i
);
ScanSidTuneInfo
(
info
,
i
,
n_tracks
,
add_tag_handler
,
&
tag_builder
);
char
track_name
[
32
];
/* Construct container/tune path names, eg.
Delta.sid/tune_001.sid */
sprintf
(
track_name
,
SUBTUNE_PREFIX
"%03u.sid"
,
i
);
tail
=
list
.
emplace_after
(
tail
,
track_name
);
tail
=
list
.
emplace_after
(
tail
,
track_name
,
tag_builder
.
Commit
());
}
return
list
;
...
...
test/ContainerScan.cxx
View file @
95e2bec2
...
...
@@ -19,6 +19,8 @@
#include "config.h"
#include "Log.hxx"
#include "DetachedSong.hxx"
#include "SongSave.hxx"
#include "decoder/DecoderList.hxx"
#include "decoder/DecoderPlugin.hxx"
#include "fs/Path.hxx"
...
...
@@ -84,7 +86,7 @@ try {
BufferedOutputStream
bos
(
sos
);
for
(
const
auto
&
song
:
v
)
bos
.
Format
(
"%s
\n
"
,
song
.
c_str
()
);
song_save
(
bos
,
song
);
bos
.
Flush
();
...
...
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