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
9ae9b2c1
Commit
9ae9b2c1
authored
Aug 14, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/VorbisComment: use struct StringView
parent
8e0d8109
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
34 deletions
+34
-34
FlacStreamMetadata.cxx
src/lib/xiph/FlacStreamMetadata.cxx
+8
-7
VorbisComments.cxx
src/lib/xiph/VorbisComments.cxx
+4
-6
MixRamp.cxx
src/tag/MixRamp.cxx
+2
-2
ReplayGain.cxx
src/tag/ReplayGain.cxx
+4
-4
ReplayGain.hxx
src/tag/ReplayGain.hxx
+2
-1
VorbisComment.cxx
src/tag/VorbisComment.cxx
+10
-12
VorbisComment.hxx
src/tag/VorbisComment.hxx
+4
-2
No files found.
src/lib/xiph/FlacStreamMetadata.cxx
View file @
9ae9b2c1
...
@@ -68,11 +68,12 @@ flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc)
...
@@ -68,11 +68,12 @@ flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc)
* Checks if the specified name matches the entry's name, and if yes,
* Checks if the specified name matches the entry's name, and if yes,
* returns the comment value;
* returns the comment value;
*/
*/
static
const
char
*
static
StringView
flac_comment_v
alue
(
const
FLAC__StreamMetadata_VorbisComment_Entry
*
entry
,
GetFlacCommentV
alue
(
const
FLAC__StreamMetadata_VorbisComment_Entry
*
entry
,
const
char
*
name
)
noexcept
StringView
name
)
noexcept
{
{
return
vorbis_comment_value
((
const
char
*
)
entry
->
entry
,
name
);
return
GetVorbisCommentValue
({(
const
char
*
)
entry
->
entry
,
entry
->
length
},
name
);
}
}
/**
/**
...
@@ -81,11 +82,11 @@ flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
...
@@ -81,11 +82,11 @@ flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
*/
*/
static
bool
static
bool
flac_copy_comment
(
const
FLAC__StreamMetadata_VorbisComment_Entry
*
entry
,
flac_copy_comment
(
const
FLAC__StreamMetadata_VorbisComment_Entry
*
entry
,
const
char
*
name
,
TagType
tag_type
,
StringView
name
,
TagType
tag_type
,
TagHandler
&
handler
)
noexcept
TagHandler
&
handler
)
noexcept
{
{
const
char
*
value
=
flac_comment_v
alue
(
entry
,
name
);
const
auto
value
=
GetFlacCommentV
alue
(
entry
,
name
);
if
(
value
!=
nullptr
)
{
if
(
!
value
.
IsNull
()
)
{
handler
.
OnTag
(
tag_type
,
value
);
handler
.
OnTag
(
tag_type
,
value
);
return
true
;
return
true
;
}
}
...
...
src/lib/xiph/VorbisComments.cxx
View file @
9ae9b2c1
...
@@ -50,14 +50,12 @@ vorbis_comments_to_replay_gain(ReplayGainInfo &rgi, char **comments) noexcept
...
@@ -50,14 +50,12 @@ vorbis_comments_to_replay_gain(ReplayGainInfo &rgi, char **comments) noexcept
* the comment value into the tag.
* the comment value into the tag.
*/
*/
static
bool
static
bool
vorbis_copy_comment
(
const
char
*
comment
,
vorbis_copy_comment
(
StringView
comment
,
const
char
*
name
,
TagType
tag_type
,
StringView
name
,
TagType
tag_type
,
TagHandler
&
handler
)
noexcept
TagHandler
&
handler
)
noexcept
{
{
const
char
*
value
;
const
auto
value
=
GetVorbisCommentValue
(
comment
,
name
);
if
(
!
value
.
IsNull
())
{
value
=
vorbis_comment_value
(
comment
,
name
);
if
(
value
!=
nullptr
)
{
handler
.
OnTag
(
tag_type
,
value
);
handler
.
OnTag
(
tag_type
,
value
);
return
true
;
return
true
;
}
}
...
...
src/tag/MixRamp.cxx
View file @
9ae9b2c1
...
@@ -72,8 +72,8 @@ ParseMixRampVorbis(MixRampInfo &info, const char *entry)
...
@@ -72,8 +72,8 @@ ParseMixRampVorbis(MixRampInfo &info, const char *entry)
const
char
*
entry
;
const
char
*
entry
;
gcc_pure
gcc_pure
StringView
operator
[](
const
char
*
n
)
const
noexcept
{
StringView
operator
[](
StringView
n
)
const
noexcept
{
return
vorbis_comment_v
alue
(
entry
,
n
);
return
GetVorbisCommentV
alue
(
entry
,
n
);
}
}
};
};
...
...
src/tag/ReplayGain.cxx
View file @
9ae9b2c1
...
@@ -70,14 +70,14 @@ ParseReplayGainTag(ReplayGainInfo &info, const char *name, const char *value)
...
@@ -70,14 +70,14 @@ ParseReplayGainTag(ReplayGainInfo &info, const char *name, const char *value)
}
}
bool
bool
ParseReplayGainVorbis
(
ReplayGainInfo
&
info
,
const
char
*
entry
)
ParseReplayGainVorbis
(
ReplayGainInfo
&
info
,
StringView
entry
)
{
{
struct
VorbisCommentEntry
{
struct
VorbisCommentEntry
{
const
char
*
entry
;
StringView
entry
;
gcc_pure
gcc_pure
const
char
*
operator
[](
const
char
*
n
)
const
noexcept
{
const
char
*
operator
[](
StringView
n
)
const
noexcept
{
return
vorbis_comment_value
(
entry
,
n
)
;
return
GetVorbisCommentValue
(
entry
,
n
).
data
;
}
}
};
};
...
...
src/tag/ReplayGain.hxx
View file @
9ae9b2c1
...
@@ -20,12 +20,13 @@
...
@@ -20,12 +20,13 @@
#ifndef MPD_TAG_REPLAY_GAIN_HXX
#ifndef MPD_TAG_REPLAY_GAIN_HXX
#define MPD_TAG_REPLAY_GAIN_HXX
#define MPD_TAG_REPLAY_GAIN_HXX
struct
StringView
;
struct
ReplayGainInfo
;
struct
ReplayGainInfo
;
bool
bool
ParseReplayGainTag
(
ReplayGainInfo
&
info
,
const
char
*
name
,
const
char
*
value
);
ParseReplayGainTag
(
ReplayGainInfo
&
info
,
const
char
*
name
,
const
char
*
value
);
bool
bool
ParseReplayGainVorbis
(
ReplayGainInfo
&
info
,
const
char
*
entry
);
ParseReplayGainVorbis
(
ReplayGainInfo
&
info
,
StringView
entry
);
#endif
#endif
src/tag/VorbisComment.cxx
View file @
9ae9b2c1
...
@@ -18,23 +18,21 @@
...
@@ -18,23 +18,21 @@
*/
*/
#include "VorbisComment.hxx"
#include "VorbisComment.hxx"
#include "util/
ASCII
.hxx"
#include "util/
StringView
.hxx"
#include <assert.h>
#include <assert.h>
#include <string.h>
const
char
*
StringView
vorbis_comment_value
(
const
char
*
entry
,
const
char
*
name
)
noexcept
GetVorbisCommentValue
(
StringView
entry
,
StringView
name
)
noexcept
{
{
assert
(
entry
!=
nullptr
);
assert
(
!
name
.
empty
());
assert
(
name
!=
nullptr
);
assert
(
*
name
!=
0
);
const
size_t
length
=
strlen
(
name
);
if
(
entry
.
StartsWithIgnoreCase
(
name
)
&&
entry
.
size
>
name
.
size
&&
if
(
StringEqualsCaseASCII
(
entry
,
name
,
length
)
&&
entry
[
name
.
size
]
==
'='
)
{
entry
[
length
]
==
'='
)
entry
.
skip_front
(
name
.
size
+
1
);
return
entry
+
length
+
1
;
return
entry
;
}
return
nullptr
;
return
nullptr
;
}
}
src/tag/VorbisComment.hxx
View file @
9ae9b2c1
...
@@ -22,12 +22,14 @@
...
@@ -22,12 +22,14 @@
#include "util/Compiler.h"
#include "util/Compiler.h"
struct
StringView
;
/**
/**
* Checks if the specified name matches the entry's name, and if yes,
* Checks if the specified name matches the entry's name, and if yes,
* returns the comment value.
* returns the comment value.
*/
*/
gcc_pure
gcc_pure
const
char
*
StringView
vorbis_comment_value
(
const
char
*
entry
,
const
char
*
name
)
noexcept
;
GetVorbisCommentValue
(
StringView
entry
,
StringView
name
)
noexcept
;
#endif
#endif
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