Skip to content

Commit

Permalink
perf: 优化minicap读取细节
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Nov 30, 2023
1 parent 18576ab commit 55434ce
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions source/MaaAdbControlUnit/Screencap/Minicap/MinicapStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,25 @@ bool MinicapStream::init(int swidth, int sheight)
return false;
}

std::string outputBuffer;
int i = 50;
while (--i) {
bool ok = false;

std::string buffer;
constexpr int kMaxTry = 50;
for (int i = 0; i < kMaxTry; ++i) {
auto res = process_handle_->read(5);
if (res.length() > 0) {
LogInfo << "minicap stdout:" << res;
outputBuffer.append(res);
if (!res.empty()) {
LogDebug << "minicap stdout:" << res;
buffer.append(res);
}
if (outputBuffer.find("Allocating") != std::string::npos) {
if (buffer.find("Allocating") != std::string::npos) {
ok = true;
break;
}
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
}

if (i == 0) {
if (!ok) {
LogError << "minicap stdout:" << buffer;
return false;
}

Expand Down

0 comments on commit 55434ce

Please sign in to comment.