From: Lars Op den Kamp Date: Tue, 28 Feb 2012 23:33:43 +0000 (+0100) Subject: cec: fix access violation when starting the bootloader directly on windows X-Git-Tag: upstream/2.2.0~1^2~33^2~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=08d80226f8f7cf067439eba8a89bb1ba9fdf0dcb;p=deb_libcec.git cec: fix access violation when starting the bootloader directly on windows --- diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index ef4c84c..5b8bb3c 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -33,6 +33,7 @@ #include "LibCEC.h" #include "adapter/USBCECAdapterDetection.h" +#include "adapter/USBCECAdapterCommunication.h" #include "CECProcessor.h" #include "devices/CECBusDevice.h" #include "platform/util/timeutils.h" @@ -65,7 +66,6 @@ CLibCEC::CLibCEC(libcec_configuration *configuration) : CLibCEC::~CLibCEC(void) { - Close(); delete m_cec; } @@ -504,17 +504,22 @@ void * CECInitialise(libcec_configuration *configuration) bool CECStartBootloader(void) { - libcec_configuration dummy; - dummy.Clear(); - CLibCEC *lib = new CLibCEC(&dummy); - bool bReturn(false); cec_adapter deviceList[1]; if (CUSBCECAdapterDetection::FindAdapters(deviceList, 1) > 0) { - bReturn = lib->m_cec->StartBootloader(deviceList[0].comm); - delete lib; + CUSBCECAdapterCommunication comm(NULL, deviceList[0].comm); + CTimeout timeout(10000); + int iConnectTry(0); + while (timeout.TimeLeft() > 0 && (bReturn = comm.Open(NULL, (timeout.TimeLeft() / CEC_CONNECT_TRIES)), true) == false) + { + comm.Close(); + Sleep(500); + } + if (comm.IsOpen()) + bReturn = comm.StartBootloader(); } + return bReturn; }