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
545af857
Commit
545af857
authored
Aug 14, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/xiph/{FlacStreamMetadata,VorbisComments}: merge redundant code
parent
01f86e1c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
78 deletions
+98
-78
FlacStreamMetadata.cxx
src/lib/xiph/FlacStreamMetadata.cxx
+2
-42
ScanVorbisComment.cxx
src/lib/xiph/ScanVorbisComment.cxx
+64
-0
ScanVorbisComment.hxx
src/lib/xiph/ScanVorbisComment.hxx
+29
-0
VorbisComments.cxx
src/lib/xiph/VorbisComments.cxx
+2
-36
meson.build
src/lib/xiph/meson.build
+1
-0
No files found.
src/lib/xiph/FlacStreamMetadata.cxx
View file @
545af857
...
...
@@ -19,14 +19,12 @@
#include "FlacStreamMetadata.hxx"
#include "FlacAudioFormat.hxx"
#include "
XiphTags
.hxx"
#include "
ScanVorbisComment
.hxx"
#include "CheckAudioFormat.hxx"
#include "MixRampInfo.hxx"
#include "tag/Handler.hxx"
#include "tag/Table.hxx"
#include "tag/Builder.hxx"
#include "tag/Tag.hxx"
#include "tag/VorbisComment.hxx"
#include "tag/ReplayGain.hxx"
#include "tag/MixRamp.hxx"
#include "ReplayGainInfo.hxx"
...
...
@@ -68,50 +66,12 @@ flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc)
return
mix_ramp
;
}
/**
* Check if the comment's name equals the passed name, and if so, copy
* the comment value into the tag.
*/
static
bool
flac_copy_comment
(
StringView
comment
,
StringView
name
,
TagType
tag_type
,
TagHandler
&
handler
)
noexcept
{
const
auto
value
=
GetVorbisCommentValue
(
comment
,
name
);
if
(
!
value
.
IsNull
())
{
handler
.
OnTag
(
tag_type
,
value
);
return
true
;
}
return
false
;
}
static
void
flac_scan_comment
(
StringView
comment
,
TagHandler
&
handler
)
noexcept
{
if
(
handler
.
WantPair
())
{
const
auto
split
=
comment
.
Split
(
'='
);
if
(
!
split
.
first
.
empty
()
&&
!
split
.
second
.
IsNull
())
handler
.
OnPair
(
split
.
first
,
split
.
second
);
}
for
(
const
struct
tag_table
*
i
=
xiph_tags
;
i
->
name
!=
nullptr
;
++
i
)
if
(
flac_copy_comment
(
comment
,
i
->
name
,
i
->
type
,
handler
))
return
;
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
if
(
flac_copy_comment
(
comment
,
tag_item_names
[
i
],
(
TagType
)
i
,
handler
))
return
;
}
static
void
flac_scan_comments
(
const
FLAC__StreamMetadata_VorbisComment
*
comment
,
TagHandler
&
handler
)
noexcept
{
for
(
unsigned
i
=
0
;
i
<
comment
->
num_comments
;
++
i
)
flac_scan_c
omment
(
ToStringView
(
comment
->
comments
[
i
]),
handler
);
ScanVorbisC
omment
(
ToStringView
(
comment
->
comments
[
i
]),
handler
);
}
gcc_pure
...
...
src/lib/xiph/ScanVorbisComment.cxx
0 → 100644
View file @
545af857
/*
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ScanVorbisComment.hxx"
#include "XiphTags.hxx"
#include "tag/Table.hxx"
#include "tag/Handler.hxx"
#include "tag/VorbisComment.hxx"
#include "util/StringView.hxx"
/**
* Check if the comment's name equals the passed name, and if so, copy
* the comment value into the tag.
*/
static
bool
vorbis_copy_comment
(
StringView
comment
,
StringView
name
,
TagType
tag_type
,
TagHandler
&
handler
)
noexcept
{
const
auto
value
=
GetVorbisCommentValue
(
comment
,
name
);
if
(
!
value
.
IsNull
())
{
handler
.
OnTag
(
tag_type
,
value
);
return
true
;
}
return
false
;
}
void
ScanVorbisComment
(
StringView
comment
,
TagHandler
&
handler
)
noexcept
{
if
(
handler
.
WantPair
())
{
const
auto
split
=
comment
.
Split
(
'='
);
if
(
!
split
.
first
.
empty
()
&&
!
split
.
second
.
IsNull
())
handler
.
OnPair
(
split
.
first
,
split
.
second
);
}
for
(
const
struct
tag_table
*
i
=
xiph_tags
;
i
->
name
!=
nullptr
;
++
i
)
if
(
vorbis_copy_comment
(
comment
,
i
->
name
,
i
->
type
,
handler
))
return
;
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
if
(
vorbis_copy_comment
(
comment
,
tag_item_names
[
i
],
TagType
(
i
),
handler
))
return
;
}
src/lib/xiph/ScanVorbisComment.hxx
0 → 100644
View file @
545af857
/*
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_SCAN_VORBIS_COMMENT_HXX
#define MPD_SCAN_VORBIS_COMMENT_HXX
struct
StringView
;
class
TagHandler
;
void
ScanVorbisComment
(
StringView
comment
,
TagHandler
&
handler
)
noexcept
;
#endif
src/lib/xiph/VorbisComments.cxx
View file @
545af857
...
...
@@ -19,8 +19,7 @@
#include "VorbisComments.hxx"
#include "VorbisPicture.hxx"
#include "XiphTags.hxx"
#include "tag/Table.hxx"
#include "ScanVorbisComment.hxx"
#include "tag/Handler.hxx"
#include "tag/Builder.hxx"
#include "tag/Tag.hxx"
...
...
@@ -64,24 +63,6 @@ VorbisCommentToReplayGain(ReplayGainInfo &rgi,
return
found
;
}
/**
* Check if the comment's name equals the passed name, and if so, copy
* the comment value into the tag.
*/
static
bool
vorbis_copy_comment
(
StringView
comment
,
StringView
name
,
TagType
tag_type
,
TagHandler
&
handler
)
noexcept
{
const
auto
value
=
GetVorbisCommentValue
(
comment
,
name
);
if
(
!
value
.
IsNull
())
{
handler
.
OnTag
(
tag_type
,
value
);
return
true
;
}
return
false
;
}
static
void
vorbis_scan_comment
(
StringView
comment
,
TagHandler
&
handler
)
noexcept
{
...
...
@@ -91,22 +72,7 @@ vorbis_scan_comment(StringView comment, TagHandler &handler) noexcept
if
(
!
picture_b64
.
IsNull
())
return
ScanVorbisPicture
(
picture_b64
,
handler
);
if
(
handler
.
WantPair
())
{
const
auto
split
=
comment
.
Split
(
'='
);
if
(
!
split
.
first
.
empty
()
&&
!
split
.
second
.
IsNull
())
handler
.
OnPair
(
split
.
first
,
split
.
second
);
}
for
(
const
struct
tag_table
*
i
=
xiph_tags
;
i
->
name
!=
nullptr
;
++
i
)
if
(
vorbis_copy_comment
(
comment
,
i
->
name
,
i
->
type
,
handler
))
return
;
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
if
(
vorbis_copy_comment
(
comment
,
tag_item_names
[
i
],
TagType
(
i
),
handler
))
return
;
ScanVorbisComment
(
comment
,
handler
);
}
void
...
...
src/lib/xiph/meson.build
View file @
545af857
...
...
@@ -46,6 +46,7 @@ endif
xiph = static_library(
'xiph',
'ScanVorbisComment.cxx',
'VorbisComments.cxx',
'VorbisPicture.cxx',
'XiphTags.cxx',
...
...
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