ladybird/Userland/Libraries/LibAudio/WavLoader.cpp

347 lines
15 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021-2023, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "WavLoader.h"
#include "LoaderError.h"
#include "RIFFTypes.h"
#include <AK/Debug.h>
#include <AK/Endian.h>
LibAudio+Userland: Use new audio queue in client-server communication Previously, we were sending Buffers to the server whenever we had new audio data for it. This meant that for every audio enqueue action, we needed to create a new shared memory anonymous buffer, send that buffer's file descriptor over IPC (+recfd on the other side) and then map the buffer into the audio server's memory to be able to play it. This was fine for sending large chunks of audio data, like when playing existing audio files. However, in the future we want to move to real-time audio in some applications like Piano. This means that the size of buffers that are sent need to be very small, as just the size of a buffer itself is part of the audio latency. If we were to try real-time audio with the existing system, we would run into problems really quickly. Dealing with a continuous stream of new anonymous files like the current audio system is rather expensive, as we need Kernel help in multiple places. Additionally, every enqueue incurs an IPC call, which are not optimized for >1000 calls/second (which would be needed for real-time audio with buffer sizes of ~40 samples). So a fundamental change in how we handle audio sending in userspace is necessary. This commit moves the audio sending system onto a shared single producer circular queue (SSPCQ) (introduced with one of the previous commits). This queue is intended to live in shared memory and be accessed by multiple processes at the same time. It was specifically written to support the audio sending case, so e.g. it only supports a single producer (the audio client). Now, audio sending follows these general steps: - The audio client connects to the audio server. - The audio client creates a SSPCQ in shared memory. - The audio client sends the SSPCQ's file descriptor to the audio server with the set_buffer() IPC call. - The audio server receives the SSPCQ and maps it. - The audio client signals start of playback with start_playback(). - At the same time: - The audio client writes its audio data into the shared-memory queue. - The audio server reads audio data from the shared-memory queue(s). Both sides have additional before-queue/after-queue buffers, depending on the exact application. - Pausing playback is just an IPC call, nothing happens to the buffer except that the server stops reading from it until playback is resumed. - Muting has nothing to do with whether audio data is read or not. - When the connection closes, the queues are unmapped on both sides. This should already improve audio playback performance in a bunch of places. Implementation & commit notes: - Audio loaders don't create LegacyBuffers anymore. LegacyBuffer is kept for WavLoader, see previous commit message. - Most intra-process audio data passing is done with FixedArray<Sample> or Vector<Sample>. - Improvements to most audio-enqueuing applications. (If necessary I can try to extract some of the aplay improvements.) - New APIs on LibAudio/ClientConnection which allows non-realtime applications to enqueue audio in big chunks like before. - Removal of status APIs from the audio server connection for information that can be directly obtained from the shared queue. - Split the pause playback API into two APIs with more intuitive names. I know this is a large commit, and you can kinda tell from the commit message. It's basically impossible to break this up without hacks, so please forgive me. These are some of the best changes to the audio subsystem and I hope that that makes up for this :yaktangle: commit. :yakring:
2022-02-20 13:01:22 +01:00
#include <AK/FixedArray.h>
2023-01-25 20:19:05 +01:00
#include <AK/MemoryStream.h>
#include <AK/NumericLimits.h>
2021-11-27 17:00:19 +01:00
#include <AK/Try.h>
#include <LibCore/File.h>
namespace Audio {
static constexpr size_t const maximum_wav_size = 1 * GiB; // FIXME: is there a more appropriate size limit?
WavLoaderPlugin::WavLoaderPlugin(NonnullOwnPtr<SeekableStream> stream)
: LoaderPlugin(move(stream))
{
2021-11-27 17:00:19 +01:00
}
Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::create(StringView path)
2021-11-27 17:00:19 +01:00
{
auto stream = LOADER_TRY(Core::InputBufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read))));
auto loader = make<WavLoaderPlugin>(move(stream));
LOADER_TRY(loader->initialize());
return loader;
}
Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::create(Bytes buffer)
{
auto stream = LOADER_TRY(try_make<FixedMemoryStream>(buffer));
auto loader = make<WavLoaderPlugin>(move(stream));
LOADER_TRY(loader->initialize());
return loader;
}
MaybeLoaderError WavLoaderPlugin::initialize()
{
LOADER_TRY(parse_header());
return {};
}
template<typename SampleReader>
MaybeLoaderError WavLoaderPlugin::read_samples_from_stream(Stream& stream, SampleReader read_sample, FixedArray<Sample>& samples) const
{
switch (m_num_channels) {
case 1:
for (auto& sample : samples)
sample = Sample(LOADER_TRY(read_sample(stream)));
break;
case 2:
for (auto& sample : samples) {
auto left_channel_sample = LOADER_TRY(read_sample(stream));
auto right_channel_sample = LOADER_TRY(read_sample(stream));
sample = Sample(left_channel_sample, right_channel_sample);
}
break;
default:
VERIFY_NOT_REACHED();
}
return {};
}
// There's no i24 type + we need to do the endianness conversion manually anyways.
static ErrorOr<double> read_sample_int24(Stream& stream)
{
i32 sample1 = TRY(stream.read_value<u8>());
i32 sample2 = TRY(stream.read_value<u8>());
i32 sample3 = TRY(stream.read_value<u8>());
i32 value = 0;
value = sample1;
value |= sample2 << 8;
value |= sample3 << 16;
// Sign extend the value, as it can currently not have the correct sign.
value = (value << 8) >> 8;
// Range of value is now -2^23 to 2^23-1 and we can rescale normally.
return static_cast<double>(value) / static_cast<double>((1 << 23) - 1);
}
template<typename T>
static ErrorOr<double> read_sample(Stream& stream)
{
T sample { 0 };
TRY(stream.read_until_filled(Bytes { &sample, sizeof(T) }));
// Remap integer samples to normalized floating-point range of -1 to 1.
if constexpr (IsIntegral<T>) {
if constexpr (NumericLimits<T>::is_signed()) {
// Signed integer samples are centered around zero, so this division is enough.
return static_cast<double>(AK::convert_between_host_and_little_endian(sample)) / static_cast<double>(NumericLimits<T>::max());
} else {
// Unsigned integer samples, on the other hand, need to be shifted to center them around zero.
// The first division therefore remaps to the range 0 to 2.
return static_cast<double>(AK::convert_between_host_and_little_endian(sample)) / (static_cast<double>(NumericLimits<T>::max()) / 2.0) - 1.0;
}
} else {
return static_cast<double>(AK::convert_between_host_and_little_endian(sample));
}
}
LoaderSamples WavLoaderPlugin::samples_from_pcm_data(Bytes const& data, size_t samples_to_read) const
{
FixedArray<Sample> samples = LOADER_TRY(FixedArray<Sample>::create(samples_to_read));
FixedMemoryStream stream { data };
switch (m_sample_format) {
case PcmSampleFormat::Uint8:
TRY(read_samples_from_stream(stream, read_sample<u8>, samples));
break;
case PcmSampleFormat::Int16:
TRY(read_samples_from_stream(stream, read_sample<i16>, samples));
break;
case PcmSampleFormat::Int24:
TRY(read_samples_from_stream(stream, read_sample_int24, samples));
break;
case PcmSampleFormat::Float32:
TRY(read_samples_from_stream(stream, read_sample<float>, samples));
break;
case PcmSampleFormat::Float64:
TRY(read_samples_from_stream(stream, read_sample<double>, samples));
break;
default:
VERIFY_NOT_REACHED();
}
return samples;
}
LibAudio: Move audio stream buffering into the loader Before, some loader plugins implemented their own buffering (FLAC&MP3), some didn't require any (WAV), and some didn't buffer at all (QOA). This meant that in practice, while you could load arbitrary amounts of samples from some loader plugins, you couldn't do that with some others. Also, it was ill-defined how many samples you would actually get back from a get_more_samples call. This commit fixes that by introducing a layer of abstraction between the loader and its plugins (because that's the whole point of having the extra class!). The plugins now only implement a load_chunks() function, which is much simpler to implement and allows plugins to play fast and loose with what they actually return. Basically, they can return many chunks of samples, where one chunk is simply a convenient block of samples to load. In fact, some loaders such as FLAC and QOA have separate internal functions for loading exactly one chunk. The loaders *should* load as many chunks as necessary for the sample count to be reached or surpassed (the latter simplifies loading loops in the implementations, since you don't need to know how large your next chunk is going to be; a problem for e.g. FLAC). If a plugin has no problems returning data of arbitrary size (currently WAV), it can return a single chunk that exactly (or roughly) matches the requested sample count. If a plugin is at the stream end, it can also return less samples than was requested! The loader can handle all of these cases and may call into load_chunk multiple times. If the plugin returns an empty chunk list (or only empty chunks; again, they can play fast and loose), the loader takes that as a stream end signal. Otherwise, the loader will always return exactly as many samples as the user requested. Buffering is handled by the loader, allowing any underlying plugin to deal with any weird sample count requirement the user throws at it (looking at you, SoundPlayer!). This (not accidentally!) makes QOA work in SoundPlayer.
2023-02-27 00:05:14 +01:00
ErrorOr<Vector<FixedArray<Sample>>, LoaderError> WavLoaderPlugin::load_chunks(size_t samples_to_read_from_input)
{
auto remaining_samples = m_total_samples - m_loaded_samples;
2021-11-27 17:00:19 +01:00
if (remaining_samples <= 0)
LibAudio: Move audio stream buffering into the loader Before, some loader plugins implemented their own buffering (FLAC&MP3), some didn't require any (WAV), and some didn't buffer at all (QOA). This meant that in practice, while you could load arbitrary amounts of samples from some loader plugins, you couldn't do that with some others. Also, it was ill-defined how many samples you would actually get back from a get_more_samples call. This commit fixes that by introducing a layer of abstraction between the loader and its plugins (because that's the whole point of having the extra class!). The plugins now only implement a load_chunks() function, which is much simpler to implement and allows plugins to play fast and loose with what they actually return. Basically, they can return many chunks of samples, where one chunk is simply a convenient block of samples to load. In fact, some loaders such as FLAC and QOA have separate internal functions for loading exactly one chunk. The loaders *should* load as many chunks as necessary for the sample count to be reached or surpassed (the latter simplifies loading loops in the implementations, since you don't need to know how large your next chunk is going to be; a problem for e.g. FLAC). If a plugin has no problems returning data of arbitrary size (currently WAV), it can return a single chunk that exactly (or roughly) matches the requested sample count. If a plugin is at the stream end, it can also return less samples than was requested! The loader can handle all of these cases and may call into load_chunk multiple times. If the plugin returns an empty chunk list (or only empty chunks; again, they can play fast and loose), the loader takes that as a stream end signal. Otherwise, the loader will always return exactly as many samples as the user requested. Buffering is handled by the loader, allowing any underlying plugin to deal with any weird sample count requirement the user throws at it (looking at you, SoundPlayer!). This (not accidentally!) makes QOA work in SoundPlayer.
2023-02-27 00:05:14 +01:00
return Vector<FixedArray<Sample>> {};
// One "sample" contains data from all channels.
// In the Wave spec, this is also called a block.
2021-11-27 17:00:19 +01:00
size_t bytes_per_sample
= m_num_channels * pcm_bits_per_sample(m_sample_format) / 8;
LibAudio: Move audio stream buffering into the loader Before, some loader plugins implemented their own buffering (FLAC&MP3), some didn't require any (WAV), and some didn't buffer at all (QOA). This meant that in practice, while you could load arbitrary amounts of samples from some loader plugins, you couldn't do that with some others. Also, it was ill-defined how many samples you would actually get back from a get_more_samples call. This commit fixes that by introducing a layer of abstraction between the loader and its plugins (because that's the whole point of having the extra class!). The plugins now only implement a load_chunks() function, which is much simpler to implement and allows plugins to play fast and loose with what they actually return. Basically, they can return many chunks of samples, where one chunk is simply a convenient block of samples to load. In fact, some loaders such as FLAC and QOA have separate internal functions for loading exactly one chunk. The loaders *should* load as many chunks as necessary for the sample count to be reached or surpassed (the latter simplifies loading loops in the implementations, since you don't need to know how large your next chunk is going to be; a problem for e.g. FLAC). If a plugin has no problems returning data of arbitrary size (currently WAV), it can return a single chunk that exactly (or roughly) matches the requested sample count. If a plugin is at the stream end, it can also return less samples than was requested! The loader can handle all of these cases and may call into load_chunk multiple times. If the plugin returns an empty chunk list (or only empty chunks; again, they can play fast and loose), the loader takes that as a stream end signal. Otherwise, the loader will always return exactly as many samples as the user requested. Buffering is handled by the loader, allowing any underlying plugin to deal with any weird sample count requirement the user throws at it (looking at you, SoundPlayer!). This (not accidentally!) makes QOA work in SoundPlayer.
2023-02-27 00:05:14 +01:00
auto samples_to_read = min(samples_to_read_from_input, remaining_samples);
auto bytes_to_read = samples_to_read * bytes_per_sample;
dbgln_if(AWAVLOADER_DEBUG, "Read {} bytes WAV with num_channels {} sample rate {}, "
"bits per sample {}, sample format {}",
bytes_to_read, m_num_channels, m_sample_rate,
pcm_bits_per_sample(m_sample_format), sample_format_name(m_sample_format));
auto sample_data = LOADER_TRY(ByteBuffer::create_zeroed(bytes_to_read));
LOADER_TRY(m_stream->read_until_filled(sample_data.bytes()));
// m_loaded_samples should contain the amount of actually loaded samples
m_loaded_samples += samples_to_read;
LibAudio: Move audio stream buffering into the loader Before, some loader plugins implemented their own buffering (FLAC&MP3), some didn't require any (WAV), and some didn't buffer at all (QOA). This meant that in practice, while you could load arbitrary amounts of samples from some loader plugins, you couldn't do that with some others. Also, it was ill-defined how many samples you would actually get back from a get_more_samples call. This commit fixes that by introducing a layer of abstraction between the loader and its plugins (because that's the whole point of having the extra class!). The plugins now only implement a load_chunks() function, which is much simpler to implement and allows plugins to play fast and loose with what they actually return. Basically, they can return many chunks of samples, where one chunk is simply a convenient block of samples to load. In fact, some loaders such as FLAC and QOA have separate internal functions for loading exactly one chunk. The loaders *should* load as many chunks as necessary for the sample count to be reached or surpassed (the latter simplifies loading loops in the implementations, since you don't need to know how large your next chunk is going to be; a problem for e.g. FLAC). If a plugin has no problems returning data of arbitrary size (currently WAV), it can return a single chunk that exactly (or roughly) matches the requested sample count. If a plugin is at the stream end, it can also return less samples than was requested! The loader can handle all of these cases and may call into load_chunk multiple times. If the plugin returns an empty chunk list (or only empty chunks; again, they can play fast and loose), the loader takes that as a stream end signal. Otherwise, the loader will always return exactly as many samples as the user requested. Buffering is handled by the loader, allowing any underlying plugin to deal with any weird sample count requirement the user throws at it (looking at you, SoundPlayer!). This (not accidentally!) makes QOA work in SoundPlayer.
2023-02-27 00:05:14 +01:00
Vector<FixedArray<Sample>> samples;
TRY(samples.try_append(TRY(samples_from_pcm_data(sample_data.bytes(), samples_to_read))));
return samples;
}
MaybeLoaderError WavLoaderPlugin::seek(int sample_index)
{
dbgln_if(AWAVLOADER_DEBUG, "seek sample_index {}", sample_index);
if (sample_index < 0 || sample_index >= static_cast<int>(m_total_samples))
return LoaderError { LoaderError::Category::Internal, m_loaded_samples, "Seek outside the sample range" };
size_t sample_offset = m_byte_offset_of_data_samples + static_cast<size_t>(sample_index * m_num_channels * (pcm_bits_per_sample(m_sample_format) / 8));
LOADER_TRY(m_stream->seek(sample_offset, SeekMode::SetPosition));
m_loaded_samples = sample_index;
2021-11-27 17:00:19 +01:00
return {};
}
// Specification reference: http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
2021-11-27 17:00:19 +01:00
MaybeLoaderError WavLoaderPlugin::parse_header()
{
#define CHECK(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(LOADER_TRY(m_stream->tell())), DeprecatedString::formatted("WAV header: {}", msg) }; \
} \
} while (0)
auto riff = TRY(m_stream->read_value<RIFF::ChunkID>());
CHECK(riff == RIFF::riff_magic, LoaderError::Category::Format, "RIFF header magic invalid");
u32 size = TRY(m_stream->read_value<LittleEndian<u32>>());
CHECK(size < maximum_wav_size, LoaderError::Category::Format, "File size too large");
auto wave = TRY(m_stream->read_value<RIFF::ChunkID>());
CHECK(wave == RIFF::wave_subformat_id, LoaderError::Category::Format, "WAVE subformat id invalid");
auto format_chunk = TRY(m_stream->read_value<RIFF::Chunk>());
CHECK(format_chunk.id.as_ascii_string() == RIFF::format_chunk_id, LoaderError::Category::Format, "FMT chunk id invalid");
auto format_stream = format_chunk.data_stream();
u16 audio_format = TRY(format_stream.read_value<LittleEndian<u16>>());
CHECK(audio_format == to_underlying(RIFF::WaveFormat::Pcm) || audio_format == to_underlying(RIFF::WaveFormat::IEEEFloat) || audio_format == to_underlying(RIFF::WaveFormat::Extensible),
LoaderError::Category::Unimplemented, "Audio format not supported");
m_num_channels = TRY(format_stream.read_value<LittleEndian<u16>>());
CHECK(m_num_channels == 1 || m_num_channels == 2, LoaderError::Category::Unimplemented, "Channel count");
m_sample_rate = TRY(format_stream.read_value<LittleEndian<u32>>());
// Data rate; can be ignored.
TRY(format_stream.read_value<LittleEndian<u32>>());
u16 block_size_bytes = TRY(format_stream.read_value<LittleEndian<u16>>());
u16 bits_per_sample = TRY(format_stream.read_value<LittleEndian<u16>>());
if (audio_format == to_underlying(RIFF::WaveFormat::Extensible)) {
CHECK(format_chunk.size == 40, LoaderError::Category::Format, "Extensible fmt size is not 40 bytes");
// Discard everything until the GUID.
// We've already read 16 bytes from the stream. The GUID starts in another 8 bytes.
TRY(format_stream.read_value<LittleEndian<u64>>());
// Get the underlying audio format from the first two bytes of GUID
u16 guid_subformat = TRY(format_stream.read_value<LittleEndian<u16>>());
CHECK(guid_subformat == to_underlying(RIFF::WaveFormat::Pcm) || guid_subformat == to_underlying(RIFF::WaveFormat::IEEEFloat), LoaderError::Category::Unimplemented, "GUID SubFormat not supported");
audio_format = guid_subformat;
}
if (audio_format == to_underlying(RIFF::WaveFormat::Pcm)) {
CHECK(bits_per_sample == 8 || bits_per_sample == 16 || bits_per_sample == 24, LoaderError::Category::Unimplemented, "PCM bits per sample not supported");
// We only support 8-24 bit audio right now because other formats are uncommon
if (bits_per_sample == 8) {
m_sample_format = PcmSampleFormat::Uint8;
} else if (bits_per_sample == 16) {
m_sample_format = PcmSampleFormat::Int16;
} else if (bits_per_sample == 24) {
m_sample_format = PcmSampleFormat::Int24;
}
} else if (audio_format == to_underlying(RIFF::WaveFormat::IEEEFloat)) {
CHECK(bits_per_sample == 32 || bits_per_sample == 64, LoaderError::Category::Unimplemented, "Float bits per sample not supported");
// Again, only the common 32 and 64 bit
if (bits_per_sample == 32) {
m_sample_format = PcmSampleFormat::Float32;
} else if (bits_per_sample == 64) {
m_sample_format = PcmSampleFormat::Float64;
}
}
CHECK(block_size_bytes == (m_num_channels * (bits_per_sample / 8)), LoaderError::Category::Format, "Block size invalid");
dbgln_if(AWAVLOADER_DEBUG, "WAV format {} at {} bit, {} channels, rate {}Hz ",
sample_format_name(m_sample_format), pcm_bits_per_sample(m_sample_format), m_num_channels, m_sample_rate);
// Read all chunks before DATA.
bool found_data = false;
while (!found_data) {
auto chunk_header = TRY(m_stream->read_value<RIFF::ChunkID>());
if (chunk_header == RIFF::data_chunk_id) {
found_data = true;
} else {
TRY(m_stream->seek(-RIFF::chunk_id_size, SeekMode::FromCurrentPosition));
auto chunk = TRY(m_stream->read_value<RIFF::Chunk>());
if (chunk.id == RIFF::list_chunk_id) {
auto maybe_list = chunk.data_stream().read_value<RIFF::List>();
if (maybe_list.is_error()) {
dbgln("WAV Warning: LIST chunk invalid, error: {}", maybe_list.release_error());
continue;
}
auto list = maybe_list.release_value();
if (list.type == RIFF::info_chunk_id) {
auto maybe_error = load_wav_info_block(move(list.chunks));
if (maybe_error.is_error())
dbgln("WAV Warning: INFO chunk invalid, error: {}", maybe_error.release_error());
} else {
dbgln("Unhandled WAV list of type {} with {} subchunks", list.type.as_ascii_string(), list.chunks.size());
}
} else {
dbgln_if(AWAVLOADER_DEBUG, "Unhandled WAV chunk of type {}, size {} bytes", chunk.id.as_ascii_string(), chunk.size);
}
}
}
u32 data_size = TRY(m_stream->read_value<LittleEndian<u32>>());
CHECK(found_data, LoaderError::Category::Format, "Found no data chunk");
CHECK(data_size < maximum_wav_size, LoaderError::Category::Format, "Data too large");
m_total_samples = data_size / block_size_bytes;
dbgln_if(AWAVLOADER_DEBUG, "WAV data size {}, bytes per sample {}, total samples {}",
data_size,
block_size_bytes,
m_total_samples);
m_byte_offset_of_data_samples = TRY(m_stream->tell());
2021-11-27 17:00:19 +01:00
return {};
}
// http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Docs/riffmci.pdf page 23 (LIST type)
// We only recognize the relevant official metadata types; types added in later errata of RIFF are not relevant for audio.
MaybeLoaderError WavLoaderPlugin::load_wav_info_block(Vector<RIFF::Chunk> info_chunks)
{
for (auto const& chunk : info_chunks) {
auto metadata_name = chunk.id.as_ascii_string();
// Chunk contents are zero-terminated strings "ZSTR", so we just drop the null terminator.
StringView metadata_text { chunk.data.span().trim(chunk.data.size() - 1) };
// Note that we assume chunks to be unique, since that seems to almost always be the case.
// Worst case we just drop some metadata.
if (metadata_name == "IART"sv) {
// Artists are combined together with semicolons, at least when you edit them in Windows File Explorer.
auto artists = metadata_text.split_view(";"sv);
for (auto artist : artists)
TRY(m_metadata.add_person(Person::Role::Artist, TRY(String::from_utf8(artist))));
} else if (metadata_name == "ICMT"sv) {
m_metadata.comment = TRY(String::from_utf8(metadata_text));
} else if (metadata_name == "ICOP"sv) {
m_metadata.copyright = TRY(String::from_utf8(metadata_text));
} else if (metadata_name == "ICRD"sv) {
m_metadata.unparsed_time = TRY(String::from_utf8(metadata_text));
} else if (metadata_name == "IENG"sv) {
TRY(m_metadata.add_person(Person::Role::Engineer, TRY(String::from_utf8(metadata_text))));
} else if (metadata_name == "IGNR"sv) {
m_metadata.genre = TRY(String::from_utf8(metadata_text));
} else if (metadata_name == "INAM"sv) {
m_metadata.title = TRY(String::from_utf8(metadata_text));
} else if (metadata_name == "ISFT"sv) {
m_metadata.encoder = TRY(String::from_utf8(metadata_text));
} else if (metadata_name == "ISRC"sv) {
TRY(m_metadata.add_person(Person::Role::Publisher, TRY(String::from_utf8(metadata_text))));
} else {
TRY(m_metadata.add_miscellaneous(TRY(String::from_utf8(metadata_name)), TRY(String::from_utf8(metadata_text))));
}
}
return {};
}
}