summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_output_controller_unittest.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 03:07:19 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 03:07:19 +0000
commit9ade381f46175dead00a1cc9ffc3328230e8c982 (patch)
tree64c6caf04643408b2e25bce192f03c9b7b93eaa2 /media/audio/audio_output_controller_unittest.cc
parentadc19c0eeac9f3caaae4e35bd64e79e6b6e72a0f (diff)
downloadchromium_src-9ade381f46175dead00a1cc9ffc3328230e8c982.zip
chromium_src-9ade381f46175dead00a1cc9ffc3328230e8c982.tar.gz
chromium_src-9ade381f46175dead00a1cc9ffc3328230e8c982.tar.bz2
Simplified AudioOutputStream interface.
1. Removed packet_size parameter from Open(). 2. Removed OnClose() from the callback. Now the callback is guaranteed to be called only between Start() and Stop(). 3. Added samples_per_packet in the AudioParameters struct. BUG=39825 TEST=Unittests Review URL: http://codereview.chromium.org/4661001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_output_controller_unittest.cc')
-rw-r--r--media/audio/audio_output_controller_unittest.cc34
1 files changed, 15 insertions, 19 deletions
diff --git a/media/audio/audio_output_controller_unittest.cc b/media/audio/audio_output_controller_unittest.cc
index 6997016..d70aed1 100644
--- a/media/audio/audio_output_controller_unittest.cc
+++ b/media/audio/audio_output_controller_unittest.cc
@@ -21,8 +21,9 @@ using ::testing::Return;
static const int kSampleRate = AudioParameters::kAudioCDSampleRate;
static const int kBitsPerSample = 16;
static const int kChannels = 2;
-static const int kHardwareBufferSize = kSampleRate * kBitsPerSample *
- kChannels / 8;
+static const int kSamplesPerPacket = kSampleRate / 10;
+static const int kHardwareBufferSize = kSamplesPerPacket * kChannels *
+ kBitsPerSample / 8;
static const int kBufferCapacity = 3 * kHardwareBufferSize;
namespace media {
@@ -97,10 +98,9 @@ TEST(AudioOutputControllerTest, CreateAndClose) {
EXPECT_CALL(event_handler, OnMoreData(NotNull(), _));
AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannels,
- kSampleRate, kBitsPerSample);
+ kSampleRate, kBitsPerSample, kSamplesPerPacket);
scoped_refptr<AudioOutputController> controller =
- AudioOutputController::Create(&event_handler, params,
- kHardwareBufferSize, kBufferCapacity);
+ AudioOutputController::Create(&event_handler, params, kBufferCapacity);
ASSERT_TRUE(controller.get());
// Close the controller immediately.
@@ -128,10 +128,9 @@ TEST(AudioOutputControllerTest, PlayAndClose) {
.WillRepeatedly(SignalEvent(&event));
AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannels,
- kSampleRate, kBitsPerSample);
+ kSampleRate, kBitsPerSample, kSamplesPerPacket);
scoped_refptr<AudioOutputController> controller =
- AudioOutputController::Create(&event_handler, params,
- kHardwareBufferSize, kBufferCapacity);
+ AudioOutputController::Create(&event_handler, params, kBufferCapacity);
ASSERT_TRUE(controller.get());
// Wait for OnCreated() to be called.
@@ -178,10 +177,9 @@ TEST(AudioOutputControllerTest, PlayPauseClose) {
.WillOnce(InvokeWithoutArgs(&pause_event, &base::WaitableEvent::Signal));
AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannels,
- kSampleRate, kBitsPerSample);
+ kSampleRate, kBitsPerSample, kSamplesPerPacket);
scoped_refptr<AudioOutputController> controller =
- AudioOutputController::Create(&event_handler, params,
- kHardwareBufferSize, kBufferCapacity);
+ AudioOutputController::Create(&event_handler, params, kBufferCapacity);
ASSERT_TRUE(controller.get());
// Wait for OnCreated() to be called.
@@ -239,10 +237,9 @@ TEST(AudioOutputControllerTest, PlayPausePlay) {
.RetiresOnSaturation();
AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannels,
- kSampleRate, kBitsPerSample);
+ kSampleRate, kBitsPerSample, kSamplesPerPacket);
scoped_refptr<AudioOutputController> controller =
- AudioOutputController::Create(&event_handler, params,
- kHardwareBufferSize, kBufferCapacity);
+ AudioOutputController::Create(&event_handler, params, kBufferCapacity);
ASSERT_TRUE(controller.get());
// Wait for OnCreated() to be called.
@@ -283,10 +280,10 @@ TEST(AudioOutputControllerTest, HardwareBufferTooLarge) {
// Create an audio device with a very large hardware buffer size.
MockAudioOutputControllerEventHandler event_handler;
AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannels,
- kSampleRate, kBitsPerSample);
+ kSampleRate, kBitsPerSample,
+ kSamplesPerPacket * 1000);
scoped_refptr<AudioOutputController> controller =
AudioOutputController::Create(&event_handler, params,
- kHardwareBufferSize * 1000,
kBufferCapacity);
// Use assert because we don't stop the device and assume we can't
@@ -311,10 +308,9 @@ TEST(AudioOutputControllerTest, CloseTwice) {
.WillRepeatedly(SignalEvent(&event));
AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannels,
- kSampleRate, kBitsPerSample);
+ kSampleRate, kBitsPerSample, kSamplesPerPacket);
scoped_refptr<AudioOutputController> controller =
- AudioOutputController::Create(&event_handler, params,
- kHardwareBufferSize, kBufferCapacity);
+ AudioOutputController::Create(&event_handler, params, kBufferCapacity);
ASSERT_TRUE(controller.get());
// Wait for OnCreated() to be called.