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/filters/gpu_video_decoder.h" | 5 #include "media/filters/gpu_video_decoder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 size_t min_size) { | 694 size_t min_size) { |
695 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 695 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
696 if (available_shm_segments_.empty() || | 696 if (available_shm_segments_.empty() || |
697 available_shm_segments_.back()->size < min_size) { | 697 available_shm_segments_.back()->size < min_size) { |
698 size_t size_to_allocate = std::max(min_size, kSharedMemorySegmentBytes); | 698 size_t size_to_allocate = std::max(min_size, kSharedMemorySegmentBytes); |
699 std::unique_ptr<base::SharedMemory> shm = | 699 std::unique_ptr<base::SharedMemory> shm = |
700 factories_->CreateSharedMemory(size_to_allocate); | 700 factories_->CreateSharedMemory(size_to_allocate); |
701 // CreateSharedMemory() can return NULL during Shutdown. | 701 // CreateSharedMemory() can return NULL during Shutdown. |
702 if (!shm) | 702 if (!shm) |
703 return NULL; | 703 return NULL; |
704 return base::WrapUnique(new SHMBuffer(std::move(shm), size_to_allocate)); | 704 return base::MakeUnique<SHMBuffer>(std::move(shm), size_to_allocate); |
705 } | 705 } |
706 std::unique_ptr<SHMBuffer> ret(available_shm_segments_.back()); | 706 std::unique_ptr<SHMBuffer> ret(available_shm_segments_.back()); |
707 available_shm_segments_.pop_back(); | 707 available_shm_segments_.pop_back(); |
708 return ret; | 708 return ret; |
709 } | 709 } |
710 | 710 |
711 void GpuVideoDecoder::PutSHM(std::unique_ptr<SHMBuffer> shm_buffer) { | 711 void GpuVideoDecoder::PutSHM(std::unique_ptr<SHMBuffer> shm_buffer) { |
712 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 712 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
713 available_shm_segments_.push_back(shm_buffer.release()); | 713 available_shm_segments_.push_back(shm_buffer.release()); |
714 } | 714 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 } | 824 } |
825 return false; | 825 return false; |
826 } | 826 } |
827 | 827 |
828 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 828 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
829 const { | 829 const { |
830 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 830 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
831 } | 831 } |
832 | 832 |
833 } // namespace media | 833 } // namespace media |
OLD | NEW |