code: Fix incorrect behavior for encoder::ffmpeg

As we previously relied on an additional function call, we should now merge this call into the constructor.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2023-05-14 15:43:26 +02:00 committed by Xaymar
parent a8704e6028
commit 8817248dfd
2 changed files with 6 additions and 15 deletions

View file

@ -1165,15 +1165,7 @@ ffmpeg_manager::ffmpeg_manager() : _factories(), _handlers(), _debug_handler()
#ifdef ENABLE_ENCODER_FFMPEG_DNXHR #ifdef ENABLE_ENCODER_FFMPEG_DNXHR
register_handler("dnxhd", ::std::make_shared<handler::dnxhd_handler>()); register_handler("dnxhd", ::std::make_shared<handler::dnxhd_handler>());
#endif #endif
}
ffmpeg_manager::~ffmpeg_manager()
{
_factories.clear();
}
void ffmpeg_manager::register_encoders()
{
// Encoders // Encoders
void* iterator = nullptr; void* iterator = nullptr;
for (const AVCodec* codec = av_codec_iterate(&iterator); codec != nullptr; codec = av_codec_iterate(&iterator)) { for (const AVCodec* codec = av_codec_iterate(&iterator); codec != nullptr; codec = av_codec_iterate(&iterator)) {
@ -1191,6 +1183,11 @@ void ffmpeg_manager::register_encoders()
} }
} }
ffmpeg_manager::~ffmpeg_manager()
{
_factories.clear();
}
void ffmpeg_manager::register_handler(std::string codec, std::shared_ptr<handler::handler> handler) void ffmpeg_manager::register_handler(std::string codec, std::shared_ptr<handler::handler> handler)
{ {
_handlers.emplace(codec, handler); _handlers.emplace(codec, handler);

View file

@ -147,8 +147,6 @@ namespace streamfx::encoder::ffmpeg {
ffmpeg_manager(); ffmpeg_manager();
~ffmpeg_manager(); ~ffmpeg_manager();
void register_encoders();
void register_handler(std::string codec, std::shared_ptr<handler::handler> handler); void register_handler(std::string codec, std::shared_ptr<handler::handler> handler);
std::shared_ptr<handler::handler> get_handler(std::string codec); std::shared_ptr<handler::handler> get_handler(std::string codec);
@ -156,10 +154,6 @@ namespace streamfx::encoder::ffmpeg {
bool has_handler(std::string_view codec); bool has_handler(std::string_view codec);
public: // Singleton public: // Singleton
static void initialize();
static void finalize();
static std::shared_ptr<ffmpeg_manager> instance(); static std::shared_ptr<ffmpeg_manager> instance();
}; };
} // namespace streamfx::encoder::ffmpeg } // namespace streamfx::encoder::ffmpeg