mirror of
https://github.com/WiVRn/WiVRn.git
synced 2026-11-21 01:21:38 -08:00
Return to lobby when the video is stalled
This commit is contained in:
1 parent
554b62e643
commit
8d408c0792
5 files changed
+28
-12
No files matched your search
@@ -526,7 +526,7 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render)
|
||||
{
|
||||
if (!next_scene->alive())
|
||||
next_scene.reset();
|
||||
else if (next_scene->ready())
|
||||
else if (next_scene->current_state() == scenes::stream::state::streaming)
|
||||
application::push_scene(next_scene);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "imgui_internal.h"
|
||||
#include "lobby.h"
|
||||
#include "version.h"
|
||||
#include "stream.h"
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
#include <utils/strings.h>
|
||||
|
||||
@@ -71,7 +72,12 @@ void scenes::lobby::gui_connecting()
|
||||
|
||||
std::string status;
|
||||
if (next_scene)
|
||||
status = "Waiting for video stream";
|
||||
{
|
||||
if (next_scene->current_state() == scenes::stream::state::stalled)
|
||||
status = "Video stream interrupted";
|
||||
else
|
||||
status = "Waiting for video stream";
|
||||
}
|
||||
else if (async_session.valid())
|
||||
status = async_session.get_progress();
|
||||
else if (async_error)
|
||||
|
||||
@@ -230,11 +230,11 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
|
||||
}
|
||||
}
|
||||
|
||||
if (!ready_ && std::all_of(decoders.begin(), decoders.end(), [](accumulator_images & i) {
|
||||
if (state_ != state::streaming && std::all_of(decoders.begin(), decoders.end(), [](accumulator_images & i) {
|
||||
return i.latest_frames.back();
|
||||
}))
|
||||
{
|
||||
ready_ = true;
|
||||
state_ = state::streaming;
|
||||
first_frame_time = application::now();
|
||||
spdlog::info("Stream scene ready at t={}", first_frame_time);
|
||||
}
|
||||
@@ -465,6 +465,9 @@ void scenes::stream::render(XrTime predicted_display_time, bool should_render)
|
||||
return;
|
||||
}
|
||||
|
||||
if (state_ == state::stalled)
|
||||
application::pop_scene();
|
||||
|
||||
session.begin_frame();
|
||||
|
||||
auto [flags, views] = session.locate_views(viewconfig, predicted_display_time, world_space);
|
||||
|
||||
+12
-4
@@ -35,6 +35,15 @@ namespace scenes
|
||||
{
|
||||
class stream : public scene_impl<stream>, public std::enable_shared_from_this<stream>
|
||||
{
|
||||
public:
|
||||
enum class state
|
||||
{
|
||||
initializing,
|
||||
streaming,
|
||||
stalled
|
||||
};
|
||||
|
||||
private:
|
||||
static const size_t view_count = 2;
|
||||
|
||||
using stream_description = xrt::drivers::wivrn::to_headset::video_stream_description::item;
|
||||
@@ -79,8 +88,7 @@ class stream : public scene_impl<stream>, public std::enable_shared_from_this<st
|
||||
std::array<std::pair<XrAction, XrPath>, 2> haptics_actions;
|
||||
std::vector<std::tuple<device_id, XrAction, XrActionType>> input_actions;
|
||||
|
||||
bool ready_ = false;
|
||||
bool video_started_ = false;
|
||||
state state_ = state::initializing;
|
||||
XrTime first_frame_time{};
|
||||
const float dbrightness = 2;
|
||||
bool show_performance_metrics = false;
|
||||
@@ -116,9 +124,9 @@ public:
|
||||
|
||||
void send_feedback(const xrt::drivers::wivrn::from_headset::feedback & feedback);
|
||||
|
||||
bool ready() const
|
||||
state current_state() const
|
||||
{
|
||||
return ready_;
|
||||
return state_ ;
|
||||
}
|
||||
|
||||
bool alive() const
|
||||
|
||||
@@ -27,9 +27,9 @@ void scenes::stream::process_packets()
|
||||
{
|
||||
try
|
||||
{
|
||||
int n = network_session->poll(*this, std::chrono::milliseconds(5000));
|
||||
if (n == 0 && video_started_)
|
||||
throw std::runtime_error("Timeout waiting for network packets");
|
||||
int n = network_session->poll(*this, std::chrono::milliseconds(500));
|
||||
if (n == 0 && state_ == state::streaming)
|
||||
state_ = state::stalled;
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
@@ -41,7 +41,6 @@ void scenes::stream::process_packets()
|
||||
|
||||
void scenes::stream::operator()(to_headset::video_stream_data_shard && shard)
|
||||
{
|
||||
video_started_ = true;
|
||||
shard_queue.push(std::move(shard));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user