Chromium Code Reviews| Index: content/common/gpu/media/dxva_video_decode_accelerator.cc |
| diff --git a/content/common/gpu/media/dxva_video_decode_accelerator.cc b/content/common/gpu/media/dxva_video_decode_accelerator.cc |
| index 5f15f90e64654bfe1828231cee98fe7ba921c31b..7034864ad9ebf270321045e7c4145cbc5e1ed88d 100644 |
| --- a/content/common/gpu/media/dxva_video_decode_accelerator.cc |
| +++ b/content/common/gpu/media/dxva_video_decode_accelerator.cc |
| @@ -562,8 +562,21 @@ void DXVAVideoDecodeAccelerator::ReusePictureBuffer( |
| return; |
| OutputBuffers::iterator it = output_picture_buffers_.find(picture_buffer_id); |
| - RETURN_AND_NOTIFY_ON_FAILURE(it != output_picture_buffers_.end(), |
| - "Invalid picture id: " << picture_buffer_id, INVALID_ARGUMENT,); |
| + // If we didn't find the picture id in the |output_picture_buffers_| map we |
| + // try the |stale_output_picture_buffers_| map, as this may have been an |
| + // output picture buffer from before a resolution change, that at resolution |
| + // change time had yet to be displayed. The client is calling us back to tell |
| + // us that we can now recycle this picture buffer, so if we were waiting to |
| + // dispose of it we now can. |
| + if (it == output_picture_buffers_.end()) { |
| + it = stale_output_picture_buffers_.find(picture_buffer_id); |
| + RETURN_AND_NOTIFY_ON_FAILURE(it != stale_output_picture_buffers_.end(), |
| + "Invalid picture id: " << picture_buffer_id, INVALID_ARGUMENT,); |
| + DVLOG(1) << "Dismissing picture id: " << it->second->id(); |
| + 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.
|
| + stale_output_picture_buffers_.erase(it); |
| + return; |
| + } |
| it->second->ReusePictureBuffer(); |
| ProcessPendingSamples(); |
| @@ -1172,8 +1185,7 @@ void DXVAVideoDecodeAccelerator::HandleResolutionChanged(int width, |
| base::MessageLoop::current()->PostTask( |
| FROM_HERE, |
| base::Bind(&DXVAVideoDecodeAccelerator::DismissStaleBuffers, |
| - weak_this_factory_.GetWeakPtr(), |
| - output_picture_buffers_)); |
| + weak_this_factory_.GetWeakPtr())); |
| base::MessageLoop::current()->PostTask( |
| FROM_HERE, |
| @@ -1181,20 +1193,25 @@ void DXVAVideoDecodeAccelerator::HandleResolutionChanged(int width, |
| weak_this_factory_.GetWeakPtr(), |
| width, |
| height)); |
| - |
| - output_picture_buffers_.clear(); |
| } |
| -void DXVAVideoDecodeAccelerator::DismissStaleBuffers( |
| - const OutputBuffers& picture_buffers) { |
| - OutputBuffers::const_iterator index; |
| +void DXVAVideoDecodeAccelerator::DismissStaleBuffers() { |
| + OutputBuffers::iterator index; |
| - for (index = picture_buffers.begin(); |
| - index != picture_buffers.end(); |
| + for (index = output_picture_buffers_.begin(); |
| + index != output_picture_buffers_.end(); |
| ++index) { |
| - DVLOG(1) << "Dismissing picture id: " << index->second->id(); |
| - client_->DismissPictureBuffer(index->second->id()); |
| + if (index->second->available()) { |
| + DVLOG(1) << "Dismissing picture id: " << index->second->id(); |
| + client_->DismissPictureBuffer(index->second->id()); |
| + } else { |
| + // Move to |stale_output_picture_buffers_| for deferred deletion. |
| + stale_output_picture_buffers_.insert( |
| + std::make_pair(index->first, index->second)); |
| + } |
| } |
| + |
| + output_picture_buffers_.clear(); |
| } |
| } // namespace content |