Skip to content

Commit

Permalink
Merge pull request wang-bin#967 from 0xFelix/fixAVRaceCondition
Browse files Browse the repository at this point in the history
Use dedicated variable to track open state of AVMuxer
  • Loading branch information
wang-bin authored Oct 15, 2017
2 parents cd07d20 66ad0cc commit 658eae6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/AVMuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 43,7 @@ class AVMuxer::Private
, started(false)
, eof(false)
, media_changed(true)
, open(false)
, format_ctx(0)
, format(0)
, io(0)
Expand Down Expand Up @@ -73,6 74,7 @@ class AVMuxer::Private
bool started;
bool eof;
bool media_changed;
bool open;
AVFormatContext *format_ctx;
//copy the info, not parse the file when constructed, then need member vars
QString file;
Expand Down Expand Up @@ -408,6 410,7 @@ bool AVMuxer::open()
// d->format_ctx->start_time_realtime
AV_ENSURE_OK(avformat_write_header(d->format_ctx, &d->dict), false);
d->started = false;
d->open = true;

return true;
}
Expand All @@ -416,6 419,7 @@ bool AVMuxer::close()
{
if (!isOpen())
return true;
d->open = false;
av_write_trailer(d->format_ctx);
// close AVCodecContext* in encoder
// custom io will call avio_close in ~MediaIO()
Expand All @@ -437,7 441,7 @@ bool AVMuxer::close()

bool AVMuxer::isOpen() const
{
return d->format_ctx;
return d->open;
}

bool AVMuxer::writeAudio(const QtAV::Packet& packet)
Expand Down

0 comments on commit 658eae6

Please sign in to comment.