src/media/audio/audio_core/mixer/test/mixer_resampling_tests.cc
// For provided sampler, validate src_pos_modulo for zero/non-zero no rollover.
For provided sampler, validate src_pos_modulo for zero/non-zero no rollover.
For provided sampler validate src_pos_modulo for zero / non - zero no rollover .
void TestPositionModuloNoRollover(Resampler sampler_type, bool mute = false) {
  auto mixer =
      SelectMixer(fuchsia::media::AudioSampleFormat::FLOAT, 1, 44100, 1, 44100, sampler_type);
  float accum[3];
  uint32_t dest_offset;
  int32_t frac_src_offset;
  float source[4] = {0.0f};
   Case: Zero src_pos_modulo, almost-but-not-rollover.
  dest_offset = 0;
  frac_src_offset = 0;
   For clarity, explicitly setting step_size and denominator, even though
   step_size is auto-initialized to FRAC_ONE and denominator's 10000 persists.
  auto& info = mixer->bookkeeping();
  info.step_size = Mixer::FRAC_ONE;
  info.rate_modulo = 3333;
  info.denominator = 10000;
  info.src_pos_modulo = 0;
  if (mute) {
    info.gain.SetSourceGain(Gain::kMinGainDb);
  }
  mixer->Mix(accum, std::size(accum), &dest_offset, source, std::size(source) << kPtsFractionalBits,
             &frac_src_offset, false);
  EXPECT_EQ(std::size(accum), dest_offset);
  EXPECT_TRUE(3 * Mixer::FRAC_ONE == frac_src_offset);
  EXPECT_EQ(9999u, info.src_pos_modulo);
   Non-zero src_pos_modulo (but rate_modulo is reduced, so same outcome).
  dest_offset = 0;
  frac_src_offset = 0;
  info.step_size = Mixer::FRAC_ONE;
  info.rate_modulo = 3332;
  info.denominator = 10000;
  info.src_pos_modulo = 3;
  if (mute) {
    info.gain.SetSourceGain(Gain::kMinGainDb);
  }
  mixer->Mix(accum, std::size(accum), &dest_offset, source, std::size(source) << kPtsFractionalBits,
             &frac_src_offset, false);
  EXPECT_EQ(std::size(accum), dest_offset);
  EXPECT_TRUE(3 * Mixer::FRAC_ONE == frac_src_offset);
  EXPECT_EQ(9999u, info.src_pos_modulo);
}
void TestPositionModuloNoRollover ( Resampler sampler_type , bool mute = false ) { auto mixer = SelectMixer ( fuchsia :: media :: AudioSampleFormat :: FLOAT , 1 , 44100 , 1 , 44100 , sampler_type ) ; float accum [ 3 ] ; uint32_t dest_offset ; int32_t frac_src_offset ; float source [ 4 ] = { 0.0f } ; dest_offset = 0 ; frac_src_offset = 0 ; auto & info = mixer -> bookkeeping ( ) ; info . step_size = Mixer :: FRAC_ONE ; info . rate_modulo = 3333 ; info . denominator = 10000 ; info . src_pos_modulo = 0 ; if ( mute ) { info . gain . SetSourceGain ( Gain :: kMinGainDb ) ; } mixer -> Mix ( accum , std :: size ( accum ) , & dest_offset , source , std :: size ( source ) << kPtsFractionalBits , & frac_src_offset , false ) ; EXPECT_EQ ( std :: size ( accum ) , dest_offset ) ; EXPECT_TRUE ( 3 * Mixer :: FRAC_ONE == frac_src_offset ) ; EXPECT_EQ ( 9999u , info . src_pos_modulo ) ; dest_offset = 0 ; frac_src_offset = 0 ; info . step_size = Mixer :: FRAC_ONE ; info . rate_modulo = 3332 ; info . denominator = 10000 ; info . src_pos_modulo = 3 ; if ( mute ) { info . gain . SetSourceGain ( Gain :: kMinGainDb ) ; } mixer -> Mix ( accum , std :: size ( accum ) , & dest_offset , source , std :: size ( source ) << kPtsFractionalBits , & frac_src_offset , false ) ; EXPECT_EQ ( std :: size ( accum ) , dest_offset ) ; EXPECT_TRUE ( 3 * Mixer :: FRAC_ONE == frac_src_offset ) ; EXPECT_EQ ( 9999u , info . src_pos_modulo ) ; }
For provided sampler, validate src_pos_modulo for zero/non-zero no rollover.
For provided sampler validate src_pos_modulo for zero / non - zero no rollover .
// For "almost-but-not-rollover" cases, we generate 3 output samples, leaving // source and dest at pos 3 and src_pos_modulo at 9999/10000. // // Case: Zero src_pos_modulo, almost-but-not-rollover. // For clarity, explicitly setting step_size and denominator, even though // step_size is auto-initialized to FRAC_ONE and denominator's 10000 persists. // Non-zero src_pos_modulo (but rate_modulo is reduced, so same outcome).