Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(735)

Unified Diff: services/media/audio/platform/generic/mixer.cc

Issue 1455303003: Add a linear interpolation resampler. (Closed) Base URL: https://github.com/domokit/mojo.git@change6
Patch Set: Final rebase before landing Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/media/audio/BUILD.gn ('k') | services/media/audio/platform/generic/mixers/linear_sampler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/media/audio/platform/generic/mixer.cc
diff --git a/services/media/audio/platform/generic/mixer.cc b/services/media/audio/platform/generic/mixer.cc
index 87183b8adc25155694fffd5b778e6758eb133530..eb1929135333d0bb12cd8c39cd2bc7125abeba2c 100644
--- a/services/media/audio/platform/generic/mixer.cc
+++ b/services/media/audio/platform/generic/mixer.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/logging.h"
+#include "mojo/services/media/common/cpp/linear_transform.h"
#include "services/media/audio/platform/generic/mixer.h"
+#include "services/media/audio/platform/generic/mixers/linear_sampler.h"
#include "services/media/audio/platform/generic/mixers/no_op.h"
#include "services/media/audio/platform/generic/mixers/point_sampler.h"
@@ -31,7 +33,15 @@ MixerPtr Mixer::Select(const LpcmMediaTypeDetailsPtr& src_format,
// probably the ThrottleOutput we are picking a mixer for.
if (!dst_format) { return MixerPtr(new mixers::NoOp()); }
- return mixers::PointSampler::Select(src_format, dst_format);
+ // If the source sample rate is an integer multiple of the destination sample
+ // rate, just use the point sampler. Otherwise, use the linear re-sampler.
+ LinearTransform::Ratio src_to_dst(src_format->frames_per_second,
+ dst_format->frames_per_second);
+ if (src_to_dst.numerator == 1) {
+ return mixers::PointSampler::Select(src_format, dst_format);
+ } else {
+ return mixers::LinearSampler::Select(src_format, dst_format);
+ }
}
} // namespace audio
« no previous file with comments | « services/media/audio/BUILD.gn ('k') | services/media/audio/platform/generic/mixers/linear_sampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698