| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/renderer_host/media/video_capture_buffer_pool.h" | 5 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // potentially modify the content). Check that the expected dimensions, | 367 // potentially modify the content). Check that the expected dimensions, |
| 368 // format, and storage match. | 368 // format, and storage match. |
| 369 TrackerMap::iterator it = trackers_.find(last_relinquished_buffer_id_); | 369 TrackerMap::iterator it = trackers_.find(last_relinquished_buffer_id_); |
| 370 DCHECK(it != trackers_.end()); | 370 DCHECK(it != trackers_.end()); |
| 371 DCHECK(!it->second->held_by_producer()); | 371 DCHECK(!it->second->held_by_producer()); |
| 372 if (it->second->consumer_hold_count() == 0 && | 372 if (it->second->consumer_hold_count() == 0 && |
| 373 it->second->dimensions() == dimensions && | 373 it->second->dimensions() == dimensions && |
| 374 it->second->pixel_format() == format && | 374 it->second->pixel_format() == format && |
| 375 it->second->storage_type() == storage) { | 375 it->second->storage_type() == storage) { |
| 376 it->second->set_held_by_producer(true); | 376 it->second->set_held_by_producer(true); |
| 377 return last_relinquished_buffer_id_; | 377 const int resurrected_buffer_id = last_relinquished_buffer_id_; |
| 378 last_relinquished_buffer_id_ = kInvalidId; |
| 379 return resurrected_buffer_id; |
| 378 } | 380 } |
| 379 | 381 |
| 380 return kInvalidId; | 382 return kInvalidId; |
| 381 } | 383 } |
| 382 | 384 |
| 383 double VideoCaptureBufferPool::GetBufferPoolUtilization() const { | 385 double VideoCaptureBufferPool::GetBufferPoolUtilization() const { |
| 384 base::AutoLock lock(lock_); | 386 base::AutoLock lock(lock_); |
| 385 int num_buffers_held = 0; | 387 int num_buffers_held = 0; |
| 386 for (const auto& entry : trackers_) { | 388 for (const auto& entry : trackers_) { |
| 387 Tracker* const tracker = entry.second; | 389 Tracker* const tracker = entry.second; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 return buffer_id; | 471 return buffer_id; |
| 470 } | 472 } |
| 471 | 473 |
| 472 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( | 474 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( |
| 473 int buffer_id) { | 475 int buffer_id) { |
| 474 TrackerMap::const_iterator it = trackers_.find(buffer_id); | 476 TrackerMap::const_iterator it = trackers_.find(buffer_id); |
| 475 return (it == trackers_.end()) ? NULL : it->second; | 477 return (it == trackers_.end()) ? NULL : it->second; |
| 476 } | 478 } |
| 477 | 479 |
| 478 } // namespace content | 480 } // namespace content |
| OLD | NEW |