|
@@ -28,23 +28,23 @@ namespace Audio {
|
|
|
using namespace AK::Exponentials;
|
|
|
|
|
|
// A buffer of audio samples.
|
|
|
-class Buffer : public RefCounted<Buffer> {
|
|
|
+class LegacyBuffer : public RefCounted<LegacyBuffer> {
|
|
|
public:
|
|
|
- static ErrorOr<NonnullRefPtr<Buffer>> from_pcm_data(ReadonlyBytes data, int num_channels, PcmSampleFormat sample_format);
|
|
|
- static ErrorOr<NonnullRefPtr<Buffer>> from_pcm_stream(InputMemoryStream& stream, int num_channels, PcmSampleFormat sample_format, int num_samples);
|
|
|
+ static ErrorOr<NonnullRefPtr<LegacyBuffer>> from_pcm_data(ReadonlyBytes data, int num_channels, PcmSampleFormat sample_format);
|
|
|
+ static ErrorOr<NonnullRefPtr<LegacyBuffer>> from_pcm_stream(InputMemoryStream& stream, int num_channels, PcmSampleFormat sample_format, int num_samples);
|
|
|
template<ArrayLike<Sample> ArrayT>
|
|
|
- static ErrorOr<NonnullRefPtr<Buffer>> create_with_samples(ArrayT&& samples)
|
|
|
+ static ErrorOr<NonnullRefPtr<LegacyBuffer>> create_with_samples(ArrayT&& samples)
|
|
|
{
|
|
|
- return adopt_nonnull_ref_or_enomem(new (nothrow) Buffer(move(samples)));
|
|
|
+ return adopt_nonnull_ref_or_enomem(new (nothrow) LegacyBuffer(move(samples)));
|
|
|
}
|
|
|
- static ErrorOr<NonnullRefPtr<Buffer>> create_with_anonymous_buffer(Core::AnonymousBuffer buffer, i32 buffer_id, int sample_count)
|
|
|
+ static ErrorOr<NonnullRefPtr<LegacyBuffer>> create_with_anonymous_buffer(Core::AnonymousBuffer buffer, i32 buffer_id, int sample_count)
|
|
|
{
|
|
|
- return adopt_nonnull_ref_or_enomem(new (nothrow) Buffer(move(buffer), buffer_id, sample_count));
|
|
|
+ return adopt_nonnull_ref_or_enomem(new (nothrow) LegacyBuffer(move(buffer), buffer_id, sample_count));
|
|
|
}
|
|
|
- static NonnullRefPtr<Buffer> create_empty()
|
|
|
+ static NonnullRefPtr<LegacyBuffer> create_empty()
|
|
|
{
|
|
|
// If we can't allocate an empty buffer, things are in a very bad state.
|
|
|
- return MUST(adopt_nonnull_ref_or_enomem(new (nothrow) Buffer));
|
|
|
+ return MUST(adopt_nonnull_ref_or_enomem(new (nothrow) LegacyBuffer));
|
|
|
}
|
|
|
|
|
|
Sample const* samples() const { return (Sample const*)data(); }
|
|
@@ -64,7 +64,7 @@ public:
|
|
|
|
|
|
private:
|
|
|
template<ArrayLike<Sample> ArrayT>
|
|
|
- explicit Buffer(ArrayT&& samples)
|
|
|
+ explicit LegacyBuffer(ArrayT&& samples)
|
|
|
: m_buffer(Core::AnonymousBuffer::create_with_size(samples.size() * sizeof(Sample)).release_value())
|
|
|
, m_id(allocate_id())
|
|
|
, m_sample_count(samples.size())
|
|
@@ -72,7 +72,7 @@ private:
|
|
|
memcpy(m_buffer.data<void>(), samples.data(), samples.size() * sizeof(Sample));
|
|
|
}
|
|
|
|
|
|
- explicit Buffer(Core::AnonymousBuffer buffer, i32 buffer_id, int sample_count)
|
|
|
+ explicit LegacyBuffer(Core::AnonymousBuffer buffer, i32 buffer_id, int sample_count)
|
|
|
: m_buffer(move(buffer))
|
|
|
, m_id(buffer_id)
|
|
|
, m_sample_count(sample_count)
|
|
@@ -80,7 +80,7 @@ private:
|
|
|
}
|
|
|
|
|
|
// Empty Buffer representation, to avoid tiny anonymous buffers in EOF states
|
|
|
- Buffer() = default;
|
|
|
+ LegacyBuffer() = default;
|
|
|
|
|
|
static i32 allocate_id();
|
|
|
|
|
@@ -90,6 +90,6 @@ private:
|
|
|
};
|
|
|
|
|
|
// This only works for double resamplers, and therefore cannot be part of the class
|
|
|
-ErrorOr<NonnullRefPtr<Buffer>> resample_buffer(ResampleHelper<double>& resampler, Buffer const& to_resample);
|
|
|
+ErrorOr<NonnullRefPtr<LegacyBuffer>> resample_buffer(ResampleHelper<double>& resampler, LegacyBuffer const& to_resample);
|
|
|
|
|
|
}
|