| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/renderer/pepper/pepper_video_decoder_host.h" | 5 #include "content/renderer/pepper/pepper_video_decoder_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if (shm_id >= ppapi::proxy::kMaximumPendingDecodes) | 189 if (shm_id >= ppapi::proxy::kMaximumPendingDecodes) |
| 190 return PP_ERROR_FAILED; | 190 return PP_ERROR_FAILED; |
| 191 // The shm_id must be inside or at the end of shm_buffers_. | 191 // The shm_id must be inside or at the end of shm_buffers_. |
| 192 if (shm_id > shm_buffers_.size()) | 192 if (shm_id > shm_buffers_.size()) |
| 193 return PP_ERROR_FAILED; | 193 return PP_ERROR_FAILED; |
| 194 // Reject an attempt to reallocate a busy shm buffer. | 194 // Reject an attempt to reallocate a busy shm buffer. |
| 195 if (shm_id < shm_buffers_.size() && shm_buffer_busy_[shm_id]) | 195 if (shm_id < shm_buffers_.size() && shm_buffer_busy_[shm_id]) |
| 196 return PP_ERROR_FAILED; | 196 return PP_ERROR_FAILED; |
| 197 | 197 |
| 198 content::RenderThread* render_thread = content::RenderThread::Get(); | 198 content::RenderThread* render_thread = content::RenderThread::Get(); |
| 199 scoped_ptr<base::SharedMemory> shm( | 199 std::unique_ptr<base::SharedMemory> shm( |
| 200 render_thread->HostAllocateSharedMemoryBuffer(shm_size)); | 200 render_thread->HostAllocateSharedMemoryBuffer(shm_size)); |
| 201 if (!shm || !shm->Map(shm_size)) | 201 if (!shm || !shm->Map(shm_size)) |
| 202 return PP_ERROR_FAILED; | 202 return PP_ERROR_FAILED; |
| 203 | 203 |
| 204 base::SharedMemoryHandle shm_handle = shm->handle(); | 204 base::SharedMemoryHandle shm_handle = shm->handle(); |
| 205 if (shm_id == shm_buffers_.size()) { | 205 if (shm_id == shm_buffers_.size()) { |
| 206 shm_buffers_.push_back(shm.release()); | 206 shm_buffers_.push_back(shm.release()); |
| 207 shm_buffer_busy_.push_back(false); | 207 shm_buffer_busy_.push_back(false); |
| 208 } else { | 208 } else { |
| 209 // Remove the old buffer. Delete manually since ScopedVector won't delete | 209 // Remove the old buffer. Delete manually since ScopedVector won't delete |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 474 |
| 475 bool PepperVideoDecoderHost::TryFallbackToSoftwareDecoder() { | 475 bool PepperVideoDecoderHost::TryFallbackToSoftwareDecoder() { |
| 476 #if defined(OS_ANDROID) | 476 #if defined(OS_ANDROID) |
| 477 return false; | 477 return false; |
| 478 #else | 478 #else |
| 479 DCHECK(!software_fallback_used_ && software_fallback_allowed_); | 479 DCHECK(!software_fallback_used_ && software_fallback_allowed_); |
| 480 | 480 |
| 481 uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1; | 481 uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1; |
| 482 shim_texture_pool_size = std::max(shim_texture_pool_size, | 482 shim_texture_pool_size = std::max(shim_texture_pool_size, |
| 483 min_picture_count_); | 483 min_picture_count_); |
| 484 scoped_ptr<VideoDecoderShim> new_decoder( | 484 std::unique_ptr<VideoDecoderShim> new_decoder( |
| 485 new VideoDecoderShim(this, shim_texture_pool_size)); | 485 new VideoDecoderShim(this, shim_texture_pool_size)); |
| 486 if (!new_decoder->Initialize(profile_, this)) | 486 if (!new_decoder->Initialize(profile_, this)) |
| 487 return false; | 487 return false; |
| 488 | 488 |
| 489 software_fallback_used_ = true; | 489 software_fallback_used_ = true; |
| 490 decoder_.reset(new_decoder.release()); | 490 decoder_.reset(new_decoder.release()); |
| 491 | 491 |
| 492 // Dismiss all assigned pictures and mark all pictures in use as DISMISSED. | 492 // Dismiss all assigned pictures and mark all pictures in use as DISMISSED. |
| 493 PictureBufferMap pictures_pending_dismission; | 493 PictureBufferMap pictures_pending_dismission; |
| 494 for (auto& picture : picture_buffer_map_) { | 494 for (auto& picture : picture_buffer_map_) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 533 |
| 534 PepperVideoDecoderHost::PendingDecodeList::iterator | 534 PepperVideoDecoderHost::PendingDecodeList::iterator |
| 535 PepperVideoDecoderHost::GetPendingDecodeById(int32_t decode_id) { | 535 PepperVideoDecoderHost::GetPendingDecodeById(int32_t decode_id) { |
| 536 return std::find_if(pending_decodes_.begin(), pending_decodes_.end(), | 536 return std::find_if(pending_decodes_.begin(), pending_decodes_.end(), |
| 537 [decode_id](const PendingDecode& item) { | 537 [decode_id](const PendingDecode& item) { |
| 538 return item.decode_id == decode_id; | 538 return item.decode_id == decode_id; |
| 539 }); | 539 }); |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace content | 542 } // namespace content |
| OLD | NEW |