| 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/gpu/ipc/client/gpu_video_decode_accelerator_host.h" | 5 #include "media/gpu/ipc/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 "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 media_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 25 media_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 26 weak_this_factory_(this) { | 26 weak_this_factory_(this) { |
| 27 DCHECK(channel_); | 27 DCHECK(channel_); |
| 28 DCHECK(impl_); | 28 DCHECK(impl_); |
| 29 | 29 |
| 30 weak_this_ = weak_this_factory_.GetWeakPtr(); | 30 weak_this_ = weak_this_factory_.GetWeakPtr(); |
| 31 impl_->AddDeletionObserver(this); | 31 impl_->AddDeletionObserver(this); |
| 32 } | 32 } |
| 33 | 33 |
| 34 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { | 34 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { |
| 35 DCHECK(CalledOnValidThread()); | 35 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 36 | 36 |
| 37 if (channel_ && decoder_route_id_ != MSG_ROUTING_NONE) | 37 if (channel_ && decoder_route_id_ != MSG_ROUTING_NONE) |
| 38 channel_->RemoveRoute(decoder_route_id_); | 38 channel_->RemoveRoute(decoder_route_id_); |
| 39 | 39 |
| 40 base::AutoLock lock(impl_lock_); | 40 base::AutoLock lock(impl_lock_); |
| 41 if (impl_) | 41 if (impl_) |
| 42 impl_->RemoveDeletionObserver(this); | 42 impl_->RemoveDeletionObserver(this); |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { | 45 bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { |
| 46 DCHECK(CalledOnValidThread()); | 46 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 47 bool handled = true; | 47 bool handled = true; |
| 48 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAcceleratorHost, msg) | 48 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAcceleratorHost, msg) |
| 49 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_InitializationComplete, | 49 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_InitializationComplete, |
| 50 OnInitializationComplete) | 50 OnInitializationComplete) |
| 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, | 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, |
| 52 OnBitstreamBufferProcessed) | 52 OnBitstreamBufferProcessed) |
| 53 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, | 53 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, |
| 54 OnProvidePictureBuffers) | 54 OnProvidePictureBuffers) |
| 55 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, | 55 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, |
| 56 OnPictureReady) | 56 OnPictureReady) |
| 57 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, OnFlushDone) | 57 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, OnFlushDone) |
| 58 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, OnResetDone) | 58 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, OnResetDone) |
| 59 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ErrorNotification, | 59 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ErrorNotification, |
| 60 OnNotifyError) | 60 OnNotifyError) |
| 61 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, | 61 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, |
| 62 OnDismissPictureBuffer) | 62 OnDismissPictureBuffer) |
| 63 IPC_MESSAGE_UNHANDLED(handled = false) | 63 IPC_MESSAGE_UNHANDLED(handled = false) |
| 64 IPC_END_MESSAGE_MAP() | 64 IPC_END_MESSAGE_MAP() |
| 65 DCHECK(handled); | 65 DCHECK(handled); |
| 66 // See OnNotifyError for why |this| mustn't be used after OnNotifyError might | 66 // See OnNotifyError for why |this| mustn't be used after OnNotifyError might |
| 67 // have been called above. | 67 // have been called above. |
| 68 return handled; | 68 return handled; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void GpuVideoDecodeAcceleratorHost::OnChannelError() { | 71 void GpuVideoDecodeAcceleratorHost::OnChannelError() { |
| 72 DCHECK(CalledOnValidThread()); | 72 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 73 if (channel_) { | 73 if (channel_) { |
| 74 if (decoder_route_id_ != MSG_ROUTING_NONE) | 74 if (decoder_route_id_ != MSG_ROUTING_NONE) |
| 75 channel_->RemoveRoute(decoder_route_id_); | 75 channel_->RemoveRoute(decoder_route_id_); |
| 76 channel_ = nullptr; | 76 channel_ = nullptr; |
| 77 } | 77 } |
| 78 DLOG(ERROR) << "OnChannelError()"; | 78 DLOG(ERROR) << "OnChannelError()"; |
| 79 PostNotifyError(PLATFORM_FAILURE); | 79 PostNotifyError(PLATFORM_FAILURE); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool GpuVideoDecodeAcceleratorHost::Initialize(const Config& config, | 82 bool GpuVideoDecodeAcceleratorHost::Initialize(const Config& config, |
| 83 Client* client) { | 83 Client* client) { |
| 84 DCHECK(CalledOnValidThread()); | 84 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 85 client_ = client; | 85 client_ = client; |
| 86 | 86 |
| 87 base::AutoLock lock(impl_lock_); | 87 base::AutoLock lock(impl_lock_); |
| 88 if (!impl_) | 88 if (!impl_) |
| 89 return false; | 89 return false; |
| 90 | 90 |
| 91 int32_t route_id = channel_->GenerateRouteID(); | 91 int32_t route_id = channel_->GenerateRouteID(); |
| 92 channel_->AddRoute(route_id, weak_this_); | 92 channel_->AddRoute(route_id, weak_this_); |
| 93 | 93 |
| 94 bool succeeded = false; | 94 bool succeeded = false; |
| 95 Send(new GpuCommandBufferMsg_CreateVideoDecoder(impl_->route_id(), config, | 95 Send(new GpuCommandBufferMsg_CreateVideoDecoder(impl_->route_id(), config, |
| 96 route_id, &succeeded)); | 96 route_id, &succeeded)); |
| 97 | 97 |
| 98 if (!succeeded) { | 98 if (!succeeded) { |
| 99 DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder()) failed"; | 99 DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder()) failed"; |
| 100 PostNotifyError(PLATFORM_FAILURE); | 100 PostNotifyError(PLATFORM_FAILURE); |
| 101 channel_->RemoveRoute(route_id); | 101 channel_->RemoveRoute(route_id); |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 decoder_route_id_ = route_id; | 104 decoder_route_id_ = route_id; |
| 105 return true; | 105 return true; |
| 106 } | 106 } |
| 107 | 107 |
| 108 void GpuVideoDecodeAcceleratorHost::Decode( | 108 void GpuVideoDecodeAcceleratorHost::Decode( |
| 109 const BitstreamBuffer& bitstream_buffer) { | 109 const BitstreamBuffer& bitstream_buffer) { |
| 110 DCHECK(CalledOnValidThread()); | 110 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 111 if (!channel_) | 111 if (!channel_) |
| 112 return; | 112 return; |
| 113 BitstreamBuffer buffer_to_send = bitstream_buffer; | 113 BitstreamBuffer buffer_to_send = bitstream_buffer; |
| 114 base::SharedMemoryHandle handle = | 114 base::SharedMemoryHandle handle = |
| 115 channel_->ShareToGpuProcess(bitstream_buffer.handle()); | 115 channel_->ShareToGpuProcess(bitstream_buffer.handle()); |
| 116 if (!base::SharedMemory::IsHandleValid(handle)) { | 116 if (!base::SharedMemory::IsHandleValid(handle)) { |
| 117 NOTREACHED() << "Failed to duplicate buffer handler"; | 117 NOTREACHED() << "Failed to duplicate buffer handler"; |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 buffer_to_send.set_handle(handle); | 120 buffer_to_send.set_handle(handle); |
| 121 Send( | 121 Send( |
| 122 new AcceleratedVideoDecoderMsg_Decode(decoder_route_id_, buffer_to_send)); | 122 new AcceleratedVideoDecoderMsg_Decode(decoder_route_id_, buffer_to_send)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( | 125 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( |
| 126 const std::vector<PictureBuffer>& buffers) { | 126 const std::vector<PictureBuffer>& buffers) { |
| 127 DCHECK(CalledOnValidThread()); | 127 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 128 if (!channel_) | 128 if (!channel_) |
| 129 return; | 129 return; |
| 130 // Rearrange data for IPC command. | 130 // Rearrange data for IPC command. |
| 131 std::vector<int32_t> buffer_ids; | 131 std::vector<int32_t> buffer_ids; |
| 132 std::vector<PictureBuffer::TextureIds> texture_ids; | 132 std::vector<PictureBuffer::TextureIds> texture_ids; |
| 133 for (uint32_t i = 0; i < buffers.size(); i++) { | 133 for (uint32_t i = 0; i < buffers.size(); i++) { |
| 134 const PictureBuffer& buffer = buffers[i]; | 134 const PictureBuffer& buffer = buffers[i]; |
| 135 if (buffer.size() != picture_buffer_dimensions_) { | 135 if (buffer.size() != picture_buffer_dimensions_) { |
| 136 DLOG(ERROR) << "buffer.size() invalid: expected " | 136 DLOG(ERROR) << "buffer.size() invalid: expected " |
| 137 << picture_buffer_dimensions_.ToString() << ", got " | 137 << picture_buffer_dimensions_.ToString() << ", got " |
| 138 << buffer.size().ToString(); | 138 << buffer.size().ToString(); |
| 139 PostNotifyError(INVALID_ARGUMENT); | 139 PostNotifyError(INVALID_ARGUMENT); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 texture_ids.push_back(buffer.client_texture_ids()); | 142 texture_ids.push_back(buffer.client_texture_ids()); |
| 143 buffer_ids.push_back(buffer.id()); | 143 buffer_ids.push_back(buffer.id()); |
| 144 } | 144 } |
| 145 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( | 145 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( |
| 146 decoder_route_id_, buffer_ids, texture_ids)); | 146 decoder_route_id_, buffer_ids, texture_ids)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( | 149 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( |
| 150 int32_t picture_buffer_id) { | 150 int32_t picture_buffer_id) { |
| 151 DCHECK(CalledOnValidThread()); | 151 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 152 if (!channel_) | 152 if (!channel_) |
| 153 return; | 153 return; |
| 154 Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer(decoder_route_id_, | 154 Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer(decoder_route_id_, |
| 155 picture_buffer_id)); | 155 picture_buffer_id)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void GpuVideoDecodeAcceleratorHost::Flush() { | 158 void GpuVideoDecodeAcceleratorHost::Flush() { |
| 159 DCHECK(CalledOnValidThread()); | 159 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 160 if (!channel_) | 160 if (!channel_) |
| 161 return; | 161 return; |
| 162 Send(new AcceleratedVideoDecoderMsg_Flush(decoder_route_id_)); | 162 Send(new AcceleratedVideoDecoderMsg_Flush(decoder_route_id_)); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void GpuVideoDecodeAcceleratorHost::Reset() { | 165 void GpuVideoDecodeAcceleratorHost::Reset() { |
| 166 DCHECK(CalledOnValidThread()); | 166 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 167 if (!channel_) | 167 if (!channel_) |
| 168 return; | 168 return; |
| 169 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_)); | 169 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void GpuVideoDecodeAcceleratorHost::SetSurface( | 172 void GpuVideoDecodeAcceleratorHost::SetSurface( |
| 173 int32_t surface_id, | 173 int32_t surface_id, |
| 174 const base::Optional<base::UnguessableToken>& routing_token) { | 174 const base::Optional<base::UnguessableToken>& routing_token) { |
| 175 DCHECK(CalledOnValidThread()); | 175 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 176 if (!channel_) | 176 if (!channel_) |
| 177 return; | 177 return; |
| 178 Send(new AcceleratedVideoDecoderMsg_SetSurface(decoder_route_id_, surface_id, | 178 Send(new AcceleratedVideoDecoderMsg_SetSurface(decoder_route_id_, surface_id, |
| 179 routing_token)); | 179 routing_token)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void GpuVideoDecodeAcceleratorHost::Destroy() { | 182 void GpuVideoDecodeAcceleratorHost::Destroy() { |
| 183 DCHECK(CalledOnValidThread()); | 183 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 184 if (channel_) | 184 if (channel_) |
| 185 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_)); | 185 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_)); |
| 186 client_ = nullptr; | 186 client_ = nullptr; |
| 187 delete this; | 187 delete this; |
| 188 } | 188 } |
| 189 | 189 |
| 190 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { | 190 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { |
| 191 base::AutoLock lock(impl_lock_); | 191 base::AutoLock lock(impl_lock_); |
| 192 impl_ = nullptr; | 192 impl_ = nullptr; |
| 193 | 193 |
| 194 // The gpu::CommandBufferProxyImpl is going away; error out this VDA. | 194 // The gpu::CommandBufferProxyImpl is going away; error out this VDA. |
| 195 media_task_runner_->PostTask( | 195 media_task_runner_->PostTask( |
| 196 FROM_HERE, | 196 FROM_HERE, |
| 197 base::Bind(&GpuVideoDecodeAcceleratorHost::OnChannelError, weak_this_)); | 197 base::Bind(&GpuVideoDecodeAcceleratorHost::OnChannelError, weak_this_)); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void GpuVideoDecodeAcceleratorHost::PostNotifyError(Error error) { | 200 void GpuVideoDecodeAcceleratorHost::PostNotifyError(Error error) { |
| 201 DCHECK(CalledOnValidThread()); | 201 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 202 DVLOG(2) << "PostNotifyError(): error=" << error; | 202 DVLOG(2) << "PostNotifyError(): error=" << error; |
| 203 media_task_runner_->PostTask( | 203 media_task_runner_->PostTask( |
| 204 FROM_HERE, base::Bind(&GpuVideoDecodeAcceleratorHost::OnNotifyError, | 204 FROM_HERE, base::Bind(&GpuVideoDecodeAcceleratorHost::OnNotifyError, |
| 205 weak_this_, error)); | 205 weak_this_, error)); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { | 208 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { |
| 209 DCHECK(CalledOnValidThread()); | 209 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 210 uint32_t message_type = message->type(); | 210 uint32_t message_type = message->type(); |
| 211 if (!channel_->Send(message)) { | 211 if (!channel_->Send(message)) { |
| 212 DLOG(ERROR) << "Send(" << message_type << ") failed"; | 212 DLOG(ERROR) << "Send(" << message_type << ") failed"; |
| 213 PostNotifyError(PLATFORM_FAILURE); | 213 PostNotifyError(PLATFORM_FAILURE); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 void GpuVideoDecodeAcceleratorHost::OnInitializationComplete(bool success) { | 217 void GpuVideoDecodeAcceleratorHost::OnInitializationComplete(bool success) { |
| 218 DCHECK(CalledOnValidThread()); | 218 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 219 if (client_) | 219 if (client_) |
| 220 client_->NotifyInitializationComplete(success); | 220 client_->NotifyInitializationComplete(success); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( | 223 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( |
| 224 int32_t bitstream_buffer_id) { | 224 int32_t bitstream_buffer_id) { |
| 225 DCHECK(CalledOnValidThread()); | 225 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 226 if (client_) | 226 if (client_) |
| 227 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); | 227 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffers( | 230 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffers( |
| 231 uint32_t num_requested_buffers, | 231 uint32_t num_requested_buffers, |
| 232 VideoPixelFormat format, | 232 VideoPixelFormat format, |
| 233 uint32_t textures_per_buffer, | 233 uint32_t textures_per_buffer, |
| 234 const gfx::Size& dimensions, | 234 const gfx::Size& dimensions, |
| 235 uint32_t texture_target) { | 235 uint32_t texture_target) { |
| 236 DCHECK(CalledOnValidThread()); | 236 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 237 picture_buffer_dimensions_ = dimensions; | 237 picture_buffer_dimensions_ = dimensions; |
| 238 | 238 |
| 239 const int kMaxVideoPlanes = 4; | 239 const int kMaxVideoPlanes = 4; |
| 240 if (textures_per_buffer > kMaxVideoPlanes) { | 240 if (textures_per_buffer > kMaxVideoPlanes) { |
| 241 PostNotifyError(PLATFORM_FAILURE); | 241 PostNotifyError(PLATFORM_FAILURE); |
| 242 return; | 242 return; |
| 243 } | 243 } |
| 244 | 244 |
| 245 if (client_) { | 245 if (client_) { |
| 246 client_->ProvidePictureBuffers(num_requested_buffers, format, | 246 client_->ProvidePictureBuffers(num_requested_buffers, format, |
| 247 textures_per_buffer, dimensions, | 247 textures_per_buffer, dimensions, |
| 248 texture_target); | 248 texture_target); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer( | 252 void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer( |
| 253 int32_t picture_buffer_id) { | 253 int32_t picture_buffer_id) { |
| 254 DCHECK(CalledOnValidThread()); | 254 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 255 if (client_) | 255 if (client_) |
| 256 client_->DismissPictureBuffer(picture_buffer_id); | 256 client_->DismissPictureBuffer(picture_buffer_id); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void GpuVideoDecodeAcceleratorHost::OnPictureReady( | 259 void GpuVideoDecodeAcceleratorHost::OnPictureReady( |
| 260 const AcceleratedVideoDecoderHostMsg_PictureReady_Params& params) { | 260 const AcceleratedVideoDecoderHostMsg_PictureReady_Params& params) { |
| 261 DCHECK(CalledOnValidThread()); | 261 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 262 if (!client_) | 262 if (!client_) |
| 263 return; | 263 return; |
| 264 Picture picture(params.picture_buffer_id, params.bitstream_buffer_id, | 264 Picture picture(params.picture_buffer_id, params.bitstream_buffer_id, |
| 265 params.visible_rect, params.color_space, | 265 params.visible_rect, params.color_space, |
| 266 params.allow_overlay); | 266 params.allow_overlay); |
| 267 picture.set_size_changed(params.size_changed); | 267 picture.set_size_changed(params.size_changed); |
| 268 picture.set_surface_texture(params.surface_texture); | 268 picture.set_surface_texture(params.surface_texture); |
| 269 picture.set_wants_promotion_hint(params.wants_promotion_hint); | 269 picture.set_wants_promotion_hint(params.wants_promotion_hint); |
| 270 client_->PictureReady(picture); | 270 client_->PictureReady(picture); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void GpuVideoDecodeAcceleratorHost::OnFlushDone() { | 273 void GpuVideoDecodeAcceleratorHost::OnFlushDone() { |
| 274 DCHECK(CalledOnValidThread()); | 274 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 275 if (client_) | 275 if (client_) |
| 276 client_->NotifyFlushDone(); | 276 client_->NotifyFlushDone(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void GpuVideoDecodeAcceleratorHost::OnResetDone() { | 279 void GpuVideoDecodeAcceleratorHost::OnResetDone() { |
| 280 DCHECK(CalledOnValidThread()); | 280 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 281 if (client_) | 281 if (client_) |
| 282 client_->NotifyResetDone(); | 282 client_->NotifyResetDone(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32_t error) { | 285 void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32_t error) { |
| 286 DCHECK(CalledOnValidThread()); | 286 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 287 if (!client_) | 287 if (!client_) |
| 288 return; | 288 return; |
| 289 weak_this_factory_.InvalidateWeakPtrs(); | 289 weak_this_factory_.InvalidateWeakPtrs(); |
| 290 | 290 |
| 291 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 291 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
| 292 // last thing done on this stack! | 292 // last thing done on this stack! |
| 293 VideoDecodeAccelerator::Client* client = nullptr; | 293 VideoDecodeAccelerator::Client* client = nullptr; |
| 294 std::swap(client, client_); | 294 std::swap(client, client_); |
| 295 client->NotifyError(static_cast<VideoDecodeAccelerator::Error>(error)); | 295 client->NotifyError(static_cast<VideoDecodeAccelerator::Error>(error)); |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace media | 298 } // namespace media |
| OLD | NEW |