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 3 // found in the LICENSE file. 4 5 #ifndef MEDIA_AUDIO_TEST_AUDIO_THREAD_H_ 6 #define MEDIA_AUDIO_TEST_AUDIO_THREAD_H_ 7 8 #include <memory> 9 10 #include "base/memory/ref_counted.h" 11 #include "base/threading/thread.h" 12 #include "base/threading/thread_checker.h" 13 #include "media/audio/audio_thread.h" 14 15 namespace media { 16 17 class TestAudioThread final : public AudioThread { 18 public: 19 TestAudioThread(); 20 explicit TestAudioThread(bool use_real_thread); 21 ~TestAudioThread() final; 22 23 // AudioThread implementation. 24 void Stop() final; 25 bool IsHung() const final; 26 base::SingleThreadTaskRunner* GetTaskRunner() final; 27 base::SingleThreadTaskRunner* GetWorkerTaskRunner() final; 28 29 private: 30 std::unique_ptr<base::Thread> thread_; 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 32 33 THREAD_CHECKER(thread_checker_); 34 DISALLOW_COPY_AND_ASSIGN(TestAudioThread); 35 }; 36 37 } // namespace media 38 39 #endif // MEDIA_AUDIO_TEST_AUDIO_THREAD_H_ 40