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 "content/common/gpu/client/gpu_video_decode_accelerator_host.h" | 5 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "content/common/gpu/client/gpu_channel_host.h" | 10 #include "content/common/gpu/client/gpu_channel_host.h" |
11 #include "content/common/gpu/gpu_messages.h" | 11 #include "content/common/gpu/gpu_messages.h" |
12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
13 #include "ipc/ipc_message_macros.h" | 13 #include "ipc/ipc_message_macros.h" |
14 #include "ipc/ipc_message_utils.h" | 14 #include "ipc/ipc_message_utils.h" |
15 | 15 |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 #include "content/public/common/sandbox_init.h" | 17 #include "content/public/common/sandbox_init.h" |
18 #endif // OS_WIN | 18 #endif // OS_WIN |
19 | 19 |
20 using media::VideoDecodeAccelerator; | 20 using media::VideoDecodeAccelerator; |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( | 23 GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( |
24 GpuChannelHost* channel, | 24 GpuChannelHost* channel, |
25 int32 decoder_route_id, | 25 int32 decoder_route_id, |
26 VideoDecodeAccelerator::Client* client, | |
27 CommandBufferProxyImpl* impl) | 26 CommandBufferProxyImpl* impl) |
28 : channel_(channel), | 27 : channel_(channel), |
29 decoder_route_id_(decoder_route_id), | 28 decoder_route_id_(decoder_route_id), |
30 client_(client), | 29 client_(NULL), |
31 impl_(impl) { | 30 impl_(impl) { |
32 DCHECK(channel_); | 31 DCHECK(channel_); |
33 DCHECK(client_); | |
34 channel_->AddRoute(decoder_route_id, base::AsWeakPtr(this)); | 32 channel_->AddRoute(decoder_route_id, base::AsWeakPtr(this)); |
35 impl_->AddDeletionObserver(this); | 33 impl_->AddDeletionObserver(this); |
36 } | 34 } |
37 | 35 |
38 void GpuVideoDecodeAcceleratorHost::OnChannelError() { | 36 void GpuVideoDecodeAcceleratorHost::OnChannelError() { |
39 DLOG(ERROR) << "GpuVideoDecodeAcceleratorHost::OnChannelError()"; | 37 DLOG(ERROR) << "GpuVideoDecodeAcceleratorHost::OnChannelError()"; |
40 if (channel_) { | 38 if (channel_) { |
41 channel_->RemoveRoute(decoder_route_id_); | 39 channel_->RemoveRoute(decoder_route_id_); |
42 channel_ = NULL; | 40 channel_ = NULL; |
43 } | 41 } |
(...skipping 21 matching lines...) Expand all Loading... |
65 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, | 63 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, |
66 OnDismissPictureBuffer) | 64 OnDismissPictureBuffer) |
67 IPC_MESSAGE_UNHANDLED(handled = false) | 65 IPC_MESSAGE_UNHANDLED(handled = false) |
68 IPC_END_MESSAGE_MAP() | 66 IPC_END_MESSAGE_MAP() |
69 DCHECK(handled); | 67 DCHECK(handled); |
70 // See OnErrorNotification for why |this| mustn't be used after | 68 // See OnErrorNotification for why |this| mustn't be used after |
71 // OnErrorNotification might have been called above. | 69 // OnErrorNotification might have been called above. |
72 return handled; | 70 return handled; |
73 } | 71 } |
74 | 72 |
75 bool GpuVideoDecodeAcceleratorHost::Initialize( | 73 bool GpuVideoDecodeAcceleratorHost::Initialize(media::VideoCodecProfile profile, |
76 media::VideoCodecProfile profile) { | 74 Client* client) { |
77 NOTREACHED(); | 75 client_ = client; |
78 return true; | 76 return true; |
79 } | 77 } |
80 | 78 |
81 void GpuVideoDecodeAcceleratorHost::Decode( | 79 void GpuVideoDecodeAcceleratorHost::Decode( |
82 const media::BitstreamBuffer& bitstream_buffer) { | 80 const media::BitstreamBuffer& bitstream_buffer) { |
83 DCHECK(CalledOnValidThread()); | 81 DCHECK(CalledOnValidThread()); |
84 // Can happen if a decode task was posted before an error was delivered. | 82 // Can happen if a decode task was posted before an error was delivered. |
85 if (!channel_) | 83 if (!channel_) |
86 return; | 84 return; |
87 | 85 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 140 |
143 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { | 141 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { |
144 impl_ = NULL; | 142 impl_ = NULL; |
145 | 143 |
146 // The CommandBufferProxyImpl is going away; error out this VDA. | 144 // The CommandBufferProxyImpl is going away; error out this VDA. |
147 OnChannelError(); | 145 OnChannelError(); |
148 } | 146 } |
149 | 147 |
150 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { | 148 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { |
151 DCHECK(CalledOnValidThread()); | 149 DCHECK(CalledOnValidThread()); |
152 DCHECK(!client_) << "destructor called without Destroy being called!"; | |
153 | 150 |
154 if (channel_) | 151 if (channel_) |
155 channel_->RemoveRoute(decoder_route_id_); | 152 channel_->RemoveRoute(decoder_route_id_); |
156 if (impl_) | 153 if (impl_) |
157 impl_->RemoveDeletionObserver(this); | 154 impl_->RemoveDeletionObserver(this); |
158 } | 155 } |
159 | 156 |
160 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { | 157 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { |
161 // After OnChannelError is called, the client should no longer send | 158 // After OnChannelError is called, the client should no longer send |
162 // messages to the gpu channel through this object. But queued posted tasks | 159 // messages to the gpu channel through this object. But queued posted tasks |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 228 |
232 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 229 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
233 // last thing done on this stack! | 230 // last thing done on this stack! |
234 media::VideoDecodeAccelerator::Client* client = NULL; | 231 media::VideoDecodeAccelerator::Client* client = NULL; |
235 std::swap(client, client_); | 232 std::swap(client, client_); |
236 client->NotifyError( | 233 client->NotifyError( |
237 static_cast<media::VideoDecodeAccelerator::Error>(error)); | 234 static_cast<media::VideoDecodeAccelerator::Error>(error)); |
238 } | 235 } |
239 | 236 |
240 } // namespace content | 237 } // namespace content |
OLD | NEW |