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 #ifndef WEBRTC_SOUND_ALSASOUNDSYSTEM_H_ | |
12 #define WEBRTC_SOUND_ALSASOUNDSYSTEM_H_ | |
13 | |
14 #include "webrtc/sound/alsasymboltable.h" | |
15 #include "webrtc/sound/soundsysteminterface.h" | |
16 #include "webrtc/base/constructormagic.h" | |
17 | |
18 namespace rtc { | |
19 | |
20 class AlsaStream; | |
21 class AlsaInputStream; | |
22 class AlsaOutputStream; | |
23 | |
24 // Sound system implementation for ALSA, the predominant sound device API on | |
25 // Linux (but typically not used directly by applications anymore). | |
26 class AlsaSoundSystem : public SoundSystemInterface { | |
27 friend class AlsaStream; | |
28 friend class AlsaInputStream; | |
29 friend class AlsaOutputStream; | |
30 public: | |
31 static SoundSystemInterface *Create() { | |
32 return new AlsaSoundSystem(); | |
33 } | |
34 | |
35 AlsaSoundSystem(); | |
36 | |
37 ~AlsaSoundSystem() override; | |
38 | |
39 bool Init() override; | |
40 void Terminate() override; | |
41 | |
42 bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices) override; | |
43 bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices) override; | |
44 | |
45 bool GetDefaultPlaybackDevice(SoundDeviceLocator **device) override; | |
46 bool GetDefaultCaptureDevice(SoundDeviceLocator **device) override; | |
47 | |
48 SoundOutputStreamInterface *OpenPlaybackDevice( | |
49 const SoundDeviceLocator *device, | |
50 const OpenParams ¶ms) override; | |
51 SoundInputStreamInterface *OpenCaptureDevice( | |
52 const SoundDeviceLocator *device, | |
53 const OpenParams ¶ms) override; | |
54 | |
55 const char *GetName() const override; | |
56 | |
57 private: | |
58 bool IsInitialized() { return initialized_; } | |
59 | |
60 bool EnumerateDevices(SoundDeviceLocatorList *devices, | |
61 bool capture_not_playback); | |
62 | |
63 bool GetDefaultDevice(SoundDeviceLocator **device); | |
64 | |
65 static size_t FrameSize(const OpenParams ¶ms); | |
66 | |
67 template <typename StreamInterface> | |
68 StreamInterface *OpenDevice( | |
69 const SoundDeviceLocator *device, | |
70 const OpenParams ¶ms, | |
71 snd_pcm_stream_t type, | |
72 StreamInterface *(AlsaSoundSystem::*start_fn)( | |
73 snd_pcm_t *handle, | |
74 size_t frame_size, | |
75 int wait_timeout_ms, | |
76 int flags, | |
77 int freq)); | |
78 | |
79 SoundOutputStreamInterface *StartOutputStream( | |
80 snd_pcm_t *handle, | |
81 size_t frame_size, | |
82 int wait_timeout_ms, | |
83 int flags, | |
84 int freq); | |
85 | |
86 SoundInputStreamInterface *StartInputStream( | |
87 snd_pcm_t *handle, | |
88 size_t frame_size, | |
89 int wait_timeout_ms, | |
90 int flags, | |
91 int freq); | |
92 | |
93 const char *GetError(int err); | |
94 | |
95 bool initialized_; | |
96 AlsaSymbolTable symbol_table_; | |
97 | |
98 RTC_DISALLOW_COPY_AND_ASSIGN(AlsaSoundSystem); | |
99 }; | |
100 | |
101 } // namespace rtc | |
102 | |
103 #endif // WEBRTC_SOUND_ALSASOUNDSYSTEM_H_ | |
OLD | NEW |