OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // A simple MediaStreamAudioSource that spawns a real-time audio thread and | 32 // A simple MediaStreamAudioSource that spawns a real-time audio thread and |
33 // emits audio samples with monotonically-increasing sample values. Includes | 33 // emits audio samples with monotonically-increasing sample values. Includes |
34 // hooks for the unit tests to confirm lifecycle status and to change audio | 34 // hooks for the unit tests to confirm lifecycle status and to change audio |
35 // format. | 35 // format. |
36 class FakeMediaStreamAudioSource | 36 class FakeMediaStreamAudioSource |
37 : public MediaStreamAudioSource, | 37 : public MediaStreamAudioSource, |
38 public base::PlatformThread::Delegate { | 38 public base::PlatformThread::Delegate { |
39 public: | 39 public: |
40 FakeMediaStreamAudioSource() | 40 FakeMediaStreamAudioSource() |
41 : MediaStreamAudioSource(true), stop_event_(true, false), | 41 : MediaStreamAudioSource(true), |
42 next_buffer_size_(kBufferSize), sample_count_(0) {} | 42 stop_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 43 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 44 next_buffer_size_(kBufferSize), |
| 45 sample_count_(0) {} |
43 | 46 |
44 ~FakeMediaStreamAudioSource() final { | 47 ~FakeMediaStreamAudioSource() final { |
45 CHECK(main_thread_checker_.CalledOnValidThread()); | 48 CHECK(main_thread_checker_.CalledOnValidThread()); |
46 EnsureSourceIsStopped(); | 49 EnsureSourceIsStopped(); |
47 } | 50 } |
48 | 51 |
49 bool was_started() const { | 52 bool was_started() const { |
50 CHECK(main_thread_checker_.CalledOnValidThread()); | 53 CHECK(main_thread_checker_.CalledOnValidThread()); |
51 return !thread_.is_null(); | 54 return !thread_.is_null(); |
52 } | 55 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // enabled state of the second track and sink. They should still be disabled, | 444 // enabled state of the second track and sink. They should still be disabled, |
442 // with silent audio being consumed at the sink. | 445 // with silent audio being consumed at the sink. |
443 EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, sink.enable_state()); | 446 EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, sink.enable_state()); |
444 EXPECT_TRUE(sink.is_audio_silent()); | 447 EXPECT_TRUE(sink.is_audio_silent()); |
445 | 448 |
446 MediaStreamAudioTrack::From(another_blink_track)->RemoveSink(&another_sink); | 449 MediaStreamAudioTrack::From(another_blink_track)->RemoveSink(&another_sink); |
447 track()->RemoveSink(&sink); | 450 track()->RemoveSink(&sink); |
448 } | 451 } |
449 | 452 |
450 } // namespace content | 453 } // namespace content |
OLD | NEW |