X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcec-config%2Fcec-config.cpp;h=29bdf593c58fc200a2bfdb67a07c077179d1bceb;hb=d2f9b488f5c2d8450b2f87082f9aef984670a747;hp=a3d2b77f5666a592ba6b21d72a5307becf68e913;hpb=1664420dd2cd46c9daafeb541c45d055d176bcdc;p=deb_libcec.git diff --git a/src/cec-config/cec-config.cpp b/src/cec-config/cec-config.cpp index a3d2b77..29bdf59 100644 --- a/src/cec-config/cec-config.cpp +++ b/src/cec-config/cec-config.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include "../lib/platform/threads/mutex.h" #include "../lib/platform/util/timeutils.h" #include "../lib/implementations/CECCommandHandler.h" @@ -293,20 +294,17 @@ bool PowerOnTV(uint64_t iTimeout = 60000) uint64_t iNow = GetTimeMs(); uint64_t iTarget = iNow + iTimeout; + currentTvPower = g_parser->GetDevicePowerStatus(CECDEVICE_TV); if (currentTvPower != CEC_POWER_STATUS_ON) { - currentTvPower = g_parser->GetDevicePowerStatus(CECDEVICE_TV); - if (currentTvPower != CEC_POWER_STATUS_ON) + PrintToStdOut("Sending 'power on' command to the TV\n=== Please wait ==="); + g_parser->PowerOnDevices(CECDEVICE_TV); + while (iTarget > iNow) { - PrintToStdOut("Sending 'power on' command to the TV\n=== Please wait ==="); - g_parser->PowerOnDevices(CECDEVICE_TV); - while (iTarget > iNow) - { - g_responseEvent.Wait((uint32_t)(iTarget - iNow)); - if (g_lastCommand == CEC_OPCODE_REQUEST_ACTIVE_SOURCE) - break; - iNow = GetTimeMs(); - } + g_responseEvent.Wait((uint32_t)(iTarget - iNow)); + if (g_lastCommand == CEC_OPCODE_REQUEST_ACTIVE_SOURCE) + break; + iNow = GetTimeMs(); } } @@ -318,8 +316,24 @@ bool PowerOnTV(uint64_t iTimeout = 60000) return currentTvPower == CEC_POWER_STATUS_ON; } +void sighandler(int iSignal) +{ + PrintToStdOut("signal caught: %d - exiting", iSignal); + + g_parser->Close(); + UnloadLibCec(g_parser); + + exit(1); +} + int main (int UNUSED(argc), char *UNUSED(argv[])) { + if (signal(SIGINT, sighandler) == SIG_ERR) + { + PrintToStdOut("can't register sighandler"); + return -1; + } + g_callbacks.Clear(); g_config.Clear(); PrintToStdOut("=== USB-CEC Adapter Configuration ===\n");