Skip to content

Commit

Permalink
Feat: use while loop and do nothing to avoid using msleep
Browse files Browse the repository at this point in the history
  • Loading branch information
ppodds committed Dec 30, 2021
1 parent a16059d commit b74659a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions AAAAnimation/player/ascii_player_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ void AsciiPlayerThread::run()
arr = new unsigned char[(long long)height * (width + 1)]();
transform(frame->data[0], arr, width, height, frame->linesize[0]);
// check time again
// if this frame is too late, play it now
qint64 t = position;
if (play_time - 200 > t) // 200ms offset to avoid drop too many frames
// wait until the proper time and play this frame
msleep(play_time - t);
// wait until the proper time and play this frame
while (play_time - 150 > position); // 150ms offset to avoid drop too many frames
std::cout << arr;
console_controller.top();
}
Expand Down

0 comments on commit b74659a

Please sign in to comment.