mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 16:10:20 +00:00
LibAudio: Add an array conversion transitional API to Buffer
Of course, Buffer is going to be removed very soon, but much of the WavLoader behavior still depends on it. Therefore, this intermediary API will allow adopting the Loader infrastructure without digging too deep into the WavLoader legacy code. That's for later :^)
This commit is contained in:
parent
63d9ec8e94
commit
50dc9a7be7
Notes:
sideshowbarker
2024-07-17 18:12:52 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/50dc9a7be7 Pull-request: https://github.com/SerenityOS/serenity/pull/12734 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/awesomekling
1 changed files with 9 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "AK/TypedTransfer.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/FixedArray.h>
|
||||
|
@ -47,6 +48,14 @@ public:
|
|||
}
|
||||
|
||||
Sample const* samples() const { return (const Sample*)data(); }
|
||||
|
||||
ErrorOr<FixedArray<Sample>> to_sample_array() const
|
||||
{
|
||||
FixedArray<Sample> samples = TRY(FixedArray<Sample>::try_create(m_sample_count));
|
||||
AK::TypedTransfer<Sample>::copy(samples.data(), this->samples(), m_sample_count);
|
||||
return samples;
|
||||
}
|
||||
|
||||
int sample_count() const { return m_sample_count; }
|
||||
void const* data() const { return m_buffer.data<void>(); }
|
||||
int size_in_bytes() const { return m_sample_count * (int)sizeof(Sample); }
|
||||
|
|
Loading…
Reference in a new issue