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

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

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from patch 48 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 has the following purposes: 14 // which avoids to use the actual (system and platform dependent) AudioManager.
15 // 1) Avoids to use the actual (system and platform dependent) AudioManager. 15 // Some bots does not have input devices, thus using the actual AudioManager
16 // Some bots does not have input devices, thus using the actual AudioManager 16 // would causing failures on classes which expect that.
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).
23 class MockAudioManager : public media::AudioManager { 17 class MockAudioManager : public media::AudioManager {
24 public: 18 public:
25 explicit MockAudioManager( 19 explicit MockAudioManager(
26 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 20 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
27 21
28 bool HasAudioOutputDevices() override; 22 bool HasAudioOutputDevices() override;
29 23
30 bool HasAudioInputDevices() override; 24 bool HasAudioInputDevices() override;
31 25
32 base::string16 GetAudioInputDeviceModel() override; 26 base::string16 GetAudioInputDeviceModel() override;
33 27
34 void ShowAudioInputSettings() override; 28 void ShowAudioInputSettings() override;
35 29
36 void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) override; 30 void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) override;
37 31
38 void GetAudioOutputDeviceNames( 32 void GetAudioOutputDeviceNames(
39 media::AudioDeviceNames* device_names) override; 33 media::AudioDeviceNames* device_names) override;
40 34
41 media::AudioOutputStream* MakeAudioOutputStream( 35 media::AudioOutputStream* MakeAudioOutputStream(
42 const media::AudioParameters& params, 36 const media::AudioParameters& params,
43 const std::string& device_id) override; 37 const std::string& device_id) override;
44 38
45 media::AudioOutputStream* MakeAudioOutputStreamProxy( 39 media::AudioOutputStream* MakeAudioOutputStreamProxy(
46 const media::AudioParameters& params, 40 const media::AudioParameters& params,
47 const std::string& device_id) override; 41 const std::string& device_id) override;
48 42
49 media::AudioInputStream* MakeAudioInputStream( 43 media::AudioInputStream* MakeAudioInputStream(
50 const media::AudioParameters& params, 44 const media::AudioParameters& params,
51 const std::string& device_id) override; 45 const std::string& device_id) override;
52 46
53 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override;
54 scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() override;
55
56 void AddOutputDeviceChangeListener(AudioDeviceListener* listener) override; 47 void AddOutputDeviceChangeListener(AudioDeviceListener* listener) override;
57 void RemoveOutputDeviceChangeListener(AudioDeviceListener* listener) override; 48 void RemoveOutputDeviceChangeListener(AudioDeviceListener* listener) override;
58 49
59 AudioParameters GetDefaultOutputStreamParameters() override; 50 AudioParameters GetDefaultOutputStreamParameters() override;
60 AudioParameters GetOutputStreamParameters( 51 AudioParameters GetOutputStreamParameters(
61 const std::string& device_id) override; 52 const std::string& device_id) override;
62 AudioParameters GetInputStreamParameters( 53 AudioParameters GetInputStreamParameters(
63 const std::string& device_id) override; 54 const std::string& device_id) override;
64 std::string GetAssociatedOutputDeviceID( 55 std::string GetAssociatedOutputDeviceID(
65 const std::string& input_device_id) override; 56 const std::string& input_device_id) override;
66 57
67 scoped_ptr<AudioLog> CreateAudioLog( 58 scoped_ptr<AudioLog> CreateAudioLog(
68 AudioLogFactory::AudioComponent component) override; 59 AudioLogFactory::AudioComponent component) override;
69 60
70 protected: 61 protected:
71 ~MockAudioManager() override; 62 ~MockAudioManager() override;
72 63
73 private: 64 private:
74 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
75
76 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); 65 DISALLOW_COPY_AND_ASSIGN(MockAudioManager);
77 }; 66 };
78 67
79 } // namespace media. 68 } // namespace media.
80 69
81 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 70 #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