virtio: video: encoder: set frame rate only if successfully changed

Encoders Stream's frame rate was updated before a request was made.
This could cause hypervisor to report incorrect frame rate to guest and other
invalid behaviour if the request failed.

This CL changes the order in which frame rate is updated. First a
request is made, and then if successful, the frame rate is updated in
the stream structure.

BUG=b:160440787
BUG=b:161774071
TEST=v4l2-compliance -d /dev/video1
TEST=v4l2-ctl -d 1 --set-fmt-video-out
width=1280,height=1280,pixelformat=NV12 \
        --set-output-parm 10 --get-output-parm
        TEST=tast run eve arc.Video*

Change-Id: I11a93d6d6338829ee0622f40f9b544a4ef2a69dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3425362
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
This commit is contained in:
Bartłomiej Grzesik 2022-01-31 13:00:34 +00:00 committed by Commit Bot
parent 2bbbe1184a
commit 73072d6d16

View file

@ -1038,8 +1038,6 @@ impl<T: Encoder> EncoderDevice<T> {
// active we will request a dynamic framerate change instead, and it's up to the encoder
// backend to return an error on invalid requests.
if stream.dst_params.frame_rate != frame_rate {
stream.src_params.frame_rate = frame_rate;
stream.dst_params.frame_rate = frame_rate;
if let Some(ref mut encoder_session) = stream.encoder_session {
if !resources_queued {
create_session = true;
@ -1051,6 +1049,8 @@ impl<T: Encoder> EncoderDevice<T> {
return Err(VideoError::InvalidOperation);
}
}
stream.src_params.frame_rate = frame_rate;
stream.dst_params.frame_rate = frame_rate;
}
match queue_type {