diff --git a/client/decoder/android/android_decoder.cpp b/client/decoder/android/android_decoder.cpp index 22e41533..b1ca1616 100644 --- a/client/decoder/android/android_decoder.cpp +++ b/client/decoder/android/android_decoder.cpp @@ -140,7 +140,7 @@ decoder::decoder( // latency mode AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, width); AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_HEIGHT, height); - AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(description.fps)); + AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(description.frame_rate)); AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_PRIORITY, 0); media_codec.reset(AMediaCodec_createDecoderByType(mime(description.codec[stream_index]))); diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index 70af6748..6884d36d 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -1165,7 +1165,7 @@ void scenes::stream::exit() void scenes::stream::setup(const to_headset::video_stream_description & description) { - session.set_refresh_rate(description.fps); + session.set_refresh_rate(description.refresh_rate); std::unique_lock lock(decoder_mutex); if (video_stream_description == description) @@ -1189,7 +1189,7 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint assert(swapchain_width); assert(swapchain_height); device.waitIdle(); - session.set_refresh_rate(video_stream_description->fps); + session.set_refresh_rate(video_stream_description->refresh_rate); auto views = system.view_configuration_views(viewconfig); diff --git a/client/scenes/stream_network.cpp b/client/scenes/stream_network.cpp index 5fa2ee67..ec74f0d2 100644 --- a/client/scenes/stream_network.cpp +++ b/client/scenes/stream_network.cpp @@ -111,10 +111,10 @@ void scenes::stream::operator()(to_headset::video_stream_description && desc) void scenes::stream::operator()(to_headset::refresh_rate_change && rate) { - session.set_refresh_rate(rate.fps); + session.set_refresh_rate(rate.hz); std::shared_lock lock(decoder_mutex); if (video_stream_description) - video_stream_description->fps = rate.fps; + video_stream_description->refresh_rate = rate.hz; } void scenes::stream::operator()(to_headset::stream_tab_change && tab) diff --git a/common/wivrn_packets.h b/common/wivrn_packets.h index 348270be..8a01f2c7 100644 --- a/common/wivrn_packets.h +++ b/common/wivrn_packets.h @@ -678,7 +678,8 @@ struct video_stream_description uint16_t width; uint16_t height; std::array codec; // left, right, alpha - float fps; + float frame_rate; + float refresh_rate; bool operator==(const video_stream_description &) const = default; }; @@ -765,7 +766,7 @@ struct feature_control struct refresh_rate_change { - float fps; + float hz; }; struct stream_tab_change diff --git a/server/compositor/compositor.cpp b/server/compositor/compositor.cpp index 06386d98..571fc9a7 100644 --- a/server/compositor/compositor.cpp +++ b/server/compositor/compositor.cpp @@ -550,7 +550,7 @@ xrt_result_t compositor::request_display_refresh_rate(float hz) try { requested_refresh_rate = hz; - session.send_control(to_headset::refresh_rate_change{.fps = hz}); + session.send_control(to_headset::refresh_rate_change{.hz = hz}); } catch (std::exception & e) { @@ -641,8 +641,9 @@ void compositor::send_video_stream_description() to_headset::video_stream_description desc{ .width = uint16_t(images[0].image.info().extent.width), .height = uint16_t(images[0].image.info().extent.height), - .fps = settings[0].fps, + .frame_rate = settings[0].fps, }; + get_display_refresh_rate(&desc.refresh_rate); static_assert(std::tuple_size_v == std::tuple_size_v); std::ranges::transform(settings, desc.codec.begin(), &encoder_settings::codec); session.send_control(std::move(desc)); diff --git a/server/driver/wivrn_session.cpp b/server/driver/wivrn_session.cpp index 2a40e13d..8eb2f52f 100644 --- a/server/driver/wivrn_session.cpp +++ b/server/driver/wivrn_session.cpp @@ -401,9 +401,10 @@ void wivrn_session::resume_session() if (target_fps != current_fps) { + auto s = settings.lock(); (*this)(from_headset::refresh_rate_changed{ - .from = current_fps, - .to = target_fps, + .from = current_fps * s->fps_divider, + .to = target_fps * s->fps_divider, }); } } @@ -964,7 +965,7 @@ struct refresh_rate_adjuster if (requested != last) { U_LOG_I("requesting refresh rate: %.0f (app rate %.1f)", requested, app_rate); - cnx.send_control(to_headset::refresh_rate_change{.fps = requested}); + cnx.send_control(to_headset::refresh_rate_change{.hz = requested}); last = requested; } }