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
34246eb7
Commit
34246eb7
authored
Aug 15, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/flac: read the file only once using FLAC__Metadata_Chain
parent
5894514c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
13 deletions
+30
-13
FlacPlaylistPlugin.cxx
src/playlist/plugins/FlacPlaylistPlugin.cxx
+30
-13
No files found.
src/playlist/plugins/FlacPlaylistPlugin.cxx
View file @
34246eb7
...
...
@@ -26,10 +26,13 @@
#include "FlacPlaylistPlugin.hxx"
#include "../PlaylistPlugin.hxx"
#include "../MemorySongEnumerator.hxx"
#include "lib/xiph/FlacMetadataChain.hxx"
#include "lib/xiph/FlacMetadataIterator.hxx"
#include "song/DetachedSong.hxx"
#include "fs/Traits.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/NarrowPath.hxx"
#include "util/RuntimeError.hxx"
#include "util/ScopeExit.hxx"
#include <FLAC/metadata.h>
...
...
@@ -74,23 +77,37 @@ flac_playlist_open_uri(const char *uri,
const
NarrowPath
narrow_path_fs
(
path_fs
);
FLAC__StreamMetadata
*
cuesheet
;
if
(
!
FLAC__metadata_get_cuesheet
(
narrow_path_fs
,
&
cuesheet
))
return
nullptr
;
FlacMetadataChain
chain
;
if
(
!
chain
.
Read
(
narrow_path_fs
))
throw
FormatRuntimeError
(
"Failed to read FLAC metadata: %s"
,
chain
.
GetStatusString
());
AtScopeExit
(
cuesheet
)
{
FLAC__metadata_object_delete
(
cuesheet
);
}
;
FlacMetadataIterator
iterator
((
FLAC__Metadata_Chain
*
)
chain
)
;
FLAC__StreamMetadata
streaminfo
;
if
(
!
FLAC__metadata_get_streaminfo
(
narrow_path_fs
,
&
streaminfo
)
||
streaminfo
.
data
.
stream_info
.
sample_rate
==
0
)
{
return
nullptr
;
}
unsigned
sample_rate
=
0
;
FLAC__uint64
total_samples
;
do
{
auto
&
block
=
*
iterator
.
GetBlock
();
switch
(
block
.
type
)
{
case
FLAC__METADATA_TYPE_STREAMINFO
:
sample_rate
=
block
.
data
.
stream_info
.
sample_rate
;
total_samples
=
block
.
data
.
stream_info
.
total_samples
;
break
;
case
FLAC__METADATA_TYPE_CUESHEET
:
if
(
sample_rate
==
0
)
break
;
return
ToSongEnumerator
(
uri
,
block
.
data
.
cue_sheet
,
sample_rate
,
total_samples
);
const
unsigned
sample_rate
=
streaminfo
.
data
.
stream_info
.
sample_rate
;
const
FLAC__uint64
total_samples
=
streaminfo
.
data
.
stream_info
.
total_samples
;
default
:
break
;
}
}
while
(
iterator
.
Next
());
return
ToSongEnumerator
(
uri
,
cuesheet
->
data
.
cue_sheet
,
sample_rate
,
total_samples
);
return
nullptr
;
}
static
const
char
*
const
flac_playlist_suffixes
[]
=
{
...
...
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