src/media/audio/audio_core/mixer/sinc_sampler_unittest.cc
// Test that position advances as it should
Test that position advances as it should
Test that position advances as it should
TEST(SincSamplerTest, SamplingPosition_Basic) {
  auto mixer = SelectSincSampler(1, 48000, fuchsia::media::AudioSampleFormat::FLOAT, 1, 48000);
  EXPECT_EQ(mixer->pos_filter_width().raw_value(), kSincFilterSideLength - 1u);
  EXPECT_EQ(mixer->neg_filter_width().raw_value(), kSincFilterSideLength - 1u);
  bool should_not_accum = false;
  bool source_is_consumed;
  float source[] = {1.0f,  2.0f,  3.0f,  4.0f,  5.0f,  6.0f,  7.0f,  8.0f,  9.0f,  10.0f,
                    11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f};
  float dest[20];
  const uint32_t src_frames = std::size(source);
  const uint32_t frac_src_frames = src_frames << kPtsFractionalBits;
  const uint32_t dest_frames = std::size(dest);
  int32_t frac_src_offset = (3 << (kPtsFractionalBits - 2));
  uint32_t dest_offset = 0;
  source_is_consumed = mixer->Mix(dest, dest_frames, &dest_offset, source, frac_src_frames,
                                  &frac_src_offset, should_not_accum);
  EXPECT_TRUE(source_is_consumed);
  EXPECT_TRUE(frac_src_offset + mixer->pos_filter_width().raw_value() >= frac_src_frames);
  EXPECT_EQ(dest_offset, static_cast<uint32_t>(frac_src_offset) >> kPtsFractionalBits);
}
TEST ( SincSamplerTest , SamplingPosition_Basic ) { auto mixer = SelectSincSampler ( 1 , 48000 , fuchsia :: media :: AudioSampleFormat :: FLOAT , 1 , 48000 ) ; EXPECT_EQ ( mixer -> pos_filter_width ( ) . raw_value ( ) , kSincFilterSideLength - 1u ) ; EXPECT_EQ ( mixer -> neg_filter_width ( ) . raw_value ( ) , kSincFilterSideLength - 1u ) ; bool should_not_accum = false ; bool source_is_consumed ; float source [ ] = { 1.0f , 2.0f , 3.0f , 4.0f , 5.0f , 6.0f , 7.0f , 8.0f , 9.0f , 10.0f , 11.0f , 12.0f , 13.0f , 14.0f , 15.0f , 16.0f , 17.0f , 18.0f , 19.0f , 20.0f } ; float dest [ 20 ] ; const uint32_t src_frames = std :: size ( source ) ; const uint32_t frac_src_frames = src_frames << kPtsFractionalBits ; const uint32_t dest_frames = std :: size ( dest ) ; int32_t frac_src_offset = ( 3 << ( kPtsFractionalBits - 2 ) ) ; uint32_t dest_offset = 0 ; source_is_consumed = mixer -> Mix ( dest , dest_frames , & dest_offset , source , frac_src_frames , & frac_src_offset , should_not_accum ) ; EXPECT_TRUE ( source_is_consumed ) ; EXPECT_TRUE ( frac_src_offset + mixer -> pos_filter_width ( ) . raw_value ( ) >= frac_src_frames ) ; EXPECT_EQ ( dest_offset , static_cast < uint32_t > ( frac_src_offset ) >> kPtsFractionalBits ) ; }
Test that position advances as it should
Test that position advances as it should
// Pass in 20 frames