]> git.sesse.net Git - nageru/commitdiff
Fix crash without SRT output.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 7 Sep 2023 18:44:39 +0000 (20:44 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 7 Sep 2023 18:44:39 +0000 (20:44 +0200)
nageru/audio_encoder.h
nageru/quicksync_encoder.cpp
nageru/video_encoder.cpp

index ca2634fe62df2cd2f0bc311a4112b52e44415cd6..bd279784950752fae64cbcd7eccd26430e6419bf 100644 (file)
@@ -3,6 +3,7 @@
 #ifndef _AUDIO_ENCODER_H
 #define _AUDIO_ENCODER_H 1
 
+#include <assert.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <string>
@@ -25,6 +26,7 @@ public:
        ~AudioEncoder();
 
        void add_mux(Mux *mux) {  // Does not take ownership.
+               assert(mux != nullptr);
                muxes.push_back(mux);
        }
        void encode_audio(const std::vector<float> &audio, int64_t audio_pts);
index d75dbeb7372ea4a2553a753bce40b94a72e41751..a1894595e548f577d7ea6eb8a088c057fb642953 100644 (file)
@@ -1353,7 +1353,9 @@ void QuickSyncEncoderImpl::save_codeddata(GLSurface *surf, storage_task task)
                if (!global_flags.x264_video_to_http &&
                    !global_flags.av1_video_to_http) {
                        http_mux->add_packet(pkt, task.pts + global_delay(), task.dts + global_delay());
-                       srt_mux->add_packet(pkt, task.pts + global_delay(), task.dts + global_delay());
+                       if (srt_mux != nullptr) {
+                               srt_mux->add_packet(pkt, task.pts + global_delay(), task.dts + global_delay());
+                       }
                }
        }
 }
index 4d6a403d0051cfec8d3a8c6c5ad638b3983c600c..4a84ddce1efe786a0f401b2d4e700f358c5482d5 100644 (file)
@@ -89,17 +89,25 @@ VideoEncoder::VideoEncoder(ResourcePool *resource_pool, QSurface *surface, const
 
        open_output_streams();
        stream_audio_encoder->add_mux(http_mux.get());
-       stream_audio_encoder->add_mux(srt_mux.get());
+       if (srt_mux != nullptr) {
+               stream_audio_encoder->add_mux(srt_mux.get());
+       }
        quicksync_encoder->set_http_mux(http_mux.get());
-       quicksync_encoder->set_srt_mux(srt_mux.get());
+       if (srt_mux != nullptr) {
+               quicksync_encoder->set_srt_mux(srt_mux.get());
+       }
        if (global_flags.x264_video_to_http) {
                x264_encoder->add_mux(http_mux.get());
-               x264_encoder->add_mux(srt_mux.get());
+               if (srt_mux != nullptr) {
+                       x264_encoder->add_mux(srt_mux.get());
+               }
        }
 #ifdef HAVE_AV1
        if (global_flags.av1_video_to_http) {
                av1_encoder->add_mux(http_mux.get());
-               av1_encoder->add_mux(srt_mux.get());
+               if (srt_mux != nullptr) {
+                       av1_encoder->add_mux(srt_mux.get());
+               }
        }
 #endif
 }