OLD | NEW |
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_controller.h" | 5 #include "media/audio/audio_output_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 12 #include "base/threading/thread_restrictions.h" |
12 #include "base/time.h" | 13 #include "base/time.h" |
13 | 14 |
14 using base::Time; | 15 using base::Time; |
15 using base::WaitableEvent; | 16 using base::WaitableEvent; |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 | 19 |
19 // Signal a pause in low-latency mode. | 20 // Signal a pause in low-latency mode. |
20 const int AudioOutputController::kPauseMark = -1; | 21 const int AudioOutputController::kPauseMark = -1; |
21 | 22 |
(...skipping 13 matching lines...) Expand all Loading... |
35 ALLOW_THIS_IN_INITIALIZER_LIST(weak_this_(this)) { | 36 ALLOW_THIS_IN_INITIALIZER_LIST(weak_this_(this)) { |
36 } | 37 } |
37 | 38 |
38 AudioOutputController::~AudioOutputController() { | 39 AudioOutputController::~AudioOutputController() { |
39 DCHECK_EQ(kClosed, state_); | 40 DCHECK_EQ(kClosed, state_); |
40 DCHECK(message_loop_); | 41 DCHECK(message_loop_); |
41 | 42 |
42 if (!message_loop_.get() || message_loop_->BelongsToCurrentThread()) { | 43 if (!message_loop_.get() || message_loop_->BelongsToCurrentThread()) { |
43 DoStopCloseAndClearStream(NULL); | 44 DoStopCloseAndClearStream(NULL); |
44 } else { | 45 } else { |
| 46 // http://crbug.com/120973 |
| 47 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
45 WaitableEvent completion(true /* manual reset */, | 48 WaitableEvent completion(true /* manual reset */, |
46 false /* initial state */); | 49 false /* initial state */); |
47 message_loop_->PostTask(FROM_HERE, | 50 message_loop_->PostTask(FROM_HERE, |
48 base::Bind(&AudioOutputController::DoStopCloseAndClearStream, | 51 base::Bind(&AudioOutputController::DoStopCloseAndClearStream, |
49 base::Unretained(this), | 52 base::Unretained(this), |
50 &completion)); | 53 &completion)); |
51 completion.Wait(); | 54 completion.Wait(); |
52 } | 55 } |
53 } | 56 } |
54 | 57 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 stream_ = NULL; | 327 stream_ = NULL; |
325 weak_this_.InvalidateWeakPtrs(); | 328 weak_this_.InvalidateWeakPtrs(); |
326 } | 329 } |
327 | 330 |
328 // Should be last in the method, do not touch "this" from here on. | 331 // Should be last in the method, do not touch "this" from here on. |
329 if (done != NULL) | 332 if (done != NULL) |
330 done->Signal(); | 333 done->Signal(); |
331 } | 334 } |
332 | 335 |
333 } // namespace media | 336 } // namespace media |
OLD | NEW |