| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ | 5 #ifndef MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ |
| 6 #define MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ | 6 #define MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ |
| 7 | 7 |
| 8 #include <AudioToolbox/AudioFormat.h> | 8 #include <AudioToolbox/AudioFormat.h> |
| 9 #include <AudioToolbox/AudioQueue.h> | 9 #include <AudioToolbox/AudioQueue.h> |
| 10 #include <AudioUnit/AudioUnit.h> | 10 #include <AudioUnit/AudioUnit.h> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" |
| 12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 13 #include "media/audio/audio_io.h" | 14 #include "media/audio/audio_io.h" |
| 14 #include "media/audio/audio_parameters.h" | 15 #include "media/audio/audio_parameters.h" |
| 15 | 16 |
| 16 class AudioManagerMac; | 17 class AudioManagerMac; |
| 17 | 18 |
| 18 // Implementation of AudioOuputStream for Mac OS X using the audio queue service | 19 // Implementation of AudioOuputStream for Mac OS X using the audio queue service |
| 19 // present in OS 10.5 and later. Audioqueue is the successor to the SoundManager | 20 // present in OS 10.5 and later. Audioqueue is the successor to the SoundManager |
| 20 // services but it is supported in 64 bits. | 21 // services but it is supported in 64 bits. |
| 21 class PCMQueueOutAudioOutputStream : public AudioOutputStream { | 22 class PCMQueueOutAudioOutputStream : public AudioOutputStream { |
| 22 public: | 23 public: |
| 23 // The ctor takes all the usual parameters, plus |manager| which is the | 24 // The ctor takes all the usual parameters, plus |manager| which is the |
| 24 // the audio manager who is creating this object. | 25 // the audio manager who is creating this object. |
| 25 PCMQueueOutAudioOutputStream(AudioManagerMac* manager, | 26 PCMQueueOutAudioOutputStream(AudioManagerMac* manager, |
| 26 const AudioParameters& params); | 27 const AudioParameters& params); |
| 27 // The dtor is typically called by the AudioManager only and it is usually | 28 // The dtor is typically called by the AudioManager only and it is usually |
| 28 // triggered by calling AudioOutputStream::Close(). | 29 // triggered by calling AudioOutputStream::Close(). |
| 29 virtual ~PCMQueueOutAudioOutputStream(); | 30 virtual ~PCMQueueOutAudioOutputStream(); |
| 30 | 31 |
| 31 // Implementation of AudioOutputStream. | 32 // Implementation of AudioOutputStream. |
| 32 virtual bool Open(); | 33 virtual bool Open() OVERRIDE; |
| 33 virtual void Close(); | 34 virtual void Close() OVERRIDE; |
| 34 virtual void Start(AudioSourceCallback* callback); | 35 virtual void Start(AudioSourceCallback* callback) OVERRIDE; |
| 35 virtual void Stop(); | 36 virtual void Stop() OVERRIDE; |
| 36 virtual void SetVolume(double volume); | 37 virtual void SetVolume(double volume) OVERRIDE; |
| 37 virtual void GetVolume(double* volume); | 38 virtual void GetVolume(double* volume) OVERRIDE; |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 // The audio is double buffered. | 41 // The audio is double buffered. |
| 41 static const uint32 kNumBuffers = 2; | 42 static const uint32 kNumBuffers = 2; |
| 42 static const int kEmptyChannel = -1; | 43 static const int kEmptyChannel = -1; |
| 43 | 44 |
| 44 // Reorder PCM from source layout to device layout found in Core Audio. | 45 // Reorder PCM from source layout to device layout found in Core Audio. |
| 45 template<class Format> | 46 template<class Format> |
| 46 void SwizzleLayout(Format* b, uint32 filled); | 47 void SwizzleLayout(Format* b, uint32 filled); |
| 47 // Check and move channels if surround sound layout needs adjusted. | 48 // Check and move channels if surround sound layout needs adjusted. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 int num_core_channels_; | 91 int num_core_channels_; |
| 91 // A flag to determine if swizzle is needed from source to device layouts. | 92 // A flag to determine if swizzle is needed from source to device layouts. |
| 92 bool should_swizzle_; | 93 bool should_swizzle_; |
| 93 // A flag to determine if downmix is needed from source to device layouts. | 94 // A flag to determine if downmix is needed from source to device layouts. |
| 94 bool should_down_mix_; | 95 bool should_down_mix_; |
| 95 | 96 |
| 96 DISALLOW_COPY_AND_ASSIGN(PCMQueueOutAudioOutputStream); | 97 DISALLOW_COPY_AND_ASSIGN(PCMQueueOutAudioOutputStream); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 #endif // MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ | 100 #endif // MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ |
| OLD | NEW |