Skip to content

Commit

Permalink
Retry capture on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
nowrep authored and ammen99 committed Aug 9, 2023
1 parent f679b51 commit 4c62832
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ static void frame_handle_ready(void *, struct zwlr_screencopy_frame_v1 *,

static void frame_handle_failed(void *, struct zwlr_screencopy_frame_v1 *) {
std::cerr << "Failed to copy frame, retrying..." << std::endl;
buffer_copy_done = true;
++frame_failed_cnt;
request_next_frame();
if (frame_failed_cnt > MAX_FRAME_FAILURES)
{
std::cerr << "Failed to copy frame too many times, exiting!" << std::endl;
Expand Down Expand Up @@ -548,12 +548,12 @@ static void write_loop(FrameWriterParams params)
buffer.base_usec, buffer.y_invert);
}

frame_writer_mutex.unlock();

if (!do_cont) {
break;
}

frame_writer_mutex.unlock();

buffer.available = false;
buffer.released = true;

Expand Down Expand Up @@ -1212,7 +1212,10 @@ int main(int argc, char *argv[])
active_buffer = next_frame(active_buffer);
}

writer_thread.join();
if (writer_thread.joinable())
{
writer_thread.join();
}

for (auto& buffer : buffers)
{
Expand Down

0 comments on commit 4c62832

Please sign in to comment.