summaryrefslogtreecommitdiffstats
path: root/media/base/audio_block_fifo_unittest.cc
diff options
context:
space:
mode:
authorxians <xians@chromium.org>2014-08-27 10:28:18 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-27 17:34:57 +0000
commitf9872e1a026bfe61e12ae84087fdf142b0d407b6 (patch)
tree62769bb7f59357dc0e96c36bdca1270f3f5d59b5 /media/base/audio_block_fifo_unittest.cc
parent42485ac75b825f1eb30132fa5341985ade5b1eb5 (diff)
downloadchromium_src-f9872e1a026bfe61e12ae84087fdf142b0d407b6.zip
chromium_src-f9872e1a026bfe61e12ae84087fdf142b0d407b6.tar.gz
chromium_src-f9872e1a026bfe61e12ae84087fdf142b0d407b6.tar.bz2
Revert of Used native deinterleaved and float point format for the input streams. (patchset #5 of https://codereview.chromium.org/501823002/)
Reason for revert: It broke the mac asan bot, http://build.chromium.org/p/chromium.memory/builders/Mac%20ASan%2064%20Tests%20%281%29/builds/1976 Original issue's description: > Used native deinterleaved and float point format for the input streams. > > If we call GetProperty of kAudioUnitProperty_StreamFormat before setting the format, the device will report kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved as the native format of the device, which is the same as the output. > > This patch changes the format to use kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved to open the device, so that we will avoid format flipping back and forth. Hope this optimization will help increase the stability of the input audio on Mac. > > > BUG=404884 > TEST=media_unittests && https://webrtc.googlecode.com/svn-history/r5497/trunk/samples/js/demos/html/pc1.html, https://www.google.com/intl/en/chrome/demos/speech.html > > Committed: https://chromium.googlesource.com/chromium/src/+/1a9ce977642c7f2cc2e30d83757c42264f052f0b TBR=dalecurtis@chromium.org,eroman@chromium.org NOTREECHECKS=true NOTRY=true BUG=404884 Review URL: https://codereview.chromium.org/514773002 Cr-Commit-Position: refs/heads/master@{#292176}
Diffstat (limited to 'media/base/audio_block_fifo_unittest.cc')
-rw-r--r--media/base/audio_block_fifo_unittest.cc69
1 files changed, 24 insertions, 45 deletions
diff --git a/media/base/audio_block_fifo_unittest.cc b/media/base/audio_block_fifo_unittest.cc
index f1ed228..8e8b5e0 100644
--- a/media/base/audio_block_fifo_unittest.cc
+++ b/media/base/audio_block_fifo_unittest.cc
@@ -8,48 +8,29 @@
namespace media {
class AudioBlockFifoTest : public testing::Test {
- protected:
+ public:
AudioBlockFifoTest() {}
virtual ~AudioBlockFifoTest() {}
- private:
- DISALLOW_COPY_AND_ASSIGN(AudioBlockFifoTest);
-};
-
-class AudioBlockFifoFormatTest : public AudioBlockFifoTest,
- public testing::WithParamInterface<bool> {
- protected:
- void PushAndVerify(AudioBlockFifo* fifo,
- int frames_to_push,
- int channels,
- int block_frames,
- int max_frames) {
+ void PushAndVerify(AudioBlockFifo* fifo, int frames_to_push,
+ int channels, int block_frames, int max_frames) {
const int bytes_per_sample = 2;
const int data_byte_size = bytes_per_sample * channels * frames_to_push;
- if (GetParam()) {
- scoped_ptr<media::AudioBus> data =
- AudioBus::Create(channels, frames_to_push);
- for (int filled_frames = max_frames - fifo->GetUnfilledFrames();
- filled_frames + frames_to_push <= max_frames;) {
- fifo->Push(data.get());
- filled_frames += frames_to_push;
- EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames());
- EXPECT_EQ(static_cast<int>(filled_frames / block_frames),
- fifo->available_blocks());
- }
- } else {
- scoped_ptr<uint8[]> data(new uint8[data_byte_size]);
- memset(data.get(), 0, data_byte_size);
- for (int filled_frames = max_frames - fifo->GetUnfilledFrames();
- filled_frames + frames_to_push <= max_frames;) {
- fifo->Push(data.get(), frames_to_push, bytes_per_sample);
- filled_frames += frames_to_push;
- EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames());
- EXPECT_EQ(static_cast<int>(filled_frames / block_frames),
- fifo->available_blocks());
- }
+ scoped_ptr<uint8[]> data(new uint8[data_byte_size]);
+ memset(data.get(), 0, data_byte_size);
+
+ for (int filled_frames = max_frames - fifo->GetUnfilledFrames();
+ filled_frames + frames_to_push <= max_frames;) {
+ fifo->Push(data.get(), frames_to_push, bytes_per_sample);
+ filled_frames += frames_to_push;
+ EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames());
+ EXPECT_EQ(static_cast<int>(filled_frames / block_frames),
+ fifo->available_blocks());
}
}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AudioBlockFifoTest);
};
// Verify that construction works as intended.
@@ -63,7 +44,7 @@ TEST_F(AudioBlockFifoTest, Construct) {
}
// Pushes audio bus objects to/from a FIFO up to different degrees.
-TEST_P(AudioBlockFifoFormatTest, Push) {
+TEST_F(AudioBlockFifoTest, Push) {
const int channels = 2;
const int frames = 128;
const int blocks = 2;
@@ -84,7 +65,7 @@ TEST_P(AudioBlockFifoFormatTest, Push) {
// Perform a sequence of Push/Consume calls to different degrees, and verify
// things are correct.
-TEST_P(AudioBlockFifoFormatTest, PushAndConsume) {
+TEST_F(AudioBlockFifoTest, PushAndConsume) {
const int channels = 2;
const int frames = 441;
const int blocks = 4;
@@ -119,9 +100,10 @@ TEST_P(AudioBlockFifoFormatTest, PushAndConsume) {
fifo.Clear();
int new_push_frames = 128;
// Change the input frame and try to fill up the FIFO.
- PushAndVerify(&fifo, new_push_frames, channels, frames, frames * blocks);
+ PushAndVerify(&fifo, new_push_frames, channels, frames,
+ frames * blocks);
EXPECT_TRUE(fifo.GetUnfilledFrames() != 0);
- EXPECT_TRUE(fifo.available_blocks() == blocks - 1);
+ EXPECT_TRUE(fifo.available_blocks() == blocks -1);
// Consume all the existing filled blocks of data.
while (fifo.available_blocks()) {
@@ -140,13 +122,14 @@ TEST_P(AudioBlockFifoFormatTest, PushAndConsume) {
// Completely fill up the buffer again.
new_push_frames = frames * blocks - remain_frames;
- PushAndVerify(&fifo, new_push_frames, channels, frames, frames * blocks);
+ PushAndVerify(&fifo, new_push_frames, channels, frames,
+ frames * blocks);
EXPECT_TRUE(fifo.GetUnfilledFrames() == 0);
EXPECT_TRUE(fifo.available_blocks() == blocks);
}
// Perform a sequence of Push/Consume calls to a 1 block FIFO.
-TEST_P(AudioBlockFifoFormatTest, PushAndConsumeOneBlockFifo) {
+TEST_F(AudioBlockFifoTest, PushAndConsumeOneBlockFifo) {
static const int channels = 2;
static const int frames = 441;
static const int blocks = 1;
@@ -163,8 +146,4 @@ TEST_P(AudioBlockFifoFormatTest, PushAndConsumeOneBlockFifo) {
EXPECT_TRUE(fifo.GetUnfilledFrames() == frames);
}
-INSTANTIATE_TEST_CASE_P(AudioBlockFifoTests,
- AudioBlockFifoFormatTest,
- ::testing::Values(false, true));
-
} // namespace media