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

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

Issue 7888055: Add a lock around getting and setting of source_ to avoid possible compiler reorderings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 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_output_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_output_mac.h
diff --git a/media/audio/mac/audio_output_mac.h b/media/audio/mac/audio_output_mac.h
index 031dc3f60d53b1e400711ad3c27e0da9183b3b1d..8d18c3eeb0dab720b508c96d4adcafe9795505c0 100644
--- a/media/audio/mac/audio_output_mac.h
+++ b/media/audio/mac/audio_output_mac.h
@@ -9,6 +9,7 @@
#include <AudioToolbox/AudioQueue.h>
#include <AudioUnit/AudioUnit.h>
+#include "base/synchronization/lock.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_parameters.h"
@@ -52,12 +53,19 @@ class PCMQueueOutAudioOutputStream : public AudioOutputStream {
// Called when an error occurs.
void HandleError(OSStatus err);
+ // Atomic operations for setting/getting the source callback.
+ void SetSource(AudioSourceCallback* source);
+ AudioSourceCallback* GetSource();
+
// Structure that holds the stream format details such as bitrate.
AudioStreamBasicDescription format_;
// Handle to the OS audio queue object.
AudioQueueRef audio_queue_;
// Array of pointers to the OS managed audio buffers.
AudioQueueBufferRef buffer_[kNumBuffers];
+ // Mutex for the |source_| to implment atomic set and get.
+ // It is important to NOT wait on any other locks while this is held.
+ base::Lock source_lock_;
// Pointer to the object that will provide the audio samples.
AudioSourceCallback* source_;
// Our creator, the audio manager needs to be notified when we close.
« no previous file with comments | « no previous file | media/audio/mac/audio_output_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698