Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: media/audio/audio_output_controller_unittest.cc

Issue 9691001: Audio software mixer. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/environment.h" 6 #include "base/environment.h"
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "media/audio/audio_output_controller.h" 10 #include "media/audio/audio_output_controller.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return; 77 return;
78 78
79 MockAudioOutputControllerEventHandler event_handler; 79 MockAudioOutputControllerEventHandler event_handler;
80 80
81 EXPECT_CALL(event_handler, OnCreated(NotNull())) 81 EXPECT_CALL(event_handler, OnCreated(NotNull()))
82 .Times(1); 82 .Times(1);
83 83
84 MockAudioOutputControllerSyncReader sync_reader; 84 MockAudioOutputControllerSyncReader sync_reader;
85 EXPECT_CALL(sync_reader, Close()); 85 EXPECT_CALL(sync_reader, Close());
86 86
87 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, 87 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, false,
88 kSampleRate, kBitsPerSample, kSamplesPerPacket); 88 kChannelLayout, kSampleRate, kBitsPerSample,
89 kSamplesPerPacket);
89 scoped_refptr<AudioOutputController> controller = 90 scoped_refptr<AudioOutputController> controller =
90 AudioOutputController::Create( 91 AudioOutputController::Create(
91 audio_manager.get(), &event_handler, params, &sync_reader); 92 audio_manager.get(), &event_handler, params, &sync_reader);
92 ASSERT_TRUE(controller.get()); 93 ASSERT_TRUE(controller.get());
93 94
94 // Close the controller immediately. 95 // Close the controller immediately.
95 CloseAudioController(controller); 96 CloseAudioController(controller);
96 } 97 }
97 98
98 TEST(AudioOutputControllerTest, PlayPauseClose) { 99 TEST(AudioOutputControllerTest, PlayPauseClose) {
(...skipping 15 matching lines...) Expand all
114 MockAudioOutputControllerSyncReader sync_reader; 115 MockAudioOutputControllerSyncReader sync_reader;
115 EXPECT_CALL(sync_reader, UpdatePendingBytes(_)) 116 EXPECT_CALL(sync_reader, UpdatePendingBytes(_))
116 .Times(AtLeast(2)); 117 .Times(AtLeast(2));
117 EXPECT_CALL(sync_reader, Read(_, kHardwareBufferSize)) 118 EXPECT_CALL(sync_reader, Read(_, kHardwareBufferSize))
118 .WillRepeatedly(DoAll(SignalEvent(&event), 119 .WillRepeatedly(DoAll(SignalEvent(&event),
119 Return(4))); 120 Return(4)));
120 EXPECT_CALL(event_handler, OnPaused(NotNull())) 121 EXPECT_CALL(event_handler, OnPaused(NotNull()))
121 .WillOnce(InvokeWithoutArgs(&pause_event, &base::WaitableEvent::Signal)); 122 .WillOnce(InvokeWithoutArgs(&pause_event, &base::WaitableEvent::Signal));
122 EXPECT_CALL(sync_reader, Close()); 123 EXPECT_CALL(sync_reader, Close());
123 124
124 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, 125 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, false,
125 kSampleRate, kBitsPerSample, kSamplesPerPacket); 126 kChannelLayout, kSampleRate, kBitsPerSample,
127 kSamplesPerPacket);
126 scoped_refptr<AudioOutputController> controller = 128 scoped_refptr<AudioOutputController> controller =
127 AudioOutputController::Create( 129 AudioOutputController::Create(
128 audio_manager.get(), &event_handler, params, &sync_reader); 130 audio_manager.get(), &event_handler, params, &sync_reader);
129 ASSERT_TRUE(controller.get()); 131 ASSERT_TRUE(controller.get());
130 132
131 // Wait for OnCreated() to be called. 133 // Wait for OnCreated() to be called.
132 event.Wait(); 134 event.Wait();
133 135
134 ASSERT_FALSE(pause_event.IsSignaled()); 136 ASSERT_FALSE(pause_event.IsSignaled());
135 controller->Play(); 137 controller->Play();
136 controller->Pause(); 138 controller->Pause();
137 pause_event.Wait(); 139 pause_event.Wait();
138 140
139 // Now stop the controller. 141 // Now stop the controller.
140 CloseAudioController(controller); 142 CloseAudioController(controller);
141 } 143 }
142 144
143 145
144 TEST(AudioOutputControllerTest, HardwareBufferTooLarge) { 146 TEST(AudioOutputControllerTest, HardwareBufferTooLarge) {
145 scoped_ptr<AudioManager> audio_manager(AudioManager::Create()); 147 scoped_ptr<AudioManager> audio_manager(AudioManager::Create());
146 if (!audio_manager->HasAudioOutputDevices()) 148 if (!audio_manager->HasAudioOutputDevices())
147 return; 149 return;
148 150
149 // Create an audio device with a very large hardware buffer size. 151 // Create an audio device with a very large hardware buffer size.
150 MockAudioOutputControllerEventHandler event_handler; 152 MockAudioOutputControllerEventHandler event_handler;
151 153
152 MockAudioOutputControllerSyncReader sync_reader; 154 MockAudioOutputControllerSyncReader sync_reader;
153 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, 155 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, false,
154 kSampleRate, kBitsPerSample, 156 kChannelLayout, kSampleRate, kBitsPerSample,
155 kSamplesPerPacket * 1000); 157 kSamplesPerPacket * 1000);
156 scoped_refptr<AudioOutputController> controller = 158 scoped_refptr<AudioOutputController> controller =
157 AudioOutputController::Create( 159 AudioOutputController::Create(
158 audio_manager.get(), &event_handler, params, &sync_reader); 160 audio_manager.get(), &event_handler, params, &sync_reader);
159 161
160 // Use assert because we don't stop the device and assume we can't 162 // Use assert because we don't stop the device and assume we can't
161 // create one. 163 // create one.
162 ASSERT_FALSE(controller); 164 ASSERT_FALSE(controller);
163 } 165 }
164 166
165 } // namespace media 167 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698