Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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 // Notes: | |
| 6 // It's required to first get the native sample-rate of the default | |
|
scherkus (not reviewing)
2012/09/10 11:26:19
can we merge this into the class docs?
Chris Rogers
2012/09/10 22:19:06
Done.
| |
| 7 // output device and then use the same rate when creating this object. | |
| 8 // | |
| 9 | |
| 10 #ifndef MEDIA_AUDIO_MAC_AUDIO_UNIFIED_MAC_H_ | |
| 11 #define MEDIA_AUDIO_MAC_AUDIO_UNIFIED_MAC_H_ | |
| 12 | |
| 13 #include <AudioUnit/AudioUnit.h> | |
| 14 | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "media/audio/audio_io.h" | |
| 17 #include "media/audio/audio_parameters.h" | |
| 18 | |
| 19 namespace media { | |
| 20 | |
| 21 class AudioManagerMac; | |
| 22 | |
| 23 // Implementation of AudioOuputStream for Mac OS X using the | |
| 24 // CoreAudio AudioHardware API suitable for low-latency synchronized audio I/O | |
| 25 // when using devices which support *both* input and output | |
| 26 // in the same driver. This is the case with professional | |
| 27 // USB and Firewire devices. | |
| 28 class AudioHardwareUnifiedStream : public AudioOutputStream { | |
| 29 public: | |
| 30 // The ctor takes all the usual parameters, plus |manager| which is the | |
| 31 // the audio manager who is creating this object. | |
| 32 AudioHardwareUnifiedStream(AudioManagerMac* manager, | |
| 33 const AudioParameters& params); | |
| 34 // The dtor is typically called by the AudioManager only and it is usually | |
| 35 // triggered by calling AudioOutputStream::Close(). | |
| 36 virtual ~AudioHardwareUnifiedStream(); | |
| 37 | |
| 38 // Implementation of AudioOutputStream. | |
| 39 virtual bool Open() OVERRIDE; | |
| 40 virtual void Close() OVERRIDE; | |
| 41 virtual void Start(AudioSourceCallback* callback) OVERRIDE; | |
| 42 virtual void Stop() OVERRIDE; | |
| 43 virtual void SetVolume(double volume) OVERRIDE; | |
| 44 virtual void GetVolume(double* volume) OVERRIDE; | |
| 45 | |
| 46 unsigned input_channels() const { return input_channels_; } | |
|
scherkus (not reviewing)
2012/09/10 11:26:19
s/unsigned/int/ here and everywhere else
Rest of
Chris Rogers
2012/09/10 22:19:06
Done.
| |
| 47 unsigned output_channels() const { return output_channels_; } | |
| 48 | |
| 49 private: | |
| 50 OSStatus Render(AudioDeviceID inDevice, | |
|
scherkus (not reviewing)
2012/09/10 11:26:19
unix_hacker style for all parmas
Chris Rogers
2012/09/10 22:19:06
Done.
| |
| 51 const AudioTimeStamp* inNow, | |
| 52 const AudioBufferList* inInputData, | |
| 53 const AudioTimeStamp* inInputTime, | |
| 54 AudioBufferList* outOutputData, | |
| 55 const AudioTimeStamp* inOutputTime); | |
| 56 | |
| 57 static OSStatus RenderProc(AudioDeviceID inDevice, | |
|
scherkus (not reviewing)
2012/09/10 11:26:19
unix_hacker style
Chris Rogers
2012/09/10 22:19:06
Done.
| |
| 58 const AudioTimeStamp* inNow, | |
| 59 const AudioBufferList* inInputData, | |
| 60 const AudioTimeStamp* inInputTime, | |
| 61 AudioBufferList* outOutputData, | |
| 62 const AudioTimeStamp* inOutputTime, | |
| 63 void* user_data); | |
| 64 | |
| 65 // Our creator, the audio manager needs to be notified when we close. | |
| 66 AudioManagerMac* manager_; | |
| 67 | |
| 68 // Pointer to the object that will provide the audio samples. | |
| 69 AudioSourceCallback* source_; | |
| 70 | |
| 71 // Structure that holds the stream format details such as bitrate. | |
| 72 AudioStreamBasicDescription format_; | |
| 73 | |
| 74 // Hardware buffer size. | |
| 75 size_t number_of_frames_; | |
| 76 | |
| 77 // Number of audio channels provided to the client via OnMoreIOData(). | |
| 78 unsigned client_input_channels_; | |
|
scherkus (not reviewing)
2012/09/10 11:26:19
s/unsigned/int/ here and below
Chris Rogers
2012/09/10 22:19:06
Done.
| |
| 79 | |
| 80 // Volume level from 0 to 1. | |
| 81 float volume_; | |
| 82 | |
| 83 // Number of input and output channels queried from the hardware. | |
| 84 unsigned input_channels_; | |
|
no longer working on chromium
2012/09/10 12:14:59
I know they are the same, but how about using unsi
Chris Rogers
2012/09/10 22:19:06
I switched to "int" according to Andrew's comments
| |
| 85 unsigned output_channels_; | |
| 86 unsigned input_channels_per_frame_; | |
| 87 unsigned output_channels_per_frame_; | |
| 88 | |
| 89 AudioDeviceIOProcID io_proc_id_; | |
| 90 AudioDeviceID device_; | |
| 91 bool is_playing_; | |
| 92 | |
| 93 // Intermediate buffers used with call to OnMoreIOData(). | |
| 94 scoped_ptr<AudioBus> input_bus_; | |
| 95 scoped_ptr<AudioBus> output_bus_; | |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(AudioHardwareUnifiedStream); | |
| 98 }; | |
| 99 | |
| 100 } // namespace media | |
| 101 | |
| 102 #endif // MEDIA_AUDIO_MAC_AUDIO_UNIFIED_MAC_H_ | |
| OLD | NEW |