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

Quit wf-recorder when the recording target fails #94

Merged
merged 1 commit into from
May 27, 2020
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
4 changes: 3 additions & 1 deletion src/frame-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,9 @@ void FrameWriter::finish_frame(AVCodecContext *enc_ctx, AVPacket& pkt)
pending_mutex.unlock();
}

av_interleaved_write_frame(fmtCtx, &pkt);
if (av_interleaved_write_frame(fmtCtx, &pkt) != 0) {
params.write_aborted_flag = true;
}
av_packet_unref(&pkt);

if (params.enable_audio)
Expand Down
4 changes: 4 additions & 0 deletions src/frame-writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <string>
#include <vector>
#include <map>
#include <atomic>
#include "config.h"

#define AUDIO_RATE 44100
Expand Down Expand Up @@ -64,6 +65,9 @@ struct FrameWriterParams
bool force_yuv;
int opencl_device;
int bframes;

std::atomic<bool>& write_aborted_flag;
FrameWriterParams(std::atomic<bool>& flag): write_aborted_flag(flag) {}
};

class FrameWriter
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ With no FILE, start recording the current screen.

int main(int argc, char *argv[])
{
FrameWriterParams params;
FrameWriterParams params = FrameWriterParams(exit_main_loop);
params.file = "recording.mp4";
params.codec = DEFAULT_CODEC;
params.enable_ffmpeg_debug_output = false;
Expand Down