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

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

Issue 1816483002: Resolves crash in device notifier for audio input on Mac OS X (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback from Tommi Created 4 years, 9 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
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 59dd618dad4d9952eaf5837beeaeb613085f9373..4881646c99d56cc6dd1710d000f479de483929b6 100644
--- a/media/audio/mac/audio_low_latency_input_mac.h
+++ b/media/audio/mac/audio_low_latency_input_mac.h
@@ -39,11 +39,13 @@
#include <AudioUnit/AudioUnit.h>
#include <CoreAudio/CoreAudio.h>
#include <map>
+#include <vector>
#include "base/atomicops.h"
#include "base/cancelable_callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@@ -122,6 +124,10 @@ class MEDIA_EXPORT AUAudioInputStream
UInt32 num_addresses,
const AudioObjectPropertyAddress addresses[]);
+ // Updates the |device_property_changes_map_| on the main browser thread,
+ // (CrBrowserMain) which is the same thread as this instance is created on.
+ void DevicePropertyChangedOnMainThread(const std::vector<UInt32>& properties);
+
// Registers OnDevicePropertyChanged() to receive notifications when device
// properties changes.
void RegisterDeviceChangeListener();
@@ -283,6 +289,11 @@ class MEDIA_EXPORT AUAudioInputStream
UInt32 largest_glitch_frames_;
int glitches_detected_;
+ // Used to ensure DevicePropertyChangedOnMainThread() is not called when
+ // this object is destroyed.
+ // Note that, all member variables should appear before the WeakPtrFactory.
+ base::WeakPtrFactory<AUAudioInputStream> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream);
};
« no previous file with comments | « no previous file | media/audio/mac/audio_low_latency_input_mac.cc » ('j') | media/audio/mac/audio_low_latency_input_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698