Skip to content

Commit

Permalink
fix: samsung error stack corruption detected
Browse files Browse the repository at this point in the history
  • Loading branch information
barry-ran committed Oct 21, 2022
1 parent a90fa3f commit cbe8869
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/QtScrcpyCoreDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; // 是否保持唤醒
Expand Down
41 changes: 28 additions & 13 deletions src/device/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
// <https://d.android.com/reference/android/media/MediaFormat>
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/device/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; // 是否保持唤醒
Expand Down

0 comments on commit cbe8869

Please sign in to comment.