1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 02:47:34 +00:00

Everywhere: Stop using NonnullRefPtrVector

This class had slightly confusing semantics and the added weirdness
doesn't seem worth it just so we can say "." instead of "->" when
iterating over a vector of NNRPs.

This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
This commit is contained in:
Andreas Kling 2023-03-06 14:17:01 +01:00
parent 104be6c8ac
commit 8a48246ed1
168 changed files with 1280 additions and 1280 deletions

View file

@ -33,22 +33,22 @@ bool Track::check_processor_chain_valid_with_initial_type(SignalType initial_typ
for (auto& processor : m_processor_chain) {
// The first processor must have the given initial signal type as input.
if (previous_processor == nullptr) {
if (processor.input_type() != initial_type)
if (processor->input_type() != initial_type)
return false;
} else if (previous_processor->output_type() != processor.input_type())
} else if (previous_processor->output_type() != processor->input_type())
return false;
previous_processor = &processor;
previous_processor = processor.ptr();
}
return true;
}
NonnullRefPtr<Synthesizers::Classic> Track::synth()
{
return static_ptr_cast<Synthesizers::Classic>(m_processor_chain.ptr_at(0));
return static_ptr_cast<Synthesizers::Classic>(m_processor_chain[0]);
}
NonnullRefPtr<Effects::Delay> Track::delay()
{
return static_ptr_cast<Effects::Delay>(m_processor_chain.ptr_at(1));
return static_ptr_cast<Effects::Delay>(m_processor_chain[1]);
}
bool AudioTrack::check_processor_chain_valid() const
@ -81,11 +81,11 @@ void Track::current_signal(FixedArray<Sample>& output_signal)
for (auto& processor : m_processor_chain) {
// Depending on what the processor needs to have as output, we need to place either a pre-allocated note hash map or a pre-allocated sample buffer in the target signal.
if (processor.output_type() == SignalType::Note)
if (processor->output_type() == SignalType::Note)
target_signal = &m_secondary_note_buffer;
else
target_signal = &m_secondary_sample_buffer;
processor.process(*source_signal, *target_signal);
processor->process(*source_signal, *target_signal);
swap(source_signal, target_signal);
}
VERIFY(source_signal->type() == SignalType::Sample);
@ -109,9 +109,9 @@ void NoteTrack::compute_current_clips_signal()
for (auto& clip : m_clips) {
// A clip is playing if its start time or end time fall in the current time range.
// Or, if they both enclose the current time range.
if ((clip.start() <= start_time && clip.end() >= end_time)
|| (clip.start() >= start_time && clip.start() < end_time)
|| (clip.end() > start_time && clip.end() <= end_time)) {
if ((clip->start() <= start_time && clip->end() >= end_time)
|| (clip->start() >= start_time && clip->start() < end_time)
|| (clip->end() > start_time && clip->end() <= end_time)) {
VERIFY(playing_clips_index < playing_clips.size());
playing_clips[playing_clips_index++] = clip;
}
@ -149,8 +149,8 @@ void AudioTrack::compute_current_clips_signal()
Optional<RollNote> NoteTrack::note_at(u32 time, u8 pitch) const
{
for (auto& clip : m_clips) {
if (time >= clip.start() && time <= clip.end())
return clip.note_at(time, pitch);
if (time >= clip->start() && time <= clip->end())
return clip->note_at(time, pitch);
}
return {};
@ -159,15 +159,15 @@ Optional<RollNote> NoteTrack::note_at(u32 time, u8 pitch) const
void NoteTrack::set_note(RollNote note)
{
for (auto& clip : m_clips) {
if (clip.start() <= note.on_sample && clip.end() >= note.on_sample)
clip.set_note(note);
if (clip->start() <= note.on_sample && clip->end() >= note.on_sample)
clip->set_note(note);
}
}
void NoteTrack::remove_note(RollNote note)
{
for (auto& clip : m_clips)
clip.remove_note(note);
clip->remove_note(note);
}
void NoteTrack::add_clip(u32 start_time, u32 end_time)

View file

@ -33,7 +33,7 @@ public:
// We are informed of an audio buffer size change. This happens off-audio-thread so we can allocate.
ErrorOr<void> resize_internal_buffers_to(size_t buffer_size);
NonnullRefPtrVector<Processor> const& processor_chain() const { return m_processor_chain; }
Vector<NonnullRefPtr<Processor>> const& processor_chain() const { return m_processor_chain; }
NonnullRefPtr<Transport const> transport() const { return m_transport; }
NonnullRefPtr<DSP::Effects::Mastering> track_mastering() { return m_track_mastering; }
@ -53,7 +53,7 @@ protected:
// Subclasses override to provide the base signal to the processing chain
virtual void compute_current_clips_signal() = 0;
NonnullRefPtrVector<Processor> m_processor_chain;
Vector<NonnullRefPtr<Processor>> m_processor_chain;
NonnullRefPtr<Transport> m_transport;
NonnullRefPtr<Effects::Mastering> m_track_mastering;
NonnullRefPtr<Keyboard> m_keyboard;
@ -90,7 +90,7 @@ protected:
void compute_current_clips_signal() override;
private:
NonnullRefPtrVector<NoteClip> m_clips;
Vector<NonnullRefPtr<NoteClip>> m_clips;
};
class AudioTrack final : public Track {
@ -103,13 +103,13 @@ public:
}
bool check_processor_chain_valid() const override;
NonnullRefPtrVector<AudioClip> const& clips() const { return m_clips; }
Vector<NonnullRefPtr<AudioClip>> const& clips() const { return m_clips; }
protected:
void compute_current_clips_signal() override;
private:
NonnullRefPtrVector<AudioClip> m_clips;
Vector<NonnullRefPtr<AudioClip>> m_clips;
};
}