Commit 7ee85d62 authored by bbudge@chromium.org's avatar bbudge@chromium.org

Pepper: Change PPB_VideoDecoder::Reset behavior so plugin always manages textures.

Reset now will allow plugin to call RecyclePicture. The plugin must recycle any
texture it receives now. This makes plugin code simpler, since it can treat all
textures it receives in the same way (no special Reset handling).

Also fix a bug where Reset didn't return textures to the hardware decoder, which
already has this behavior.

BUG=281689

Review URL: https://codereview.chromium.org/390213002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283483 0039d316-1c4b-4281-b951-d872f2087c98
parent 11db6c2a
...@@ -269,8 +269,6 @@ int32_t PepperVideoDecoderHost::OnHostMsgRecyclePicture( ...@@ -269,8 +269,6 @@ int32_t PepperVideoDecoderHost::OnHostMsgRecyclePicture(
if (!initialized_) if (!initialized_)
return PP_ERROR_FAILED; return PP_ERROR_FAILED;
DCHECK(decoder_); DCHECK(decoder_);
if (reset_reply_context_.is_valid())
return PP_ERROR_FAILED;
decoder_->ReusePictureBuffer(texture_id); decoder_->ReusePictureBuffer(texture_id);
return PP_OK; return PP_OK;
......
...@@ -556,12 +556,6 @@ void VideoDecoderShim::OnResetComplete() { ...@@ -556,12 +556,6 @@ void VideoDecoderShim::OnResetComplete() {
// Dismiss any old textures now. // Dismiss any old textures now.
while (!textures_to_dismiss_.empty()) while (!textures_to_dismiss_.empty())
DismissTexture(*textures_to_dismiss_.begin()); DismissTexture(*textures_to_dismiss_.begin());
// Make all textures available.
for (TextureIdMap::const_iterator it = texture_id_map_.begin();
it != texture_id_map_.end();
++it) {
available_textures_.insert(it->first);
}
state_ = DECODING; state_ = DECODING;
host_->NotifyResetDone(); host_->NotifyResetDone();
......
...@@ -429,10 +429,6 @@ bool MyInstance::HandleInputEvent(const pp::InputEvent& event) { ...@@ -429,10 +429,6 @@ bool MyInstance::HandleInputEvent(const pp::InputEvent& event) {
if (!video_decoders_[i]->resetting()) if (!video_decoders_[i]->resetting())
video_decoders_[i]->Reset(); video_decoders_[i]->Reset();
} }
// Clear pending pictures.
while (!pending_pictures_.empty())
pending_pictures_.pop();
} }
return true; return true;
} }
......
...@@ -177,8 +177,8 @@ interface PPB_VideoDecoder { ...@@ -177,8 +177,8 @@ interface PPB_VideoDecoder {
* the decoder signals completion by running |callback|. Just before * the decoder signals completion by running |callback|. Just before
* completion, any pending GetPicture() call will complete by running its * completion, any pending GetPicture() call will complete by running its
* callback with result PP_ERROR_ABORTED to signal that no more pictures are * callback with result PP_ERROR_ABORTED to signal that no more pictures are
* available. The plugin should recycle any pictures it is using before * available. Any pictures held by the plugin remain valid during and after
* resuming decoding. * the flush and should be recycled back to the decoder.
* *
* @param[in] video_decoder A <code>PP_Resource</code> identifying the video * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
* decoder. * decoder.
...@@ -197,9 +197,10 @@ interface PPB_VideoDecoder { ...@@ -197,9 +197,10 @@ interface PPB_VideoDecoder {
* skip to another position in the video stream. After Reset() returns, any * skip to another position in the video stream. After Reset() returns, any
* pending calls to Decode() and GetPicture()) abort, causing their callbacks * pending calls to Decode() and GetPicture()) abort, causing their callbacks
* to run with PP_ERROR_ABORTED. The plugin should not make further calls to * to run with PP_ERROR_ABORTED. The plugin should not make further calls to
* the decoder until the decoder signals completion by running |callback|. * the decoder other than RecyclePicture() until the decoder signals
* The pictures in use by the plugin remain valid until decoding is resumed, * completion by running |callback|. Any pictures held by the plugin remain
* but need not be recycled. * valid during and after the reset and should be recycled back to the
* decoder.
* *
* @param[in] video_decoder A <code>PP_Resource</code> identifying the video * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
* decoder. * decoder.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
/* From ppb_video_decoder.idl modified Wed May 21 09:50:52 2014. */ /* From ppb_video_decoder.idl modified Fri Jul 11 18:06:37 2014. */
#ifndef PPAPI_C_PPB_VIDEO_DECODER_H_ #ifndef PPAPI_C_PPB_VIDEO_DECODER_H_
#define PPAPI_C_PPB_VIDEO_DECODER_H_ #define PPAPI_C_PPB_VIDEO_DECODER_H_
...@@ -180,8 +180,8 @@ struct PPB_VideoDecoder_0_1 { /* dev */ ...@@ -180,8 +180,8 @@ struct PPB_VideoDecoder_0_1 { /* dev */
* the decoder signals completion by running |callback|. Just before * the decoder signals completion by running |callback|. Just before
* completion, any pending GetPicture() call will complete by running its * completion, any pending GetPicture() call will complete by running its
* callback with result PP_ERROR_ABORTED to signal that no more pictures are * callback with result PP_ERROR_ABORTED to signal that no more pictures are
* available. The plugin should recycle any pictures it is using before * available. Any pictures held by the plugin remain valid during and after
* resuming decoding. * the flush and should be recycled back to the decoder.
* *
* @param[in] video_decoder A <code>PP_Resource</code> identifying the video * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
* decoder. * decoder.
...@@ -198,9 +198,10 @@ struct PPB_VideoDecoder_0_1 { /* dev */ ...@@ -198,9 +198,10 @@ struct PPB_VideoDecoder_0_1 { /* dev */
* skip to another position in the video stream. After Reset() returns, any * skip to another position in the video stream. After Reset() returns, any
* pending calls to Decode() and GetPicture()) abort, causing their callbacks * pending calls to Decode() and GetPicture()) abort, causing their callbacks
* to run with PP_ERROR_ABORTED. The plugin should not make further calls to * to run with PP_ERROR_ABORTED. The plugin should not make further calls to
* the decoder until the decoder signals completion by running |callback|. * the decoder other than RecyclePicture() until the decoder signals
* The pictures in use by the plugin remain valid until decoding is resumed, * completion by running |callback|. Any pictures held by the plugin remain
* but need not be recycled. * valid during and after the reset and should be recycled back to the
* decoder.
* *
* @param[in] video_decoder A <code>PP_Resource</code> identifying the video * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
* decoder. * decoder.
......
...@@ -149,8 +149,8 @@ class VideoDecoder : public Resource { ...@@ -149,8 +149,8 @@ class VideoDecoder : public Resource {
/// the decoder signals completion by running |callback|. Just before /// the decoder signals completion by running |callback|. Just before
/// completion, any pending GetPicture() call will complete by running its /// completion, any pending GetPicture() call will complete by running its
/// callback with result PP_ERROR_ABORTED to signal that no more pictures are /// callback with result PP_ERROR_ABORTED to signal that no more pictures are
/// available. The plugin should recycle any pictures it is using before /// available. Any pictures held by the plugin remain valid during and after
/// resuming decoding. /// the flush and should be recycled back to the decoder.
/// ///
/// @param[in] callback A <code>CompletionCallback</code> to be called on /// @param[in] callback A <code>CompletionCallback</code> to be called on
/// completion. /// completion.
...@@ -163,9 +163,10 @@ class VideoDecoder : public Resource { ...@@ -163,9 +163,10 @@ class VideoDecoder : public Resource {
/// skip to another position in the video stream. After Reset() returns, any /// skip to another position in the video stream. After Reset() returns, any
/// pending calls to Decode() and GetPicture()) abort, causing their callbacks /// pending calls to Decode() and GetPicture()) abort, causing their callbacks
/// to run with PP_ERROR_ABORTED. The plugin should not make further calls to /// to run with PP_ERROR_ABORTED. The plugin should not make further calls to
/// the decoder until the decoder signals completion by running |callback|. /// the decoder other than RecyclePicture() until the decoder signals
/// The pictures in use by the plugin remain valid until decoding is resumed, /// completion by running |callback|. Any pictures held by the plugin remain
/// but need not be recycled. /// valid during and after the reset and should be recycled back to the
/// decoder.
/// ///
/// @param[in] callback A <code>CompletionCallback</code> to be called on /// @param[in] callback A <code>CompletionCallback</code> to be called on
/// completion. /// completion.
......
...@@ -430,10 +430,6 @@ bool MyInstance::HandleInputEvent(const pp::InputEvent& event) { ...@@ -430,10 +430,6 @@ bool MyInstance::HandleInputEvent(const pp::InputEvent& event) {
if (!video_decoders_[i]->resetting()) if (!video_decoders_[i]->resetting())
video_decoders_[i]->Reset(); video_decoders_[i]->Reset();
} }
// Clear pending pictures.
while (!pending_pictures_.empty())
pending_pictures_.pop();
} }
return true; return true;
} }
......
...@@ -260,8 +260,6 @@ int32_t VideoDecoderResource::GetPicture( ...@@ -260,8 +260,6 @@ int32_t VideoDecoderResource::GetPicture(
void VideoDecoderResource::RecyclePicture(const PP_VideoPicture* picture) { void VideoDecoderResource::RecyclePicture(const PP_VideoPicture* picture) {
if (decoder_last_error_) if (decoder_last_error_)
return; return;
if (reset_callback_)
return;
Post(RENDERER, PpapiHostMsg_VideoDecoder_RecyclePicture(picture->texture_id)); Post(RENDERER, PpapiHostMsg_VideoDecoder_RecyclePicture(picture->texture_id));
} }
...@@ -471,9 +469,12 @@ void VideoDecoderResource::OnPluginMsgResetComplete( ...@@ -471,9 +469,12 @@ void VideoDecoderResource::OnPluginMsgResetComplete(
const ResourceMessageReplyParams& params) { const ResourceMessageReplyParams& params) {
// All shm buffers should have been made available by now. // All shm buffers should have been made available by now.
DCHECK_EQ(shm_buffers_.size(), available_shm_buffers_.size()); DCHECK_EQ(shm_buffers_.size(), available_shm_buffers_.size());
// Received pictures are no longer valid. // Recycle any pictures which haven't been passed to the plugin.
while (!received_pictures_.empty()) while (!received_pictures_.empty()) {
Post(RENDERER, PpapiHostMsg_VideoDecoder_RecyclePicture(
received_pictures_.front().texture_id));
received_pictures_.pop(); received_pictures_.pop();
}
scoped_refptr<TrackedCallback> callback; scoped_refptr<TrackedCallback> callback;
callback.swap(reset_callback_); callback.swap(reset_callback_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment