| 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..7861186224870d05516c23dc5f487baca1e802a5 100644
|
| --- a/media/audio/mac/audio_low_latency_input_mac.h
|
| +++ b/media/audio/mac/audio_low_latency_input_mac.h
|
| @@ -38,6 +38,7 @@
|
|
|
| #include <AudioUnit/AudioUnit.h>
|
| #include <CoreAudio/CoreAudio.h>
|
| +#include <map>
|
| #include <stddef.h>
|
| #include <stdint.h>
|
|
|
| @@ -94,6 +95,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 +114,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();
|
| @@ -132,6 +152,10 @@ class MEDIA_EXPORT AUAudioInputStream
|
| void SetInputCallbackIsActive(bool active);
|
| bool GetInputCallbackIsActive();
|
|
|
| + // Helper methods to set and get atomic |device_listener_is_active_|.
|
| + void SetDeviceListenerIsActive(bool active);
|
| + bool GetDeviceListenerIsActive();
|
| +
|
| // Checks if a stream was started successfully and the audio unit also starts
|
| // to call InputProc() as it should. This method is called once when a timer
|
| // expires 5 seconds after calling Start().
|
| @@ -143,6 +167,9 @@ class MEDIA_EXPORT AUAudioInputStream
|
| // Adds extra UMA stats when it has been detected that startup failed.
|
| void AddHistogramsForFailedStartup();
|
|
|
| + // TODO(henrika): add comments
|
| + void AddDevicePropertyChangesToUMA();
|
| +
|
| // 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 +245,11 @@ class MEDIA_EXPORT AUAudioInputStream
|
| // Set to true once when AudioUnitRender() succeeds for the first time.
|
| bool audio_unit_render_has_worked_;
|
|
|
| + std::map<UInt32, int> device_property_changes_map_;
|
| +
|
| + // Set to true when we are listening for changes in device properties.
|
| + base::subtle::Atomic32 device_listener_is_active_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream);
|
| };
|
|
|
|
|