src/media/audio/audio_core/mixer/mixer.cc
//
// Select an appropriate instance of a mixer based on the user-specified
// resampler type, else by the properties of source/destination formats.
//
// With 'resampler', users indicate which resampler they require. If not
// specified, or if Resampler::Default, the existing selection algorithm is
// used. Note that requiring a specific resampler may cause Mixer::Select() to
// fail (i.e. return nullptr), even in cases where 'Default' would succeed.
Select an appropriate instance of a mixer based on the user-specified
resampler type, else by the properties of source/destination formats.

With 'resampler', users indicate which resampler they require. If not
specified, or if Resampler::Default, the existing selection algorithm is
used. Note that requiring a specific resampler may cause Mixer::Select() to
fail , even in cases where 'Default' would succeed.
Select an appropriate instance of a mixer based on the user - specified resampler type else by the properties of source / destination formats . With ' resampler ' users indicate which resampler they require . If not specified or if Resampler :: Default the existing selection algorithm is used . Note that requiring a specific resampler may cause Mixer :: Select () to fail even in cases where ' Default ' would succeed .
std::unique_ptr<Mixer> Mixer::Select(const fuchsia::media::AudioStreamType& src_format,
                                     const fuchsia::media::AudioStreamType& dest_format,
                                     Resampler resampler) {
  TRACE_DURATION("audio", "Mixer::Select");
  switch (resampler) {
    case Resampler::SampleAndHold:
      return mixer::PointSampler::Select(src_format, dest_format);
    case Resampler::LinearInterpolation:
      return mixer::LinearSampler::Select(src_format, dest_format);
    case Resampler::WindowedSinc:
      return mixer::SincSampler::Select(src_format, dest_format);
    case Resampler::Default:
      break;
  }
  TimelineRate src_to_dest(dest_format.frames_per_second, src_format.frames_per_second);
  if (src_to_dest.subject_delta() == 1 && src_to_dest.reference_delta() == 1) {
    return mixer::PointSampler::Select(src_format, dest_format);
  } else {
    return mixer::SincSampler::Select(src_format, dest_format);
  }
}
std :: unique_ptr < Mixer > Mixer :: Select ( const fuchsia :: media :: AudioStreamType & src_format , const fuchsia :: media :: AudioStreamType & dest_format , Resampler resampler ) { TRACE_DURATION ( " " , " " ) ; switch ( resampler ) { case Resampler :: SampleAndHold : return mixer :: PointSampler :: Select ( src_format , dest_format ) ; case Resampler :: LinearInterpolation : return mixer :: LinearSampler :: Select ( src_format , dest_format ) ; case Resampler :: WindowedSinc : return mixer :: SincSampler :: Select ( src_format , dest_format ) ; case Resampler :: Default : break ; } TimelineRate src_to_dest ( dest_format . frames_per_second , src_format . frames_per_second ) ; if ( src_to_dest . subject_delta ( ) == 1 && src_to_dest . reference_delta ( ) == 1 ) { return mixer :: PointSampler :: Select ( src_format , dest_format ) ; } else { return mixer :: SincSampler :: Select ( src_format , dest_format ) ; } }
Select an appropriate instance of a mixer based on the user-specified
resampler type, else by the properties of source/destination formats.
Select an appropriate instance of a mixer based on the user - specified resampler type else by the properties of source / destination formats .
// If user specified a particular Resampler, directly select it. // Otherwise (if Default), continue onward. // Use SampleAndHold if no rate conversion (unity 1:1). Otherwise, use WindowedSinc (with // integrated low-pass filter). Unless explicitly invoked, we do not use LinearInterpolation.