Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: media/audio/mac/scoped_audio_unit.h

Issue 2771093002: Use AudioUnit instead of AudioDevice properties to get channel count. (Closed)
Patch Set: Revert deletion of GetDeviceTotalChannelCount. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/mac/audio_manager_mac.cc ('k') | media/audio/mac/scoped_audio_unit.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_AUDIO_MAC_SCOPED_AUDIO_UNIT_H_
6 #define MEDIA_AUDIO_MAC_SCOPED_AUDIO_UNIT_H_
7
8 #include <AudioUnit/AudioUnit.h>
9 #include <CoreAudio/CoreAudio.h>
10
11 #include "base/macros.h"
12
13 namespace media {
14
15 // For whatever reason Apple doesn't have constants defined for these; per the
16 // documentation, we use bus 0 for output and bus 1 for input:
17 // http://developer.apple.com/library/mac/#technotes/tn2091/_index.html
18 enum AUElement : AudioUnitElement { OUTPUT = 0, INPUT = 1 };
19
20 // A helper class that ensures AudioUnits are properly disposed of.
21 class ScopedAudioUnit {
22 public:
23 // Creates a new AudioUnit and sets its device for |element| to |device|. If
24 // the operation fails, is_valid() will return false and audio_unit() will
25 // return nullptr.
26 ScopedAudioUnit(AudioDeviceID device, AUElement element);
27 ~ScopedAudioUnit();
28
29 bool is_valid() const { return audio_unit_ != nullptr; }
30 AudioUnit audio_unit() const { return audio_unit_; }
31
32 private:
33 AudioUnit audio_unit_ = nullptr;
34
35 DISALLOW_COPY_AND_ASSIGN(ScopedAudioUnit);
36 };
37
38 } // namespace media
39
40 #endif // MEDIA_AUDIO_MAC_SCOPED_AUDIO_UNIT_H_
OLDNEW
« no previous file with comments | « media/audio/mac/audio_manager_mac.cc ('k') | media/audio/mac/scoped_audio_unit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698