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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "gpu/command_buffer/service/gpu_switches.h" | 12 #include "gpu/command_buffer/service/gpu_switches.h" |
13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
14 #include "content/common/gpu/gpu_channel.h" | 14 #include "content/common/gpu/gpu_channel.h" |
15 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 15 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
16 #include "media/base/bind_to_loop.h" | 16 #include "media/base/bind_to_loop.h" |
17 #include "media/video/picture.h" | 17 #include "media/video/picture.h" |
18 #include "third_party/libva/va/va.h" | 18 #include "third_party/libva/va/va.h" |
19 #include "ui/gl/gl_bindings.h" | 19 #include "ui/gl/gl_bindings.h" |
20 | 20 |
21 #define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \ | 21 #define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \ |
22 do { \ | 22 do { \ |
23 if (!(result)) { \ | 23 if (!(result)) { \ |
24 DVLOG(1) << log; \ | 24 DVLOG(1) << log; \ |
25 NotifyError(error_code); \ | 25 message_loop_->PostTask(FROM_HERE, base::Bind( \ |
Ami GONE FROM CHROMIUM
2012/09/18 02:21:28
This will delay clearing client_ potentially for l
sheu
2012/09/19 08:21:35
That would possibly be racy as well. I imagine th
sheu
2012/09/19 08:58:57
Oh! I see what you're doing there.
Posting the c
| |
26 &VaapiVideoDecodeAccelerator::NotifyError, \ | |
27 weak_this_, error_code)); \ | |
26 return ret; \ | 28 return ret; \ |
27 } \ | 29 } \ |
28 } while (0) | 30 } while (0) |
29 | 31 |
30 using content::VaapiH264Decoder; | 32 using content::VaapiH264Decoder; |
31 | 33 |
32 VaapiVideoDecodeAccelerator::InputBuffer::InputBuffer() : id(0), size(0) { | 34 VaapiVideoDecodeAccelerator::InputBuffer::InputBuffer() : id(0), size(0) { |
33 } | 35 } |
34 | 36 |
35 VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() { | 37 VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() { |
36 } | 38 } |
37 | 39 |
38 void VaapiVideoDecodeAccelerator::NotifyError(Error error) { | 40 void VaapiVideoDecodeAccelerator::NotifyError(Error error) { |
39 if (message_loop_ != MessageLoop::current()) { | 41 // Always call this from a posted task, as it calls Cleanup(), which acquires |
40 DCHECK_EQ(decoder_thread_.message_loop(), MessageLoop::current()); | 42 // the member lock_. |
41 message_loop_->PostTask(FROM_HERE, base::Bind( | |
42 &VaapiVideoDecodeAccelerator::NotifyError, weak_this_, error)); | |
43 return; | |
44 } | |
45 | |
46 DVLOG(1) << "Notifying of error " << error; | 43 DVLOG(1) << "Notifying of error " << error; |
47 | |
48 if (client_) { | 44 if (client_) { |
49 client_->NotifyError(error); | 45 client_->NotifyError(error); |
50 client_ptr_factory_.InvalidateWeakPtrs(); | 46 client_ptr_factory_.InvalidateWeakPtrs(); |
51 } | 47 } |
52 Cleanup(); | 48 Cleanup(); |
53 } | 49 } |
54 | 50 |
55 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( | 51 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( |
56 Display* x_display, GLXContext glx_context, | 52 Display* x_display, GLXContext glx_context, |
57 Client* client, | 53 Client* client, |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 | 581 |
586 // static | 582 // static |
587 void VaapiVideoDecodeAccelerator::PreSandboxInitialization() { | 583 void VaapiVideoDecodeAccelerator::PreSandboxInitialization() { |
588 VaapiH264Decoder::PreSandboxInitialization(); | 584 VaapiH264Decoder::PreSandboxInitialization(); |
589 } | 585 } |
590 | 586 |
591 // static | 587 // static |
592 bool VaapiVideoDecodeAccelerator::PostSandboxInitialization() { | 588 bool VaapiVideoDecodeAccelerator::PostSandboxInitialization() { |
593 return VaapiH264Decoder::PostSandboxInitialization(); | 589 return VaapiH264Decoder::PostSandboxInitialization(); |
594 } | 590 } |
OLD | NEW |