Chromium Code Reviews| 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..08d1775723c6dff716ee544dce80f556b7f6723d 100644 |
| --- a/media/audio/mac/audio_low_latency_input_mac.h |
| +++ b/media/audio/mac/audio_low_latency_input_mac.h |
| @@ -38,8 +38,7 @@ |
| #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" |
| @@ -94,6 +93,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 +112,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 +161,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(const std::string& name); |
| + |
| // 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 +240,13 @@ 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. |
|
tommi (sloooow) - chröme
2016/02/19 15:17:33
can you add a note about what thread is allowed to
henrika (OOO until Aug 14)
2016/02/22 12:32:52
Tommi, FYI, each callback can come from "any" thre
tommi (sloooow) - chröme
2016/02/22 14:16:43
If we don't need a lock, I'd prefer to not have a
|
| + std::map<UInt32, int> device_property_changes_map_; |
| + |
| + // Set to true when we are listening for changes in device properties. |
| + bool device_listener_is_active_; |
|
tommi (sloooow) - chröme
2016/02/19 15:17:33
modified/checked on what threads?
henrika (OOO until Aug 14)
2016/02/22 12:32:52
Done, also uses DCHECK to ensure proper calling.
|
| + |
| DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream); |
| }; |