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

Side by Side Diff: media/audio/win/core_audio_util_win_unittest.cc

Issue 12049070: Avoids irregular OnMoreData callbacks on Windows using Core Audio (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed audio glitch at startup Created 7 years, 10 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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/synchronization/waitable_event.h" 6 #include "base/synchronization/waitable_event.h"
7 #include "base/win/scoped_com_initializer.h" 7 #include "base/win/scoped_com_initializer.h"
8 #include "base/win/scoped_handle.h" 8 #include "base/win/scoped_handle.h"
9 #include "media/audio/win/core_audio_util_win.h" 9 #include "media/audio/win/core_audio_util_win.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // Do a proper initialization and verify that it works this time. 377 // Do a proper initialization and verify that it works this time.
378 CoreAudioUtil::SharedModeInitialize(client, &format, NULL, 378 CoreAudioUtil::SharedModeInitialize(client, &format, NULL,
379 &endpoint_buffer_size); 379 &endpoint_buffer_size);
380 capture_client = CoreAudioUtil::CreateCaptureClient(client); 380 capture_client = CoreAudioUtil::CreateCaptureClient(client);
381 EXPECT_TRUE(capture_client); 381 EXPECT_TRUE(capture_client);
382 EXPECT_GT(endpoint_buffer_size, 0u); 382 EXPECT_GT(endpoint_buffer_size, 0u);
383 } 383 }
384 } 384 }
385 } 385 }
386 386
387 TEST_F(CoreAudioUtilWinTest, FillRenderEndpointBufferWithSilence) {
388 if (!CanRunAudioTest())
389 return;
390
391 WAVEFORMATPCMEX format;
tommi (sloooow) - chröme 2013/02/01 11:57:53 move these variables down to where they're used.
henrika (OOO until Aug 14) 2013/02/01 12:23:52 Done.
392 size_t endpoint_buffer_size = 0;
393
394 // Create default clients using the default mixing format for shared mode.
395 ScopedComPtr<IAudioClient> client(
396 CoreAudioUtil::CreateDefaultClient(eRender, eConsole));
397 EXPECT_TRUE(client);
398 EXPECT_TRUE(SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client,
399 &format)));
400 CoreAudioUtil::SharedModeInitialize(client, &format, NULL,
401 &endpoint_buffer_size);
402 ScopedComPtr<IAudioRenderClient> render_client(
403 CoreAudioUtil::CreateRenderClient(client));
404 EXPECT_TRUE(render_client);
405 EXPECT_GT(endpoint_buffer_size, 0u);
406
407 // The endpoint audio buffer should not be filled up by default after being
408 // created.
409 UINT32 num_queued_frames = 0;
410 client->GetCurrentPadding(&num_queued_frames);
411 EXPECT_EQ(num_queued_frames, 0u);
412
413 // Fill it up with zeros and verify that the buffer is full.
414 // It is not possible to verify that the actual data consists of zeros
415 // since we can't access data that has already been sent to the endpoint
416 // buffer.
417 EXPECT_TRUE(CoreAudioUtil::FillRenderEndpointBufferWithSilence(
418 client, render_client));
tommi (sloooow) - chröme 2013/02/01 11:57:53 fix indent
henrika (OOO until Aug 14) 2013/02/01 12:23:52 Done.
419 client->GetCurrentPadding(&num_queued_frames);
420 EXPECT_EQ(num_queued_frames, endpoint_buffer_size);
421 }
422
387 // 423 //
388 424
389 } // namespace media 425 } // namespace media
OLDNEW
« media/audio/win/audio_unified_win.cc ('K') | « media/audio/win/core_audio_util_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698