X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mux.cpp;h=bcbbef3c1c7ba429a534c6cda6b4e98cf9852005;hb=3795723be95f2fe82f3c8b8b45b1a905b2c811fd;hp=2f682c9b3c63967487d8c52986b44b65cba9933e;hpb=1f40445577316ae2f2df53c09147fe254cbe9772;p=nageru diff --git a/mux.cpp b/mux.cpp index 2f682c9..bcbbef3 100644 --- a/mux.cpp +++ b/mux.cpp @@ -1,12 +1,12 @@ #include "mux.h" +#include #include +#include #include #include #include #include -#include -#include #include #include #include @@ -171,7 +171,8 @@ void Mux::add_packet(const AVPacket &pkt, int64_t pts, int64_t dts, AVRational t lock_guard lock(mu); if (write_strategy == WriteStrategy::WRITE_BACKGROUND) { packet_queue.push_back(QueuedPacket{ av_packet_clone(&pkt_copy), pts }); - if (plug_count == 0) packet_queue_ready.notify_all(); + if (plug_count == 0) + packet_queue_ready.notify_all(); } else if (plug_count > 0) { packet_queue.push_back(QueuedPacket{ av_packet_clone(&pkt_copy), pts }); } else { @@ -196,7 +197,7 @@ void Mux::write_packet_or_die(const AVPacket &pkt, int64_t unscaled_pts) int64_t old_pos = avctx->pb->pos; if (av_interleaved_write_frame(avctx, const_cast(&pkt)) < 0) { fprintf(stderr, "av_interleaved_write_frame() failed\n"); - exit(1); + abort(); } avio_flush(avctx->pb); for (MuxMetrics *metric : metrics) { @@ -237,6 +238,8 @@ void Mux::unplug() void Mux::thread_func() { + pthread_setname_np(pthread_self(), "Mux"); + unique_lock lock(mu); for ( ;; ) { packet_queue_ready.wait(lock, [this]() {