mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 10:36:24 +00:00
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:
parent
d6571f54d8
commit
968038aa79
|
@ -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)))));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue