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

Side by Side Diff: media/audio/mac/audio_output_mac.h

Issue 10560038: Change the way we are stopping audio stream on Mac once again. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 6 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 | « media/audio/audio_output_mixer.cc ('k') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // The audio is double buffered. 44 // The audio is double buffered.
45 static const uint32 kNumBuffers = 2; 45 static const uint32 kNumBuffers = 2;
46 static const int kEmptyChannel = -1; 46 static const int kEmptyChannel = -1;
47 47
48 // Reorder PCM from source layout to device layout found in Core Audio. 48 // Reorder PCM from source layout to device layout found in Core Audio.
49 template<class Format> 49 template<class Format>
50 void SwizzleLayout(Format* b, uint32 filled); 50 void SwizzleLayout(Format* b, uint32 filled);
51 // Check and move channels if surround sound layout needs adjusted. 51 // Check and move channels if surround sound layout needs adjusted.
52 bool CheckForAdjustedLayout(Channels input_channel, Channels output_channel); 52 bool CheckForAdjustedLayout(Channels input_channel, Channels output_channel);
53 53
54 // Callback we are installing to find out when the stream is stopped.
55 static void IsRunningCallback(void* p_this,
56 AudioQueueRef queue,
57 AudioQueuePropertyID inID);
58
54 // The OS calls back here when an audio buffer has been processed. 59 // The OS calls back here when an audio buffer has been processed.
55 static void RenderCallback(void* p_this, AudioQueueRef queue, 60 static void RenderCallback(void* p_this, AudioQueueRef queue,
56 AudioQueueBufferRef buffer); 61 AudioQueueBufferRef buffer);
57 // Called when an error occurs. 62 // Called when an error occurs.
58 void HandleError(OSStatus err); 63 void HandleError(OSStatus err);
59 64
60 // Atomic operations for setting/getting the source callback. 65 // Atomic operations for setting/getting the source callback.
61 void SetSource(AudioSourceCallback* source); 66 void SetSource(AudioSourceCallback* source);
62 AudioSourceCallback* GetSource(); 67 AudioSourceCallback* GetSource();
63 68
(...skipping 27 matching lines...) Expand all
91 // An array for remapping source to device channel layouts during a swizzle. 96 // An array for remapping source to device channel layouts during a swizzle.
92 int channel_remap_[CHANNELS_MAX]; 97 int channel_remap_[CHANNELS_MAX];
93 // Number of channels in device layout. 98 // Number of channels in device layout.
94 int num_core_channels_; 99 int num_core_channels_;
95 // A flag to determine if swizzle is needed from source to device layouts. 100 // A flag to determine if swizzle is needed from source to device layouts.
96 bool should_swizzle_; 101 bool should_swizzle_;
97 // A flag to determine if downmix is needed from source to device layouts. 102 // A flag to determine if downmix is needed from source to device layouts.
98 bool should_down_mix_; 103 bool should_down_mix_;
99 104
100 // Event used for synchronization when stopping the stream. 105 // Event used for synchronization when stopping the stream.
101 // Callback sets it after stream is stopped. 106 // Callback sets it after stream is fully stopped.
102 base::WaitableEvent stopped_event_; 107 base::WaitableEvent stopped_event_;
103 // When stopping we keep track of number of buffers in flight and 108 // Flag set by rendering callback when it asks OS to stop the stream.
104 // signal "stop completed" from the last buffer's callback. 109 // All subsequent renderer callbacks calls just exit immediately, they
105 int num_buffers_left_; 110 // are called to release the buffer (and we do it when closing the stream,
111 // not in the callback).
112 bool stop_requested_;
106 113
107 DISALLOW_COPY_AND_ASSIGN(PCMQueueOutAudioOutputStream); 114 DISALLOW_COPY_AND_ASSIGN(PCMQueueOutAudioOutputStream);
108 }; 115 };
109 116
110 } // namespace media 117 } // namespace media
111 118
112 #endif // MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_ 119 #endif // MEDIA_AUDIO_MAC_AUDIO_OUTPUT_MAC_H_
OLDNEW
« no previous file with comments | « media/audio/audio_output_mixer.cc ('k') | media/audio/mac/audio_output_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698