26 #include <core/posix/signal.h>
34 #if defined(MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER)
35 #include <hybris/media/media_codec_layer.h>
42 decoding_service_init();
45 #else // MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER
54 #endif // MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER
58 auto trap = core::posix::trap_signals_for_all_subsequent_threads(
60 core::posix::Signal::sig_int,
61 core::posix::Signal::sig_term
64 trap->signal_raised().connect([trap](core::posix::Signal)
73 bool shutdown_requested{
false};
80 std::thread external_services_worker
85 [&shutdown_requested, &external_services]()
87 while (not shutdown_requested)
95 catch (
const std::exception& e)
97 std::cerr <<
"Error while executing the underlying io_service: " << e.what() << std::endl;
101 std::cerr <<
"Error while executing the underlying io_service." << std::endl;
108 auto player_store = std::make_shared<media::HashedKeyedPlayerStore>();
110 media::ServiceImplementation::Configuration service_config
112 std::make_shared<media::HashedKeyedPlayerStore>(),
116 auto impl = std::make_shared<media::ServiceImplementation>(media::ServiceImplementation::Configuration
122 auto skeleton = std::make_shared<media::ServiceSkeleton>(media::ServiceSkeleton::Configuration
129 std::thread service_worker
131 [&shutdown_requested, skeleton]()
133 while (not shutdown_requested)
139 catch (
const std::exception& e)
141 std::cerr <<
"Recoverable error while executing the service: " << e.what() << std::endl;
145 std::cerr <<
"Recoverable error while executing the service." << std::endl;
157 shutdown_requested =
true;
162 if (service_worker.joinable())
163 service_worker.join();
165 external_services.
stop();
167 if (external_services_worker.joinable())
168 external_services_worker.join();