| 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 22 matching lines...) Expand all Loading... |
| 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( |
| 74 Client* client, |
| 76 media::VideoCodecProfile profile) { | 75 media::VideoCodecProfile profile) { |
| 77 NOTREACHED(); | 76 client_ = client; |
| 78 return true; | 77 return true; |
| 79 } | 78 } |
| 80 | 79 |
| 81 void GpuVideoDecodeAcceleratorHost::Decode( | 80 void GpuVideoDecodeAcceleratorHost::Decode( |
| 82 const media::BitstreamBuffer& bitstream_buffer) { | 81 const media::BitstreamBuffer& bitstream_buffer) { |
| 83 DCHECK(CalledOnValidThread()); | 82 DCHECK(CalledOnValidThread()); |
| 84 // Can happen if a decode task was posted before an error was delivered. | 83 // Can happen if a decode task was posted before an error was delivered. |
| 85 if (!channel_) | 84 if (!channel_) |
| 86 return; | 85 return; |
| 87 | 86 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 141 |
| 143 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { | 142 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { |
| 144 impl_ = NULL; | 143 impl_ = NULL; |
| 145 | 144 |
| 146 // The CommandBufferProxyImpl is going away; error out this VDA. | 145 // The CommandBufferProxyImpl is going away; error out this VDA. |
| 147 OnChannelError(); | 146 OnChannelError(); |
| 148 } | 147 } |
| 149 | 148 |
| 150 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { | 149 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { |
| 151 DCHECK(CalledOnValidThread()); | 150 DCHECK(CalledOnValidThread()); |
| 152 DCHECK(!client_) << "destructor called without Destroy being called!"; | |
| 153 | 151 |
| 154 if (channel_) | 152 if (channel_) |
| 155 channel_->RemoveRoute(decoder_route_id_); | 153 channel_->RemoveRoute(decoder_route_id_); |
| 156 if (impl_) | 154 if (impl_) |
| 157 impl_->RemoveDeletionObserver(this); | 155 impl_->RemoveDeletionObserver(this); |
| 158 } | 156 } |
| 159 | 157 |
| 160 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { | 158 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { |
| 161 // After OnChannelError is called, the client should no longer send | 159 // After OnChannelError is called, the client should no longer send |
| 162 // messages to the gpu channel through this object. But queued posted tasks | 160 // 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 | 229 |
| 232 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 230 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
| 233 // last thing done on this stack! | 231 // last thing done on this stack! |
| 234 media::VideoDecodeAccelerator::Client* client = NULL; | 232 media::VideoDecodeAccelerator::Client* client = NULL; |
| 235 std::swap(client, client_); | 233 std::swap(client, client_); |
| 236 client->NotifyError( | 234 client->NotifyError( |
| 237 static_cast<media::VideoDecodeAccelerator::Error>(error)); | 235 static_cast<media::VideoDecodeAccelerator::Error>(error)); |
| 238 } | 236 } |
| 239 | 237 |
| 240 } // namespace content | 238 } // namespace content |
| OLD | NEW |