OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/sound/nullsoundsystem.h" | |
12 | |
13 #include "webrtc/sound/sounddevicelocator.h" | |
14 #include "webrtc/sound/soundinputstreaminterface.h" | |
15 #include "webrtc/sound/soundoutputstreaminterface.h" | |
16 #include "webrtc/base/logging.h" | |
17 | |
18 namespace rtc { | |
19 class Thread; | |
20 } | |
21 | |
22 namespace rtc { | |
23 | |
24 // Name used for the single device and the sound system itself. | |
25 static const char kNullName[] = "null"; | |
26 | |
27 class NullSoundDeviceLocator : public SoundDeviceLocator { | |
28 public: | |
29 NullSoundDeviceLocator() : SoundDeviceLocator(kNullName, kNullName) {} | |
30 | |
31 SoundDeviceLocator *Copy() const override { | |
32 return new NullSoundDeviceLocator(); | |
33 } | |
34 }; | |
35 | |
36 class NullSoundInputStream : public SoundInputStreamInterface { | |
37 public: | |
38 bool StartReading() override { | |
39 return true; | |
40 } | |
41 | |
42 bool StopReading() override { | |
43 return true; | |
44 } | |
45 | |
46 bool GetVolume(int *volume) override { | |
47 *volume = SoundSystemInterface::kMinVolume; | |
48 return true; | |
49 } | |
50 | |
51 bool SetVolume(int volume) override { | |
52 return false; | |
53 } | |
54 | |
55 bool Close() override { | |
56 return true; | |
57 } | |
58 | |
59 int LatencyUsecs() override { | |
60 return 0; | |
61 } | |
62 }; | |
63 | |
64 class NullSoundOutputStream : public SoundOutputStreamInterface { | |
65 public: | |
66 bool EnableBufferMonitoring() override { | |
67 return true; | |
68 } | |
69 | |
70 bool DisableBufferMonitoring() override { | |
71 return true; | |
72 } | |
73 | |
74 bool WriteSamples(const void *sample_data, size_t size) override { | |
75 LOG(LS_VERBOSE) << "Got " << size << " bytes of playback samples"; | |
76 return true; | |
77 } | |
78 | |
79 bool GetVolume(int *volume) override { | |
80 *volume = SoundSystemInterface::kMinVolume; | |
81 return true; | |
82 } | |
83 | |
84 bool SetVolume(int volume) override { | |
85 return false; | |
86 } | |
87 | |
88 bool Close() override { | |
89 return true; | |
90 } | |
91 | |
92 int LatencyUsecs() override { | |
93 return 0; | |
94 } | |
95 }; | |
96 | |
97 NullSoundSystem::~NullSoundSystem() { | |
98 } | |
99 | |
100 bool NullSoundSystem::Init() { | |
101 return true; | |
102 } | |
103 | |
104 void NullSoundSystem::Terminate() { | |
105 // Nothing to do. | |
106 } | |
107 | |
108 bool NullSoundSystem::EnumeratePlaybackDevices( | |
109 SoundSystemInterface::SoundDeviceLocatorList *devices) { | |
110 ClearSoundDeviceLocatorList(devices); | |
111 SoundDeviceLocator *device; | |
112 GetDefaultPlaybackDevice(&device); | |
113 devices->push_back(device); | |
114 return true; | |
115 } | |
116 | |
117 bool NullSoundSystem::EnumerateCaptureDevices( | |
118 SoundSystemInterface::SoundDeviceLocatorList *devices) { | |
119 ClearSoundDeviceLocatorList(devices); | |
120 SoundDeviceLocator *device; | |
121 GetDefaultCaptureDevice(&device); | |
122 devices->push_back(device); | |
123 return true; | |
124 } | |
125 | |
126 bool NullSoundSystem::GetDefaultPlaybackDevice( | |
127 SoundDeviceLocator **device) { | |
128 *device = new NullSoundDeviceLocator(); | |
129 return true; | |
130 } | |
131 | |
132 bool NullSoundSystem::GetDefaultCaptureDevice( | |
133 SoundDeviceLocator **device) { | |
134 *device = new NullSoundDeviceLocator(); | |
135 return true; | |
136 } | |
137 | |
138 SoundOutputStreamInterface *NullSoundSystem::OpenPlaybackDevice( | |
139 const SoundDeviceLocator *device, | |
140 const OpenParams ¶ms) { | |
141 return new NullSoundOutputStream(); | |
142 } | |
143 | |
144 SoundInputStreamInterface *NullSoundSystem::OpenCaptureDevice( | |
145 const SoundDeviceLocator *device, | |
146 const OpenParams ¶ms) { | |
147 return new NullSoundInputStream(); | |
148 } | |
149 | |
150 const char *NullSoundSystem::GetName() const { | |
151 return kNullName; | |
152 } | |
153 | |
154 } // namespace rtc | |
OLD | NEW |