mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +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>
|
template<ArrayLike<SampleType> Samples>
|
||||||
Vector<SampleType> resample(Samples&& to_resample)
|
ErrorOr<Vector<SampleType>> try_resample(Samples&& to_resample)
|
||||||
{
|
{
|
||||||
Vector<SampleType> resampled;
|
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) {
|
for (auto sample : to_resample) {
|
||||||
process_sample(sample, sample);
|
process_sample(sample, sample);
|
||||||
|
|
||||||
|
@ -66,6 +66,12 @@ public:
|
||||||
return resampled;
|
return resampled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<ArrayLike<SampleType> Samples>
|
||||||
|
Vector<SampleType> resample(Samples&& to_resample)
|
||||||
|
{
|
||||||
|
return MUST(try_resample(forward<Samples>(to_resample)));
|
||||||
|
}
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
m_current_ratio = 0;
|
m_current_ratio = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue