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

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

Issue 9692038: stopping the audio thread before destroying the AudioManager<Platform> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased and fixed the speech recognition unittest 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
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 * 2, 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 oas->Close();
82 81
83 ASSERT_TRUE(FakeAudioOutputStream::GetLastFakeStream()); 82 ASSERT_TRUE(FakeAudioOutputStream::GetCurrentFakeStream());
84 const int16* last_buffer = 83 const int16* last_buffer =
85 reinterpret_cast<int16*>( 84 reinterpret_cast<int16*>(
86 FakeAudioOutputStream::GetLastFakeStream()->buffer()); 85 FakeAudioOutputStream::GetCurrentFakeStream()->buffer());
87 ASSERT_TRUE(NULL != last_buffer); 86 ASSERT_TRUE(NULL != last_buffer);
88 87
89 uint32 half_period = AudioParameters::kTelephoneSampleRate / (freq * 2); 88 uint32 half_period = AudioParameters::kTelephoneSampleRate / (freq * 2);
90 89
91 // Spot test positive incursion of sine wave. 90 // Spot test positive incursion of sine wave.
92 EXPECT_EQ(0, last_buffer[0]); 91 EXPECT_EQ(0, last_buffer[0]);
93 EXPECT_EQ(5126, last_buffer[1]); 92 EXPECT_EQ(5126, last_buffer[1]);
94 EXPECT_TRUE(last_buffer[1] < last_buffer[2]); 93 EXPECT_TRUE(last_buffer[1] < last_buffer[2]);
95 EXPECT_TRUE(last_buffer[2] < last_buffer[3]); 94 EXPECT_TRUE(last_buffer[2] < last_buffer[3]);
96 // Spot test negative incursion of sine wave. 95 // Spot test negative incursion of sine wave.
97 EXPECT_EQ(0, last_buffer[half_period]); 96 EXPECT_EQ(0, last_buffer[half_period]);
98 EXPECT_EQ(-5126, last_buffer[half_period + 1]); 97 EXPECT_EQ(-5126, last_buffer[half_period + 1]);
99 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]);
100 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();
101 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698