Skip to content

Commit

Permalink
refactor: extract closeHandlersAndSession()
Browse files Browse the repository at this point in the history
  • Loading branch information
haruyama committed Sep 7, 2023
1 parent 908c5f5 commit dd2eb1d
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions src/hisui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@
#include "video/vpl_session.hpp"
#endif

static void closeHandlersAndSession() {
if (hisui::video::OpenH264Handler::hasInstance()) {
hisui::video::OpenH264Handler::close();
}

if (hisui::audio::LyraHandler::hasInstance()) {
hisui::audio::LyraHandler::close();
}

#ifdef USE_ONEVPL
if (hisui::video::VPLSession::hasInstance()) {
hisui::video::VPLSession::close();
}
#endif
}

int main(int argc, char** argv) {
CLI::App app{"hisui"};
hisui::Config config;
Expand Down Expand Up @@ -105,19 +121,7 @@ int main(int argc, char** argv) {
hisui::video::DecoderFactory::setup(config);
auto ret = hisui::layout::compose(config);

if (hisui::video::OpenH264Handler::hasInstance()) {
hisui::video::OpenH264Handler::close();
}

if (hisui::audio::LyraHandler::hasInstance()) {
hisui::audio::LyraHandler::close();
}

#ifdef USE_ONEVPL
if (hisui::video::VPLSession::hasInstance()) {
hisui::video::VPLSession::close();
}
#endif
closeHandlersAndSession();

return ret;
}
Expand Down Expand Up @@ -227,19 +231,7 @@ int main(int argc, char** argv) {
}
delete muxer;

if (hisui::video::OpenH264Handler::hasInstance()) {
hisui::video::OpenH264Handler::close();
}

if (hisui::audio::LyraHandler::hasInstance()) {
hisui::audio::LyraHandler::close();
}

#ifdef USE_ONEVPL
if (hisui::video::VPLSession::hasInstance()) {
hisui::video::VPLSession::close();
}
#endif
closeHandlersAndSession();

if (config.enabledSuccessReport()) {
try {
Expand All @@ -257,3 +249,4 @@ int main(int argc, char** argv) {

return EXIT_SUCCESS;
}

0 comments on commit dd2eb1d

Please sign in to comment.