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

Side by Side Diff: media/audio/simple_sources_unittest.cc

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright years Created 8 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/pulse/pulse_output.h ('k') | media/audio/win/audio_low_latency_input_win.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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "media/audio/audio_manager.h" 9 #include "media/audio/audio_manager.h"
10 #include "media/audio/fake_audio_output_stream.h" 10 #include "media/audio/fake_audio_output_stream.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const uint32 samples = 1024; 64 const uint32 samples = 1024;
65 const uint32 bytes_per_sample = 2; 65 const uint32 bytes_per_sample = 2;
66 const int freq = 200; 66 const int freq = 200;
67 67
68 SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1, 68 SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
69 freq, AudioParameters::kTelephoneSampleRate); 69 freq, AudioParameters::kTelephoneSampleRate);
70 70
71 scoped_ptr<AudioManager> audio_man(AudioManager::Create()); 71 scoped_ptr<AudioManager> audio_man(AudioManager::Create());
72 AudioParameters params( 72 AudioParameters params(
73 AudioParameters::AUDIO_MOCK, CHANNEL_LAYOUT_MONO, 73 AudioParameters::AUDIO_MOCK, CHANNEL_LAYOUT_MONO,
74 AudioParameters::kTelephoneSampleRate, bytes_per_sample * 2, samples); 74 AudioParameters::kTelephoneSampleRate, bytes_per_sample * 8, samples);
75 AudioOutputStream* oas = audio_man->MakeAudioOutputStream(params); 75 AudioOutputStream* oas = audio_man->MakeAudioOutputStream(params);
76 ASSERT_TRUE(NULL != oas); 76 ASSERT_TRUE(NULL != oas);
77 EXPECT_TRUE(oas->Open()); 77 EXPECT_TRUE(oas->Open());
78 78
79 oas->Start(&source); 79 oas->Start(&source);
80 oas->Stop(); 80 oas->Stop();
81 81
82 ASSERT_TRUE(FakeAudioOutputStream::GetCurrentFakeStream()); 82 ASSERT_TRUE(FakeAudioOutputStream::GetCurrentFakeStream());
83 const int16* last_buffer = 83 const int16* last_buffer =
84 reinterpret_cast<int16*>( 84 reinterpret_cast<int16*>(
85 FakeAudioOutputStream::GetCurrentFakeStream()->buffer()); 85 FakeAudioOutputStream::GetCurrentFakeStream()->buffer());
86 ASSERT_TRUE(NULL != last_buffer); 86 ASSERT_TRUE(NULL != last_buffer);
87 87
88 uint32 half_period = AudioParameters::kTelephoneSampleRate / (freq * 2); 88 uint32 half_period = AudioParameters::kTelephoneSampleRate / (freq * 2);
89 89
90 // Spot test positive incursion of sine wave. 90 // Spot test positive incursion of sine wave.
91 EXPECT_EQ(0, last_buffer[0]); 91 EXPECT_EQ(0, last_buffer[0]);
92 EXPECT_EQ(5126, last_buffer[1]); 92 EXPECT_EQ(5126, last_buffer[1]);
93 EXPECT_TRUE(last_buffer[1] < last_buffer[2]); 93 EXPECT_TRUE(last_buffer[1] < last_buffer[2]);
94 EXPECT_TRUE(last_buffer[2] < last_buffer[3]); 94 EXPECT_TRUE(last_buffer[2] < last_buffer[3]);
95 // Spot test negative incursion of sine wave. 95 // Spot test negative incursion of sine wave.
96 EXPECT_EQ(0, last_buffer[half_period]); 96 EXPECT_EQ(0, last_buffer[half_period]);
97 EXPECT_EQ(-5126, last_buffer[half_period + 1]); 97 EXPECT_EQ(-5126, last_buffer[half_period + 1]);
98 EXPECT_TRUE(last_buffer[half_period + 1] > last_buffer[half_period + 2]); 98 EXPECT_TRUE(last_buffer[half_period + 1] > last_buffer[half_period + 2]);
99 EXPECT_TRUE(last_buffer[half_period + 2] > last_buffer[half_period + 3]); 99 EXPECT_TRUE(last_buffer[half_period + 2] > last_buffer[half_period + 3]);
100 oas->Close(); 100 oas->Close();
101 } 101 }
OLDNEW
« no previous file with comments | « media/audio/pulse/pulse_output.h ('k') | media/audio/win/audio_low_latency_input_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698