decoder/opus: pass StringView to ScanOneOpusTag()
This commit is contained in:
parent
dffa25c55e
commit
8a136b79e5
|
@ -23,11 +23,12 @@
|
||||||
#include "tag/Handler.hxx"
|
#include "tag/Handler.hxx"
|
||||||
#include "tag/ParseName.hxx"
|
#include "tag/ParseName.hxx"
|
||||||
#include "ReplayGainInfo.hxx"
|
#include "ReplayGainInfo.hxx"
|
||||||
|
#include "util/NumberParser.hxx"
|
||||||
|
#include "util/StringView.hxx"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
static TagType
|
static TagType
|
||||||
|
@ -41,7 +42,7 @@ ParseOpusTagName(StringView name) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ScanOneOpusTag(StringView name, const char *value,
|
ScanOneOpusTag(StringView name, StringView value,
|
||||||
ReplayGainInfo *rgi,
|
ReplayGainInfo *rgi,
|
||||||
TagHandler &handler) noexcept
|
TagHandler &handler) noexcept
|
||||||
{
|
{
|
||||||
|
@ -49,17 +50,17 @@ ScanOneOpusTag(StringView name, const char *value,
|
||||||
/* R128_TRACK_GAIN is a Q7.8 fixed point number in
|
/* R128_TRACK_GAIN is a Q7.8 fixed point number in
|
||||||
dB */
|
dB */
|
||||||
|
|
||||||
char *endptr;
|
const char *endptr;
|
||||||
long l = strtol(value, &endptr, 10);
|
const auto l = ParseInt64(value, &endptr, 10);
|
||||||
if (endptr > value && *endptr == 0)
|
if (endptr > value.begin() && endptr == value.end())
|
||||||
rgi->track.gain = double(l) / 256.;
|
rgi->track.gain = double(l) / 256.;
|
||||||
} else if (rgi != nullptr && name.Equals("R128_ALBUM_GAIN")) {
|
} else if (rgi != nullptr && name.Equals("R128_ALBUM_GAIN")) {
|
||||||
/* R128_ALBUM_GAIN is a Q7.8 fixed point number in
|
/* R128_ALBUM_GAIN is a Q7.8 fixed point number in
|
||||||
dB */
|
dB */
|
||||||
|
|
||||||
char *endptr;
|
const char *endptr;
|
||||||
long l = strtol(value, &endptr, 10);
|
const auto l = ParseInt64(value, &endptr, 10);
|
||||||
if (endptr > value && *endptr == 0)
|
if (endptr > value.begin() && endptr == value.end())
|
||||||
rgi->album.gain = double(l) / 256.;
|
rgi->album.gain = double(l) / 256.;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +104,7 @@ ScanOpusTags(const void *data, size_t size,
|
||||||
if (split.first.empty() || split.second.IsNull())
|
if (split.first.empty() || split.second.IsNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string value2(split.second.data, split.second.size);
|
ScanOneOpusTag(split.first, split.second, rgi, handler);
|
||||||
|
|
||||||
ScanOneOpusTag(split.first, value2.c_str(), rgi, handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue