Chromium Code Reviews| Index: media/audio/mac/audio_unified_mac.h | 
| =================================================================== | 
| --- media/audio/mac/audio_unified_mac.h (revision 0) | 
| +++ media/audio/mac/audio_unified_mac.h (revision 0) | 
| @@ -0,0 +1,102 @@ | 
| +// Copyright (c) 2012 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. | 
| +// | 
| +// Notes: | 
| +// 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.
 
 | 
| +// output device and then use the same rate when creating this object. | 
| +// | 
| + | 
| +#ifndef MEDIA_AUDIO_MAC_AUDIO_UNIFIED_MAC_H_ | 
| +#define MEDIA_AUDIO_MAC_AUDIO_UNIFIED_MAC_H_ | 
| + | 
| +#include <AudioUnit/AudioUnit.h> | 
| + | 
| +#include "base/memory/scoped_ptr.h" | 
| +#include "media/audio/audio_io.h" | 
| +#include "media/audio/audio_parameters.h" | 
| + | 
| +namespace media { | 
| + | 
| +class AudioManagerMac; | 
| + | 
| +// Implementation of AudioOuputStream for Mac OS X using the | 
| +// CoreAudio AudioHardware API suitable for low-latency synchronized audio I/O | 
| +// when using devices which support *both* input and output | 
| +// in the same driver. This is the case with professional | 
| +// USB and Firewire devices. | 
| +class AudioHardwareUnifiedStream : public AudioOutputStream { | 
| + public: | 
| + // The ctor takes all the usual parameters, plus |manager| which is the | 
| + // the audio manager who is creating this object. | 
| + AudioHardwareUnifiedStream(AudioManagerMac* manager, | 
| + const AudioParameters& params); | 
| + // The dtor is typically called by the AudioManager only and it is usually | 
| + // triggered by calling AudioOutputStream::Close(). | 
| + virtual ~AudioHardwareUnifiedStream(); | 
| + | 
| + // Implementation of AudioOutputStream. | 
| + virtual bool Open() OVERRIDE; | 
| + virtual void Close() OVERRIDE; | 
| + virtual void Start(AudioSourceCallback* callback) OVERRIDE; | 
| + virtual void Stop() OVERRIDE; | 
| + virtual void SetVolume(double volume) OVERRIDE; | 
| + virtual void GetVolume(double* volume) OVERRIDE; | 
| + | 
| + 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.
 
 | 
| + unsigned output_channels() const { return output_channels_; } | 
| + | 
| + private: | 
| + 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.
 
 | 
| + const AudioTimeStamp* inNow, | 
| + const AudioBufferList* inInputData, | 
| + const AudioTimeStamp* inInputTime, | 
| + AudioBufferList* outOutputData, | 
| + const AudioTimeStamp* inOutputTime); | 
| + | 
| + 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.
 
 | 
| + const AudioTimeStamp* inNow, | 
| + const AudioBufferList* inInputData, | 
| + const AudioTimeStamp* inInputTime, | 
| + AudioBufferList* outOutputData, | 
| + const AudioTimeStamp* inOutputTime, | 
| + void* user_data); | 
| + | 
| + // Our creator, the audio manager needs to be notified when we close. | 
| + AudioManagerMac* manager_; | 
| + | 
| + // Pointer to the object that will provide the audio samples. | 
| + AudioSourceCallback* source_; | 
| + | 
| + // Structure that holds the stream format details such as bitrate. | 
| + AudioStreamBasicDescription format_; | 
| + | 
| + // Hardware buffer size. | 
| + size_t number_of_frames_; | 
| + | 
| + // Number of audio channels provided to the client via OnMoreIOData(). | 
| + 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.
 
 | 
| + | 
| + // Volume level from 0 to 1. | 
| + float volume_; | 
| + | 
| + // Number of input and output channels queried from the hardware. | 
| + 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
 
 | 
| + unsigned output_channels_; | 
| + unsigned input_channels_per_frame_; | 
| + unsigned output_channels_per_frame_; | 
| + | 
| + AudioDeviceIOProcID io_proc_id_; | 
| + AudioDeviceID device_; | 
| + bool is_playing_; | 
| + | 
| + // Intermediate buffers used with call to OnMoreIOData(). | 
| + scoped_ptr<AudioBus> input_bus_; | 
| + scoped_ptr<AudioBus> output_bus_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(AudioHardwareUnifiedStream); | 
| +}; | 
| + | 
| +} // namespace media | 
| + | 
| +#endif // MEDIA_AUDIO_MAC_AUDIO_UNIFIED_MAC_H_ |