summaryrefslogtreecommitdiffstats
path: root/media/audio/linux/audio_manager_linux.h
blob: 6a5d287f0df359072afa401c83f0f09d7ab4eb4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_
#define MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_

#include <map>

#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
#include "media/audio/audio_manager_base.h"

class AlsaPcmOutputStream;
class AlsaWrapper;

class AudioManagerLinux : public AudioManagerBase {
 public:
  AudioManagerLinux();

  // Call before using a newly created AudioManagerLinux instance.
  virtual void Init();

  // Implementation of AudioManager.
  virtual bool HasAudioOutputDevices();
  virtual bool HasAudioInputDevices();
  virtual AudioOutputStream* MakeAudioOutputStream(AudioParameters params);
  virtual AudioInputStream* MakeAudioInputStream(AudioParameters params);
  virtual bool CanShowAudioInputSettings();
  virtual void ShowAudioInputSettings();
  virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names);

  virtual void MuteAll();
  virtual void UnMuteAll();

  virtual void ReleaseOutputStream(AlsaPcmOutputStream* stream);

 protected:
  virtual ~AudioManagerLinux();

 private:
  // Helper method to query if there is any valid input device
  bool HasAnyValidAudioInputDevice(void** hint);

  scoped_ptr<AlsaWrapper> wrapper_;

  base::Lock lock_;
  std::map<AlsaPcmOutputStream*, scoped_refptr<AlsaPcmOutputStream> >
      active_streams_;

  DISALLOW_COPY_AND_ASSIGN(AudioManagerLinux);
};

#endif  // MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_