OLD | NEW |
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 Loading... |
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 // Create default clients using the default mixing format for shared mode. |
| 392 ScopedComPtr<IAudioClient> client( |
| 393 CoreAudioUtil::CreateDefaultClient(eRender, eConsole)); |
| 394 EXPECT_TRUE(client); |
| 395 |
| 396 WAVEFORMATPCMEX format; |
| 397 size_t endpoint_buffer_size = 0; |
| 398 EXPECT_TRUE(SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client, |
| 399 &format))); |
| 400 CoreAudioUtil::SharedModeInitialize(client, &format, NULL, |
| 401 &endpoint_buffer_size); |
| 402 EXPECT_GT(endpoint_buffer_size, 0u); |
| 403 |
| 404 ScopedComPtr<IAudioRenderClient> render_client( |
| 405 CoreAudioUtil::CreateRenderClient(client)); |
| 406 EXPECT_TRUE(render_client); |
| 407 |
| 408 // The endpoint audio buffer should not be filled up by default after being |
| 409 // created. |
| 410 UINT32 num_queued_frames = 0; |
| 411 client->GetCurrentPadding(&num_queued_frames); |
| 412 EXPECT_EQ(num_queued_frames, 0u); |
| 413 |
| 414 // Fill it up with zeros and verify that the buffer is full. |
| 415 // It is not possible to verify that the actual data consists of zeros |
| 416 // since we can't access data that has already been sent to the endpoint |
| 417 // buffer. |
| 418 EXPECT_TRUE(CoreAudioUtil::FillRenderEndpointBufferWithSilence( |
| 419 client, render_client)); |
| 420 client->GetCurrentPadding(&num_queued_frames); |
| 421 EXPECT_EQ(num_queued_frames, endpoint_buffer_size); |
| 422 } |
| 423 |
387 // | 424 // |
388 | 425 |
389 } // namespace media | 426 } // namespace media |
OLD | NEW |