2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
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.
11 #ifndef WEBRTC_SOUND_ALSASOUNDSYSTEM_H_
12 #define WEBRTC_SOUND_ALSASOUNDSYSTEM_H_
14 #include "webrtc/sound/alsasymboltable.h"
15 #include "webrtc/sound/soundsysteminterface.h"
16 #include "webrtc/base/constructormagic.h"
21 class AlsaInputStream;
22 class AlsaOutputStream;
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;
31 static SoundSystemInterface *Create() {
32 return new AlsaSoundSystem();
37 virtual ~AlsaSoundSystem();
40 virtual void Terminate();
42 virtual bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices);
43 virtual bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices);
45 virtual bool GetDefaultPlaybackDevice(SoundDeviceLocator **device);
46 virtual bool GetDefaultCaptureDevice(SoundDeviceLocator **device);
48 virtual SoundOutputStreamInterface *OpenPlaybackDevice(
49 const SoundDeviceLocator *device,
50 const OpenParams ¶ms);
51 virtual SoundInputStreamInterface *OpenCaptureDevice(
52 const SoundDeviceLocator *device,
53 const OpenParams ¶ms);
55 virtual const char *GetName() const;
58 bool IsInitialized() { return initialized_; }
60 bool EnumerateDevices(SoundDeviceLocatorList *devices,
61 bool capture_not_playback);
63 bool GetDefaultDevice(SoundDeviceLocator **device);
65 static size_t FrameSize(const OpenParams ¶ms);
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)(
79 SoundOutputStreamInterface *StartOutputStream(
86 SoundInputStreamInterface *StartInputStream(
93 const char *GetError(int err);
96 AlsaSymbolTable symbol_table_;
98 DISALLOW_COPY_AND_ASSIGN(AlsaSoundSystem);
103 #endif // WEBRTC_SOUND_ALSASOUNDSYSTEM_H_