LibAudio: Use mapped files for audio playback

This is 10-20% of a speed increase on platforms with fast I/O (Linux)
and not a slowdown on Serenity. Again, the file system layer is the
limit for us :^)
This commit is contained in:
kleines Filmröllchen 2023-09-12 22:44:07 +02:00 committed by Tim Schumacher
parent d6571f54d8
commit 968038aa79

View file

@ -10,7 +10,7 @@
#include <LibAudio/MP3Loader.h>
#include <LibAudio/QOALoader.h>
#include <LibAudio/WavLoader.h>
#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
namespace Audio {
@ -44,7 +44,7 @@ static constexpr LoaderPluginInitializer s_initializers[] = {
ErrorOr<NonnullRefPtr<Loader>, LoaderError> Loader::create(StringView path)
{
auto stream = TRY(Core::InputBufferedFile::create(TRY(Core::File::open(path, Core::File::OpenMode::Read))));
auto stream = TRY(Core::MappedFile::map(path, Core::MappedFile::OpenMode::ReadOnly));
return adopt_ref(*new (nothrow) Loader(TRY(Loader::create_plugin(move(stream)))));
}