CLockObject lock(m_mutex);
if (!m_communication)
{
- m_controller->AddLog(CEC_LOG_ERROR, "no connection handler found");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "no connection handler found");
return bReturn;
}
/* check for an already opened connection */
if (m_communication->IsOpen())
{
- m_controller->AddLog(CEC_LOG_ERROR, "connection already opened");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "connection already opened");
return bReturn;
}
/* open a new connection */
if ((bReturn = m_communication->Open(strPort, iBaudRate, iTimeoutMs)) == false)
- m_controller->AddLog(CEC_LOG_ERROR, "could not open a connection");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection");
/* try to ping the adapter */
if ((bReturn = m_communication->PingAdapter()) == false)
- m_controller->AddLog(CEC_LOG_ERROR, "the adapter does not respond correctly");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter does not respond correctly");
uint16_t iFirmwareVersion = m_communication->GetFirmwareVersion();
if ((bReturn = (iFirmwareVersion != CEC_FW_VERSION_UNKNOWN)) == false)
m_controller->AddLog(CEC_LOG_ERROR, "the adapter is running an unknown firmware version");
- CStdString strLog;
- strLog.Format("CEC Adapter firmware version: %d", iFirmwareVersion);
- m_controller->AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "CEC Adapter firmware version: %d", iFirmwareVersion);
return bReturn;
}
if (!FindLogicalAddresses())
{
- m_controller->AddLog(CEC_LOG_ERROR, "could not detect our logical addresses");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not detect our logical addresses");
return bReturn;
}
ReplaceHandlers();
if ((bReturn = SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true)) == false)
- {
- CStdString strLog;
- strLog.Format("unable to set HDMI port %d on %s (%x)", m_iHDMIPort, ToString(m_iBaseDevice), (uint8_t)m_iBaseDevice);
- m_controller->AddLog(CEC_LOG_ERROR, strLog);
- }
+ CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set HDMI port %d on %s (%x)", m_iHDMIPort, ToString(m_iBaseDevice), (uint8_t)m_iBaseDevice);
SetInitialised(bReturn);
/* create the processor thread */
if (!CreateThread() || !m_startCondition.Wait(m_mutex) || !m_bStarted)
{
- m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a processor thread");
return bReturn;
}
}
if ((bReturn = Initialise()) == false)
{
- m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a processor thread");
StopThread(true);
}
else
{
- m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started");
}
return bReturn;
bool CCECProcessor::FindLogicalAddressRecordingDevice(void)
{
- AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'recording device'");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'recording device'");
return TryLogicalAddress(CECDEVICE_RECORDINGDEVICE1) ||
TryLogicalAddress(CECDEVICE_RECORDINGDEVICE2) ||
TryLogicalAddress(CECDEVICE_RECORDINGDEVICE3);
bool CCECProcessor::FindLogicalAddressTuner(void)
{
- AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'tuner'");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'tuner'");
return TryLogicalAddress(CECDEVICE_TUNER1) ||
TryLogicalAddress(CECDEVICE_TUNER2) ||
TryLogicalAddress(CECDEVICE_TUNER3) ||
bool CCECProcessor::FindLogicalAddressPlaybackDevice(void)
{
- AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'playback device'");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'playback device'");
return TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE1) ||
TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE2) ||
TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE3);
bool CCECProcessor::FindLogicalAddressAudioSystem(void)
{
- AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'audio'");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'audio'");
return TryLogicalAddress(CECDEVICE_AUDIOSYSTEM);
}
{
bool bChanged(false);
- CStdString strLog;
- strLog.Format("changing device type '%s' into '%s'", ToString(from), ToString(to));
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "changing device type '%s' into '%s'", ToString(from), ToString(to));
CLockObject lock(m_mutex);
CCECBusDevice *previousDevice = GetDeviceByType(from);
{
bool bReturn(true);
m_logicalAddresses.Clear();
- CStdString strLog;
for (unsigned int iPtr = 0; iPtr < 5; iPtr++)
{
if (m_types.types[iPtr] == CEC_DEVICE_TYPE_RESERVED)
continue;
- strLog.Format("%s - device %d: type %d", __FUNCTION__, iPtr, m_types.types[iPtr]);
- AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - device %d: type %d", __FUNCTION__, iPtr, m_types.types[iPtr]);
if (m_types.types[iPtr] == CEC_DEVICE_TYPE_RECORDING_DEVICE)
bReturn &= FindLogicalAddressRecordingDevice();
{
CLockObject lock(m_mutex);
m_bStarted = true;
- m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started");
m_startCondition.Signal();
}
if (!m_bStarted && !bForce)
return true;
- CStdString strLog;
- strLog.Format("setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice);
- AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice);
uint16_t iPhysicalAddress(0);
if (iBaseDevice > CECDEVICE_TV)
}
if (!bReturn)
- m_controller->AddLog(CEC_LOG_ERROR, "failed to set the physical address");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "failed to set the physical address");
else
{
lock.Unlock();
for (uint8_t iPtr = 0; iPtr < data.parameters.size; iPtr++)
strTx.AppendFormat(":%02x", data.parameters[iPtr]);
- m_controller->AddLog(CEC_LOG_TRAFFIC, strTx.c_str());
+ CLibCEC::AddLog(CEC_LOG_TRAFFIC, strTx.c_str());
}
bool CCECProcessor::SetLogicalAddress(cec_logical_address iLogicalAddress)
CLockObject lock(m_mutex);
if (m_logicalAddresses.primary != iLogicalAddress)
{
- CStdString strLog;
- strLog.Format("<< setting primary logical address to %1x", iLogicalAddress);
- m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< setting primary logical address to %1x", iLogicalAddress);
m_logicalAddresses.primary = iLogicalAddress;
m_logicalAddresses.Set(iLogicalAddress);
return SetAckMask(m_logicalAddresses.AckMask());
bool CCECProcessor::SwitchMonitoring(bool bEnable)
{
- CStdString strLog;
- strLog.Format("== %s monitoring mode ==", bEnable ? "enabling" : "disabling");
- m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "== %s monitoring mode ==", bEnable ? "enabling" : "disabling");
{
CLockObject lock(m_mutex);
void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode, cec_abort_reason reason /* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */)
{
- m_controller->AddLog(CEC_LOG_DEBUG, "<< transmitting abort message");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< transmitting abort message");
cec_command command;
// TODO
break;
}
- m_controller->AddLog(bIsError ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
+ CLibCEC::AddLog(bIsError ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
return bEom;
}
dataStr.Format(">> %1x%1x:%02x", command.initiator, command.destination, command.opcode);
for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]);
- m_controller->AddLog(CEC_LOG_TRAFFIC, dataStr.c_str());
+ CLibCEC::AddLog(CEC_LOG_TRAFFIC, dataStr.c_str());
if (!m_bMonitor && command.initiator >= CECDEVICE_TV && command.initiator <= CECDEVICE_BROADCAST)
m_busDevices[(uint8_t)command.initiator]->HandleCommand(command);
m_controller->AddKey();
}
-void CCECProcessor::AddLog(cec_log_level level, const CStdString &strMessage)
-{
- m_controller->AddLog(level, strMessage);
-}
-
bool CCECProcessor::SetAckMask(uint16_t iMask)
{
return m_communication->SetAckMask(iMask);
virtual void AddCommand(const cec_command &command);
virtual void AddKey(cec_keypress &key);
virtual void AddKey(void);
- virtual void AddLog(cec_log_level level, const CStdString &strMessage);
virtual bool ChangeDeviceType(cec_device_type from, cec_device_type to);
virtual bool FindLogicalAddresses(void);
return retVal;
}
-void CLibCEC::AddLog(cec_log_level level, const string &strMessage)
+void CLibCEC::AddLog(cec_log_level level, const char *strFormat, ...)
{
- CLockObject lock(m_mutex);
- if (m_cec)
- {
- cec_log_message message;
- message.level = level;
- message.time = GetTimeMs() - m_iStartTime;
- snprintf(message.message, sizeof(message.message), "%s", strMessage.c_str());
+ CStdString strLog;
- if (m_callbacks)
- m_callbacks->CBCecLogMessage(m_cbParam, message);
- else
- m_logBuffer.Push(message);
- }
+ va_list argList;
+ va_start(argList, strFormat);
+ strLog.FormatV(strFormat, argList);
+ va_end(argList);
+
+ CLibCEC *instance = CLibCEC::GetInstance();
+ CLockObject lock(instance->m_mutex);
+
+ cec_log_message message;
+ message.level = level;
+ message.time = GetTimeMs() - instance->m_iStartTime;
+ snprintf(message.message, sizeof(message.message), "%s", strLog.c_str());
+
+ if (instance->m_callbacks)
+ instance->m_callbacks->CBCecLogMessage(instance->m_cbParam, message);
+ else
+ instance->m_logBuffer.Push(message);
}
void CLibCEC::AddKey(cec_keypress &key)
m_keyBuffer.Push(key);
}
+static CLibCEC *g_libCEC_instance(NULL);
+CLibCEC *CLibCEC::GetInstance(void)
+{
+ return g_libCEC_instance;
+}
+
+void CLibCEC::SetInstance(CLibCEC *instance)
+{
+ if (g_libCEC_instance)
+ delete g_libCEC_instance;
+ g_libCEC_instance = instance;
+}
+
void * CECCreate(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress /*= CEC::CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
{
- return static_cast< void* > (new CLibCEC(strDeviceName, iLogicalAddress, iPhysicalAddress));
+ CLibCEC *lib = new CLibCEC(strDeviceName, iLogicalAddress, iPhysicalAddress);
+ CLibCEC::SetInstance(lib);
+ return static_cast< void* > (lib);
}
void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types)
{
- return static_cast< void* > (new CLibCEC(strDeviceName, types));
+ CLibCEC *lib = new CLibCEC(strDeviceName, types);
+ CLibCEC::SetInstance(lib);
+ return static_cast< void* > (lib);
}
-void CECDestroy(CEC::ICECAdapter *instance)
+void CECDestroy(CEC::ICECAdapter *UNUSED(instance))
{
- CLibCEC *lib = static_cast< CLibCEC* > (instance);
- if (lib)
- delete lib;
+ CLibCEC::SetInstance(NULL);
}
const char *CLibCEC::ToString(const cec_menu_state state)
const char *ToString(const cec_vendor_id vendor);
//@}
- virtual void AddLog(cec_log_level level, const std::string &strMessage);
+ static void AddLog(cec_log_level level, const char *strFormat, ...);
virtual void AddKey(void);
virtual void AddKey(cec_keypress &key);
virtual void AddCommand(const cec_command &command);
virtual void CheckKeypressTimeout(void);
virtual void SetCurrentButton(cec_user_control_code iButtonCode);
+ static CLibCEC *GetInstance(void);
+ static void SetInstance(CLibCEC *instance);
+
protected:
int64_t m_iStartTime;
cec_user_control_code m_iCurrentButton;
#include "AdapterMessage.h"
#include "CECProcessor.h"
#include "platform/serialport/serialport.h"
+#include "../LibCEC.h"
using namespace std;
using namespace CEC;
if (!m_port)
{
- m_processor->AddLog(CEC_LOG_ERROR, "port is NULL");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "port is NULL");
return false;
}
if (IsOpen())
{
- m_processor->AddLog(CEC_LOG_ERROR, "port is already open");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "port is already open");
return true;
}
if (!bConnected)
{
- m_processor->AddLog(CEC_LOG_ERROR, strError);
+ CLibCEC::AddLog(CEC_LOG_ERROR, strError);
return false;
}
- m_processor->AddLog(CEC_LOG_DEBUG, "connection opened");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "connection opened");
//clear any input bytes
uint8_t buff[1];
if (CreateThread())
{
- m_processor->AddLog(CEC_LOG_DEBUG, "communication thread started");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "communication thread started");
return true;
}
else
{
- m_processor->AddLog(CEC_LOG_ERROR, "could not create a communication thread");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a communication thread");
}
return false;
if (data->state != ADAPTER_MESSAGE_STATE_SENT)
{
- m_processor->AddLog(CEC_LOG_ERROR, "command was not sent");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "command was not sent");
}
if (data->expectControllerAck)
else
{
data->state = ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED;
- m_processor->AddLog(CEC_LOG_DEBUG, "did not receive ack");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "did not receive ack");
}
}
else
else if (buf == MSGSTART) //we found a msgstart before msgend, this is not right, remove
{
if (msg.Size() > 0)
- m_processor->AddLog(CEC_LOG_WARNING, "received MSGSTART before MSGEND, removing previous buffer contents");
+ CLibCEC::AddLog(CEC_LOG_WARNING, "received MSGSTART before MSGEND, removing previous buffer contents");
msg.Clear();
bGotStart = true;
}
if (!IsRunning())
return bReturn;
- m_processor->AddLog(CEC_LOG_DEBUG, "starting the bootloader");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "starting the bootloader");
CCECAdapterMessage *output = new CCECAdapterMessage;
output->PushBack(MSGSTART);
output->expectControllerAck = false;
if ((bReturn = Write(output)) == false)
- m_processor->AddLog(CEC_LOG_ERROR, "could not start the bootloader");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not start the bootloader");
delete output;
return bReturn;
if (!IsRunning())
return bReturn;
- m_processor->AddLog(CEC_LOG_DEBUG, "sending ping");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "sending ping");
CCECAdapterMessage *output = new CCECAdapterMessage;
output->PushBack(MSGSTART);
output->isTransmission = false;
if ((bReturn = Write(output)) == false)
- m_processor->AddLog(CEC_LOG_ERROR, "could not ping the adapter");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not ping the adapter");
delete output;
return bReturn;
if (iReturn == CEC_FW_VERSION_UNKNOWN)
{
- m_processor->AddLog(CEC_LOG_DEBUG, "requesting the firmware version");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "requesting the firmware version");
CCECAdapterMessage *output = new CCECAdapterMessage;
output->PushBack(MSGSTART);
CCECAdapterMessage input;
if (!Read(input, CEC_DEFAULT_TRANSMIT_WAIT) || input.Message() != MSGCODE_FIRMWARE_VERSION || input.Size() != 3)
- m_processor->AddLog(CEC_LOG_ERROR, "no or invalid firmware version");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "no or invalid firmware version");
else
{
m_iFirmwareVersion = (input[1] << 8 | input[2]);
output->isTransmission = false;
if ((bReturn = Write(output)) == false)
- m_processor->AddLog(CEC_LOG_ERROR, "could not set the idletime");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not set the idletime");
delete output;
}
bool bReturn(false);
CStdString strLog;
strLog.Format("setting ackmask to %2x", iMask);
- m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, strLog.c_str());
CCECAdapterMessage *output = new CCECAdapterMessage;
output->isTransmission = false;
if ((bReturn = Write(output)) == false)
- m_processor->AddLog(CEC_LOG_ERROR, "could not set the ackmask");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "could not set the ackmask");
delete output;
return bReturn;
if (bError)
{
message->reply = msg.Message();
- m_processor->AddLog(CEC_LOG_DEBUG, msg.ToString());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, msg.ToString());
}
else
{
switch(msg.Message())
{
case MSGCODE_COMMAND_ACCEPTED:
- m_processor->AddLog(CEC_LOG_DEBUG, msg.ToString());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, msg.ToString());
if (iPacketsLeft > 0)
iPacketsLeft--;
if (!message->isTransmission && iPacketsLeft == 0)
bTransmitSucceeded = true;
break;
case MSGCODE_TRANSMIT_SUCCEEDED:
- m_processor->AddLog(CEC_LOG_DEBUG, msg.ToString());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, msg.ToString());
bTransmitSucceeded = (iPacketsLeft == 0);
bError = !bTransmitSucceeded;
message->reply = MSGCODE_TRANSMIT_SUCCEEDED;
{
CStdString strError;
strError.Format("error reading from serial port: %s", m_port->GetError().c_str());
- m_processor->AddLog(CEC_LOG_ERROR, strError);
+ CLibCEC::AddLog(CEC_LOG_ERROR, strError);
return false;
}
else if (iBytesRead > 0)
{
CStdString strError;
strError.Format("error writing to serial port: %s", m_port->GetError().c_str());
- m_processor->AddLog(CEC_LOG_ERROR, strError);
+ CLibCEC::AddLog(CEC_LOG_ERROR, strError);
msg->state = ADAPTER_MESSAGE_STATE_ERROR;
}
else
{
- m_processor->AddLog(CEC_LOG_DEBUG, "command sent");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "command sent");
msg->state = ADAPTER_MESSAGE_STATE_SENT;
}
msg->condition.Signal();
#include "CECAudioSystem.h"
#include "../CECProcessor.h"
#include "../implementations/CECCommandHandler.h"
+#include "../LibCEC.h"
using namespace CEC;
using namespace PLATFORM;
CLockObject lock(m_mutex);
if (m_audioStatus != status)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): audio status changed from %2x to %2x", GetLogicalAddressName(), m_iLogicalAddress, m_audioStatus, status);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): audio status changed from %2x to %2x", GetLogicalAddressName(), m_iLogicalAddress, m_audioStatus, status);
m_audioStatus = status;
return true;
}
CLockObject lock(m_mutex);
if (m_systemAudioStatus != mode)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): system audio mode status changed from %s to %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_systemAudioStatus), ToString(mode));
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): system audio mode status changed from %s to %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_systemAudioStatus), ToString(mode));
m_systemAudioStatus = mode;
return true;
}
uint8_t state;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %x -> %x: audio status '%2x'", m_iLogicalAddress, dest, m_audioStatus);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %x -> %x: audio status '%2x'", m_iLogicalAddress, dest, m_audioStatus);
state = m_audioStatus;
}
cec_system_audio_status state;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %x -> %x: set system audio mode '%2x'", m_iLogicalAddress, dest, m_audioStatus);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %x -> %x: set system audio mode '%2x'", m_iLogicalAddress, dest, m_audioStatus);
state = m_systemAudioStatus;
}
cec_system_audio_status state;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %x -> %x: system audio mode '%s'", m_iLogicalAddress, dest, ToString(m_systemAudioStatus));
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %x -> %x: system audio mode '%s'", m_iLogicalAddress, dest, ToString(m_systemAudioStatus));
state = m_systemAudioStatus;
}
#include "../implementations/CECCommandHandler.h"
#include "../implementations/SLCommandHandler.h"
#include "../implementations/VLCommandHandler.h"
+#include "../LibCEC.h"
using namespace CEC;
using namespace PLATFORM;
delete m_handler;
}
-void CCECBusDevice::AddLog(cec_log_level level, const CStdString &strMessage)
-{
- m_processor->AddLog(level, strMessage);
-}
-
bool CCECBusDevice::HandleCommand(const cec_command &command)
{
bool bHandled(false);
if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
{
if (m_deviceStatus != CEC_DEVICE_STATUS_PRESENT)
- {
- CStdString strLog;
- strLog.Format("device %s (%x) status changed to present after command %s", GetLogicalAddressName(), (uint8_t)GetLogicalAddress(), ToString(command.opcode));
- AddLog(CEC_LOG_DEBUG, strLog);
- }
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "device %s (%x) status changed to present after command %s", GetLogicalAddressName(), (uint8_t)GetLogicalAddress(), ToString(command.opcode));
m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
}
}
bool CCECBusDevice::PowerOn(void)
{
- CStdString strLog;
- strLog.Format("<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
if (m_handler->TransmitImageViewOn(GetMyLogicalAddress(), m_iLogicalAddress))
{
// /* sending the normal power on command appears to have failed */
// CStdString strLog;
// strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
-// AddLog(CEC_LOG_DEBUG, strLog.c_str());
+// CLibCEC::AddLog(CEC_LOG_DEBUG, strLog.c_str());
//
// TransmitKeypress(CEC_USER_CONTROL_CODE_POWER);
// return TransmitKeyRelease();
bool CCECBusDevice::Standby(void)
{
- CStdString strLog;
- strLog.Format("<< putting '%s' (%X) in standby mode", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< putting '%s' (%X) in standby mode", GetLogicalAddressName(), m_iLogicalAddress);
return m_handler->TransmitStandby(GetMyLogicalAddress(), m_iLogicalAddress);
}
if (!MyLogicalAddressContains(m_iLogicalAddress))
{
m_handler->MarkBusy();
- CStdString strLog;
- strLog.Format("<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bReturn = m_handler->TransmitRequestCecVersion(GetMyLogicalAddress(), m_iLogicalAddress);
m_handler->MarkReady();
!IsUnsupportedFeature(CEC_OPCODE_GET_MENU_LANGUAGE))
{
m_handler->MarkBusy();
- CStdString strLog;
- strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bReturn = m_handler->TransmitRequestMenuLanguage(GetMyLogicalAddress(), m_iLogicalAddress);
m_handler->MarkReady();
}
!IsUnsupportedFeature(CEC_OPCODE_GIVE_OSD_NAME))
{
m_handler->MarkBusy();
- CStdString strLog;
- strLog.Format("<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bReturn = m_handler->TransmitRequestOSDName(GetMyLogicalAddress(), m_iLogicalAddress);
m_handler->MarkReady();
}
}
if (bRequestUpdate && !RequestPhysicalAddress())
- AddLog(CEC_LOG_ERROR, "failed to request the physical address (1)");
+ CLibCEC::AddLog(CEC_LOG_ERROR, "failed to request the physical address");
CLockObject lock(m_mutex);
return m_iPhysicalAddress;
if (!MyLogicalAddressContains(m_iLogicalAddress))
{
m_handler->MarkBusy();
- CStdString strLog;
- strLog.Format("<< requesting physical address of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting physical address of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bReturn = m_handler->TransmitRequestPhysicalAddress(GetMyLogicalAddress(), m_iLogicalAddress);
m_handler->MarkReady();
}
!IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS))
{
m_handler->MarkBusy();
- CStdString strLog;
- strLog.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bReturn = m_handler->TransmitRequestPowerStatus(GetMyLogicalAddress(), m_iLogicalAddress);
m_handler->MarkReady();
}
if (!MyLogicalAddressContains(m_iLogicalAddress))
{
m_handler->MarkBusy();
- CStdString strLog;
- strLog.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bReturn = m_handler->TransmitRequestVendorId(GetMyLogicalAddress(), m_iLogicalAddress);
m_handler->MarkReady();
void CCECBusDevice::SetCecVersion(const cec_version newVersion)
{
m_cecVersion = newVersion;
-
- CStdString strLog;
- strLog.Format("%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(newVersion));
- AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(newVersion));
}
void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
CLockObject lock(m_mutex);
if (language.device == m_iLogicalAddress)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): menu language set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, language.language);
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): menu language set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, language.language);
m_menuLanguage = language;
}
}
CLockObject lock(m_mutex);
if (m_strDeviceName != strName)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): osd name set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, strName);
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): osd name set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, strName.c_str());
m_strDeviceName = strName;
}
}
CLockObject lock(m_mutex);
if (m_menuState != state)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): menu state set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_menuState));
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): menu state set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_menuState));
m_menuState = state;
}
}
{
CLockObject lock(m_mutex);
if (!m_bActiveSource)
- {
- CStdString strLog;
- strLog.Format("making %s (%x) the active source", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- }
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "making %s (%x) the active source", GetLogicalAddressName(), m_iLogicalAddress);
for (int iPtr = 0; iPtr < 16; iPtr++)
if (iPtr != m_iLogicalAddress)
bool CCECBusDevice::TryLogicalAddress(void)
{
- CStdString strLog;
- strLog.Format("trying logical address '%s'", GetLogicalAddressName());
- AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "trying logical address '%s'", GetLogicalAddressName());
m_processor->SetAckMask(0x1 << m_iLogicalAddress);
if (!TransmitPoll(m_iLogicalAddress))
{
- strLog.Format("using logical address '%s'", GetLogicalAddressName());
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "using logical address '%s'", GetLogicalAddressName());
SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC);
return true;
}
- strLog.Format("logical address '%s' already taken", GetLogicalAddressName());
- AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "logical address '%s' already taken", GetLogicalAddressName());
SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT);
return false;
}
CLockObject lock(m_mutex);
if (iNewAddress > 0 && m_iPhysicalAddress != iNewAddress)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress, iNewAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress, iNewAddress);
m_iPhysicalAddress = iNewAddress;
}
}
CLockObject lock(m_mutex);
if (iNewAddress > 0)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress == 0 ? m_iStreamPath : iOldAddress, iNewAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress == 0 ? m_iStreamPath : iOldAddress, iNewAddress);
m_iStreamPath = iNewAddress;
if (iNewAddress > 0)
if (m_powerStatus != powerStatus)
{
m_iLastPowerStateUpdate = GetTimeMs();
- CStdString strLog;
- strLog.Format(">> %s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(powerStatus));
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(powerStatus));
m_powerStatus = powerStatus;
}
}
CStdString strLog;
if (m_handler->InUse())
{
- strLog.Format("handler for device '%s' (%x) is being used. not replacing the command handler", GetLogicalAddressName(), GetLogicalAddress());
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "handler for device '%s' (%x) is being used. not replacing the command handler", GetLogicalAddressName(), GetLogicalAddress());
return false;
}
- strLog.Format("replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress());
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress());
delete m_handler;
switch (m_vendor)
m_vendor = (cec_vendor_id)iVendorId;
}
- CStdString strLog;
- strLog.Format("%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_vendor), m_vendor);
- m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_vendor), m_vendor);
return bVendorChanged;
}
{
CLockObject lock(m_mutex);
if (m_powerStatus != CEC_POWER_STATUS_ON)
- {
- CStdString strLog;
- strLog.Format("<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- }
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress);
else if (m_bActiveSource)
{
- CStdString strLog;
- strLog.Format("<< %s (%X) -> broadcast (F): active source (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> broadcast (F): active source (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
bSendActiveSource = true;
}
else
- {
- CStdString strLog;
- strLog.Format("<< %s (%X) is not the active source", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- }
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< %s (%X) is not the active source", GetLogicalAddressName(), m_iLogicalAddress);
}
if (bSendActiveSource)
cec_version version;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_cecVersion));
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_cecVersion));
version = m_cecVersion;
}
uint16_t iPhysicalAddress;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %s (%X) -> broadcast (F): inactive source", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> broadcast (F): inactive source", GetLogicalAddressName(), m_iLogicalAddress);
iPhysicalAddress = m_iPhysicalAddress;
}
cec_menu_state menuState;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState));
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState));
menuState = m_menuState;
}
CStdString strDeviceName;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, m_strDeviceName.c_str());
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, m_strDeviceName.c_str());
strDeviceName = m_strDeviceName;
}
{
if (!IsUnsupportedFeature(CEC_OPCODE_SET_OSD_STRING))
{
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
return m_handler->TransmitOSDString(m_iLogicalAddress, dest, duration, strMessage);
}
return false;
if (m_iPhysicalAddress == 0xffff)
return false;
- CStdString strLog;
- strLog.Format("<< %s (%X) -> broadcast (F): physical adddress %4x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> broadcast (F): physical adddress %4x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
iPhysicalAddress = m_iPhysicalAddress;
type = m_type;
}
if (destDevice->m_deviceStatus == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
return bReturn;
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
bReturn = m_handler->TransmitPoll(m_iLogicalAddress, dest);
- AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
CLockObject lock(m_mutex);
if (bReturn)
cec_power_status state;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus));
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus));
state = m_powerStatus;
}
{
if (bSendAbort)
{
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
- AddLog(CEC_LOG_NOTICE, strLog);
-
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
}
return false;
}
else
{
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): vendor id %s (%x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString((cec_vendor_id)iVendorId), iVendorId);
- AddLog(CEC_LOG_NOTICE, strLog);
-
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): vendor id %s (%x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString((cec_vendor_id)iVendorId), iVendorId);
return m_handler->TransmitVendorID(m_iLogicalAddress, iVendorId);
}
}
CCECBusDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0);
virtual ~CCECBusDevice(void);
- virtual void AddLog(cec_log_level level, const CStdString &strMessage);
virtual bool HandleCommand(const cec_command &command);
virtual bool PowerOn(void);
virtual bool Standby(void);
#include "CECPlaybackDevice.h"
#include "../implementations/CECCommandHandler.h"
#include "../CECProcessor.h"
+#include "../LibCEC.h"
using namespace CEC;
using namespace PLATFORM;
CLockObject lock(m_mutex);
if (m_deckStatus != deckStatus && m_deckStatus != CEC_DECK_INFO_OTHER_STATUS_LG)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): deck status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_deckStatus), ToString(deckStatus));
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): deck status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_deckStatus), ToString(deckStatus));
m_deckStatus = deckStatus;
}
}
CLockObject lock(m_mutex);
if (m_deckControlMode != mode)
{
- CStdString strLog;
- strLog.Format(">> %s (%X): deck control mode changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_deckControlMode), ToString(mode));
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): deck control mode changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_deckControlMode), ToString(mode));
m_deckControlMode = mode;
}
}
cec_deck_info state;
{
CLockObject lock(m_mutex);
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): deck status '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_deckStatus));
- AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): deck status '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_deckStatus));
state = m_deckStatus;
}
#include "ANCommandHandler.h"
#include "../devices/CECBusDevice.h"
#include "../CECProcessor.h"
+#include "../LibCEC.h"
using namespace CEC;
if (key.keycode != CEC_USER_CONTROL_CODE_UNKNOWN)
{
- CStdString strLog;
- strLog.Format("key pressed: %1x", key.keycode);
- m_busDevice->AddLog(CEC_LOG_DEBUG, strLog);
-
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "key pressed: %1x", key.keycode);
m_busDevice->GetProcessor()->AddKey(key);
}
}
#include "../devices/CECAudioSystem.h"
#include "../devices/CECPlaybackDevice.h"
#include "../CECProcessor.h"
+#include "../LibCEC.h"
using namespace CEC;
using namespace std;
bool bHandled(true);
MarkBusy();
- CStdString strLog;
- strLog.Format(">> %s (%X) -> %s (%X): %s (%2X)", m_processor->ToString(command.initiator), command.initiator, m_processor->ToString(command.destination), command.destination, m_processor->ToString(command.opcode), command.opcode);
- m_busDevice->AddLog(CEC_LOG_NOTICE, strLog);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, ">> %s (%X) -> %s (%X): %s (%2X)", m_processor->ToString(command.initiator), command.initiator, m_processor->ToString(command.destination), command.destination, m_processor->ToString(command.opcode), command.opcode);
m_processor->AddCommand(command);
{
if (m_processor->IsStarted())
{
- CStdString strLog;
- strLog.Format(">> %i requests active source", (uint8_t) command.initiator);
- m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %i requests active source", (uint8_t) command.initiator);
vector<CCECBusDevice *> devices;
for (size_t iDevicePtr = 0; iDevicePtr < GetMyDevices(devices); iDevicePtr++)
if (m_processor->IsStarted() && command.parameters.size >= 2)
{
uint16_t iStreamAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
- CStdString strLog;
- strLog.Format(">> %i sets stream path to physical address %04x", command.initiator, iStreamAddress);
- m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %i sets stream path to physical address %04x", command.initiator, iStreamAddress);
/* one of the device handled by libCEC has been made active */
CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress);
if (command.parameters[0] <= CEC_USER_CONTROL_CODE_MAX)
{
- CStdString strLog;
- strLog.Format("key pressed: %x", command.parameters[0]);
- m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "key pressed: %x", command.parameters[0]);
if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER ||
command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION)
void CCECCommandHandler::UnhandledCommand(const cec_command &command)
{
- CStdString strLog;
- strLog.Format("unhandled command with opcode %02x from address %d", command.opcode, command.initiator);
- m_busDevice->AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "unhandled command with opcode %02x from address %d", command.opcode, command.initiator);
}
size_t CCECCommandHandler::GetMyDevices(vector<CCECBusDevice *> &devices) const
bool bChanged(false);
if (command.parameters.size < 3)
{
- m_busDevice->AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
+ CLibCEC::AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
return bChanged;
}
void CCECCommandHandler::HandlePoll(const cec_logical_address iInitiator, const cec_logical_address iDestination)
{
- CStdString strLog;
- strLog.Format("<< POLL: %s (%x) -> %s (%x)", m_processor->ToString(iInitiator), iInitiator, m_processor->ToString(iDestination), iDestination);
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< POLL: %s (%x) -> %s (%x)", m_processor->ToString(iInitiator), iInitiator, m_processor->ToString(iDestination), iDestination);
}
bool CCECCommandHandler::HandleReceiveFailed(void)
m_expectedResponse = expectedResponse;
if (m_processor->Transmit(command))
{
- m_processor->AddLog(CEC_LOG_DEBUG, "command transmitted");
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "command transmitted");
bReturn = bExpectResponse ?
m_condition.Wait(m_receiveMutex, m_iTransmitWait) :
true;