mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:17:44 +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
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…
Add table
Add a link
Reference in a new issue