diff options
author | miu@chromium.org <miu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-19 02:47:46 +0000 |
---|---|---|
committer | miu@chromium.org <miu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-19 02:47:46 +0000 |
commit | a7735e3463b17b20634ab326e4f1f0ebeb38fb9c (patch) | |
tree | b3d25771c1803a36fa30b6ac1b4b68fc30f19a8a /media/audio/virtual_audio_input_stream_unittest.cc | |
parent | 7a7bd4610c1b5ba899498ff665da6c8ed71fb0c8 (diff) | |
download | chromium_src-a7735e3463b17b20634ab326e4f1f0ebeb38fb9c.zip chromium_src-a7735e3463b17b20634ab326e4f1f0ebeb38fb9c.tar.gz chromium_src-a7735e3463b17b20634ab326e4f1f0ebeb38fb9c.tar.bz2 |
Revert 207105 "Rejigger audio capture pipeline to work with sepa..."
> Rejigger audio capture pipeline to work with separate main+worker threads (Mac).
>
> The audio capture pipeline (specifically: WebContentsAudioInputStream, VirtualAudio[In|Out]putStream, and FakeAudioConsumer) was implemented under the assumption that the thread pumping audio data was the same as the thread invoking Open/Start/Stop/Close. This assumption was correct until SVN rev 204130 (https://codereview.chromium.org/14273018/), where these tasks were split across two separate threads.
>
> This change restores functionality by utilizing the same design assumptions as the normal, "non-virtual" input/output stream implementations. Data pumping is assumed to occur by one thread, and the implementation must block the control thread on a call to Stop() and not return from Stop() until the data pumping has ceased.
>
> Augmented VirtualAudioInputStream unit testing to run all tests under the one-thread (non-Mac platforms) versus two-thread (Mac only) scenario.
>
> BUG=249089
> TEST=media_unittests, content_unittests, manual confirmation
>
> Review URL: https://chromiumcodereview.appspot.com/17122006
TBR=miu@chromium.org
Review URL: https://codereview.chromium.org/17351004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/virtual_audio_input_stream_unittest.cc')
-rw-r--r-- | media/audio/virtual_audio_input_stream_unittest.cc | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/media/audio/virtual_audio_input_stream_unittest.cc b/media/audio/virtual_audio_input_stream_unittest.cc index d444cf7..144ce82 100644 --- a/media/audio/virtual_audio_input_stream_unittest.cc +++ b/media/audio/virtual_audio_input_stream_unittest.cc @@ -97,11 +97,10 @@ class TestAudioSource : public SineWaveAudioSource { } // namespace -class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { +class VirtualAudioInputStreamTest : public testing::Test { public: VirtualAudioInputStreamTest() : audio_thread_(new base::Thread("AudioThread")), - worker_thread_(new base::Thread("AudioWorkerThread")), stream_(NULL), closed_stream_(false, false) { audio_thread_->Start(); @@ -116,9 +115,8 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { } void Create() { - const bool worker_is_separate_thread = GetParam(); stream_ = new VirtualAudioInputStream( - kParams, GetWorkerLoop(worker_is_separate_thread), + kParams, audio_message_loop_, base::Bind(&base::DeletePointer<VirtualAudioInputStream>)); stream_->Open(); } @@ -136,6 +134,7 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { ASSERT_TRUE(!!stream_); AudioOutputStream* const output_stream = new VirtualAudioOutputStream( kParams, + audio_message_loop_.get(), stream_, base::Bind(&base::DeletePointer<VirtualAudioOutputStream>)); output_streams_.push_back(output_stream); @@ -213,19 +212,6 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { return audio_message_loop_; } - const scoped_refptr<base::MessageLoopProxy>& GetWorkerLoop( - bool worker_is_separate_thread) { - if (worker_is_separate_thread) { - if (!worker_thread_->IsRunning()) { - worker_thread_->Start(); - worker_message_loop_ = worker_thread_->message_loop_proxy(); - } - return worker_message_loop_; - } else { - return audio_message_loop_; - } - } - private: void SyncWithAudioThread() { base::WaitableEvent done(false, false); @@ -237,8 +223,6 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { scoped_ptr<base::Thread> audio_thread_; scoped_refptr<base::MessageLoopProxy> audio_message_loop_; - scoped_ptr<base::Thread> worker_thread_; - scoped_refptr<base::MessageLoopProxy> worker_message_loop_; VirtualAudioInputStream* stream_; MockInputCallback input_callback_; @@ -256,13 +240,13 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { FROM_HERE, base::Bind(&VirtualAudioInputStreamTest::method, \ base::Unretained(this))) -TEST_P(VirtualAudioInputStreamTest, CreateAndClose) { +TEST_F(VirtualAudioInputStreamTest, CreateAndClose) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Close); WaitUntilClosed(); } -TEST_P(VirtualAudioInputStreamTest, NoOutputs) { +TEST_F(VirtualAudioInputStreamTest, NoOutputs) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Start); WaitForDataToFlow(); @@ -271,7 +255,7 @@ TEST_P(VirtualAudioInputStreamTest, NoOutputs) { WaitUntilClosed(); } -TEST_P(VirtualAudioInputStreamTest, SingleOutput) { +TEST_F(VirtualAudioInputStreamTest, SingleOutput) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Start); RUN_ON_AUDIO_THREAD(CreateAndStartOneOutputStream); @@ -282,7 +266,7 @@ TEST_P(VirtualAudioInputStreamTest, SingleOutput) { WaitUntilClosed(); } -TEST_P(VirtualAudioInputStreamTest, SingleOutputPausedAndRestarted) { +TEST_F(VirtualAudioInputStreamTest, SingleOutputPausedAndRestarted) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Start); RUN_ON_AUDIO_THREAD(CreateAndStartOneOutputStream); @@ -296,7 +280,7 @@ TEST_P(VirtualAudioInputStreamTest, SingleOutputPausedAndRestarted) { WaitUntilClosed(); } -TEST_P(VirtualAudioInputStreamTest, MultipleOutputs) { +TEST_F(VirtualAudioInputStreamTest, MultipleOutputs) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Start); RUN_ON_AUDIO_THREAD(CreateAndStartOneOutputStream); @@ -319,7 +303,7 @@ TEST_P(VirtualAudioInputStreamTest, MultipleOutputs) { } // A combination of all of the above tests with many output streams. -TEST_P(VirtualAudioInputStreamTest, ComprehensiveTest) { +TEST_F(VirtualAudioInputStreamTest, ComprehensiveTest) { static const int kNumOutputs = 8; static const int kHalfNumOutputs = kNumOutputs / 2; static const int kPauseIterations = 5; @@ -351,8 +335,4 @@ TEST_P(VirtualAudioInputStreamTest, ComprehensiveTest) { WaitUntilClosed(); } -INSTANTIATE_TEST_CASE_P(SingleVersusMultithreaded, - VirtualAudioInputStreamTest, - ::testing::Values(false, true)); - } // namespace media |