| Index: media/audio/mac/audio_low_latency_input_mac.h
|
| diff --git a/media/audio/mac/audio_low_latency_input_mac.h b/media/audio/mac/audio_low_latency_input_mac.h
|
| index 6d2d8f5e5830fa4ac344a4807df6750de8959ae3..c66c8143f39aa4365121f04d52f79a65de8e352c 100644
|
| --- a/media/audio/mac/audio_low_latency_input_mac.h
|
| +++ b/media/audio/mac/audio_low_latency_input_mac.h
|
| @@ -38,14 +38,12 @@
|
|
|
| #include <AudioUnit/AudioUnit.h>
|
| #include <CoreAudio/CoreAudio.h>
|
| -#include <stddef.h>
|
| -#include <stdint.h>
|
| +#include <map>
|
|
|
| #include "base/atomicops.h"
|
| #include "base/cancelable_callback.h"
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "base/synchronization/lock.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "base/time/time.h"
|
| #include "base/timer/timer.h"
|
| @@ -94,6 +92,8 @@ class MEDIA_EXPORT AUAudioInputStream
|
| size_t requested_buffer_size() const { return number_of_frames_; }
|
|
|
| private:
|
| + static const AudioObjectPropertyAddress kDeviceChangePropertyAddress;
|
| +
|
| // Callback functions called on a real-time priority I/O thread from the audio
|
| // unit. These methods are called when recorded audio is available.
|
| static OSStatus DataIsAvailable(void* context,
|
| @@ -111,6 +111,23 @@ class MEDIA_EXPORT AUAudioInputStream
|
| OSStatus Provide(UInt32 number_of_frames, AudioBufferList* io_data,
|
| const AudioTimeStamp* time_stamp);
|
|
|
| + // Callback functions called on different system threads from the Core Audio
|
| + // framework. These methods are called when device properties are changed.
|
| + static OSStatus OnDevicePropertyChanged(
|
| + AudioObjectID object_id,
|
| + UInt32 num_addresses,
|
| + const AudioObjectPropertyAddress addresses[],
|
| + void* context);
|
| + OSStatus DevicePropertyChanged(AudioObjectID object_id,
|
| + UInt32 num_addresses,
|
| + const AudioObjectPropertyAddress addresses[]);
|
| +
|
| + // Registers OnDevicePropertyChanged() to receive notifications when device
|
| + // properties changes.
|
| + void RegisterDeviceChangeListener();
|
| + // Stop listening for changes in device properties.
|
| + void DeRegisterDeviceChangeListener();
|
| +
|
| // Gets the fixed capture hardware latency and store it during initialization.
|
| // Returns 0 if not available.
|
| double GetHardwareLatency();
|
| @@ -143,6 +160,10 @@ class MEDIA_EXPORT AUAudioInputStream
|
| // Adds extra UMA stats when it has been detected that startup failed.
|
| void AddHistogramsForFailedStartup();
|
|
|
| + // Scans the map of all available property changes (notification types) and
|
| + // filters out some that make sense to add to UMA stats.
|
| + void AddDevicePropertyChangesToUMA(bool startup_failed);
|
| +
|
| // Verifies that Open(), Start(), Stop() and Close() are all called on the
|
| // creating thread which is the main browser thread (CrBrowserMain) on Mac.
|
| base::ThreadChecker thread_checker_;
|
| @@ -218,6 +239,21 @@ class MEDIA_EXPORT AUAudioInputStream
|
| // Set to true once when AudioUnitRender() succeeds for the first time.
|
| bool audio_unit_render_has_worked_;
|
|
|
| + // Maps unique representations of device property notification types and
|
| + // number of times we have been notified about a change in such a type.
|
| + // While the notifier is active, this member is modified by several different
|
| + // internal thread. My guess is that a serial dispatch queue is used under
|
| + // the hood and it executes one task at a time in the order in which they are
|
| + // added to the queue. The currently executing task runs on a distinct thread
|
| + // (which can vary from task to task) that is managed by the dispatch queue.
|
| + // The map is always read on the creating thread but only while the notifier
|
| + // is disabled, hence no lock is required.
|
| + std::map<UInt32, int> device_property_changes_map_;
|
| +
|
| + // Set to true when we are listening for changes in device properties.
|
| + // Only touched on the creating thread.
|
| + bool device_listener_is_active_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream);
|
| };
|
|
|
|
|