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

Unified Diff: media/audio/mac/audio_unified_mac.h

Issue 10916105: Add Mac OS X unified audio I/O back-end (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/audio/mac/audio_unified_mac.cc » ('j') | media/audio/mac/audio_unified_mac.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « no previous file | media/audio/mac/audio_unified_mac.cc » ('j') | media/audio/mac/audio_unified_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698