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
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84

media / audio / cras / audio_manager_cras_base.h [blame]

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_AUDIO_CRAS_AUDIO_MANAGER_CRAS_BASE_H_
#define MEDIA_AUDIO_CRAS_AUDIO_MANAGER_CRAS_BASE_H_

#include <cras_types.h>

#include <memory>
#include <string>
#include <vector>

#include "base/compiler_specific.h"
#include "media/audio/audio_manager_base.h"

namespace media {

class MEDIA_EXPORT AudioManagerCrasBase : public AudioManagerBase {
 public:
  AudioManagerCrasBase(std::unique_ptr<AudioThread> audio_thread,
                       AudioLogFactory* audio_log_factory);

  AudioManagerCrasBase(const AudioManagerCrasBase&) = delete;
  AudioManagerCrasBase& operator=(const AudioManagerCrasBase&) = delete;

  ~AudioManagerCrasBase() override;

  // AudioManager implementation.
  const char* GetName() override;

  // AudioManagerBase implementation.
  AudioOutputStream* MakeLinearOutputStream(
      const AudioParameters& params,
      const LogCallback& log_callback) override;
  AudioOutputStream* MakeLowLatencyOutputStream(
      const AudioParameters& params,
      const std::string& device_id,
      const LogCallback& log_callback) override;
  AudioInputStream* MakeLinearInputStream(
      const AudioParameters& params,
      const std::string& device_id,
      const LogCallback& log_callback) override;
  AudioInputStream* MakeLowLatencyInputStream(
      const AudioParameters& params,
      const std::string& device_id,
      const LogCallback& log_callback) override;

  // Checks if |device_id| corresponds to the default device.
  // Set |is_input| to true for capture devices, false for output.
  virtual bool IsDefault(const std::string& device_id, bool is_input) = 0;

  // Returns CRAS client type.
  virtual enum CRAS_CLIENT_TYPE GetClientType() = 0;

  // Registers a CrasInputStream as the source of system AEC dump.
  virtual void RegisterSystemAecDumpSource(AecdumpRecordingSource* stream);

  // Unregisters system AEC dump. Virtual to mock in unittest.
  virtual void DeregisterSystemAecDumpSource(AecdumpRecordingSource* stream);

  virtual void SetAecDumpRecordingManager(
      base::WeakPtr<AecdumpRecordingManager> aecdump_recording_manager)
      override;

 protected:
  // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream.
  AudioOutputStream* MakeOutputStream(const AudioParameters& params,
                                      const std::string& device_id,
                                      const LogCallback& log_callback);

  // Called by MakeLinearInputStream and MakeLowLatencyInputStream.
  AudioInputStream* MakeInputStream(const AudioParameters& params,
                                    const std::string& device_id,
                                    const LogCallback& log_callback);

 private:
  // Manages starting / stopping of aecdump recording.
  base::WeakPtr<AecdumpRecordingManager> aecdump_recording_manager_;
};

}  // namespace media

#endif  // MEDIA_AUDIO_CRAS_AUDIO_MANAGER_CRAS_BASE_H_