Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/AudioResampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ auto AudioResampler::process(InterleavedBufferView<const float> input, Interleav
throw std::invalid_argument{"Invalid channel count"};
}

// libsamplerate throws on empty buffers; bail before touching it.
if (input.frames() == 0 || output.frames() == 0) { return {0, 0}; }
Copy link
Copy Markdown
Contributor

@sakertooth sakertooth May 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use the empty member function provided within the buffer views. Using these is more robust than just the frame count check because it checks if the data pointer is nullptr as well as if the channel and frame count are 0.

Suggested change
if (input.frames() == 0 || output.frames() == 0) { return {0, 0}; }
if (input.empty() || output.empty()) { return {0, 0}; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this check should come before the mismatching channel count one right above it: we dont want to throw an exception when the input channel count is 0 and the output channel count is 2 for example.


auto data = SRC_DATA{};

data.data_in = input.data();
Expand Down
Loading