Fix improper cast from PipeWire portal to RequestResponse
When ScreencastPortal::OnStartRequestResponseSignal receives either a non-zero response code or is missing the response data, it would directly cast this to a RequestResponse. However, this direct cast is an error. Per the documentation, the response signal returns the following values with their corresponding meanings: 0 - Success 1 - User Cancelled 2 - Error The RequestResponse enum however, has "kUnknown" as 0, and thus "kSuccess" as 1 (with all other values also shifted up by 1 value). This means that when the portal was cancelled, we were still receiving RequestResponse::kSuccess. This fixes the issue by removing the improper cast and adding a translation function. This function is local for now since no where else attempted to cast values to a RequestResponse; but can be moved if the need arises. Fixed: chromium:1351824 Change-Id: I4cd44d90055147c9592d590c7969dcfc3297a3d9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/271240 Commit-Queue: Alexander Cooper <alcooper@chromium.org> Auto-Submit: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37755}
This commit is contained in:
parent
71434ae614
commit
ea20e95cdc
@ -30,6 +30,21 @@ using xdg_portal::SetupSessionRequestHandlers;
|
|||||||
using xdg_portal::StartSessionRequest;
|
using xdg_portal::StartSessionRequest;
|
||||||
using xdg_portal::TearDownSession;
|
using xdg_portal::TearDownSession;
|
||||||
|
|
||||||
|
RequestResponse ToRequestResponseFromSignal(uint32_t signal_response) {
|
||||||
|
// See:
|
||||||
|
// https://docs.flatpak.org/en/latest/portal-api-reference.html#gdbus-signal-org-freedesktop-portal-Request.Response
|
||||||
|
switch (signal_response) {
|
||||||
|
case 0:
|
||||||
|
return RequestResponse::kSuccess;
|
||||||
|
case 1:
|
||||||
|
return RequestResponse::kUserCancelled;
|
||||||
|
case 2:
|
||||||
|
return RequestResponse::kError;
|
||||||
|
default:
|
||||||
|
return RequestResponse::kUnknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ScreenCastPortal::ScreenCastPortal(
|
ScreenCastPortal::ScreenCastPortal(
|
||||||
@ -342,7 +357,7 @@ void ScreenCastPortal::OnStartRequestResponseSignal(GDBusConnection* connection,
|
|||||||
response_data.receive());
|
response_data.receive());
|
||||||
if (portal_response || !response_data) {
|
if (portal_response || !response_data) {
|
||||||
RTC_LOG(LS_ERROR) << "Failed to start the screen cast session.";
|
RTC_LOG(LS_ERROR) << "Failed to start the screen cast session.";
|
||||||
that->OnPortalDone(static_cast<RequestResponse>(portal_response));
|
that->OnPortalDone(ToRequestResponseFromSignal(portal_response));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user