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

Side by Side Diff: media/audio/mock_audio_manager.h

Issue 1901583005: Revert of Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « media/audio/mac/audio_manager_mac.cc ('k') | media/audio/mock_audio_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 5 #ifndef MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_
6 #define MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 6 #define MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "media/audio/audio_manager.h" 9 #include "media/audio/audio_manager.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 // This class is a simple mock around AudioManager, used exclusively for tests, 13 // This class is a simple mock around AudioManager, used exclusively for tests,
14 // which avoids to use the actual (system and platform dependent) AudioManager. 14 // which has the following purposes:
15 // Some bots does not have input devices, thus using the actual AudioManager 15 // 1) Avoids to use the actual (system and platform dependent) AudioManager.
16 // would causing failures on classes which expect that. 16 // Some bots does not have input devices, thus using the actual AudioManager
17 // would causing failures on classes which expect that.
18 // 2) Allows the mock audio events to be dispatched on an arbitrary thread,
19 // rather than forcing them on the audio thread, easing their handling in
20 // browser tests (Note: sharing a thread can cause deadlocks on production
21 // classes if WaitableEvents or any other form of lock is used for
22 // synchronization purposes).
17 class MockAudioManager : public media::AudioManager { 23 class MockAudioManager : public media::AudioManager {
18 public: 24 public:
19 explicit MockAudioManager( 25 explicit MockAudioManager(
20 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 26 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
21 27
22 bool HasAudioOutputDevices() override; 28 bool HasAudioOutputDevices() override;
23 29
24 bool HasAudioInputDevices() override; 30 bool HasAudioInputDevices() override;
25 31
26 base::string16 GetAudioInputDeviceModel() override; 32 base::string16 GetAudioInputDeviceModel() override;
27 33
28 void ShowAudioInputSettings() override; 34 void ShowAudioInputSettings() override;
29 35
30 void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) override; 36 void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) override;
31 37
32 void GetAudioOutputDeviceNames( 38 void GetAudioOutputDeviceNames(
33 media::AudioDeviceNames* device_names) override; 39 media::AudioDeviceNames* device_names) override;
34 40
35 media::AudioOutputStream* MakeAudioOutputStream( 41 media::AudioOutputStream* MakeAudioOutputStream(
36 const media::AudioParameters& params, 42 const media::AudioParameters& params,
37 const std::string& device_id) override; 43 const std::string& device_id) override;
38 44
39 media::AudioOutputStream* MakeAudioOutputStreamProxy( 45 media::AudioOutputStream* MakeAudioOutputStreamProxy(
40 const media::AudioParameters& params, 46 const media::AudioParameters& params,
41 const std::string& device_id) override; 47 const std::string& device_id) override;
42 48
43 media::AudioInputStream* MakeAudioInputStream( 49 media::AudioInputStream* MakeAudioInputStream(
44 const media::AudioParameters& params, 50 const media::AudioParameters& params,
45 const std::string& device_id) override; 51 const std::string& device_id) override;
46 52
53 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override;
54 scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() override;
55
47 void AddOutputDeviceChangeListener(AudioDeviceListener* listener) override; 56 void AddOutputDeviceChangeListener(AudioDeviceListener* listener) override;
48 void RemoveOutputDeviceChangeListener(AudioDeviceListener* listener) override; 57 void RemoveOutputDeviceChangeListener(AudioDeviceListener* listener) override;
49 58
50 AudioParameters GetDefaultOutputStreamParameters() override; 59 AudioParameters GetDefaultOutputStreamParameters() override;
51 AudioParameters GetOutputStreamParameters( 60 AudioParameters GetOutputStreamParameters(
52 const std::string& device_id) override; 61 const std::string& device_id) override;
53 AudioParameters GetInputStreamParameters( 62 AudioParameters GetInputStreamParameters(
54 const std::string& device_id) override; 63 const std::string& device_id) override;
55 std::string GetAssociatedOutputDeviceID( 64 std::string GetAssociatedOutputDeviceID(
56 const std::string& input_device_id) override; 65 const std::string& input_device_id) override;
57 66
58 scoped_ptr<AudioLog> CreateAudioLog( 67 scoped_ptr<AudioLog> CreateAudioLog(
59 AudioLogFactory::AudioComponent component) override; 68 AudioLogFactory::AudioComponent component) override;
60 69
61 protected: 70 protected:
62 ~MockAudioManager() override; 71 ~MockAudioManager() override;
63 72
64 private: 73 private:
74 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
75
65 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); 76 DISALLOW_COPY_AND_ASSIGN(MockAudioManager);
66 }; 77 };
67 78
68 } // namespace media. 79 } // namespace media.
69 80
70 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 81 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_
OLDNEW
« no previous file with comments | « media/audio/mac/audio_manager_mac.cc ('k') | media/audio/mock_audio_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698