Chromium Code Reviews| 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 "content/common/gpu/media/dxva_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
| 8 #error This file should only be built on Windows. | 8 #error This file should only be built on Windows. |
| 9 #endif // !defined(OS_WIN) | 9 #endif // !defined(OS_WIN) |
| 10 | 10 |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 int32 picture_buffer_id) { | 555 int32 picture_buffer_id) { |
| 556 DCHECK(CalledOnValidThread()); | 556 DCHECK(CalledOnValidThread()); |
| 557 | 557 |
| 558 RETURN_AND_NOTIFY_ON_FAILURE((state_ != kUninitialized), | 558 RETURN_AND_NOTIFY_ON_FAILURE((state_ != kUninitialized), |
| 559 "Invalid state: " << state_, ILLEGAL_STATE,); | 559 "Invalid state: " << state_, ILLEGAL_STATE,); |
| 560 | 560 |
| 561 if (output_picture_buffers_.empty()) | 561 if (output_picture_buffers_.empty()) |
| 562 return; | 562 return; |
| 563 | 563 |
| 564 OutputBuffers::iterator it = output_picture_buffers_.find(picture_buffer_id); | 564 OutputBuffers::iterator it = output_picture_buffers_.find(picture_buffer_id); |
| 565 RETURN_AND_NOTIFY_ON_FAILURE(it != output_picture_buffers_.end(), | 565 // If we didn't find the picture id in the |output_picture_buffers_| map we |
| 566 "Invalid picture id: " << picture_buffer_id, INVALID_ARGUMENT,); | 566 // try the |stale_output_picture_buffers_| map, as this may have been an |
| 567 // output picture buffer from before a resolution change, that at resolution | |
| 568 // change time had yet to be displayed. The client is calling us back to tell | |
| 569 // us that we can now recycle this picture buffer, so if we were waiting to | |
| 570 // dispose of it we now can. | |
| 571 if (it == output_picture_buffers_.end()) { | |
| 572 it = stale_output_picture_buffers_.find(picture_buffer_id); | |
| 573 RETURN_AND_NOTIFY_ON_FAILURE(it != stale_output_picture_buffers_.end(), | |
| 574 "Invalid picture id: " << picture_buffer_id, INVALID_ARGUMENT,); | |
| 575 DVLOG(1) << "Dismissing picture id: " << it->second->id(); | |
| 576 client_->DismissPictureBuffer(it->second->id()); | |
|
ananta
2014/09/04 21:15:51
Please do this in a task. This may cause problems
luken
2014/09/04 21:24:27
Done.
| |
| 577 stale_output_picture_buffers_.erase(it); | |
| 578 return; | |
| 579 } | |
| 567 | 580 |
| 568 it->second->ReusePictureBuffer(); | 581 it->second->ReusePictureBuffer(); |
| 569 ProcessPendingSamples(); | 582 ProcessPendingSamples(); |
| 570 | 583 |
| 571 if (state_ == kFlushing && pending_output_samples_.empty()) | 584 if (state_ == kFlushing && pending_output_samples_.empty()) |
| 572 FlushInternal(); | 585 FlushInternal(); |
| 573 } | 586 } |
| 574 | 587 |
| 575 void DXVAVideoDecodeAccelerator::Flush() { | 588 void DXVAVideoDecodeAccelerator::Flush() { |
| 576 DCHECK(CalledOnValidThread()); | 589 DCHECK(CalledOnValidThread()); |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 base::Bind(&DXVAVideoDecodeAccelerator::NotifyInputBufferRead, | 1178 base::Bind(&DXVAVideoDecodeAccelerator::NotifyInputBufferRead, |
| 1166 weak_this_factory_.GetWeakPtr(), | 1179 weak_this_factory_.GetWeakPtr(), |
| 1167 input_buffer_id)); | 1180 input_buffer_id)); |
| 1168 } | 1181 } |
| 1169 | 1182 |
| 1170 void DXVAVideoDecodeAccelerator::HandleResolutionChanged(int width, | 1183 void DXVAVideoDecodeAccelerator::HandleResolutionChanged(int width, |
| 1171 int height) { | 1184 int height) { |
| 1172 base::MessageLoop::current()->PostTask( | 1185 base::MessageLoop::current()->PostTask( |
| 1173 FROM_HERE, | 1186 FROM_HERE, |
| 1174 base::Bind(&DXVAVideoDecodeAccelerator::DismissStaleBuffers, | 1187 base::Bind(&DXVAVideoDecodeAccelerator::DismissStaleBuffers, |
| 1175 weak_this_factory_.GetWeakPtr(), | 1188 weak_this_factory_.GetWeakPtr())); |
| 1176 output_picture_buffers_)); | |
| 1177 | 1189 |
| 1178 base::MessageLoop::current()->PostTask( | 1190 base::MessageLoop::current()->PostTask( |
| 1179 FROM_HERE, | 1191 FROM_HERE, |
| 1180 base::Bind(&DXVAVideoDecodeAccelerator::RequestPictureBuffers, | 1192 base::Bind(&DXVAVideoDecodeAccelerator::RequestPictureBuffers, |
| 1181 weak_this_factory_.GetWeakPtr(), | 1193 weak_this_factory_.GetWeakPtr(), |
| 1182 width, | 1194 width, |
| 1183 height)); | 1195 height)); |
| 1196 } | |
| 1197 | |
| 1198 void DXVAVideoDecodeAccelerator::DismissStaleBuffers() { | |
| 1199 OutputBuffers::iterator index; | |
| 1200 | |
| 1201 for (index = output_picture_buffers_.begin(); | |
| 1202 index != output_picture_buffers_.end(); | |
| 1203 ++index) { | |
| 1204 if (index->second->available()) { | |
| 1205 DVLOG(1) << "Dismissing picture id: " << index->second->id(); | |
| 1206 client_->DismissPictureBuffer(index->second->id()); | |
| 1207 } else { | |
| 1208 // Move to |stale_output_picture_buffers_| for deferred deletion. | |
| 1209 stale_output_picture_buffers_.insert( | |
| 1210 std::make_pair(index->first, index->second)); | |
| 1211 } | |
| 1212 } | |
| 1184 | 1213 |
| 1185 output_picture_buffers_.clear(); | 1214 output_picture_buffers_.clear(); |
| 1186 } | 1215 } |
| 1187 | 1216 |
| 1188 void DXVAVideoDecodeAccelerator::DismissStaleBuffers( | |
| 1189 const OutputBuffers& picture_buffers) { | |
| 1190 OutputBuffers::const_iterator index; | |
| 1191 | |
| 1192 for (index = picture_buffers.begin(); | |
| 1193 index != picture_buffers.end(); | |
| 1194 ++index) { | |
| 1195 DVLOG(1) << "Dismissing picture id: " << index->second->id(); | |
| 1196 client_->DismissPictureBuffer(index->second->id()); | |
| 1197 } | |
| 1198 } | |
| 1199 | |
| 1200 } // namespace content | 1217 } // namespace content |
| OLD | NEW |