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

Unified Diff: media/audio/audio_output_proxy_unittest.cc

Issue 61203008: Attempt to fix audio wedges by restarting all streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mock. Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_output_dispatcher_impl.cc ('k') | media/audio/audio_output_resampler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_proxy_unittest.cc
diff --git a/media/audio/audio_output_proxy_unittest.cc b/media/audio/audio_output_proxy_unittest.cc
index 3cffcc95cfbf73743f181e0f8b458d24a407cf06..74e93ebedf773bf285c04512c17bec61b4d820c1 100644
--- a/media/audio/audio_output_proxy_unittest.cc
+++ b/media/audio/audio_output_proxy_unittest.cc
@@ -748,4 +748,64 @@ TEST_F(AudioOutputResamplerTest, LowLatencyOpenEventuallyFails) {
EXPECT_FALSE(stream3.start_called());
}
+// Ensures the methods used to fix audio output wedges are working correctly.
+TEST_F(AudioOutputResamplerTest, WedgeFix) {
+ MockAudioOutputStream stream1(&manager_, params_);
+ MockAudioOutputStream stream2(&manager_, params_);
+ MockAudioOutputStream stream3(&manager_, params_);
+
+ // Setup the mock such that all three streams are successfully created.
+ EXPECT_CALL(manager(), MakeAudioOutputStream(_, _, _))
+ .WillOnce(Return(&stream1))
+ .WillOnce(Return(&stream2))
+ .WillOnce(Return(&stream3));
+
+ // Stream1 should be able to successfully open and start.
+ EXPECT_CALL(stream1, Open())
+ .WillOnce(Return(true));
+ EXPECT_CALL(stream1, Close());
+ EXPECT_CALL(stream1, SetVolume(_));
+ EXPECT_CALL(stream2, Open())
+ .WillOnce(Return(true));
+ EXPECT_CALL(stream2, Close());
+
+ // Open and start the first proxy and stream.
+ AudioOutputProxy* proxy1 = new AudioOutputProxy(resampler_.get());
+ EXPECT_TRUE(proxy1->Open());
+ proxy1->Start(&callback_);
+ OnStart();
+
+ // Open, but do not start the second proxy.
+ AudioOutputProxy* proxy2 = new AudioOutputProxy(resampler_.get());
+ EXPECT_TRUE(proxy2->Open());
+
+ // Wait for stream to timeout and shutdown.
+ WaitForCloseTimer(kTestCloseDelayMs);
+
+ resampler_->CloseStreamsForWedgeFix();
+
+ // Stream3 should take Stream1's place after RestartStreamsForWedgeFix().
+ EXPECT_CALL(stream3, Open())
+ .WillOnce(Return(true));
+ EXPECT_CALL(stream3, Close());
+ EXPECT_CALL(stream3, SetVolume(_));
+
+ resampler_->RestartStreamsForWedgeFix();
+ OnStart();
+
+ // Perform the required Stop()/Close() shutdown dance for each proxy.
+ proxy2->Close();
+ proxy1->Stop();
+ proxy1->Close();
+
+ // Wait for all of the messages to fly and then verify stream behavior.
+ WaitForCloseTimer(kTestCloseDelayMs);
+ EXPECT_TRUE(stream1.stop_called());
+ EXPECT_TRUE(stream1.start_called());
+ EXPECT_FALSE(stream2.stop_called());
+ EXPECT_FALSE(stream2.start_called());
+ EXPECT_TRUE(stream3.stop_called());
+ EXPECT_TRUE(stream3.start_called());
+}
+
} // namespace media
« no previous file with comments | « media/audio/audio_output_dispatcher_impl.cc ('k') | media/audio/audio_output_resampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698