| OLD | NEW | 
|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "platform/audio/PushPullFIFO.h" | 5 #include "platform/audio/PushPullFIFO.h" | 
| 6 | 6 | 
| 7 #include <memory> | 7 #include <memory> | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 #include "platform/CrossThreadFunctional.h" | 9 #include "platform/CrossThreadFunctional.h" | 
| 10 #include "platform/WaitableEvent.h" | 10 #include "platform/WaitableEvent.h" | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 55 | 55 | 
| 56  private: | 56  private: | 
| 57   void RunTaskOnOwnThread() { | 57   void RunTaskOnOwnThread() { | 
| 58     double interval_with_jitter = interval_ms_ | 58     double interval_with_jitter = interval_ms_ | 
| 59         + (static_cast<double>(std::rand()) / RAND_MAX) * jitter_range_ms_; | 59         + (static_cast<double>(std::rand()) / RAND_MAX) * jitter_range_ms_; | 
| 60     elapsed_ms_ += interval_with_jitter; | 60     elapsed_ms_ += interval_with_jitter; | 
| 61     ++counter_; | 61     ++counter_; | 
| 62     RunTask(); | 62     RunTask(); | 
| 63     if (elapsed_ms_ < duration_ms_) { | 63     if (elapsed_ms_ < duration_ms_) { | 
| 64       client_thread_->GetWebTaskRunner()->PostDelayedTask( | 64       client_thread_->GetWebTaskRunner()->PostDelayedTask( | 
| 65               BLINK_FROM_HERE, | 65           BLINK_FROM_HERE, | 
| 66               CrossThreadBind(&FIFOClient::RunTaskOnOwnThread, | 66           CrossThreadBind(&FIFOClient::RunTaskOnOwnThread, | 
| 67                               CrossThreadUnretained(this)), | 67                           CrossThreadUnretained(this)), | 
| 68               interval_with_jitter); | 68           TimeDelta::FromMillisecondsD(interval_with_jitter)); | 
| 69     } else { | 69     } else { | 
| 70       Stop(counter_); | 70       Stop(counter_); | 
| 71       done_event_->Signal(); | 71       done_event_->Signal(); | 
| 72     } | 72     } | 
| 73   } | 73   } | 
| 74 | 74 | 
| 75   PushPullFIFO* fifo_; | 75   PushPullFIFO* fifo_; | 
| 76   RefPtr<AudioBus> bus_; | 76   RefPtr<AudioBus> bus_; | 
| 77   std::unique_ptr<WebThread> client_thread_; | 77   std::unique_ptr<WebThread> client_thread_; | 
| 78   std::unique_ptr<WaitableEvent> done_event_; | 78   std::unique_ptr<WaitableEvent> done_event_; | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 214   {48000, 2, 8192, 10000, 256, 0, 128, 1} | 214   {48000, 2, 8192, 10000, 256, 0, 128, 1} | 
| 215 }; | 215 }; | 
| 216 | 216 | 
| 217 INSTANTIATE_TEST_CASE_P(PushPullFIFOSmokeTest, | 217 INSTANTIATE_TEST_CASE_P(PushPullFIFOSmokeTest, | 
| 218                         PushPullFIFOSmokeTest, | 218                         PushPullFIFOSmokeTest, | 
| 219                         ::testing::ValuesIn(smoke_test_params)); | 219                         ::testing::ValuesIn(smoke_test_params)); | 
| 220 | 220 | 
| 221 }  // namespace | 221 }  // namespace | 
| 222 | 222 | 
| 223 }  // namespace blink | 223 }  // namespace blink | 
| OLD | NEW | 
|---|