mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibAudio: Use ReadonlyBytes instead of Bytes for buffer parameters
Bytes will implicitly cast to StringView, but not to ReadonlyBytes. That means that if you call `Audio::Loader::create_plugin(mapped_file->bytes())` it will silently use the `create_plugin(StringView path)` overload. Reading audio data does not require that data to be writable, so let's use ReadonlyBytes for it and avoid the footgun.
This commit is contained in:
parent
8e0fa57e5b
commit
0a9fa85e86
Notes:
sideshowbarker
2024-07-17 02:29:45 +09:00
Author: https://github.com/AtkinsSJ
Commit: 0a9fa85e86
Pull-request: https://github.com/SerenityOS/serenity/pull/19691
Reviewed-by: https://github.com/LucasChollet
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
Reviewed-by: https://github.com/nico ✅
4 changed files with 5 additions and 4 deletions
|
@ -104,7 +104,7 @@ static ErrorOr<double> read_sample(Stream& stream)
|
|||
}
|
||||
}
|
||||
|
||||
LoaderSamples WavLoaderPlugin::samples_from_pcm_data(Bytes const& data, size_t samples_to_read) const
|
||||
LoaderSamples WavLoaderPlugin::samples_from_pcm_data(ReadonlyBytes data, size_t samples_to_read) const
|
||||
{
|
||||
FixedArray<Sample> samples = TRY(FixedArray<Sample>::create(samples_to_read));
|
||||
FixedMemoryStream stream { data };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue