Don't recreate decoders if only fps changes
This commit is contained in:
+31
-12
@@ -935,6 +935,37 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
|
||||
{
|
||||
std::unique_lock lock(decoder_mutex);
|
||||
|
||||
if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
|
||||
{
|
||||
try
|
||||
{
|
||||
session.set_refresh_rate(description.fps);
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
if (std::ranges::equal(description.items, video_stream_description->items, [](const auto & a, const auto & b) {
|
||||
// clang-format off
|
||||
return a.width == b.width
|
||||
and a.height == b.height
|
||||
and a.video_width == b.video_width
|
||||
and a.offset_x == b.offset_x
|
||||
and a.offset_y == b.offset_y
|
||||
and a.codec == b.codec
|
||||
and a.channels == b.channels
|
||||
and a.subsampling == b.subsampling
|
||||
and a.range == b.range
|
||||
and a.color_model == b.color_model;
|
||||
//clang-format on
|
||||
}))
|
||||
{
|
||||
video_stream_description = description;
|
||||
return;
|
||||
}
|
||||
|
||||
decoders.clear();
|
||||
|
||||
if (description.items.empty())
|
||||
@@ -1048,18 +1079,6 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
|
||||
});
|
||||
}
|
||||
|
||||
if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
|
||||
{
|
||||
try
|
||||
{
|
||||
session.set_refresh_rate(description.fps);
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto & [stream_index, item]: utils::enumerate(description.items))
|
||||
{
|
||||
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);
|
||||
|
||||
@@ -738,7 +738,6 @@ static xrt_result_t comp_wivrn_request_refresh_rate(struct comp_target * ct, flo
|
||||
auto from = cn->desc.fps;
|
||||
cn->desc.fps = refresh_rate_hz;
|
||||
cn->pacer.set_frame_duration(U_TIME_1S_IN_NS / refresh_rate_hz);
|
||||
cn->cnx.send_control(decltype(cn->desc)(cn->desc));
|
||||
cn->cnx.push_event(
|
||||
{
|
||||
.display = {
|
||||
@@ -747,7 +746,7 @@ static xrt_result_t comp_wivrn_request_refresh_rate(struct comp_target * ct, flo
|
||||
.to_display_refresh_rate_hz = refresh_rate_hz,
|
||||
},
|
||||
});
|
||||
cn->reset_encoders();
|
||||
cn->cnx.send_control(to_headset::video_stream_description{cn->desc});
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user