Use `pubsetbuf` only with `libstdc++`
This usage of the function seems only to work as intended with that standard lib. With `libc++` and the MSVC standard lib the call has no effect.
This commit is contained in:
parent
981db492e4
commit
d80736743b
|
@ -717,7 +717,11 @@ Popularity TagValue::toPopularity() const
|
||||||
auto reader = BinaryReader(&s);
|
auto reader = BinaryReader(&s);
|
||||||
try {
|
try {
|
||||||
s.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
s.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
||||||
|
#if defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION)
|
||||||
s.rdbuf()->pubsetbuf(m_ptr.get(), static_cast<std::streamsize>(m_size));
|
s.rdbuf()->pubsetbuf(m_ptr.get(), static_cast<std::streamsize>(m_size));
|
||||||
|
#else
|
||||||
|
s.write(m_ptr.get(), static_cast<std::streamsize>(m_size));
|
||||||
|
#endif
|
||||||
popularity.user = reader.readLengthPrefixedString();
|
popularity.user = reader.readLengthPrefixedString();
|
||||||
popularity.rating = reader.readFloat64LE();
|
popularity.rating = reader.readFloat64LE();
|
||||||
popularity.playCounter = reader.readUInt64LE();
|
popularity.playCounter = reader.readUInt64LE();
|
||||||
|
|
|
@ -78,7 +78,11 @@ template <class StreamType> void VorbisCommentField::internalParse(StreamType &s
|
||||||
auto decoded = decodeBase64(data.get() + idSize + 1, size - idSize - 1);
|
auto decoded = decodeBase64(data.get() + idSize + 1, size - idSize - 1);
|
||||||
stringstream bufferStream(ios_base::in | ios_base::out | ios_base::binary);
|
stringstream bufferStream(ios_base::in | ios_base::out | ios_base::binary);
|
||||||
bufferStream.exceptions(ios_base::failbit | ios_base::badbit);
|
bufferStream.exceptions(ios_base::failbit | ios_base::badbit);
|
||||||
|
#if defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION)
|
||||||
bufferStream.rdbuf()->pubsetbuf(reinterpret_cast<char *>(decoded.first.get()), decoded.second);
|
bufferStream.rdbuf()->pubsetbuf(reinterpret_cast<char *>(decoded.first.get()), decoded.second);
|
||||||
|
#else
|
||||||
|
bufferStream.write(reinterpret_cast<const char *>(decoded.first.get()), decoded.second);
|
||||||
|
#endif
|
||||||
FlacMetaDataBlockPicture pictureBlock(value());
|
FlacMetaDataBlockPicture pictureBlock(value());
|
||||||
pictureBlock.parse(bufferStream, decoded.second);
|
pictureBlock.parse(bufferStream, decoded.second);
|
||||||
setTypeInfo(pictureBlock.pictureType());
|
setTypeInfo(pictureBlock.pictureType());
|
||||||
|
@ -197,10 +201,15 @@ bool VorbisCommentField::make(BinaryWriter &writer, VorbisCommentFlags flags, Di
|
||||||
auto buffer = make_unique<char[]>(requiredSize);
|
auto buffer = make_unique<char[]>(requiredSize);
|
||||||
stringstream bufferStream(ios_base::in | ios_base::out | ios_base::binary);
|
stringstream bufferStream(ios_base::in | ios_base::out | ios_base::binary);
|
||||||
bufferStream.exceptions(ios_base::failbit | ios_base::badbit);
|
bufferStream.exceptions(ios_base::failbit | ios_base::badbit);
|
||||||
|
#if defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION)
|
||||||
bufferStream.rdbuf()->pubsetbuf(buffer.get(), requiredSize);
|
bufferStream.rdbuf()->pubsetbuf(buffer.get(), requiredSize);
|
||||||
|
#endif
|
||||||
pictureBlock.make(bufferStream);
|
pictureBlock.make(bufferStream);
|
||||||
|
#if defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION)
|
||||||
|
bufferStream.read(buffer.get(), static_cast<std::streamsize>(requiredSize));
|
||||||
|
#endif
|
||||||
valueString = encodeBase64(reinterpret_cast<std::uint8_t *>(buffer.get()), requiredSize);
|
valueString = encodeBase64(reinterpret_cast<std::uint8_t *>(buffer.get()), requiredSize);
|
||||||
|
|
||||||
} catch (const Failure &) {
|
} catch (const Failure &) {
|
||||||
diag.emplace_back(DiagLevel::Critical, "Unable to make METADATA_BLOCK_PICTURE struct from the assigned value.", context);
|
diag.emplace_back(DiagLevel::Critical, "Unable to make METADATA_BLOCK_PICTURE struct from the assigned value.", context);
|
||||||
throw;
|
throw;
|
||||||
|
|
Loading…
Reference in New Issue