summaryrefslogtreecommitdiff
path: root/chromium/media/audio/mac/aggregate_device_manager.h
blob: 7b8b71ff655bea76dc93d779460447c58fd23682 (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
57
58
// Copyright 2013 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_MAC_AGGREGATE_DEVICE_MANAGER_H_
#define MEDIA_AUDIO_MAC_AGGREGATE_DEVICE_MANAGER_H_

#include <CoreAudio/CoreAudio.h>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "media/base/media_export.h"

namespace media {

class MEDIA_EXPORT AggregateDeviceManager {
 public:
  AggregateDeviceManager();
  ~AggregateDeviceManager();

  // Lazily creates an aggregate device based on the default
  // input and output devices.
  // It will either return a valid device or kAudioDeviceUnknown
  // if the default devices are not suitable for aggregate devices.
  AudioDeviceID GetDefaultAggregateDevice();

 private:
  // The caller is responsible for releasing the CFStringRef.
  static CFStringRef GetDeviceUID(AudioDeviceID id);

  static void GetDeviceName(AudioDeviceID id, char* name, UInt32 size);
  static UInt32 GetClockDomain(AudioDeviceID device_id);
  static OSStatus GetPluginID(AudioObjectID* id);

  CFMutableDictionaryRef CreateAggregateDeviceDictionary(
      AudioDeviceID input_id,
      AudioDeviceID output_id);

  CFMutableArrayRef CreateSubDeviceArray(CFStringRef input_device_UID,
                                         CFStringRef output_device_UID);

  OSStatus CreateAggregateDevice(AudioDeviceID input_id,
                                 AudioDeviceID output_id,
                                 AudioDeviceID* aggregate_device);
  void DestroyAggregateDevice();

  AudioObjectID plugin_id_;
  AudioDeviceID input_device_;
  AudioDeviceID output_device_;

  AudioDeviceID aggregate_device_;

  DISALLOW_COPY_AND_ASSIGN(AggregateDeviceManager);
};

}  // namespace media

#endif  // MEDIA_AUDIO_MAC_AGGREGATE_DEVICE_MANAGER_H_