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

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

Issue 12316131: Moved AudioUtil static functions to AudioManager interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: made the GetPreferredOutputStreamParameters protected Created 7 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
« no previous file with comments | « media/audio/win/audio_manager_win.cc ('k') | no next file » | 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 <windows.h> 5 #include <windows.h>
6 #include <mmsystem.h> 6 #include <mmsystem.h>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 if (!audio_man->HasAudioOutputDevices()) { 454 if (!audio_man->HasAudioOutputDevices()) {
455 LOG(WARNING) << "No output device detected."; 455 LOG(WARNING) << "No output device detected.";
456 return; 456 return;
457 } 457 }
458 458
459 // The WASAPI API requires a correct COM environment. 459 // The WASAPI API requires a correct COM environment.
460 ScopedCOMInitializer com_init(ScopedCOMInitializer::kMTA); 460 ScopedCOMInitializer com_init(ScopedCOMInitializer::kMTA);
461 461
462 // Use 10 ms buffer size for WASAPI and 50 ms buffer size for Wave. 462 // Use 10 ms buffer size for WASAPI and 50 ms buffer size for Wave.
463 // Take the existing native sample rate into account. 463 // Take the existing native sample rate into account.
464 int sample_rate = static_cast<int>(media::GetAudioHardwareSampleRate()); 464 const AudioParameters params = audio_man->GetDefaultOutputStreamParameters();
465 int sample_rate = params.sample_rate();
465 uint32 samples_10_ms = sample_rate / 100; 466 uint32 samples_10_ms = sample_rate / 100;
466 int n = 1; 467 int n = 1;
467 (base::win::GetVersion() <= base::win::VERSION_XP) ? n = 5 : n = 1; 468 (base::win::GetVersion() <= base::win::VERSION_XP) ? n = 5 : n = 1;
468 AudioOutputStream* oas = audio_man->MakeAudioOutputStream( 469 AudioOutputStream* oas = audio_man->MakeAudioOutputStream(
469 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 470 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
470 CHANNEL_LAYOUT_MONO, sample_rate, 471 CHANNEL_LAYOUT_MONO, sample_rate,
471 16, n * samples_10_ms)); 472 16, n * samples_10_ms));
472 ASSERT_TRUE(NULL != oas); 473 ASSERT_TRUE(NULL != oas);
473 474
474 SineWaveAudioSource source(1, 200, sample_rate); 475 SineWaveAudioSource source(1, 200, sample_rate);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 oas->Start(&source); 685 oas->Start(&source);
685 686
686 ::WaitForSingleObject(thread, INFINITE); 687 ::WaitForSingleObject(thread, INFINITE);
687 ::CloseHandle(thread); 688 ::CloseHandle(thread);
688 689
689 oas->Stop(); 690 oas->Stop();
690 oas->Close(); 691 oas->Close();
691 } 692 }
692 693
693 } // namespace media 694 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/audio_manager_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698