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

Side by Side Diff: media/audio/audio_output_device.cc

Issue 10821109: Candidate fix for a crash at shutdown when the IO thread is going away. More details in the bug rep… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missed the input filter... damn you code duplication! Created 8 years, 4 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_input_device.cc ('k') | no next file » | 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 #include "media/audio/audio_output_device.h" 5 #include "media/audio/audio_output_device.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 } 136 }
137 137
138 void AudioOutputDevice::ShutDownOnIOThread() { 138 void AudioOutputDevice::ShutDownOnIOThread() {
139 DCHECK(message_loop()->BelongsToCurrentThread()); 139 DCHECK(message_loop()->BelongsToCurrentThread());
140 140
141 // Make sure we don't call shutdown more than once. 141 // Make sure we don't call shutdown more than once.
142 if (stream_id_) { 142 if (stream_id_) {
143 is_started_ = false; 143 is_started_ = false;
144 144
145 ipc_->CloseStream(stream_id_); 145 if (ipc_) {
146 ipc_->RemoveDelegate(stream_id_); 146 ipc_->CloseStream(stream_id_);
147 ipc_->RemoveDelegate(stream_id_);
148 }
149
147 stream_id_ = 0; 150 stream_id_ = 0;
148 } 151 }
149 152
150 // We can run into an issue where ShutDownOnIOThread is called right after 153 // We can run into an issue where ShutDownOnIOThread is called right after
151 // OnStreamCreated is called in cases where Start/Stop are called before we 154 // OnStreamCreated is called in cases where Start/Stop are called before we
152 // get the OnStreamCreated callback. To handle that corner case, we call 155 // get the OnStreamCreated callback. To handle that corner case, we call
153 // Stop(). In most cases, the thread will already be stopped. 156 // Stop(). In most cases, the thread will already be stopped.
154 // Another situation is when the IO thread goes away before Stop() is called 157 // Another situation is when the IO thread goes away before Stop() is called
155 // in which case, we cannot use the message loop to close the thread handle 158 // in which case, we cannot use the message loop to close the thread handle
156 // and can't not rely on the main thread existing either. 159 // and can't not rely on the main thread existing either.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // conversions that happen in the <audio> and WebRTC scenarios. 274 // conversions that happen in the <audio> and WebRTC scenarios.
272 InterleaveFloatToInt(audio_data_, shared_memory_.memory(), 275 InterleaveFloatToInt(audio_data_, shared_memory_.memory(),
273 num_frames, audio_parameters_.bits_per_sample() / 8); 276 num_frames, audio_parameters_.bits_per_sample() / 8);
274 277
275 // Let the host know we are done. 278 // Let the host know we are done.
276 SetActualDataSizeInBytes(&shared_memory_, memory_length_, 279 SetActualDataSizeInBytes(&shared_memory_, memory_length_,
277 num_frames * audio_parameters_.GetBytesPerFrame()); 280 num_frames * audio_parameters_.GetBytesPerFrame());
278 } 281 }
279 282
280 } // namespace media. 283 } // namespace media.
OLDNEW
« no previous file with comments | « media/audio/audio_input_device.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698