]> git.sesse.net Git - nageru/blobdiff - nageru/audio_encoder.h
Fix a Clang 19 warning.
[nageru] / nageru / audio_encoder.h
index 93adbafce954d6188f3d5ca86770ff7dace53f6c..49cead7c4851dee82097fb2caed462373283ba6e 100644 (file)
@@ -3,19 +3,21 @@
 #ifndef _AUDIO_ENCODER_H
 #define _AUDIO_ENCODER_H 1
 
+#include <assert.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <string>
 #include <vector>
 
 extern "C" {
+#include <libavcodec/codec.h>
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
-#include <libavresample/avresample.h>
+#include <libswresample/swresample.h>
 #include <libavutil/frame.h>
 }
 
-#include "ffmpeg_raii.h"
+#include "shared/ffmpeg_raii.h"
 
 class Mux;
 
@@ -25,11 +27,13 @@ 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);
        void encode_last_audio();
 
+       const AVCodec *get_codec() const { return ctx->codec; }
        AVCodecParametersWithDeleter get_codec_parameters();
 
 private:
@@ -39,7 +43,7 @@ private:
        int64_t last_pts = 0;  // The first pts after all audio we've encoded.
 
        AVCodecContext *ctx;
-       AVAudioResampleContext *resampler;
+       SwrContext *resampler;
        AVFrame *audio_frame = nullptr;
        std::vector<Mux *> muxes;
 };