modules/audio_device/android/audio_device_unittest.cc
TEST_P(AudioDeviceTest, RunPlayoutAndRecordingInFullDuplex) {
  EXPECT_EQ(recording_channels(), playout_channels());
  EXPECT_EQ(recording_sample_rate(), playout_sample_rate());
  NiceMock<MockAudioTransport> mock(kPlayout | kRecording);
  rtc::scoped_ptr<FifoAudioStream> fifo_audio_stream(
      new FifoAudioStream(playout_frames_per_buffer()));
  mock.HandleCallbacks(test_is_done_.get(),
                       fifo_audio_stream.get(),
                       kFullDuplexTimeInSec * kNumCallbacksPerSecond);
  EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
  StartRecording();
  StartPlayout();
  test_is_done_->Wait(std::max(kTestTimeOutInMilliseconds,
                               1000 * kFullDuplexTimeInSec));
  StopPlayout();
  StopRecording();
  EXPECT_LE(fifo_audio_stream->average_size(), 10);
  EXPECT_LE(fifo_audio_stream->largest_size(), 20);
}
// Start playout and recording and store recorded data in an intermediate FIFO
// buffer from which the playout side then reads its samples in the same order
// as they were stored. Under ideal circumstances, a callback sequence would
// look like: ...+-+-+-+-+-+-+-..., where '+' means 'packet recorded' and '-'
// means 'packet played'. Under such conditions, the FIFO would only contain
// one packet on average. However, under more realistic conditions, the size
// of the FIFO will vary more due to an unbalance between the two sides.
// This test tries to verify that the device maintains a balanced callback-
// sequence by running in loopback for ten seconds while measuring the size
// (max and average) of the FIFO. The size of the FIFO is increased by the
// recording side and decreased by the playout side.
// TODO(henrika): tune the final test parameters after running tests on several
// different devices.
Start playout and recording and store recorded data in an intermediate FIFO
buffer from which the playout side then reads its samples in the same order
as they were stored.
Start playout and recording and store recorded data in an intermediate FIFO buffer from which the playout side then reads its samples in the same order as they were stored .
TEST_P(AudioDeviceTest, RunPlayoutAndRecordingInFullDuplex) {
  EXPECT_EQ(recording_channels(), playout_channels());
  EXPECT_EQ(recording_sample_rate(), playout_sample_rate());
  NiceMock<MockAudioTransport> mock(kPlayout | kRecording);
  rtc::scoped_ptr<FifoAudioStream> fifo_audio_stream(
      new FifoAudioStream(playout_frames_per_buffer()));
  mock.HandleCallbacks(test_is_done_.get(),
                       fifo_audio_stream.get(),
                       kFullDuplexTimeInSec * kNumCallbacksPerSecond);
  EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
  StartRecording();
  StartPlayout();
  test_is_done_->Wait(std::max(kTestTimeOutInMilliseconds,
                               1000 * kFullDuplexTimeInSec));
  StopPlayout();
  StopRecording();
  EXPECT_LE(fifo_audio_stream->average_size(), 10);
  EXPECT_LE(fifo_audio_stream->largest_size(), 20);
}
TEST_P ( AudioDeviceTest , RunPlayoutAndRecordingInFullDuplex ) { EXPECT_EQ ( recording_channels ( ) , playout_channels ( ) ) ; EXPECT_EQ ( recording_sample_rate ( ) , playout_sample_rate ( ) ) ; NiceMock < MockAudioTransport > mock ( kPlayout | kRecording ) ; rtc :: scoped_ptr < FifoAudioStream > fifo_audio_stream ( new FifoAudioStream ( playout_frames_per_buffer ( ) ) ) ; mock . HandleCallbacks ( test_is_done_ . get ( ) , fifo_audio_stream . get ( ) , kFullDuplexTimeInSec * kNumCallbacksPerSecond ) ; EXPECT_EQ ( 0 , audio_device ( ) -> RegisterAudioCallback ( & mock ) ) ; StartRecording ( ) ; StartPlayout ( ) ; test_is_done_ -> Wait ( std :: max ( kTestTimeOutInMilliseconds , 1000 * kFullDuplexTimeInSec ) ) ; StopPlayout ( ) ; StopRecording ( ) ; EXPECT_LE ( fifo_audio_stream -> average_size ( ) , 10 ) ; EXPECT_LE ( fifo_audio_stream -> largest_size ( ) , 20 ) ; }
Start playout and recording and store recorded data in an intermediate FIFO
buffer from which the playout side then reads its samples in the same order
as they were stored.
Start playout and recording and store recorded data in an intermediate FIFO buffer from which the playout side then reads its samples in the same order as they were stored .