| OLD | NEW |
| (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_ |
| OLD | NEW |