From cbe88691df89082ef621498ede2ee2a34a6a1a6b Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Fri, 21 Oct 2022 11:43:47 +0800 Subject: [PATCH] fix: samsung error stack corruption detected --- include/QtScrcpyCoreDef.h | 2 +- src/device/server/server.cpp | 41 ++++++++++++++++++++++++------------ src/device/server/server.h | 2 +- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/include/QtScrcpyCoreDef.h b/include/QtScrcpyCoreDef.h index 794e3a1..55394c4 100644 --- a/include/QtScrcpyCoreDef.h +++ b/include/QtScrcpyCoreDef.h @@ -13,7 +13,7 @@ struct DeviceParams { quint16 localPort = 27183; // reverse时本地监听端口 quint16 maxSize = 720; // 视频分辨率 quint32 bitRate = 2000000; // 视频比特率 - quint32 maxFps = 60; // 视频最大帧率 + quint32 maxFps = 0; // 视频最大帧率 bool useReverse = true; // true:先使用adb reverse,失败后自动使用adb forward;false:直接使用adb forward int lockVideoOrientation = -1; // 是否锁定视频方向 bool stayAwake = false; // 是否保持唤醒 diff --git a/src/device/server/server.cpp b/src/device/server/server.cpp index 2f5a6c9..34c30b4 100644 --- a/src/device/server/server.cpp +++ b/src/device/server/server.cpp @@ -130,22 +130,35 @@ bool Server::execute() args << "com.genymobile.scrcpy.Server"; args << m_params.serverVersion; + args << QString("bit_rate=%1").arg(QString::number(m_params.bitRate)); if (!m_params.logLevel.isEmpty()) { args << QString("log_level=%1").arg(m_params.logLevel); } - args << QString("max_size=%1").arg(QString::number(m_params.maxSize)); - args << QString("bit_rate=%1").arg(QString::number(m_params.bitRate)); - args << QString("max_fps=%1").arg(QString::number(m_params.maxFps)); - args << QString("lock_video_orientation=%1").arg(QString::number(m_params.lockVideoOrientation)); - args << QString("tunnel_forward=%1").arg((m_tunnelForward ? "true" : "false")); + if (m_params.maxSize > 0) { + args << QString("max_size=%1").arg(QString::number(m_params.maxSize)); + } + if (m_params.maxFps > 0) { + args << QString("max_fps=%1").arg(QString::number(m_params.maxFps)); + } + if (-1 != m_params.lockVideoOrientation) { + args << QString("lock_video_orientation=%1").arg(QString::number(m_params.lockVideoOrientation)); + } + if (m_tunnelForward) { + args << QString("tunnel_forward=true"); + } if (!m_params.crop.isEmpty()) { args << QString("crop=%1").arg(m_params.crop); } - args << "send_frame_meta=true"; - args << QString("control=%1").arg((m_params.control ? "true" : "false")); - args << "display_id=0"; // display id - args << "show_touches=false"; // show touch - args << QString("stay_awake=%1").arg((m_params.stayAwake ? "true" : "false")); // stay awake + if (!m_params.control) { + args << QString("control=false"); + } + // 默认是0,不需要设置 + // args << "display_id=0"; + // 默认是false,不需要设置 + // args << "show_touches=false"; + if (m_params.stayAwake) { + args << QString("stay_awake=true"); + } // code option // https://github.com/Genymobile/scrcpy/commit/080a4ee3654a9b7e96c8ffe37474b5c21c02852a // @@ -155,14 +168,16 @@ bool Server::execute() if (!m_params.codecName.isEmpty()) { args << QString("encoder_name=%1").arg(m_params.codecName); } - args << "power_off_on_close=false"; - - // 服务端有默认值,这里不传,传参太长导致三星手机报错:stack corruption detected (-fstack-protector) + // 默认是false,不需要设置 + // args << "power_off_on_close=false"; + + // 下面的参数都用服务端默认值即可,尽量减少参数传递,传参太长导致三星手机报错:stack corruption detected (-fstack-protector) /* args << "clipboard_autosync=true"; args << "downsize_on_error=true"; args << "cleanup=true"; args << "power_on=true"; + args << "send_device_meta=true"; args << "send_frame_meta=true"; args << "send_dummy_byte=true"; diff --git a/src/device/server/server.h b/src/device/server/server.h index fbeeabe..5f6006d 100644 --- a/src/device/server/server.h +++ b/src/device/server/server.h @@ -35,7 +35,7 @@ class Server : public QObject quint16 localPort = 27183; // reverse时本地监听端口 quint16 maxSize = 720; // 视频分辨率 quint32 bitRate = 8000000; // 视频比特率 - quint32 maxFps = 60; // 视频最大帧率 + quint32 maxFps = 0; // 视频最大帧率 bool useReverse = true; // true:先使用adb reverse,失败后自动使用adb forward;false:直接使用adb forward int lockVideoOrientation = -1; // 是否锁定视频方向 int stayAwake = false; // 是否保持唤醒