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

Side by Side Diff: media/audio/mac/audio_output_mac_unittest.cc

Issue 92131: Third installement of low level audio for mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "media/audio/audio_output.h" 6 #include "media/audio/audio_output.h"
7 #include "media/audio/simple_sources.h" 7 #include "media/audio/simple_sources.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 AudioManager* audio_man = AudioManager::GetAudioManager(); 47 AudioManager* audio_man = AudioManager::GetAudioManager();
48 ASSERT_TRUE(NULL != audio_man); 48 ASSERT_TRUE(NULL != audio_man);
49 if (!audio_man->HasAudioDevices()) 49 if (!audio_man->HasAudioDevices())
50 return; 50 return;
51 AudioOutputStream* oas = 51 AudioOutputStream* oas =
52 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 2, 8000, 16); 52 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 2, 8000, 16);
53 ASSERT_TRUE(NULL != oas); 53 ASSERT_TRUE(NULL != oas);
54 EXPECT_TRUE(oas->Open(1024)); 54 EXPECT_TRUE(oas->Open(1024));
55 oas->Close(); 55 oas->Close();
56 } 56 }
57
58 // This test produces actual audio for 1.5 seconds on the default wave device at
59 // 44.1K s/sec. Parameters have been chosen carefully so you should not hear
60 // pops or noises while the sound is playing. The sound must also be identical
61 // to the sound of PCMWaveStreamPlay200HzTone22KssMono test.
62 TEST(MacAudioTest, PCMWaveStreamPlay200HzTone44KssMono) {
63 AudioManager* audio_man = AudioManager::GetAudioManager();
64 ASSERT_TRUE(NULL != audio_man);
65 if (!audio_man->HasAudioDevices())
66 return;
67 AudioOutputStream* oas =
68 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1,
69 AudioManager::kAudioCDSampleRate, 16);
70 ASSERT_TRUE(NULL != oas);
71
72 SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
73 200.0, AudioManager::kAudioCDSampleRate);
74 size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
75
76 EXPECT_TRUE(oas->Open(bytes_100_ms));
77 oas->Start(&source);
78 usleep(1500000);
79 oas->Stop();
80 oas->Close();
81 }
82
83 // This test produces actual audio for 1.5 seconds on the default wave device at
84 // 22K s/sec. Parameters have been chosen carefully so you should not hear pops
85 // or noises while the sound is playing. The sound must also be identical to the
86 // sound of PCMWaveStreamPlay200HzTone44KssMono test.
87 TEST(MacAudioTest, PCMWaveStreamPlay200HzTone22KssMono) {
88 AudioManager* audio_man = AudioManager::GetAudioManager();
89 ASSERT_TRUE(NULL != audio_man);
90 if (!audio_man->HasAudioDevices())
91 return;
92 AudioOutputStream* oas =
93 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1,
94 AudioManager::kAudioCDSampleRate/2, 16);
95 ASSERT_TRUE(NULL != oas);
96
97 SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
98 200.0, AudioManager::kAudioCDSampleRate/2);
99 size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 20) * 2;
100
101 EXPECT_TRUE(oas->Open(bytes_100_ms));
102 oas->Start(&source);
103 usleep(1500000);
104 oas->Stop();
105 oas->Close();
106 }
OLDNEW
« media/audio/mac/audio_output_mac.cc ('K') | « media/audio/mac/audio_output_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698