src/media/audio/audio_core/mixer/test/mixer_resampling_tests.cc
// When setting the frac_src_pos to a value that is at the end (or within pos_filter_width) of the
// source buffer, the sampler should not mix additional frames (neither dest_offset nor
// frac_src_offset should be advanced).
When setting the frac_src_pos to a value that is at the end (or within pos_filter_width) of the
source buffer, the sampler should not mix additional frames (neither dest_offset nor
frac_src_offset should be advanced).
When setting the frac_src_pos to a value that is at the end ( or within pos_filter_width ) of the source buffer the sampler should not mix additional frames ( neither dest_offset nor frac_src_offset should be advanced ) .
void TestLateSourceOffset(Resampler sampler_type) {
  auto mixer =
      SelectMixer(fuchsia::media::AudioSampleFormat::FLOAT, 1, 44100, 1, 44100, sampler_type);
  if (mixer->pos_filter_width().raw_value() > 0) {
    float source[4] = {1.0f, 1.0f, 1.0f, 1.0f};
    int32_t frac_src_offset =
        (std::size(source) << kPtsFractionalBits) - mixer->pos_filter_width().raw_value();
    const auto initial_frac_src_offset = frac_src_offset;
    float accum[4] = {0.0f};
    uint32_t dest_offset = 0;
    auto& info = mixer->bookkeeping();
    info.step_size = Mixer::FRAC_ONE;
    EXPECT_TRUE(mixer->Mix(accum, std::size(accum), &dest_offset, source,
                           std::size(source) << kPtsFractionalBits, &frac_src_offset, false));
    EXPECT_EQ(dest_offset, 0u);
    EXPECT_EQ(frac_src_offset, initial_frac_src_offset);
    EXPECT_FLOAT_EQ(accum[0], 0.0f);
  }
}
void TestLateSourceOffset ( Resampler sampler_type ) { auto mixer = SelectMixer ( fuchsia :: media :: AudioSampleFormat :: FLOAT , 1 , 44100 , 1 , 44100 , sampler_type ) ; if ( mixer -> pos_filter_width ( ) . raw_value ( ) > 0 ) { float source [ 4 ] = { 1.0f , 1.0f , 1.0f , 1.0f } ; int32_t frac_src_offset = ( std :: size ( source ) << kPtsFractionalBits ) - mixer -> pos_filter_width ( ) . raw_value ( ) ; const auto initial_frac_src_offset = frac_src_offset ; float accum [ 4 ] = { 0.0f } ; uint32_t dest_offset = 0 ; auto & info = mixer -> bookkeeping ( ) ; info . step_size = Mixer :: FRAC_ONE ; EXPECT_TRUE ( mixer -> Mix ( accum , std :: size ( accum ) , & dest_offset , source , std :: size ( source ) << kPtsFractionalBits , & frac_src_offset , false ) ) ; EXPECT_EQ ( dest_offset , 0u ) ; EXPECT_EQ ( frac_src_offset , initial_frac_src_offset ) ; EXPECT_FLOAT_EQ ( accum [ 0 ] , 0.0f ) ; } }
When setting the frac_src_pos to a value that is at the end (or within pos_filter_width) of the
source buffer, the sampler should not mix additional frames (neither dest_offset nor
frac_src_offset should be advanced).
When setting the frac_src_pos to a value that is at the end ( or within pos_filter_width ) of the source buffer the sampler should not mix additional frames ( neither dest_offset nor frac_src_offset should be advanced ) .