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/debug/trace_event.h" | 6 #include "base/debug/trace_event.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 Display* x_display, | 239 Display* x_display, |
240 Client* client, | 240 Client* client, |
241 const base::Callback<bool(void)>& make_context_current) | 241 const base::Callback<bool(void)>& make_context_current) |
242 : x_display_(x_display), | 242 : x_display_(x_display), |
243 make_context_current_(make_context_current), | 243 make_context_current_(make_context_current), |
244 state_(kUninitialized), | 244 state_(kUninitialized), |
245 input_ready_(&lock_), | 245 input_ready_(&lock_), |
246 surfaces_available_(&lock_), | 246 surfaces_available_(&lock_), |
247 message_loop_(base::MessageLoop::current()), | 247 message_loop_(base::MessageLoop::current()), |
248 weak_this_(base::AsWeakPtr(this)), | 248 weak_this_(base::AsWeakPtr(this)), |
| 249 va_surface_release_cb_(media::BindToCurrentLoop(base::Bind( |
| 250 &VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_))), |
249 client_ptr_factory_(client), | 251 client_ptr_factory_(client), |
250 client_(client_ptr_factory_.GetWeakPtr()), | 252 client_(client_ptr_factory_.GetWeakPtr()), |
251 decoder_thread_("VaapiDecoderThread"), | 253 decoder_thread_("VaapiDecoderThread"), |
252 num_frames_at_client_(0), | 254 num_frames_at_client_(0), |
253 num_stream_bufs_at_decoder_(0), | 255 num_stream_bufs_at_decoder_(0), |
254 finish_flush_pending_(false), | 256 finish_flush_pending_(false), |
255 awaiting_va_surfaces_recycle_(false), | 257 awaiting_va_surfaces_recycle_(false), |
256 requested_num_pics_(0) { | 258 requested_num_pics_(0) { |
257 DCHECK(client); | 259 DCHECK(client); |
258 } | 260 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 base::Bind(&ReportToUMA, content::VaapiH264Decoder::VAAPI_ERROR)); | 313 base::Bind(&ReportToUMA, content::VaapiH264Decoder::VAAPI_ERROR)); |
312 | 314 |
313 if (!vaapi_wrapper_.get()) { | 315 if (!vaapi_wrapper_.get()) { |
314 DVLOG(1) << "Failed initializing VAAPI"; | 316 DVLOG(1) << "Failed initializing VAAPI"; |
315 return false; | 317 return false; |
316 } | 318 } |
317 | 319 |
318 decoder_.reset( | 320 decoder_.reset( |
319 new VaapiH264Decoder( | 321 new VaapiH264Decoder( |
320 vaapi_wrapper_.get(), | 322 vaapi_wrapper_.get(), |
321 media::BindToLoop(message_loop_->message_loop_proxy(), base::Bind( | 323 media::BindToCurrentLoop(base::Bind( |
322 &VaapiVideoDecodeAccelerator::SurfaceReady, weak_this_)), | 324 &VaapiVideoDecodeAccelerator::SurfaceReady, weak_this_)), |
323 base::Bind(&ReportToUMA))); | 325 base::Bind(&ReportToUMA))); |
324 | 326 |
325 CHECK(decoder_thread_.Start()); | 327 CHECK(decoder_thread_.Start()); |
326 | 328 |
327 state_ = kIdle; | 329 state_ = kIdle; |
328 | 330 |
329 message_loop_->PostTask(FROM_HERE, base::Bind( | 331 message_loop_->PostTask(FROM_HERE, base::Bind( |
330 &Client::NotifyInitializeDone, client_)); | 332 &Client::NotifyInitializeDone, client_)); |
331 return true; | 333 return true; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 503 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
502 | 504 |
503 while (available_va_surfaces_.empty() && | 505 while (available_va_surfaces_.empty() && |
504 (state_ == kDecoding || state_ == kFlushing || state_ == kIdle)) { | 506 (state_ == kDecoding || state_ == kFlushing || state_ == kIdle)) { |
505 surfaces_available_.Wait(); | 507 surfaces_available_.Wait(); |
506 } | 508 } |
507 | 509 |
508 if (state_ != kDecoding && state_ != kFlushing && state_ != kIdle) | 510 if (state_ != kDecoding && state_ != kFlushing && state_ != kIdle) |
509 return false; | 511 return false; |
510 | 512 |
511 VASurface::ReleaseCB va_surface_release_cb = | |
512 media::BindToLoop(message_loop_->message_loop_proxy(), base::Bind( | |
513 &VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_)); | |
514 | |
515 while (!available_va_surfaces_.empty()) { | 513 while (!available_va_surfaces_.empty()) { |
516 scoped_refptr<VASurface> va_surface( | 514 scoped_refptr<VASurface> va_surface( |
517 new VASurface(available_va_surfaces_.front(), va_surface_release_cb)); | 515 new VASurface(available_va_surfaces_.front(), va_surface_release_cb_)); |
518 available_va_surfaces_.pop_front(); | 516 available_va_surfaces_.pop_front(); |
519 decoder_->ReuseSurface(va_surface); | 517 decoder_->ReuseSurface(va_surface); |
520 } | 518 } |
521 | 519 |
522 return true; | 520 return true; |
523 } | 521 } |
524 | 522 |
525 void VaapiVideoDecodeAccelerator::DecodeTask() { | 523 void VaapiVideoDecodeAccelerator::DecodeTask() { |
526 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 524 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
527 TRACE_EVENT0("Video Decoder", "VAVDA::DecodeTask"); | 525 TRACE_EVENT0("Video Decoder", "VAVDA::DecodeTask"); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 state_ = kUninitialized; | 920 state_ = kUninitialized; |
923 } | 921 } |
924 | 922 |
925 void VaapiVideoDecodeAccelerator::Destroy() { | 923 void VaapiVideoDecodeAccelerator::Destroy() { |
926 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 924 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
927 Cleanup(); | 925 Cleanup(); |
928 delete this; | 926 delete this; |
929 } | 927 } |
930 | 928 |
931 } // namespace content | 929 } // namespace content |
OLD | NEW |