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

Side by Side Diff: ppapi/tests/test_audio.cc

Issue 22320004: Add a new parameter |latency| to PPB_Audio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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
« no previous file with comments | « ppapi/tests/test_audio.h ('k') | ppapi/thunk/interfaces_ppb_public_stable.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ppapi/tests/test_audio.h" 5 #include "ppapi/tests/test_audio.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "ppapi/c/ppb_audio_config.h" 9 #include "ppapi/c/ppb_audio_config.h"
10 #include "ppapi/c/ppb_audio.h" 10 #include "ppapi/c/ppb_audio.h"
11 #include "ppapi/cpp/module.h" 11 #include "ppapi/cpp/module.h"
12 #include "ppapi/tests/testing_instance.h" 12 #include "ppapi/tests/testing_instance.h"
13 #include "ppapi/tests/test_utils.h" 13 #include "ppapi/tests/test_utils.h"
14 14
15 #define ARRAYSIZE_UNSAFE(a) \ 15 #define ARRAYSIZE_UNSAFE(a) \
16 ((sizeof(a) / sizeof(*(a))) / \ 16 ((sizeof(a) / sizeof(*(a))) / \
17 static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) 17 static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
18 18
19 REGISTER_TEST_CASE(Audio); 19 REGISTER_TEST_CASE(Audio);
20 20
21 const int32_t kMagicValue = 12345; 21 const int32_t kMagicValue = 12345;
22 22
23 TestAudio::TestAudio(TestingInstance* instance) 23 TestAudio::TestAudio(TestingInstance* instance)
24 : TestCase(instance), 24 : TestCase(instance),
25 audio_callback_method_(NULL), 25 audio_callback_method_(NULL),
26 audio_callback_event_(instance->pp_instance()), 26 audio_callback_event_(instance->pp_instance()),
27 test_done_(false) { 27 test_done_(false),
28 audio_interface_(NULL),
29 audio_interface_1_0_(NULL),
30 audio_config_interface_(NULL),
31 core_interface_(NULL) {
28 } 32 }
29 33
30 TestAudio::~TestAudio() { 34 TestAudio::~TestAudio() {
31 } 35 }
32 36
33 bool TestAudio::Init() { 37 bool TestAudio::Init() {
34 audio_interface_ = static_cast<const PPB_Audio*>( 38 audio_interface_ = static_cast<const PPB_Audio_1_1*>(
35 pp::Module::Get()->GetBrowserInterface(PPB_AUDIO_INTERFACE)); 39 pp::Module::Get()->GetBrowserInterface(PPB_AUDIO_INTERFACE_1_1));
40 audio_interface_1_0_ = static_cast<const PPB_Audio_1_0*>(
41 pp::Module::Get()->GetBrowserInterface(PPB_AUDIO_INTERFACE_1_0));
36 audio_config_interface_ = static_cast<const PPB_AudioConfig*>( 42 audio_config_interface_ = static_cast<const PPB_AudioConfig*>(
37 pp::Module::Get()->GetBrowserInterface(PPB_AUDIO_CONFIG_INTERFACE)); 43 pp::Module::Get()->GetBrowserInterface(PPB_AUDIO_CONFIG_INTERFACE));
38 core_interface_ = static_cast<const PPB_Core*>( 44 core_interface_ = static_cast<const PPB_Core*>(
39 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE)); 45 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE));
40 return audio_interface_ && audio_config_interface_ && core_interface_; 46 return audio_interface_ && audio_interface_1_0_ && audio_config_interface_ &&
47 core_interface_;
41 } 48 }
42 49
43 void TestAudio::RunTests(const std::string& filter) { 50 void TestAudio::RunTests(const std::string& filter) {
44 RUN_TEST(Creation, filter); 51 RUN_TEST(Creation, filter);
45 RUN_TEST(DestroyNoStop, filter); 52 RUN_TEST(DestroyNoStop, filter);
46 RUN_TEST(Failures, filter); 53 RUN_TEST(Failures, filter);
47 RUN_TEST(AudioCallback1, filter); 54 RUN_TEST(AudioCallback1, filter);
48 RUN_TEST(AudioCallback2, filter); 55 RUN_TEST(AudioCallback2, filter);
49 RUN_TEST(AudioCallback3, filter); 56 RUN_TEST(AudioCallback3, filter);
57 RUN_TEST(AudioCallback4, filter);
50 } 58 }
51 59
52 // Test creating audio resources for all guaranteed sample rates and various 60 // Test creating audio resources for all guaranteed sample rates and various
53 // frame counts. 61 // frame counts.
54 std::string TestAudio::TestCreation() { 62 std::string TestAudio::TestCreation() {
55 static const PP_AudioSampleRate kSampleRates[] = { 63 static const PP_AudioSampleRate kSampleRates[] = {
56 PP_AUDIOSAMPLERATE_44100, 64 PP_AUDIOSAMPLERATE_44100,
57 PP_AUDIOSAMPLERATE_48000 65 PP_AUDIOSAMPLERATE_48000
58 }; 66 };
59 static const uint32_t kRequestFrameCounts[] = { 67 static const uint32_t kRequestFrameCounts[] = {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 119
112 core_interface_->ReleaseResource(audio); 120 core_interface_->ReleaseResource(audio);
113 } 121 }
114 } 122 }
115 123
116 PASS(); 124 PASS();
117 } 125 }
118 126
119 // Test that releasing the resource without calling |StopPlayback()| "works". 127 // Test that releasing the resource without calling |StopPlayback()| "works".
120 std::string TestAudio::TestDestroyNoStop() { 128 std::string TestAudio::TestDestroyNoStop() {
121 const PP_AudioSampleRate kSampleRate = PP_AUDIOSAMPLERATE_44100; 129 PP_Resource ac = CreateAudioConfig(PP_AUDIOSAMPLERATE_44100, 2048);
122 const uint32_t kRequestFrameCount = 2048;
123
124 uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
125 instance_->pp_instance(), kSampleRate, kRequestFrameCount);
126 PP_Resource ac = audio_config_interface_->CreateStereo16Bit(
127 instance_->pp_instance(), kSampleRate, frame_count);
128 ASSERT_TRUE(ac); 130 ASSERT_TRUE(ac);
129 audio_callback_method_ = NULL; 131 audio_callback_method_ = NULL;
130 PP_Resource audio = audio_interface_->Create( 132 PP_Resource audio = audio_interface_->Create(
131 instance_->pp_instance(), ac, AudioCallbackTrampoline, this); 133 instance_->pp_instance(), ac, AudioCallbackTrampoline, this);
132 core_interface_->ReleaseResource(ac); 134 core_interface_->ReleaseResource(ac);
133 ac = 0; 135 ac = 0;
134 136
135 ASSERT_TRUE(audio); 137 ASSERT_TRUE(audio);
136 ASSERT_TRUE(audio_interface_->IsAudio(audio)); 138 ASSERT_TRUE(audio_interface_->IsAudio(audio));
137 139
138 // Start playback and release the resource. 140 // Start playback and release the resource.
139 audio_callback_method_ = &TestAudio::AudioCallbackTrivial; 141 audio_callback_method_ = &TestAudio::AudioCallbackTrivial;
140 ASSERT_TRUE(audio_interface_->StartPlayback(audio)); 142 ASSERT_TRUE(audio_interface_->StartPlayback(audio));
141 core_interface_->ReleaseResource(audio); 143 core_interface_->ReleaseResource(audio);
142 audio_callback_method_ = NULL; 144 audio_callback_method_ = NULL;
143 145
144 PASS(); 146 PASS();
145 } 147 }
146 148
147 std::string TestAudio::TestFailures() { 149 std::string TestAudio::TestFailures() {
148 const PP_AudioSampleRate kSampleRate = PP_AUDIOSAMPLERATE_44100;
149 const uint32_t kRequestFrameCount = 2048;
150
151 // Test invalid parameters to |Create()|. 150 // Test invalid parameters to |Create()|.
152 151
153 // We want a valid config for some of our tests of |Create()|. 152 // We want a valid config for some of our tests of |Create()|.
154 uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount( 153 PP_Resource ac = CreateAudioConfig(PP_AUDIOSAMPLERATE_44100, 2048);
155 instance_->pp_instance(), kSampleRate, kRequestFrameCount);
156 PP_Resource ac = audio_config_interface_->CreateStereo16Bit(
157 instance_->pp_instance(), kSampleRate, frame_count);
158 ASSERT_TRUE(ac); 154 ASSERT_TRUE(ac);
159 155
160 // Failure cases should never lead to the callback being called. 156 // Failure cases should never lead to the callback being called.
161 audio_callback_method_ = NULL; 157 audio_callback_method_ = NULL;
162 158
163 // Invalid instance -> failure. 159 // Invalid instance -> failure.
164 PP_Resource audio = audio_interface_->Create( 160 PP_Resource audio = audio_interface_->Create(
165 0, ac, AudioCallbackTrampoline, this); 161 0, ac, AudioCallbackTrampoline, this);
166 ASSERT_EQ(0, audio); 162 ASSERT_EQ(0, audio);
167 163
(...skipping 12 matching lines...) Expand all
180 176
181 // Test the other functions with an invalid audio resource. 177 // Test the other functions with an invalid audio resource.
182 ASSERT_FALSE(audio_interface_->IsAudio(0)); 178 ASSERT_FALSE(audio_interface_->IsAudio(0));
183 ASSERT_EQ(0, audio_interface_->GetCurrentConfig(0)); 179 ASSERT_EQ(0, audio_interface_->GetCurrentConfig(0));
184 ASSERT_FALSE(audio_interface_->StartPlayback(0)); 180 ASSERT_FALSE(audio_interface_->StartPlayback(0));
185 ASSERT_FALSE(audio_interface_->StopPlayback(0)); 181 ASSERT_FALSE(audio_interface_->StopPlayback(0));
186 182
187 PASS(); 183 PASS();
188 } 184 }
189 185
190 // NOTE: |TestAudioCallback1| and |TestAudioCallback2| assume that the audio 186 // NOTE: |TestAudioCallbackN| assumes that the audio callback is called at least
191 // callback is called at least once. If the audio stream does not start up 187 // once. If the audio stream does not start up correctly or is interrupted this
192 // correctly or is interrupted this may not be the case and these tests will 188 // may not be the case and these tests will fail. However, in order to properly
193 // fail. However, in order to properly test the audio callbacks, we must have 189 // test the audio callbacks, we must have a configuration where audio can
194 // a configuration where audio can successfully play, so we assume this is the 190 // successfully play, so we assume this is the case on bots.
195 // case on bots.
196 191
197 // This test starts playback and verifies that: 192 // This test starts playback and verifies that:
198 // 1) the audio callback is actually called; 193 // 1) the audio callback is actually called;
199 // 2) that |StopPlayback()| waits for the audio callback to finish. 194 // 2) that |StopPlayback()| waits for the audio callback to finish.
200 std::string TestAudio::TestAudioCallback1() { 195 std::string TestAudio::TestAudioCallback1() {
201 const PP_AudioSampleRate kSampleRate = PP_AUDIOSAMPLERATE_44100; 196 PP_Resource ac = CreateAudioConfig(PP_AUDIOSAMPLERATE_44100, 1024);
202 const uint32_t kRequestFrameCount = 1024;
203
204 uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
205 instance_->pp_instance(), kSampleRate, kRequestFrameCount);
206 PP_Resource ac = audio_config_interface_->CreateStereo16Bit(
207 instance_->pp_instance(), kSampleRate, frame_count);
208 ASSERT_TRUE(ac); 197 ASSERT_TRUE(ac);
209 audio_callback_method_ = NULL; 198 audio_callback_method_ = NULL;
210 PP_Resource audio = audio_interface_->Create( 199 PP_Resource audio = audio_interface_->Create(
211 instance_->pp_instance(), ac, AudioCallbackTrampoline, this); 200 instance_->pp_instance(), ac, AudioCallbackTrampoline, this);
212 core_interface_->ReleaseResource(ac); 201 core_interface_->ReleaseResource(ac);
213 ac = 0; 202 ac = 0;
214 203
215 audio_callback_event_.Reset(); 204 audio_callback_event_.Reset();
216 test_done_ = false; 205 test_done_ = false;
217 206
218 audio_callback_method_ = &TestAudio::AudioCallbackTest; 207 audio_callback_method_ = &TestAudio::AudioCallbackTest;
219 ASSERT_TRUE(audio_interface_->StartPlayback(audio)); 208 ASSERT_TRUE(audio_interface_->StartPlayback(audio));
220 209
221 // Wait for the audio callback to be called. 210 // Wait for the audio callback to be called.
222 audio_callback_event_.Wait(); 211 audio_callback_event_.Wait();
223 ASSERT_TRUE(audio_interface_->StopPlayback(audio)); 212 ASSERT_TRUE(audio_interface_->StopPlayback(audio));
224 test_done_ = true; 213 test_done_ = true;
225 214
226 // If any more audio callbacks are generated, we should crash (which is good). 215 // If any more audio callbacks are generated, we should crash (which is good).
227 audio_callback_method_ = NULL; 216 audio_callback_method_ = NULL;
228 217
229 core_interface_->ReleaseResource(audio); 218 core_interface_->ReleaseResource(audio);
230 219
231 PASS(); 220 PASS();
232 } 221 }
233 222
234 // This is the same as |TestAudioCallback1()|, except that instead of calling 223 // This is the same as |TestAudioCallback1()|, except that instead of calling
235 // |StopPlayback()|, it just releases the resource. 224 // |StopPlayback()|, it just releases the resource.
236 std::string TestAudio::TestAudioCallback2() { 225 std::string TestAudio::TestAudioCallback2() {
237 const PP_AudioSampleRate kSampleRate = PP_AUDIOSAMPLERATE_44100; 226 PP_Resource ac = CreateAudioConfig(PP_AUDIOSAMPLERATE_44100, 1024);
238 const uint32_t kRequestFrameCount = 1024;
239
240 uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
241 instance_->pp_instance(), kSampleRate, kRequestFrameCount);
242 PP_Resource ac = audio_config_interface_->CreateStereo16Bit(
243 instance_->pp_instance(), kSampleRate, frame_count);
244 ASSERT_TRUE(ac); 227 ASSERT_TRUE(ac);
245 audio_callback_method_ = NULL; 228 audio_callback_method_ = NULL;
246 PP_Resource audio = audio_interface_->Create( 229 PP_Resource audio = audio_interface_->Create(
247 instance_->pp_instance(), ac, AudioCallbackTrampoline, this); 230 instance_->pp_instance(), ac, AudioCallbackTrampoline, this);
248 core_interface_->ReleaseResource(ac); 231 core_interface_->ReleaseResource(ac);
249 ac = 0; 232 ac = 0;
250 233
251 audio_callback_event_.Reset(); 234 audio_callback_event_.Reset();
252 test_done_ = false; 235 test_done_ = false;
253 callback_fired_ = false;
254 236
255 audio_callback_method_ = &TestAudio::AudioCallbackTest; 237 audio_callback_method_ = &TestAudio::AudioCallbackTest;
256 ASSERT_TRUE(audio_interface_->StartPlayback(audio)); 238 ASSERT_TRUE(audio_interface_->StartPlayback(audio));
257 239
258 // Wait for the audio callback to be called. 240 // Wait for the audio callback to be called.
259 audio_callback_event_.Wait(); 241 audio_callback_event_.Wait();
260 242
261 core_interface_->ReleaseResource(audio); 243 core_interface_->ReleaseResource(audio);
262 244
263 test_done_ = true; 245 test_done_ = true;
264 246
265 // If any more audio callbacks are generated, we should crash (which is good). 247 // If any more audio callbacks are generated, we should crash (which is good).
266 audio_callback_method_ = NULL; 248 audio_callback_method_ = NULL;
267 249
268 PASS(); 250 PASS();
269 } 251 }
270 252
271 // This is the same as |TestAudioCallback1()|, except that it attempts a second 253 // This is the same as |TestAudioCallback1()|, except that it attempts a second
272 // round of |StartPlayback| and |StopPlayback| to make sure the callback 254 // round of |StartPlayback| and |StopPlayback| to make sure the callback
273 // function still responds when using the same audio resource. 255 // function still responds when using the same audio resource.
274 std::string TestAudio::TestAudioCallback3() { 256 std::string TestAudio::TestAudioCallback3() {
275 const PP_AudioSampleRate kSampleRate = PP_AUDIOSAMPLERATE_44100; 257 PP_Resource ac = CreateAudioConfig(PP_AUDIOSAMPLERATE_44100, 1024);
276 const uint32_t kRequestFrameCount = 1024;
277
278 uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
279 instance_->pp_instance(), kSampleRate, kRequestFrameCount);
280 PP_Resource ac = audio_config_interface_->CreateStereo16Bit(
281 instance_->pp_instance(), kSampleRate, frame_count);
282 ASSERT_TRUE(ac); 258 ASSERT_TRUE(ac);
283 audio_callback_method_ = NULL; 259 audio_callback_method_ = NULL;
284 PP_Resource audio = audio_interface_->Create( 260 PP_Resource audio = audio_interface_->Create(
285 instance_->pp_instance(), ac, AudioCallbackTrampoline, this); 261 instance_->pp_instance(), ac, AudioCallbackTrampoline, this);
286 core_interface_->ReleaseResource(ac); 262 core_interface_->ReleaseResource(ac);
287 ac = 0; 263 ac = 0;
288 264
289 audio_callback_event_.Reset(); 265 audio_callback_event_.Reset();
290 test_done_ = false; 266 test_done_ = false;
291 callback_fired_ = false;
292 267
293 audio_callback_method_ = &TestAudio::AudioCallbackTest; 268 audio_callback_method_ = &TestAudio::AudioCallbackTest;
294 ASSERT_TRUE(audio_interface_->StartPlayback(audio)); 269 ASSERT_TRUE(audio_interface_->StartPlayback(audio));
295 270
296 // Wait for the audio callback to be called. 271 // Wait for the audio callback to be called.
297 audio_callback_event_.Wait(); 272 audio_callback_event_.Wait();
298 273
299 ASSERT_TRUE(audio_interface_->StopPlayback(audio)); 274 ASSERT_TRUE(audio_interface_->StopPlayback(audio));
300 275
301 // Repeat one more |StartPlayback| & |StopPlayback| cycle, and verify again 276 // Repeat one more |StartPlayback| & |StopPlayback| cycle, and verify again
302 // that the callback function was invoked. 277 // that the callback function was invoked.
303 audio_callback_event_.Reset(); 278 audio_callback_event_.Reset();
304 ASSERT_TRUE(audio_interface_->StartPlayback(audio)); 279 ASSERT_TRUE(audio_interface_->StartPlayback(audio));
305 280
306 // Wait for the audio callback to be called. 281 // Wait for the audio callback to be called.
307 audio_callback_event_.Wait(); 282 audio_callback_event_.Wait();
308 ASSERT_TRUE(audio_interface_->StopPlayback(audio)); 283 ASSERT_TRUE(audio_interface_->StopPlayback(audio));
309 test_done_ = true; 284 test_done_ = true;
310 285
311 // If any more audio callbacks are generated, we should crash (which is good). 286 // If any more audio callbacks are generated, we should crash (which is good).
312 audio_callback_method_ = NULL; 287 audio_callback_method_ = NULL;
313 288
314 core_interface_->ReleaseResource(audio); 289 core_interface_->ReleaseResource(audio);
315 290
316 PASS(); 291 PASS();
317 } 292 }
318 293
294 // This is the same as |TestAudioCallback1()|, except that it uses
295 // PPB_Audio_1_0.
296 std::string TestAudio::TestAudioCallback4() {
297 PP_Resource ac = CreateAudioConfig(PP_AUDIOSAMPLERATE_44100, 1024);
298 ASSERT_TRUE(ac);
299 audio_callback_method_ = NULL;
300 PP_Resource audio = audio_interface_1_0_->Create(
301 instance_->pp_instance(), ac, AudioCallbackTrampoline1_0, this);
302 core_interface_->ReleaseResource(ac);
303 ac = 0;
304
305 audio_callback_event_.Reset();
306 test_done_ = false;
307
308 audio_callback_method_ = &TestAudio::AudioCallbackTest;
309 ASSERT_TRUE(audio_interface_1_0_->StartPlayback(audio));
310
311 // Wait for the audio callback to be called.
312 audio_callback_event_.Wait();
313 ASSERT_TRUE(audio_interface_1_0_->StopPlayback(audio));
314 test_done_ = true;
315
316 // If any more audio callbacks are generated, we should crash (which is good).
317 audio_callback_method_ = NULL;
318
319 core_interface_->ReleaseResource(audio);
320
321 PASS();
322 }
319 323
320 // TODO(raymes): Test that actually playback happens correctly, etc. 324 // TODO(raymes): Test that actually playback happens correctly, etc.
321 325
322 static void Crash() { 326 static void Crash() {
323 *static_cast<volatile unsigned*>(NULL) = 0xdeadbeef; 327 *static_cast<volatile unsigned*>(NULL) = 0xdeadbeef;
324 } 328 }
325 329
326 // static 330 // static
327 void TestAudio::AudioCallbackTrampoline(void* sample_buffer, 331 void TestAudio::AudioCallbackTrampoline(void* sample_buffer,
328 uint32_t buffer_size_in_bytes, 332 uint32_t buffer_size_in_bytes,
333 PP_TimeDelta latency,
329 void* user_data) { 334 void* user_data) {
330 TestAudio* thiz = static_cast<TestAudio*>(user_data); 335 TestAudio* thiz = static_cast<TestAudio*>(user_data);
331 336
332 // Crash if on the main thread. 337 // Crash if on the main thread.
333 if (thiz->core_interface_->IsMainThread()) 338 if (thiz->core_interface_->IsMainThread())
334 Crash(); 339 Crash();
335 340
336 AudioCallbackMethod method = thiz->audio_callback_method_; 341 AudioCallbackMethod method = thiz->audio_callback_method_;
337 (thiz->*method)(sample_buffer, buffer_size_in_bytes); 342 (thiz->*method)(sample_buffer, buffer_size_in_bytes, latency);
343 }
344
345 // static
346 void TestAudio::AudioCallbackTrampoline1_0(void* sample_buffer,
347 uint32_t buffer_size_in_bytes,
348 void* user_data) {
349 AudioCallbackTrampoline(sample_buffer, buffer_size_in_bytes, 0.0, user_data);
338 } 350 }
339 351
340 void TestAudio::AudioCallbackTrivial(void* sample_buffer, 352 void TestAudio::AudioCallbackTrivial(void* sample_buffer,
341 uint32_t buffer_size_in_bytes) { 353 uint32_t buffer_size_in_bytes,
354 PP_TimeDelta latency) {
355 if (latency < 0)
356 Crash();
357
342 memset(sample_buffer, 0, buffer_size_in_bytes); 358 memset(sample_buffer, 0, buffer_size_in_bytes);
343 } 359 }
344 360
345 void TestAudio::AudioCallbackTest(void* sample_buffer, 361 void TestAudio::AudioCallbackTest(void* sample_buffer,
346 uint32_t buffer_size_in_bytes) { 362 uint32_t buffer_size_in_bytes,
347 if (test_done_) 363 PP_TimeDelta latency) {
364 if (test_done_ || latency < 0)
348 Crash(); 365 Crash();
349 366
350 memset(sample_buffer, 0, buffer_size_in_bytes); 367 memset(sample_buffer, 0, buffer_size_in_bytes);
351 audio_callback_event_.Signal(); 368 audio_callback_event_.Signal();
352 } 369 }
370
371 PP_Resource TestAudio::CreateAudioConfig(
372 PP_AudioSampleRate sample_rate,
373 uint32_t requested_sample_frame_count) {
374 uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
375 instance_->pp_instance(), sample_rate, requested_sample_frame_count);
376 return audio_config_interface_->CreateStereo16Bit(
377 instance_->pp_instance(), sample_rate, frame_count);
378 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_audio.h ('k') | ppapi/thunk/interfaces_ppb_public_stable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698