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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/audio/mac/audio_output_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ 5 #ifndef MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_
6 #define MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ 6 #define MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_
7 7
8 #include <AudioToolbox/AudioFormat.h> 8 #include <AudioToolbox/AudioFormat.h>
9 #include <AudioToolbox/AudioQueue.h> 9 #include <AudioToolbox/AudioQueue.h>
10 #include <AudioUnit/AudioUnit.h> 10 #include <AudioUnit/AudioUnit.h>
11 11
12 #include "base/synchronization/lock.h"
12 #include "media/audio/audio_io.h" 13 #include "media/audio/audio_io.h"
13 #include "media/audio/audio_parameters.h" 14 #include "media/audio/audio_parameters.h"
14 15
15 class AudioManagerMac; 16 class AudioManagerMac;
16 17
17 // Implementation of AudioOuputStream for Mac OS X using the audio queue service 18 // Implementation of AudioOuputStream for Mac OS X using the audio queue service
18 // present in OS 10.5 and later. Audioqueue is the successor to the SoundManager 19 // present in OS 10.5 and later. Audioqueue is the successor to the SoundManager
19 // services but it is supported in 64 bits. 20 // services but it is supported in 64 bits.
20 class PCMQueueOutAudioOutputStream : public AudioOutputStream { 21 class PCMQueueOutAudioOutputStream : public AudioOutputStream {
21 public: 22 public:
(...skipping 23 matching lines...) Expand all
45 void SwizzleLayout(Format* b, uint32 filled); 46 void SwizzleLayout(Format* b, uint32 filled);
46 // Check and move channels if surround sound layout needs adjusted. 47 // Check and move channels if surround sound layout needs adjusted.
47 bool CheckForAdjustedLayout(Channels input_channel, Channels output_channel); 48 bool CheckForAdjustedLayout(Channels input_channel, Channels output_channel);
48 49
49 // The OS calls back here when an audio buffer has been processed. 50 // The OS calls back here when an audio buffer has been processed.
50 static void RenderCallback(void* p_this, AudioQueueRef queue, 51 static void RenderCallback(void* p_this, AudioQueueRef queue,
51 AudioQueueBufferRef buffer); 52 AudioQueueBufferRef buffer);
52 // Called when an error occurs. 53 // Called when an error occurs.
53 void HandleError(OSStatus err); 54 void HandleError(OSStatus err);
54 55
56 // Atomic operations for setting/getting the source callback.
57 void SetSource(AudioSourceCallback* source);
58 AudioSourceCallback* GetSource();
59
55 // Structure that holds the stream format details such as bitrate. 60 // Structure that holds the stream format details such as bitrate.
56 AudioStreamBasicDescription format_; 61 AudioStreamBasicDescription format_;
57 // Handle to the OS audio queue object. 62 // Handle to the OS audio queue object.
58 AudioQueueRef audio_queue_; 63 AudioQueueRef audio_queue_;
59 // Array of pointers to the OS managed audio buffers. 64 // Array of pointers to the OS managed audio buffers.
60 AudioQueueBufferRef buffer_[kNumBuffers]; 65 AudioQueueBufferRef buffer_[kNumBuffers];
66 // Mutex for the |source_| to implment atomic set and get.
67 // It is important to NOT wait on any other locks while this is held.
68 base::Lock source_lock_;
61 // Pointer to the object that will provide the audio samples. 69 // Pointer to the object that will provide the audio samples.
62 AudioSourceCallback* source_; 70 AudioSourceCallback* source_;
63 // Our creator, the audio manager needs to be notified when we close. 71 // Our creator, the audio manager needs to be notified when we close.
64 AudioManagerMac* manager_; 72 AudioManagerMac* manager_;
65 // Packet size in bytes. 73 // Packet size in bytes.
66 uint32 packet_size_; 74 uint32 packet_size_;
67 // Number of bytes for making a silence buffer. 75 // Number of bytes for making a silence buffer.
68 int silence_bytes_; 76 int silence_bytes_;
69 // Volume level from 0 to 1. 77 // Volume level from 0 to 1.
70 float volume_; 78 float volume_;
(...skipping 11 matching lines...) Expand all
82 int num_core_channels_; 90 int num_core_channels_;
83 // A flag to determine if swizzle is needed from source to device layouts. 91 // A flag to determine if swizzle is needed from source to device layouts.
84 bool should_swizzle_; 92 bool should_swizzle_;
85 // A flag to determine if downmix is needed from source to device layouts. 93 // A flag to determine if downmix is needed from source to device layouts.
86 bool should_down_mix_; 94 bool should_down_mix_;
87 95
88 DISALLOW_COPY_AND_ASSIGN(PCMQueueOutAudioOutputStream); 96 DISALLOW_COPY_AND_ASSIGN(PCMQueueOutAudioOutputStream);
89 }; 97 };
90 98
91 #endif // MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ 99 #endif // MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_
OLDNEW
« 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