mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:07:34 +00:00
LibAudio: Make resampling fallible
This commit is contained in:
parent
026cc3d4b9
commit
836f28392d
1 changed files with 8 additions and 2 deletions
|
@ -52,10 +52,10 @@ public:
|
|||
}
|
||||
|
||||
template<ArrayLike<SampleType> Samples>
|
||||
Vector<SampleType> resample(Samples&& to_resample)
|
||||
ErrorOr<Vector<SampleType>> try_resample(Samples&& to_resample)
|
||||
{
|
||||
Vector<SampleType> resampled;
|
||||
resampled.ensure_capacity(to_resample.size() * ceil_div(m_source, m_target));
|
||||
TRY(resampled.try_ensure_capacity(to_resample.size() * ceil_div(m_source, m_target)));
|
||||
for (auto sample : to_resample) {
|
||||
process_sample(sample, sample);
|
||||
|
||||
|
@ -66,6 +66,12 @@ public:
|
|||
return resampled;
|
||||
}
|
||||
|
||||
template<ArrayLike<SampleType> Samples>
|
||||
Vector<SampleType> resample(Samples&& to_resample)
|
||||
{
|
||||
return MUST(try_resample(forward<Samples>(to_resample)));
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
m_current_ratio = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue