mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
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.
This commit is contained in:
parent
fc7d231b00
commit
cb0e95c928
21 changed files with 54 additions and 54 deletions
|
@ -9,8 +9,8 @@
|
|||
|
||||
#include "TrackManager.h"
|
||||
|
||||
// Converts Piano-internal data to an Audio::Buffer that AudioServer receives
|
||||
static NonnullRefPtr<Audio::Buffer> music_samples_to_buffer(Array<Sample, sample_count> samples)
|
||||
// Converts Piano-internal data to an Audio::LegacyBuffer that AudioServer receives
|
||||
static NonnullRefPtr<Audio::LegacyBuffer> music_samples_to_buffer(Array<Sample, sample_count> samples)
|
||||
{
|
||||
Vector<Audio::Sample, sample_count> frames;
|
||||
frames.ensure_capacity(sample_count);
|
||||
|
@ -19,7 +19,7 @@ static NonnullRefPtr<Audio::Buffer> music_samples_to_buffer(Array<Sample, sample
|
|||
frames.unchecked_append(frame);
|
||||
}
|
||||
// FIXME: Handle OOM better.
|
||||
return MUST(Audio::Buffer::create_with_samples(frames));
|
||||
return MUST(Audio::LegacyBuffer::create_with_samples(frames));
|
||||
}
|
||||
|
||||
AudioPlayerLoop::AudioPlayerLoop(TrackManager& track_manager, bool& need_to_write_wav, Audio::WavWriter& wav_writer)
|
||||
|
@ -42,7 +42,7 @@ AudioPlayerLoop::AudioPlayerLoop(TrackManager& track_manager, bool& need_to_writ
|
|||
void AudioPlayerLoop::enqueue_audio()
|
||||
{
|
||||
m_track_manager.fill_buffer(m_buffer);
|
||||
NonnullRefPtr<Audio::Buffer> audio_buffer = music_samples_to_buffer(m_buffer);
|
||||
NonnullRefPtr<Audio::LegacyBuffer> audio_buffer = music_samples_to_buffer(m_buffer);
|
||||
// FIXME: Handle OOM better.
|
||||
audio_buffer = MUST(Audio::resample_buffer(m_resampler.value(), *audio_buffer));
|
||||
m_audio_client->async_enqueue(audio_buffer);
|
||||
|
|
|
@ -32,12 +32,12 @@ public:
|
|||
int last_seek() const { return m_last_seek; }
|
||||
bool is_paused() const { return m_paused; }
|
||||
float total_length() const { return m_total_length; }
|
||||
RefPtr<Audio::Buffer> current_buffer() const { return m_current_buffer; }
|
||||
RefPtr<Audio::LegacyBuffer> current_buffer() const { return m_current_buffer; }
|
||||
|
||||
NonnullRefPtr<Audio::ConnectionFromClient> connection() const { return m_connection; }
|
||||
|
||||
Function<void()> on_update;
|
||||
Function<void(Audio::Buffer&)> on_load_sample_buffer;
|
||||
Function<void(Audio::LegacyBuffer&)> on_load_sample_buffer;
|
||||
Function<void()> on_finished_playing;
|
||||
|
||||
private:
|
||||
|
@ -56,7 +56,7 @@ private:
|
|||
size_t m_source_buffer_size_bytes { 0 };
|
||||
RefPtr<Audio::Loader> m_loader { nullptr };
|
||||
NonnullRefPtr<Audio::ConnectionFromClient> m_connection;
|
||||
RefPtr<Audio::Buffer> m_current_buffer;
|
||||
RefPtr<Audio::LegacyBuffer> m_current_buffer;
|
||||
Queue<i32, always_enqueued_buffer_count + 1> m_enqueued_buffers;
|
||||
Optional<Audio::ResampleHelper<double>> m_resampler;
|
||||
RefPtr<Core::Timer> m_timer;
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
virtual void volume_changed(double) = 0;
|
||||
virtual void mute_changed(bool) = 0;
|
||||
virtual void total_samples_changed(int) = 0;
|
||||
virtual void sound_buffer_played(RefPtr<Audio::Buffer>, [[maybe_unused]] int sample_rate, [[maybe_unused]] int samples_played) = 0;
|
||||
virtual void sound_buffer_played(RefPtr<Audio::LegacyBuffer>, [[maybe_unused]] int sample_rate, [[maybe_unused]] int samples_played) = 0;
|
||||
|
||||
protected:
|
||||
void done_initializing()
|
||||
|
|
|
@ -216,7 +216,7 @@ void SoundPlayerWidgetAdvancedView::total_samples_changed(int total_samples)
|
|||
m_playback_progress_slider->set_page_step(total_samples / 10);
|
||||
}
|
||||
|
||||
void SoundPlayerWidgetAdvancedView::sound_buffer_played(RefPtr<Audio::Buffer> buffer, int sample_rate, int samples_played)
|
||||
void SoundPlayerWidgetAdvancedView::sound_buffer_played(RefPtr<Audio::LegacyBuffer> buffer, int sample_rate, int samples_played)
|
||||
{
|
||||
m_visualization->set_buffer(buffer);
|
||||
m_visualization->set_samplerate(sample_rate);
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
virtual void volume_changed(double) override;
|
||||
virtual void mute_changed(bool) override;
|
||||
virtual void total_samples_changed(int) override;
|
||||
virtual void sound_buffer_played(RefPtr<Audio::Buffer>, int sample_rate, int samples_played) override;
|
||||
virtual void sound_buffer_played(RefPtr<Audio::LegacyBuffer>, int sample_rate, int samples_played) override;
|
||||
|
||||
protected:
|
||||
void keydown_event(GUI::KeyEvent&) override;
|
||||
|
|
|
@ -18,7 +18,7 @@ class VisualizationWidget : public GUI::Frame {
|
|||
public:
|
||||
virtual void render(GUI::PaintEvent&, FixedArray<double> const& samples) = 0;
|
||||
|
||||
void set_buffer(RefPtr<Audio::Buffer> buffer)
|
||||
void set_buffer(RefPtr<Audio::LegacyBuffer> buffer)
|
||||
{
|
||||
if (buffer.is_null())
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue