Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linux): add frame processing latency and logging improvements #2502

Merged
merged 5 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ namespace audio {
opus_multistream_encoder_ctl(opus.get(), OPUS_SET_BITRATE(stream->bitrate));
opus_multistream_encoder_ctl(opus.get(), OPUS_SET_VBR(0));

BOOST_LOG(info) << "Opus initialized: "sv << stream->sampleRate / 1000 << " kHz, "sv
<< stream->channelCount << " channels, "sv
<< stream->bitrate / 1000 << " kbps (total), LOWDELAY"sv;

auto frame_size = config.packetDuration * stream->sampleRate / 1000;
while (auto sample = samples->pop()) {
buffer_t packet { 1400 };
Expand Down
4 changes: 3 additions & 1 deletion src/platform/linux/kmsgrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,9 @@ namespace platf {
if (!fb->handles[0]) {
BOOST_LOG(error) << "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Probably not permitted"sv;
BOOST_LOG((window_system != window_system_e::X11 || config::video.capture == "kms") ? fatal : error)
<< "You must run [sudo setcap cap_sys_admin+p $(readlink -f $(which sunshine))] for KMS display capture to work!"sv;
<< "You must run [sudo setcap cap_sys_admin+p $(readlink -f $(which sunshine))] for KMS display capture to work!\n"sv
<< "If you installed from AppImage or Flatpak, please refer to the official documentation:\n"sv
<< "https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/setup.html#install"sv;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/platform/linux/vaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ namespace va {
return -1;
}

BOOST_LOG(debug) << "vaapi vendor: "sv << vaQueryVendorString(display.get());
BOOST_LOG(info) << "vaapi vendor: "sv << vaQueryVendorString(display.get());

*hw_device_buf = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI);
auto ctx = (AVHWDeviceContext *) (*hw_device_buf)->data;
Expand Down
2 changes: 2 additions & 0 deletions src/platform/linux/x11grab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@
}
else {
auto img_cookie = xcb::shm_get_image_unchecked(xcb.get(), display->root, offset_x, offset_y, width, height, ~0, XCB_IMAGE_FORMAT_Z_PIXMAP, seg, 0);
auto frame_timestamp = std::chrono::steady_clock::now();

Check warning on line 682 in src/platform/linux/x11grab.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/linux/x11grab.cpp#L682

Added line #L682 was not covered by tests

xcb_img_t img_reply { xcb::shm_get_image_reply(xcb.get(), img_cookie, nullptr) };
if (!img_reply) {
Expand All @@ -691,6 +692,7 @@
}

std::copy_n((std::uint8_t *) data.data, frame_size(), img_out->data);
img_out->frame_timestamp = frame_timestamp;

if (cursor) {
blend_cursor(shm_xdisplay.get(), *img_out, offset_x, offset_y);
Expand Down
4 changes: 4 additions & 0 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,10 @@ namespace video {
return ret;
}

if (av_packet->flags & AV_PKT_FLAG_KEY) {
BOOST_LOG(debug) << "Frame "sv << frame_nr << ": IDR Keyframe (AV_FRAME_FLAG_KEY)"sv;
}

if ((frame->flags & AV_FRAME_FLAG_KEY) && !(av_packet->flags & AV_PKT_FLAG_KEY)) {
BOOST_LOG(error) << "Encoder did not produce IDR frame when requested!"sv;
}
Expand Down
Loading