summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2022-02-20 13:18:38 +0100
committerLinus Groh <mail@linusgroh.de>2022-04-21 13:55:00 +0200
commitcb0e95c928e152d39dc60198ab714f437a2347ce (patch)
tree2466dca62702a23b30401e34429dc8a1d035dbef /Userland/Libraries
parentfc7d231b004e6d141caf880dc837b701dd1898f5 (diff)
downloadserenity-cb0e95c928e152d39dc60198ab714f437a2347ce.zip
LibAudio+Everywhere: Rename Audio::Buffer -> Audio::LegacyBuffer
With the following change in how we send audio, the old Buffer type is not really needed anymore. However, moving WavLoader to the new system is a bit more involved and out of the scope of this PR. Therefore, we need to keep Buffer around, but to make it clear that it's the old buffer type which will be removed soon, we rename it to LegacyBuffer. Most of the users will be gone after the next commit anyways.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibAudio/Buffer.cpp8
-rw-r--r--Userland/Libraries/LibAudio/Buffer.h26
-rw-r--r--Userland/Libraries/LibAudio/ConnectionFromClient.cpp6
-rw-r--r--Userland/Libraries/LibAudio/ConnectionFromClient.h8
-rw-r--r--Userland/Libraries/LibAudio/FlacLoader.cpp4
-rw-r--r--Userland/Libraries/LibAudio/Loader.h2
-rw-r--r--Userland/Libraries/LibAudio/MP3Loader.cpp4
-rw-r--r--Userland/Libraries/LibAudio/Resampler.cpp4
-rw-r--r--Userland/Libraries/LibAudio/Resampler.h4
-rw-r--r--Userland/Libraries/LibAudio/WavLoader.cpp4
-rw-r--r--Userland/Libraries/LibAudio/WavLoader.h4
11 files changed, 37 insertions, 37 deletions
diff --git a/Userland/Libraries/LibAudio/Buffer.cpp b/Userland/Libraries/LibAudio/Buffer.cpp
index 1152a6ade3..b313b500fe 100644
--- a/Userland/Libraries/LibAudio/Buffer.cpp
+++ b/Userland/Libraries/LibAudio/Buffer.cpp
@@ -13,7 +13,7 @@
namespace Audio {
-i32 Buffer::allocate_id()
+i32 LegacyBuffer::allocate_id()
{
static Atomic<i32> next_id;
return next_id++;
@@ -97,13 +97,13 @@ static double read_norm_sample_8(InputMemoryStream& stream)
return double(sample) / NumericLimits<u8>::max();
}
-ErrorOr<NonnullRefPtr<Buffer>> Buffer::from_pcm_data(ReadonlyBytes data, int num_channels, PcmSampleFormat sample_format)
+ErrorOr<NonnullRefPtr<LegacyBuffer>> LegacyBuffer::from_pcm_data(ReadonlyBytes data, int num_channels, PcmSampleFormat sample_format)
{
InputMemoryStream stream { data };
return from_pcm_stream(stream, num_channels, sample_format, data.size() / (pcm_bits_per_sample(sample_format) / 8));
}
-ErrorOr<NonnullRefPtr<Buffer>> Buffer::from_pcm_stream(InputMemoryStream& stream, int num_channels, PcmSampleFormat sample_format, int num_samples)
+ErrorOr<NonnullRefPtr<LegacyBuffer>> LegacyBuffer::from_pcm_stream(InputMemoryStream& stream, int num_channels, PcmSampleFormat sample_format, int num_samples)
{
Vector<Sample> fdata;
fdata.ensure_capacity(num_samples);
@@ -133,7 +133,7 @@ ErrorOr<NonnullRefPtr<Buffer>> Buffer::from_pcm_stream(InputMemoryStream& stream
// don't belong.
VERIFY(!stream.handle_any_error());
- return Buffer::create_with_samples(move(fdata));
+ return LegacyBuffer::create_with_samples(move(fdata));
}
}
diff --git a/Userland/Libraries/LibAudio/Buffer.h b/Userland/Libraries/LibAudio/Buffer.h
index cb05a06219..bf53291f45 100644
--- a/Userland/Libraries/LibAudio/Buffer.h
+++ b/Userland/Libraries/LibAudio/Buffer.h
@@ -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);
}
diff --git a/Userland/Libraries/LibAudio/ConnectionFromClient.cpp b/Userland/Libraries/LibAudio/ConnectionFromClient.cpp
index ae5ee7210b..77d747f862 100644
--- a/Userland/Libraries/LibAudio/ConnectionFromClient.cpp
+++ b/Userland/Libraries/LibAudio/ConnectionFromClient.cpp
@@ -19,7 +19,7 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSock
{
}
-void ConnectionFromClient::enqueue(Buffer const& buffer)
+void ConnectionFromClient::enqueue(LegacyBuffer const& buffer)
{
for (;;) {
auto success = enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count());
@@ -29,12 +29,12 @@ void ConnectionFromClient::enqueue(Buffer const& buffer)
}
}
-void ConnectionFromClient::async_enqueue(Buffer const& buffer)
+void ConnectionFromClient::async_enqueue(LegacyBuffer const& buffer)
{
async_enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count());
}
-bool ConnectionFromClient::try_enqueue(Buffer const& buffer)
+bool ConnectionFromClient::try_enqueue(LegacyBuffer const& buffer)
{
return enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count());
}
diff --git a/Userland/Libraries/LibAudio/ConnectionFromClient.h b/Userland/Libraries/LibAudio/ConnectionFromClient.h
index 7210353075..61ad818c42 100644
--- a/Userland/Libraries/LibAudio/ConnectionFromClient.h
+++ b/Userland/Libraries/LibAudio/ConnectionFromClient.h
@@ -12,16 +12,16 @@
namespace Audio {
-class Buffer;
+class LegacyBuffer;
class ConnectionFromClient final
: public IPC::ConnectionToServer<AudioClientEndpoint, AudioServerEndpoint>
, public AudioClientEndpoint {
IPC_CLIENT_CONNECTION(ConnectionFromClient, "/tmp/portal/audio")
public:
- void enqueue(Buffer const&);
- bool try_enqueue(Buffer const&);
- void async_enqueue(Buffer const&);
+ void enqueue(LegacyBuffer const&);
+ bool try_enqueue(LegacyBuffer const&);
+ void async_enqueue(LegacyBuffer const&);
Function<void(i32 buffer_id)> on_finish_playing_buffer;
Function<void(bool muted)> on_main_mix_muted_state_change;
diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp
index cce821a5fb..3a504151ab 100644
--- a/Userland/Libraries/LibAudio/FlacLoader.cpp
+++ b/Userland/Libraries/LibAudio/FlacLoader.cpp
@@ -242,7 +242,7 @@ LoaderSamples FlacLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_i
{
ssize_t remaining_samples = static_cast<ssize_t>(m_total_samples - m_loaded_samples);
if (remaining_samples <= 0)
- return Buffer::create_empty();
+ return LegacyBuffer::create_empty();
// FIXME: samples_to_read is calculated wrong, because when seeking not all samples are loaded.
size_t samples_to_read = min(max_bytes_to_read_from_input, remaining_samples);
@@ -267,7 +267,7 @@ LoaderSamples FlacLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_i
}
m_loaded_samples += sample_index;
- auto maybe_buffer = Buffer::create_with_samples(move(samples));
+ auto maybe_buffer = LegacyBuffer::create_with_samples(move(samples));
if (maybe_buffer.is_error())
return LoaderError { LoaderError::Category::Internal, m_loaded_samples, "Couldn't allocate sample buffer" };
return maybe_buffer.release_value();
diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h
index bca513c083..4d5b68cdd0 100644
--- a/Userland/Libraries/LibAudio/Loader.h
+++ b/Userland/Libraries/LibAudio/Loader.h
@@ -22,7 +22,7 @@ namespace Audio {
static constexpr StringView no_plugin_error = "No loader plugin available";
-using LoaderSamples = Result<NonnullRefPtr<Buffer>, LoaderError>;
+using LoaderSamples = Result<NonnullRefPtr<LegacyBuffer>, LoaderError>;
using MaybeLoaderError = Result<void, LoaderError>;
class LoaderPlugin {
diff --git a/Userland/Libraries/LibAudio/MP3Loader.cpp b/Userland/Libraries/LibAudio/MP3Loader.cpp
index 60b6ab95a7..ca0199f805 100644
--- a/Userland/Libraries/LibAudio/MP3Loader.cpp
+++ b/Userland/Libraries/LibAudio/MP3Loader.cpp
@@ -126,7 +126,7 @@ LoaderSamples MP3LoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_in
auto maybe_frame = read_next_frame();
if (maybe_frame.is_error()) {
if (m_input_stream->unreliable_eof()) {
- return Buffer::create_empty();
+ return LegacyBuffer::create_empty();
}
return maybe_frame.release_error();
}
@@ -156,7 +156,7 @@ LoaderSamples MP3LoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_in
}
m_loaded_samples += samples.size();
- auto maybe_buffer = Buffer::create_with_samples(move(samples));
+ auto maybe_buffer = LegacyBuffer::create_with_samples(move(samples));
if (maybe_buffer.is_error())
return LoaderError { LoaderError::Category::Internal, m_loaded_samples, "Couldn't allocate sample buffer" };
return maybe_buffer.release_value();
diff --git a/Userland/Libraries/LibAudio/Resampler.cpp b/Userland/Libraries/LibAudio/Resampler.cpp
index 35ed37c536..cfcd4589d1 100644
--- a/Userland/Libraries/LibAudio/Resampler.cpp
+++ b/Userland/Libraries/LibAudio/Resampler.cpp
@@ -10,7 +10,7 @@
namespace Audio {
-ErrorOr<NonnullRefPtr<Buffer>> resample_buffer(ResampleHelper<double>& resampler, Buffer const& to_resample)
+ErrorOr<NonnullRefPtr<LegacyBuffer>> resample_buffer(ResampleHelper<double>& resampler, LegacyBuffer const& to_resample)
{
Vector<Sample> resampled;
resampled.ensure_capacity(to_resample.sample_count() * ceil_div(resampler.source(), resampler.target()));
@@ -22,7 +22,7 @@ ErrorOr<NonnullRefPtr<Buffer>> resample_buffer(ResampleHelper<double>& resampler
resampled.append(sample);
}
- return Buffer::create_with_samples(move(resampled));
+ return LegacyBuffer::create_with_samples(move(resampled));
}
}
diff --git a/Userland/Libraries/LibAudio/Resampler.h b/Userland/Libraries/LibAudio/Resampler.h
index c7c7328df8..2b48dbf888 100644
--- a/Userland/Libraries/LibAudio/Resampler.h
+++ b/Userland/Libraries/LibAudio/Resampler.h
@@ -84,7 +84,7 @@ private:
SampleType m_last_sample_r {};
};
-class Buffer;
-ErrorOr<NonnullRefPtr<Buffer>> resample_buffer(ResampleHelper<double>& resampler, Buffer const& to_resample);
+class LegacyBuffer;
+ErrorOr<NonnullRefPtr<LegacyBuffer>> resample_buffer(ResampleHelper<double>& resampler, LegacyBuffer const& to_resample);
}
diff --git a/Userland/Libraries/LibAudio/WavLoader.cpp b/Userland/Libraries/LibAudio/WavLoader.cpp
index 6168cf5926..d5fa8ee57e 100644
--- a/Userland/Libraries/LibAudio/WavLoader.cpp
+++ b/Userland/Libraries/LibAudio/WavLoader.cpp
@@ -53,7 +53,7 @@ LoaderSamples WavLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_in
int remaining_samples = m_total_samples - m_loaded_samples;
if (remaining_samples <= 0)
- return Buffer::create_empty();
+ return LegacyBuffer::create_empty();
// One "sample" contains data from all channels.
// In the Wave spec, this is also called a block.
@@ -78,7 +78,7 @@ LoaderSamples WavLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_in
if (m_stream->handle_any_error())
return LoaderError { LoaderError::Category::IO, static_cast<size_t>(m_loaded_samples), "Stream read error" };
- auto buffer = Buffer::from_pcm_data(
+ auto buffer = LegacyBuffer::from_pcm_data(
sample_data.bytes(),
m_num_channels,
m_sample_format);
diff --git a/Userland/Libraries/LibAudio/WavLoader.h b/Userland/Libraries/LibAudio/WavLoader.h
index 50e97b5648..6faf3ccbbc 100644
--- a/Userland/Libraries/LibAudio/WavLoader.h
+++ b/Userland/Libraries/LibAudio/WavLoader.h
@@ -21,7 +21,7 @@
#include <LibCore/FileStream.h>
namespace Audio {
-class Buffer;
+class LegacyBuffer;
// defines for handling the WAV header data
#define WAVE_FORMAT_PCM 0x0001 // PCM
@@ -30,7 +30,7 @@ class Buffer;
#define WAVE_FORMAT_MULAW 0x0007 // 8-bit ITU-T G.711 µ-law
#define WAVE_FORMAT_EXTENSIBLE 0xFFFE // Determined by SubFormat
-// Parses a WAV file and produces an Audio::Buffer.
+// Parses a WAV file and produces an Audio::LegacyBuffer.
class WavLoaderPlugin : public LoaderPlugin {
public:
explicit WavLoaderPlugin(StringView path);