Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break early when exit_main_loop is set in encoder thread #223

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/frame-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,16 +920,13 @@ FrameWriter::~FrameWriter()
// Writing the delayed frames:
AVPacket *pkt = av_packet_alloc();

if (videoCodecCtx->delay)
{
encode(videoCodecCtx, NULL, pkt);
encode(videoCodecCtx, NULL, pkt);
#ifdef HAVE_PULSE
if (params.enable_audio)
{
encode(audioCodecCtx, NULL, pkt);
}
#endif
if (params.enable_audio)
{
encode(audioCodecCtx, NULL, pkt);
}
#endif
// Writing the end of the file.
av_write_trailer(fmtCtx);

Expand Down
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ static void write_loop(FrameWriterParams params)
while(buffers.encode().ready_encode() != true && !exit_main_loop) {
std::this_thread::sleep_for(std::chrono::microseconds(1000));
}
if (exit_main_loop) {
break;
}

auto& buffer = buffers.encode();

frame_writer_pending_mutex.lock();
Expand Down
Loading