Commit | Line | Data |
---|---|---|
abbca718 LOK |
1 | /* |
2 | * This file is part of the libCEC(R) library. | |
3 | * | |
b492c10e | 4 | * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. |
abbca718 LOK |
5 | * libCEC(R) is an original work, containing original code. |
6 | * | |
7 | * libCEC(R) is a trademark of Pulse-Eight Limited. | |
8 | * | |
9 | * This program is dual-licensed; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | * | |
23 | * | |
24 | * Alternatively, you can license this library under a commercial license, | |
25 | * please contact Pulse-Eight Licensing for more information. | |
26 | * | |
27 | * For more information contact: | |
28 | * Pulse-Eight Licensing <license@pulse-eight.com> | |
29 | * http://www.pulse-eight.com/ | |
30 | * http://www.pulse-eight.net/ | |
31 | */ | |
32 | ||
2abe74eb | 33 | #include "CECProcessor.h" |
abbca718 | 34 | |
7bb4ed43 | 35 | #include "adapter/USBCECAdapterCommunication.h" |
eafa9d46 | 36 | #include "devices/CECBusDevice.h" |
51b2a094 LOK |
37 | #include "devices/CECAudioSystem.h" |
38 | #include "devices/CECPlaybackDevice.h" | |
39 | #include "devices/CECRecordingDevice.h" | |
40 | #include "devices/CECTuner.h" | |
41 | #include "devices/CECTV.h" | |
62f5527d | 42 | #include "implementations/CECCommandHandler.h" |
2abe74eb | 43 | #include "LibCEC.h" |
ba65909d | 44 | #include "platform/util/timeutils.h" |
abbca718 LOK |
45 | |
46 | using namespace CEC; | |
47 | using namespace std; | |
f00ff009 | 48 | using namespace PLATFORM; |
abbca718 | 49 | |
3efda01a | 50 | CCECProcessor::CCECProcessor(CLibCEC *controller, libcec_configuration *configuration) : |
80726797 | 51 | m_bConnectionOpened(false), |
caca2d81 | 52 | m_bInitialised(false), |
caca2d81 LOK |
53 | m_communication(NULL), |
54 | m_controller(controller), | |
55 | m_bMonitor(false), | |
56 | m_iStandardLineTimeout(3), | |
57 | m_iRetryLineTimeout(3), | |
30b4aac0 | 58 | m_iLastTransmission(0) |
caca2d81 | 59 | { |
caca2d81 | 60 | CreateBusDevices(); |
30b4aac0 | 61 | m_configuration.Clear(); |
e69d8f19 | 62 | m_configuration.serverVersion = CEC_SERVER_VERSION_1_6_0; |
30b4aac0 LOK |
63 | SetConfiguration(configuration); |
64 | ||
65 | if (m_configuration.tvVendor != CEC_VENDOR_UNKNOWN) | |
ed63a515 | 66 | m_busDevices[CECDEVICE_TV]->ReplaceHandler(false); |
caca2d81 LOK |
67 | } |
68 | ||
7bdfd76c | 69 | CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types, uint16_t iPhysicalAddress) : |
80726797 | 70 | m_bConnectionOpened(false), |
b64db02e | 71 | m_bInitialised(false), |
99666519 | 72 | m_communication(NULL), |
f8513317 | 73 | m_controller(controller), |
dcd240b2 LOK |
74 | m_bMonitor(false), |
75 | m_iStandardLineTimeout(3), | |
5f316715 | 76 | m_iRetryLineTimeout(3), |
30b4aac0 | 77 | m_iLastTransmission(0) |
f8513317 | 78 | { |
30b4aac0 | 79 | m_configuration.Clear(); |
e69d8f19 | 80 | m_configuration.serverVersion = CEC_SERVER_VERSION_1_6_0; |
30b4aac0 LOK |
81 | |
82 | // client version < 1.5.0 | |
3efda01a | 83 | m_configuration.clientVersion = (uint32_t)CEC_CLIENT_VERSION_PRE_1_5; |
30b4aac0 LOK |
84 | snprintf(m_configuration.strDeviceName, 13, "%s", strDeviceName); |
85 | m_configuration.deviceTypes = types; | |
86 | m_configuration.iPhysicalAddress = iPhysicalAddress; | |
87 | m_configuration.baseDevice = (cec_logical_address)CEC_DEFAULT_BASE_DEVICE; | |
88 | m_configuration.iHDMIPort = CEC_DEFAULT_HDMI_PORT; | |
89 | ||
90 | if (m_configuration.deviceTypes.IsEmpty()) | |
91 | m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); | |
caca2d81 LOK |
92 | CreateBusDevices(); |
93 | } | |
94 | ||
95 | void CCECProcessor::CreateBusDevices(void) | |
96 | { | |
f8513317 | 97 | for (int iPtr = 0; iPtr < 16; iPtr++) |
51b2a094 LOK |
98 | { |
99 | switch(iPtr) | |
100 | { | |
101 | case CECDEVICE_AUDIOSYSTEM: | |
5d5a2dc2 | 102 | m_busDevices[iPtr] = new CCECAudioSystem(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
103 | break; |
104 | case CECDEVICE_PLAYBACKDEVICE1: | |
105 | case CECDEVICE_PLAYBACKDEVICE2: | |
106 | case CECDEVICE_PLAYBACKDEVICE3: | |
5d5a2dc2 | 107 | m_busDevices[iPtr] = new CCECPlaybackDevice(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
108 | break; |
109 | case CECDEVICE_RECORDINGDEVICE1: | |
110 | case CECDEVICE_RECORDINGDEVICE2: | |
111 | case CECDEVICE_RECORDINGDEVICE3: | |
5d5a2dc2 | 112 | m_busDevices[iPtr] = new CCECRecordingDevice(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
113 | break; |
114 | case CECDEVICE_TUNER1: | |
115 | case CECDEVICE_TUNER2: | |
116 | case CECDEVICE_TUNER3: | |
117 | case CECDEVICE_TUNER4: | |
5d5a2dc2 | 118 | m_busDevices[iPtr] = new CCECTuner(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
119 | break; |
120 | case CECDEVICE_TV: | |
121 | m_busDevices[iPtr] = new CCECTV(this, (cec_logical_address) iPtr, 0); | |
122 | break; | |
123 | default: | |
5d5a2dc2 | 124 | m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
125 | break; |
126 | } | |
127 | } | |
f8513317 LOK |
128 | } |
129 | ||
2abe74eb | 130 | CCECProcessor::~CCECProcessor(void) |
abbca718 | 131 | { |
eca71746 | 132 | Close(); |
7c63a480 | 133 | |
d1998c7b | 134 | for (unsigned int iPtr = 0; iPtr < 16; iPtr++) |
f401a435 | 135 | { |
d1998c7b | 136 | delete m_busDevices[iPtr]; |
f401a435 LOK |
137 | m_busDevices[iPtr] = NULL; |
138 | } | |
abbca718 LOK |
139 | } |
140 | ||
eca71746 LOK |
141 | void CCECProcessor::Close(void) |
142 | { | |
f9e01dac LOK |
143 | StopThread(false); |
144 | SetInitialised(false); | |
eca71746 LOK |
145 | StopThread(); |
146 | ||
80726797 LOK |
147 | bool bClose(false); |
148 | { | |
149 | CLockObject lock(m_mutex); | |
150 | bClose = m_bConnectionOpened; | |
151 | m_bConnectionOpened = false; | |
152 | } | |
153 | ||
154 | if (bClose && m_communication) | |
eca71746 | 155 | { |
eca71746 LOK |
156 | delete m_communication; |
157 | m_communication = NULL; | |
158 | } | |
159 | } | |
160 | ||
f80cd208 | 161 | bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs, bool bStartListening /* = true */) |
abbca718 | 162 | { |
a674fd68 | 163 | bool bReturn(false); |
80726797 LOK |
164 | Close(); |
165 | ||
578c3905 | 166 | { |
80726797 LOK |
167 | CLockObject lock(m_mutex); |
168 | if (m_bConnectionOpened) | |
169 | { | |
170 | CLibCEC::AddLog(CEC_LOG_ERROR, "connection already opened"); | |
171 | return false; | |
172 | } | |
173 | m_communication = new CUSBCECAdapterCommunication(this, strPort, iBaudRate); | |
174 | m_bConnectionOpened = (m_communication != NULL); | |
578c3905 | 175 | } |
1113cb7d | 176 | |
3b5e433a | 177 | CTimeout timeout(iTimeoutMs > 0 ? iTimeoutMs : CEC_DEFAULT_TRANSMIT_WAIT); |
c520af4f | 178 | |
578c3905 | 179 | /* open a new connection */ |
efed01e1 | 180 | unsigned iConnectTry(0); |
a75e3a5a | 181 | while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open((timeout.TimeLeft() / CEC_CONNECT_TRIES), false, bStartListening)) == false) |
3d78df91 LOK |
182 | { |
183 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry); | |
d55f263f | 184 | m_communication->Close(); |
a88017b8 | 185 | CEvent::Sleep(1000); |
3d78df91 | 186 | } |
56035c86 | 187 | |
efed01e1 | 188 | if (bReturn) |
e69d8f19 LOK |
189 | { |
190 | m_configuration.iFirmwareVersion = m_communication->GetFirmwareVersion(); | |
191 | CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d, client version = %s", m_configuration.iFirmwareVersion, ToString((cec_client_version)m_configuration.clientVersion)); | |
192 | } | |
3d78df91 | 193 | |
12a36be9 | 194 | if (m_configuration.bGetSettingsFromROM == 1) |
7c5c5bf4 LOK |
195 | { |
196 | libcec_configuration config; | |
197 | config.Clear(); | |
198 | m_communication->GetConfiguration(&config); | |
199 | ||
200 | CLockObject lock(m_mutex); | |
201 | if (!config.deviceTypes.IsEmpty()) | |
202 | m_configuration.deviceTypes = config.deviceTypes; | |
203 | if (config.iPhysicalAddress > 0) | |
204 | m_configuration.iPhysicalAddress = config.iPhysicalAddress; | |
205 | snprintf(m_configuration.strDeviceName, 13, "%s", config.strDeviceName); | |
206 | } | |
12a36be9 | 207 | |
578c3905 LOK |
208 | return bReturn; |
209 | } | |
210 | ||
0cfdeb5a LOK |
211 | bool CCECProcessor::IsInitialised(void) |
212 | { | |
213 | CLockObject lock(m_mutex); | |
214 | return m_bInitialised; | |
215 | } | |
216 | ||
2db8981f | 217 | void CCECProcessor::SetInitialised(bool bSetTo /* = true */) |
578c3905 | 218 | { |
578c3905 | 219 | CLockObject lock(m_mutex); |
2db8981f LOK |
220 | m_bInitialised = bSetTo; |
221 | } | |
578c3905 | 222 | |
2db8981f LOK |
223 | bool CCECProcessor::Initialise(void) |
224 | { | |
225 | bool bReturn(false); | |
578c3905 | 226 | { |
2db8981f | 227 | CLockObject lock(m_mutex); |
dd18e809 LOK |
228 | if (!m_configuration.logicalAddresses.IsEmpty()) |
229 | m_configuration.logicalAddresses.Clear(); | |
578c3905 | 230 | |
2db8981f LOK |
231 | if (!FindLogicalAddresses()) |
232 | { | |
5477a250 | 233 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not detect our logical addresses"); |
2db8981f LOK |
234 | return bReturn; |
235 | } | |
236 | ||
237 | /* only set our OSD name for the primary device */ | |
dd18e809 | 238 | m_busDevices[m_configuration.logicalAddresses.primary]->m_strDeviceName = m_configuration.strDeviceName; |
80726797 LOK |
239 | |
240 | /* make the primary device the active source if the option is set */ | |
241 | if (m_configuration.bActivateSource == 1) | |
dd18e809 | 242 | m_busDevices[m_configuration.logicalAddresses.primary]->m_bActiveSource = true; |
2db8981f | 243 | } |
578c3905 LOK |
244 | |
245 | /* get the vendor id from the TV, so we are using the correct handler */ | |
30b4aac0 | 246 | m_busDevices[CECDEVICE_TV]->GetVendorId(); |
578c3905 | 247 | |
30b4aac0 | 248 | if (m_configuration.iPhysicalAddress != 0) |
4f362964 | 249 | { |
30b4aac0 | 250 | CLibCEC::AddLog(CEC_LOG_NOTICE, "setting the physical address to %4x", m_configuration.iPhysicalAddress); |
dd18e809 LOK |
251 | m_busDevices[m_configuration.logicalAddresses.primary]->m_iPhysicalAddress = m_configuration.iPhysicalAddress; |
252 | if ((bReturn = m_busDevices[m_configuration.logicalAddresses.primary]->TransmitPhysicalAddress()) == false) | |
30b4aac0 | 253 | CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set the physical address to %4x", m_configuration.iPhysicalAddress); |
4f362964 | 254 | } |
30b4aac0 LOK |
255 | else if (m_configuration.iPhysicalAddress == 0 && (bReturn = SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort, true)) == false) |
256 | CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set HDMI port %d on %s (%x)", m_configuration.iHDMIPort, ToString(m_configuration.baseDevice), (uint8_t)m_configuration.baseDevice); | |
2db8981f | 257 | |
1bfdc9bd | 258 | if (bReturn && m_configuration.bActivateSource == 1) |
dd18e809 | 259 | m_busDevices[m_configuration.logicalAddresses.primary]->ActivateSource(); |
80726797 | 260 | |
2db8981f | 261 | SetInitialised(bReturn); |
ba73be2f LOK |
262 | if (bReturn) |
263 | CLibCEC::ConfigurationChanged(m_configuration); | |
578c3905 LOK |
264 | |
265 | return bReturn; | |
266 | } | |
267 | ||
268 | bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, uint32_t iTimeoutMs /* = 10000 */) | |
269 | { | |
270 | bool bReturn(false); | |
271 | ||
272 | { | |
273 | CLockObject lock(m_mutex); | |
274 | if (!OpenConnection(strPort, iBaudRate, iTimeoutMs)) | |
a674fd68 | 275 | return bReturn; |
994dbaaa | 276 | |
a674fd68 | 277 | /* create the processor thread */ |
8e57f83c | 278 | if (!CreateThread()) |
a674fd68 | 279 | { |
5477a250 | 280 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a processor thread"); |
a674fd68 | 281 | return bReturn; |
994dbaaa | 282 | } |
a674fd68 LOK |
283 | } |
284 | ||
578c3905 | 285 | if ((bReturn = Initialise()) == false) |
a674fd68 | 286 | { |
5477a250 | 287 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a processor thread"); |
578c3905 | 288 | StopThread(true); |
a674fd68 LOK |
289 | } |
290 | else | |
291 | { | |
5477a250 | 292 | CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started"); |
a674fd68 LOK |
293 | } |
294 | ||
295 | return bReturn; | |
abbca718 LOK |
296 | } |
297 | ||
b58d9277 | 298 | bool CCECProcessor::TryLogicalAddress(cec_logical_address address) |
f8513317 | 299 | { |
93fff5c1 | 300 | if (m_busDevices[address]->TryLogicalAddress()) |
f8513317 | 301 | { |
dd18e809 | 302 | m_configuration.logicalAddresses.Set(address); |
f8513317 LOK |
303 | return true; |
304 | } | |
305 | ||
f8513317 LOK |
306 | return false; |
307 | } | |
308 | ||
b58d9277 | 309 | bool CCECProcessor::FindLogicalAddressRecordingDevice(void) |
f8513317 | 310 | { |
5477a250 | 311 | CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'recording device'"); |
b58d9277 LOK |
312 | return TryLogicalAddress(CECDEVICE_RECORDINGDEVICE1) || |
313 | TryLogicalAddress(CECDEVICE_RECORDINGDEVICE2) || | |
314 | TryLogicalAddress(CECDEVICE_RECORDINGDEVICE3); | |
f8513317 LOK |
315 | } |
316 | ||
b58d9277 | 317 | bool CCECProcessor::FindLogicalAddressTuner(void) |
f8513317 | 318 | { |
5477a250 | 319 | CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'tuner'"); |
b58d9277 LOK |
320 | return TryLogicalAddress(CECDEVICE_TUNER1) || |
321 | TryLogicalAddress(CECDEVICE_TUNER2) || | |
322 | TryLogicalAddress(CECDEVICE_TUNER3) || | |
323 | TryLogicalAddress(CECDEVICE_TUNER4); | |
f8513317 LOK |
324 | } |
325 | ||
b58d9277 | 326 | bool CCECProcessor::FindLogicalAddressPlaybackDevice(void) |
f8513317 | 327 | { |
5477a250 | 328 | CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'playback device'"); |
b58d9277 LOK |
329 | return TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE1) || |
330 | TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE2) || | |
331 | TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE3); | |
f8513317 LOK |
332 | } |
333 | ||
b58d9277 | 334 | bool CCECProcessor::FindLogicalAddressAudioSystem(void) |
f8513317 | 335 | { |
5477a250 | 336 | CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'audio'"); |
b58d9277 | 337 | return TryLogicalAddress(CECDEVICE_AUDIOSYSTEM); |
f8513317 LOK |
338 | } |
339 | ||
3e61b350 LOK |
340 | bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to) |
341 | { | |
342 | bool bChanged(false); | |
343 | ||
5477a250 | 344 | CLibCEC::AddLog(CEC_LOG_NOTICE, "changing device type '%s' into '%s'", ToString(from), ToString(to)); |
3e61b350 | 345 | |
f00ff009 | 346 | CLockObject lock(m_mutex); |
3e61b350 | 347 | CCECBusDevice *previousDevice = GetDeviceByType(from); |
dd18e809 | 348 | m_configuration.logicalAddresses.primary = CECDEVICE_UNKNOWN; |
3e61b350 LOK |
349 | |
350 | for (unsigned int iPtr = 0; iPtr < 5; iPtr++) | |
351 | { | |
30b4aac0 | 352 | if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_RESERVED) |
3e61b350 LOK |
353 | continue; |
354 | ||
30b4aac0 | 355 | if (m_configuration.deviceTypes.types[iPtr] == from) |
3e61b350 LOK |
356 | { |
357 | bChanged = true; | |
30b4aac0 | 358 | m_configuration.deviceTypes.types[iPtr] = to; |
3e61b350 | 359 | } |
30b4aac0 | 360 | else if (m_configuration.deviceTypes.types[iPtr] == to && bChanged) |
3e61b350 | 361 | { |
30b4aac0 | 362 | m_configuration.deviceTypes.types[iPtr] = CEC_DEVICE_TYPE_RESERVED; |
3e61b350 LOK |
363 | } |
364 | } | |
365 | ||
366 | if (bChanged) | |
367 | { | |
368 | FindLogicalAddresses(); | |
369 | ||
370 | CCECBusDevice *newDevice = GetDeviceByType(to); | |
371 | if (previousDevice && newDevice) | |
372 | { | |
373 | newDevice->SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC); | |
4478bc79 | 374 | previousDevice->SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT); |
3e61b350 LOK |
375 | |
376 | newDevice->SetCecVersion(previousDevice->GetCecVersion(false)); | |
377 | previousDevice->SetCecVersion(CEC_VERSION_UNKNOWN); | |
378 | ||
379 | newDevice->SetMenuLanguage(previousDevice->GetMenuLanguage(false)); | |
380 | cec_menu_language lang; | |
381 | lang.device = previousDevice->GetLogicalAddress(); | |
382 | for (unsigned int iPtr = 0; iPtr < 4; iPtr++) | |
383 | lang.language[iPtr] = '?'; | |
384 | lang.language[3] = 0; | |
385 | previousDevice->SetMenuLanguage(lang); | |
386 | ||
387 | newDevice->SetMenuState(previousDevice->GetMenuState()); | |
388 | previousDevice->SetMenuState(CEC_MENU_STATE_DEACTIVATED); | |
389 | ||
390 | newDevice->SetOSDName(previousDevice->GetOSDName(false)); | |
391 | previousDevice->SetOSDName(ToString(previousDevice->GetLogicalAddress())); | |
392 | ||
393 | newDevice->SetPhysicalAddress(previousDevice->GetPhysicalAddress(false)); | |
394 | previousDevice->SetPhysicalAddress(0xFFFF); | |
395 | ||
396 | newDevice->SetPowerStatus(previousDevice->GetPowerStatus(false)); | |
397 | previousDevice->SetPowerStatus(CEC_POWER_STATUS_UNKNOWN); | |
398 | ||
399 | newDevice->SetVendorId(previousDevice->GetVendorId(false)); | |
400 | previousDevice->SetVendorId(CEC_VENDOR_UNKNOWN); | |
401 | ||
402 | if ((from == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || from == CEC_DEVICE_TYPE_RECORDING_DEVICE) && | |
403 | (to == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || to == CEC_DEVICE_TYPE_RECORDING_DEVICE)) | |
404 | { | |
405 | ((CCECPlaybackDevice *) newDevice)->SetDeckControlMode(((CCECPlaybackDevice *) previousDevice)->GetDeckControlMode()); | |
406 | ((CCECPlaybackDevice *) previousDevice)->SetDeckControlMode(CEC_DECK_CONTROL_MODE_STOP); | |
407 | ||
408 | ((CCECPlaybackDevice *) newDevice)->SetDeckStatus(((CCECPlaybackDevice *) previousDevice)->GetDeckStatus()); | |
409 | ((CCECPlaybackDevice *) previousDevice)->SetDeckStatus(CEC_DECK_INFO_STOP); | |
410 | } | |
411 | } | |
412 | } | |
413 | ||
414 | return true; | |
415 | } | |
416 | ||
f8513317 LOK |
417 | bool CCECProcessor::FindLogicalAddresses(void) |
418 | { | |
419 | bool bReturn(true); | |
dd18e809 | 420 | m_configuration.logicalAddresses.Clear(); |
f8513317 | 421 | |
30b4aac0 | 422 | if (m_configuration.deviceTypes.IsEmpty()) |
c39611ec LOK |
423 | { |
424 | CLibCEC::AddLog(CEC_LOG_ERROR, "no device types set"); | |
425 | return false; | |
426 | } | |
427 | ||
f8513317 LOK |
428 | for (unsigned int iPtr = 0; iPtr < 5; iPtr++) |
429 | { | |
30b4aac0 | 430 | if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_RESERVED) |
f8513317 LOK |
431 | continue; |
432 | ||
30b4aac0 | 433 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - device %d: type %d", __FUNCTION__, iPtr, m_configuration.deviceTypes.types[iPtr]); |
f8513317 | 434 | |
30b4aac0 | 435 | if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_RECORDING_DEVICE) |
b58d9277 | 436 | bReturn &= FindLogicalAddressRecordingDevice(); |
30b4aac0 | 437 | if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_TUNER) |
b58d9277 | 438 | bReturn &= FindLogicalAddressTuner(); |
30b4aac0 | 439 | if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_PLAYBACK_DEVICE) |
b58d9277 | 440 | bReturn &= FindLogicalAddressPlaybackDevice(); |
30b4aac0 | 441 | if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_AUDIO_SYSTEM) |
b58d9277 | 442 | bReturn &= FindLogicalAddressAudioSystem(); |
f8513317 LOK |
443 | } |
444 | ||
a674fd68 | 445 | if (bReturn) |
dd18e809 | 446 | SetAckMask(m_configuration.logicalAddresses.AckMask()); |
a674fd68 | 447 | |
f8513317 LOK |
448 | return bReturn; |
449 | } | |
450 | ||
a3ffc068 LOK |
451 | void CCECProcessor::ReplaceHandlers(void) |
452 | { | |
0cfdeb5a LOK |
453 | if (!IsInitialised()) |
454 | return; | |
a3ffc068 | 455 | for (uint8_t iPtr = 0; iPtr <= CECDEVICE_PLAYBACKDEVICE3; iPtr++) |
591170fd | 456 | m_busDevices[iPtr]->ReplaceHandler(m_bInitialised); |
a3ffc068 LOK |
457 | } |
458 | ||
b1f94db1 LOK |
459 | bool CCECProcessor::OnCommandReceived(const cec_command &command) |
460 | { | |
a4b9f561 | 461 | return m_inBuffer.Push(command); |
b1f94db1 LOK |
462 | } |
463 | ||
2abe74eb | 464 | void *CCECProcessor::Process(void) |
f99bc831 | 465 | { |
8e57f83c | 466 | CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started"); |
abbca718 | 467 | |
a4b9f561 LOK |
468 | cec_command command; |
469 | command.Clear(); | |
470 | ||
b1f94db1 | 471 | while (!IsStopped() && m_communication->IsOpen()) |
abbca718 | 472 | { |
a4b9f561 LOK |
473 | if (m_inBuffer.Pop(command, 500)) |
474 | ParseCommand(command); | |
475 | ||
f0154449 LOK |
476 | if (IsInitialised()) |
477 | { | |
478 | ReplaceHandlers(); | |
b5f34cf9 | 479 | |
f0154449 LOK |
480 | m_controller->CheckKeypressTimeout(); |
481 | } | |
abbca718 LOK |
482 | } |
483 | ||
60fa4578 | 484 | return NULL; |
abbca718 LOK |
485 | } |
486 | ||
18203d17 | 487 | bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */) |
abbca718 | 488 | { |
8ac9c610 LOK |
489 | bool bReturn(false); |
490 | ||
60fa4578 | 491 | if (!IsRunning()) |
8ac9c610 | 492 | return bReturn; |
f99bc831 | 493 | |
dd18e809 | 494 | cec_logical_address addr = m_configuration.logicalAddresses.primary; |
04437dcf | 495 | |
18203d17 LOK |
496 | if (type != CEC_DEVICE_TYPE_RESERVED) |
497 | { | |
90ea9066 | 498 | for (uint8_t iPtr = 0; iPtr <= 11; iPtr++) |
18203d17 | 499 | { |
dd18e809 | 500 | if (m_configuration.logicalAddresses[iPtr] && m_busDevices[iPtr]->m_type == type) |
18203d17 LOK |
501 | { |
502 | addr = (cec_logical_address) iPtr; | |
503 | break; | |
504 | } | |
505 | } | |
506 | } | |
507 | ||
37b0c572 | 508 | m_busDevices[addr]->SetActiveSource(); |
d383d6d0 | 509 | if (m_busDevices[addr]->GetPhysicalAddress(false) != 0xFFFF) |
bbc71623 | 510 | bReturn = m_busDevices[addr]->ActivateSource(); |
8d915412 LOK |
511 | |
512 | return bReturn; | |
18203d17 LOK |
513 | } |
514 | ||
37b0c572 LOK |
515 | bool CCECProcessor::SetActiveSource(uint16_t iStreamPath) |
516 | { | |
517 | bool bReturn(false); | |
518 | ||
a75e3a5a LOK |
519 | // suppress polls when searching for a device |
520 | CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath, false, true); | |
37b0c572 LOK |
521 | if (device) |
522 | { | |
523 | device->SetActiveSource(); | |
524 | bReturn = true; | |
525 | } | |
526 | ||
527 | return bReturn; | |
528 | } | |
529 | ||
dcd240b2 LOK |
530 | void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout) |
531 | { | |
f00ff009 | 532 | CLockObject lock(m_mutex); |
dcd240b2 LOK |
533 | m_iStandardLineTimeout = iTimeout; |
534 | } | |
535 | ||
536 | void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout) | |
537 | { | |
f00ff009 | 538 | CLockObject lock(m_mutex); |
dcd240b2 LOK |
539 | m_iRetryLineTimeout = iTimeout; |
540 | } | |
541 | ||
18203d17 LOK |
542 | bool CCECProcessor::SetActiveView(void) |
543 | { | |
8670c970 | 544 | CLibCEC::AddLog(CEC_LOG_WARNING, "deprecated method %s called", __FUNCTION__); |
30b4aac0 | 545 | return SetActiveSource(m_configuration.deviceTypes.IsEmpty() ? CEC_DEVICE_TYPE_RESERVED : m_configuration.deviceTypes[0]); |
8ac9c610 LOK |
546 | } |
547 | ||
28fa6c97 | 548 | bool CCECProcessor::SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate /* = true */) |
a9232a79 LOK |
549 | { |
550 | bool bReturn(false); | |
551 | ||
552 | CCECBusDevice *device = GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); | |
553 | if (device) | |
554 | { | |
555 | ((CCECPlaybackDevice *) device)->SetDeckControlMode(mode); | |
28fa6c97 LOK |
556 | if (bSendUpdate) |
557 | ((CCECPlaybackDevice *) device)->TransmitDeckStatus(CECDEVICE_TV); | |
a9232a79 LOK |
558 | bReturn = true; |
559 | } | |
560 | ||
561 | return bReturn; | |
562 | } | |
563 | ||
28fa6c97 | 564 | bool CCECProcessor::SetDeckInfo(cec_deck_info info, bool bSendUpdate /* = true */) |
a9232a79 LOK |
565 | { |
566 | bool bReturn(false); | |
567 | ||
568 | CCECBusDevice *device = GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); | |
569 | if (device) | |
570 | { | |
571 | ((CCECPlaybackDevice *) device)->SetDeckStatus(info); | |
28fa6c97 LOK |
572 | if (bSendUpdate) |
573 | ((CCECPlaybackDevice *) device)->TransmitDeckStatus(CECDEVICE_TV); | |
a9232a79 LOK |
574 | bReturn = true; |
575 | } | |
576 | ||
577 | return bReturn; | |
578 | } | |
579 | ||
d2f1c157 | 580 | bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, bool bForce /* = false */) |
16b1e052 LOK |
581 | { |
582 | bool bReturn(false); | |
583 | ||
86393878 MK |
584 | // limit the HDMI port range to 1-15 |
585 | if (iPort < 1) | |
586 | iPort = 1; | |
587 | if (iPort > 15) | |
588 | iPort = 15; | |
589 | ||
8670c970 LOK |
590 | { |
591 | CLockObject lock(m_mutex); | |
592 | m_configuration.baseDevice = iBaseDevice; | |
593 | m_configuration.iHDMIPort = iPort; | |
8670c970 LOK |
594 | } |
595 | ||
8e57f83c | 596 | if (!IsRunning() && !bForce) |
89b3c9df | 597 | return true; |
16b1e052 | 598 | |
5477a250 | 599 | CLibCEC::AddLog(CEC_LOG_DEBUG, "setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice); |
56035c86 | 600 | |
16b1e052 | 601 | uint16_t iPhysicalAddress(0); |
1e7afacd | 602 | if (iBaseDevice > CECDEVICE_TV) |
5d0c1164 | 603 | { |
1e7afacd | 604 | iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress(); |
5d0c1164 | 605 | } |
1e7afacd | 606 | |
a674fd68 | 607 | if (iPhysicalAddress < 0xffff) |
1e7afacd | 608 | { |
1e7afacd | 609 | if (iPhysicalAddress == 0) |
5d355340 | 610 | iPhysicalAddress += 0x1000 * iPort; |
1e7afacd | 611 | else if (iPhysicalAddress % 0x1000 == 0) |
5d355340 | 612 | iPhysicalAddress += 0x100 * iPort; |
1e7afacd | 613 | else if (iPhysicalAddress % 0x100 == 0) |
5d355340 | 614 | iPhysicalAddress += 0x10 * iPort; |
1e7afacd | 615 | else if (iPhysicalAddress % 0x10 == 0) |
5d355340 | 616 | iPhysicalAddress += iPort; |
1e7afacd | 617 | |
5d355340 | 618 | bReturn = true; |
16b1e052 LOK |
619 | } |
620 | ||
a674fd68 | 621 | if (!bReturn) |
5477a250 | 622 | CLibCEC::AddLog(CEC_LOG_ERROR, "failed to set the physical address"); |
f070564b | 623 | else |
f070564b | 624 | SetPhysicalAddress(iPhysicalAddress); |
a674fd68 | 625 | |
16b1e052 LOK |
626 | return bReturn; |
627 | } | |
628 | ||
45b97de7 | 629 | bool CCECProcessor::PhysicalAddressInUse(uint16_t iPhysicalAddress) |
16b1e052 | 630 | { |
9fd73dd4 | 631 | for (unsigned int iPtr = 0; iPtr < 15; iPtr++) |
16b1e052 LOK |
632 | { |
633 | if (m_busDevices[iPtr]->GetPhysicalAddress(false) == iPhysicalAddress) | |
634 | return true; | |
635 | } | |
636 | return false; | |
637 | } | |
638 | ||
ab27363d | 639 | bool CCECProcessor::TransmitInactiveSource(void) |
abbca718 | 640 | { |
60fa4578 | 641 | if (!IsRunning()) |
f99bc831 LOK |
642 | return false; |
643 | ||
dd18e809 LOK |
644 | if (!m_configuration.logicalAddresses.IsEmpty() && m_busDevices[m_configuration.logicalAddresses.primary]) |
645 | return m_busDevices[m_configuration.logicalAddresses.primary]->TransmitInactiveSource(); | |
cc60ab1c | 646 | return false; |
abbca718 LOK |
647 | } |
648 | ||
9dee1670 | 649 | void CCECProcessor::LogOutput(const cec_command &data) |
abbca718 | 650 | { |
1d3ca3de | 651 | CStdString strTx; |
57f45e6c LOK |
652 | strTx.Format("<< %02x", ((uint8_t)data.initiator << 4) + (uint8_t)data.destination); |
653 | if (data.opcode_set) | |
654 | strTx.AppendFormat(":%02x", (uint8_t)data.opcode); | |
9dee1670 | 655 | |
06a1f7ce | 656 | for (uint8_t iPtr = 0; iPtr < data.parameters.size; iPtr++) |
1d3ca3de | 657 | strTx.AppendFormat(":%02x", data.parameters[iPtr]); |
5477a250 | 658 | CLibCEC::AddLog(CEC_LOG_TRAFFIC, strTx.c_str()); |
9dee1670 | 659 | } |
2abe74eb | 660 | |
06bfd4d7 | 661 | bool CCECProcessor::SetLogicalAddress(cec_logical_address iLogicalAddress) |
abbca718 | 662 | { |
f00ff009 | 663 | CLockObject lock(m_mutex); |
dd18e809 | 664 | if (m_configuration.logicalAddresses.primary != iLogicalAddress) |
06775107 | 665 | { |
5477a250 | 666 | CLibCEC::AddLog(CEC_LOG_NOTICE, "<< setting primary logical address to %1x", iLogicalAddress); |
dd18e809 LOK |
667 | m_configuration.logicalAddresses.primary = iLogicalAddress; |
668 | m_configuration.logicalAddresses.Set(iLogicalAddress); | |
669 | return SetAckMask(m_configuration.logicalAddresses.AckMask()); | |
06775107 | 670 | } |
2abe74eb | 671 | |
06bfd4d7 | 672 | return true; |
abbca718 | 673 | } |
825ddb96 | 674 | |
28fa6c97 LOK |
675 | bool CCECProcessor::SetMenuState(cec_menu_state state, bool bSendUpdate /* = true */) |
676 | { | |
677 | for (uint8_t iPtr = 0; iPtr < 16; iPtr++) | |
678 | { | |
dd18e809 | 679 | if (m_configuration.logicalAddresses[iPtr]) |
28fa6c97 LOK |
680 | m_busDevices[iPtr]->SetMenuState(state); |
681 | } | |
682 | ||
683 | if (bSendUpdate) | |
dd18e809 | 684 | m_busDevices[m_configuration.logicalAddresses.primary]->TransmitMenuState(CECDEVICE_TV); |
28fa6c97 LOK |
685 | |
686 | return true; | |
687 | } | |
688 | ||
bebb19dc | 689 | bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress, bool bSendUpdate /* = true */) |
2492216a | 690 | { |
f070564b LOK |
691 | bool bSendActiveView(false); |
692 | bool bReturn(false); | |
4d6f5ac7 | 693 | cec_logical_addresses sendUpdatesTo; |
ded7e7ce | 694 | sendUpdatesTo.Clear(); |
ff684fef | 695 | |
f070564b | 696 | { |
f00ff009 | 697 | CLockObject lock(m_mutex); |
30b4aac0 | 698 | m_configuration.iPhysicalAddress = iPhysicalAddress; |
30a09f32 | 699 | CLibCEC::AddLog(CEC_LOG_DEBUG, "setting physical address to '%4x'", iPhysicalAddress); |
4f362964 | 700 | |
dd18e809 | 701 | if (!m_configuration.logicalAddresses.IsEmpty()) |
f070564b LOK |
702 | { |
703 | bool bWasActiveSource(false); | |
704 | for (uint8_t iPtr = 0; iPtr < 15; iPtr++) | |
dd18e809 | 705 | if (m_configuration.logicalAddresses[iPtr]) |
f070564b LOK |
706 | { |
707 | bWasActiveSource |= m_busDevices[iPtr]->IsActiveSource(); | |
708 | m_busDevices[iPtr]->SetInactiveSource(); | |
709 | m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress); | |
710 | if (bSendUpdate) | |
4d6f5ac7 | 711 | sendUpdatesTo.Set((cec_logical_address)iPtr); |
f070564b LOK |
712 | } |
713 | ||
714 | bSendActiveView = bWasActiveSource && bSendUpdate; | |
715 | bReturn = true; | |
716 | } | |
cc60ab1c | 717 | } |
f070564b | 718 | |
4d6f5ac7 LOK |
719 | for (uint8_t iPtr = 0; iPtr < 15; iPtr++) |
720 | if (sendUpdatesTo[iPtr]) | |
721 | m_busDevices[iPtr]->TransmitPhysicalAddress(); | |
722 | ||
f070564b LOK |
723 | if (bSendActiveView) |
724 | SetActiveView(); | |
725 | ||
32403cc3 | 726 | if (bReturn) |
7c5c5bf4 LOK |
727 | { |
728 | libcec_configuration config; | |
729 | { | |
730 | CLockObject lock(m_mutex); | |
731 | config = m_configuration; | |
732 | } | |
733 | ||
734 | PersistConfiguration(&config); | |
735 | CLibCEC::ConfigurationChanged(config); | |
736 | } | |
32403cc3 | 737 | |
f070564b | 738 | return bReturn; |
1969b140 LOK |
739 | } |
740 | ||
8b7e5ff6 LOK |
741 | bool CCECProcessor::SwitchMonitoring(bool bEnable) |
742 | { | |
5477a250 | 743 | CLibCEC::AddLog(CEC_LOG_NOTICE, "== %s monitoring mode ==", bEnable ? "enabling" : "disabling"); |
8b7e5ff6 | 744 | |
855a3a98 | 745 | { |
f00ff009 | 746 | CLockObject lock(m_mutex); |
855a3a98 | 747 | m_bMonitor = bEnable; |
855a3a98 LOK |
748 | } |
749 | ||
8b7e5ff6 | 750 | if (bEnable) |
06bfd4d7 | 751 | return SetAckMask(0); |
8b7e5ff6 | 752 | else |
dd18e809 | 753 | return SetAckMask(m_configuration.logicalAddresses.AckMask()); |
8b7e5ff6 LOK |
754 | } |
755 | ||
57f45e6c LOK |
756 | bool CCECProcessor::PollDevice(cec_logical_address iAddress) |
757 | { | |
758 | if (iAddress != CECDEVICE_UNKNOWN && m_busDevices[iAddress]) | |
95a73fa7 | 759 | { |
dd18e809 | 760 | return m_configuration.logicalAddresses.primary == CECDEVICE_UNKNOWN ? |
95a73fa7 | 761 | m_busDevices[iAddress]->TransmitPoll(iAddress) : |
dd18e809 | 762 | m_busDevices[m_configuration.logicalAddresses.primary]->TransmitPoll(iAddress); |
95a73fa7 | 763 | } |
57f45e6c LOK |
764 | return false; |
765 | } | |
766 | ||
5c73f7f7 | 767 | uint8_t CCECProcessor::VolumeUp(bool bSendRelease /* = true */) |
04e637f9 LOK |
768 | { |
769 | uint8_t status = 0; | |
37b0c572 | 770 | if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM)) |
5c73f7f7 | 771 | status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeUp(bSendRelease); |
04e637f9 LOK |
772 | |
773 | return status; | |
774 | } | |
775 | ||
5c73f7f7 | 776 | uint8_t CCECProcessor::VolumeDown(bool bSendRelease /* = true */) |
04e637f9 LOK |
777 | { |
778 | uint8_t status = 0; | |
37b0c572 | 779 | if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM)) |
5c73f7f7 | 780 | status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeDown(bSendRelease); |
04e637f9 LOK |
781 | |
782 | return status; | |
783 | } | |
784 | ||
5c73f7f7 | 785 | uint8_t CCECProcessor::MuteAudio(bool bSendRelease /* = true */) |
04e637f9 LOK |
786 | { |
787 | uint8_t status = 0; | |
37b0c572 | 788 | if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM)) |
5c73f7f7 | 789 | status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->MuteAudio(bSendRelease); |
04e637f9 LOK |
790 | |
791 | return status; | |
792 | } | |
793 | ||
a75e3a5a | 794 | CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bRefresh /* = false */, bool bSuppressPoll /* = false */) const |
8ac9c610 | 795 | { |
dd18e809 LOK |
796 | if (m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress(false) == iPhysicalAddress) |
797 | return m_busDevices[m_configuration.logicalAddresses.primary]; | |
8ac9c610 | 798 | |
b58d9277 | 799 | CCECBusDevice *device = NULL; |
8ac9c610 LOK |
800 | for (unsigned int iPtr = 0; iPtr < 16; iPtr++) |
801 | { | |
a75e3a5a | 802 | if (m_busDevices[iPtr]->GetPhysicalAddress(bRefresh, bSuppressPoll) == iPhysicalAddress) |
8ac9c610 LOK |
803 | { |
804 | device = m_busDevices[iPtr]; | |
805 | break; | |
806 | } | |
807 | } | |
808 | ||
809 | return device; | |
810 | } | |
811 | ||
a9232a79 LOK |
812 | CCECBusDevice *CCECProcessor::GetDeviceByType(cec_device_type type) const |
813 | { | |
814 | CCECBusDevice *device = NULL; | |
815 | ||
7619faad | 816 | for (uint8_t iPtr = 0; iPtr < 16; iPtr++) |
a9232a79 | 817 | { |
dd18e809 | 818 | if (m_busDevices[iPtr]->m_type == type && m_configuration.logicalAddresses[iPtr]) |
a9232a79 LOK |
819 | { |
820 | device = m_busDevices[iPtr]; | |
821 | break; | |
822 | } | |
823 | } | |
824 | ||
825 | return device; | |
826 | } | |
827 | ||
842262d8 LOK |
828 | CCECBusDevice *CCECProcessor::GetPrimaryDevice(void) const |
829 | { | |
830 | CCECBusDevice *device(NULL); | |
dd18e809 | 831 | cec_logical_address primary = m_configuration.logicalAddresses.primary; |
842262d8 LOK |
832 | if (primary != CECDEVICE_UNKNOWN) |
833 | device = m_busDevices[primary]; | |
834 | return device; | |
835 | } | |
836 | ||
6a1c0009 LOK |
837 | cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress) |
838 | { | |
839 | return m_busDevices[iAddress]->GetCecVersion(); | |
840 | } | |
841 | ||
ed21be2a LOK |
842 | cec_osd_name CCECProcessor::GetDeviceOSDName(cec_logical_address iAddress) |
843 | { | |
844 | CStdString strOSDName = m_busDevices[iAddress]->GetOSDName(); | |
845 | cec_osd_name retVal; | |
846 | ||
847 | snprintf(retVal.name, sizeof(retVal.name), "%s", strOSDName.c_str()); | |
848 | retVal.device = iAddress; | |
849 | ||
850 | return retVal; | |
851 | } | |
852 | ||
a3269a0a LOK |
853 | bool CCECProcessor::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language) |
854 | { | |
cc60ab1c LOK |
855 | if (m_busDevices[iAddress]) |
856 | { | |
857 | *language = m_busDevices[iAddress]->GetMenuLanguage(); | |
5744fbba | 858 | return (strcmp(language->language, "???") != 0); |
cc60ab1c LOK |
859 | } |
860 | return false; | |
a3269a0a LOK |
861 | } |
862 | ||
44c74256 LOK |
863 | uint64_t CCECProcessor::GetDeviceVendorId(cec_logical_address iAddress) |
864 | { | |
cc60ab1c LOK |
865 | if (m_busDevices[iAddress]) |
866 | return m_busDevices[iAddress]->GetVendorId(); | |
867 | return false; | |
44c74256 LOK |
868 | } |
869 | ||
eab72c40 LOK |
870 | uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress) |
871 | { | |
872 | if (m_busDevices[iAddress]) | |
873 | return m_busDevices[iAddress]->GetPhysicalAddress(false); | |
874 | return false; | |
875 | } | |
876 | ||
e55f3f70 LOK |
877 | cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress) |
878 | { | |
cc60ab1c LOK |
879 | if (m_busDevices[iAddress]) |
880 | return m_busDevices[iAddress]->GetPowerStatus(); | |
881 | return CEC_POWER_STATUS_UNKNOWN; | |
e55f3f70 LOK |
882 | } |
883 | ||
b4b1b49b LOK |
884 | cec_logical_address CCECProcessor::GetActiveSource(void) |
885 | { | |
886 | for (uint8_t iPtr = 0; iPtr <= 11; iPtr++) | |
887 | { | |
888 | if (m_busDevices[iPtr]->IsActiveSource()) | |
889 | return (cec_logical_address)iPtr; | |
890 | } | |
891 | ||
892 | return CECDEVICE_UNKNOWN; | |
893 | } | |
894 | ||
895 | bool CCECProcessor::IsActiveSource(cec_logical_address iAddress) | |
896 | { | |
46dfe6c4 LOK |
897 | return iAddress > CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST ? |
898 | m_busDevices[iAddress]->IsActiveSource() : | |
899 | false; | |
b4b1b49b LOK |
900 | } |
901 | ||
8d84e2c0 | 902 | bool CCECProcessor::Transmit(const cec_command &data) |
825ddb96 | 903 | { |
dd18e809 | 904 | if (m_configuration.logicalAddresses[(uint8_t)data.destination]) |
c4287bcd LOK |
905 | { |
906 | CLibCEC::AddLog(CEC_LOG_WARNING, "not sending data to myself!"); | |
907 | return false; | |
908 | } | |
909 | ||
7cf8ba15 | 910 | uint8_t iMaxTries(0); |
eb35e4ca | 911 | { |
7bb4ed43 | 912 | CLockObject lock(m_mutex); |
44a1d92a LOK |
913 | if (IsStopped()) |
914 | return false; | |
7bb4ed43 | 915 | LogOutput(data); |
5f316715 | 916 | m_iLastTransmission = GetTimeMs(); |
44195125 | 917 | if (!m_communication || !m_communication->IsOpen()) |
f9e01dac LOK |
918 | { |
919 | CLibCEC::AddLog(CEC_LOG_ERROR, "cannot transmit command: connection closed"); | |
7bb4ed43 | 920 | return false; |
f9e01dac | 921 | } |
7cf8ba15 | 922 | iMaxTries = m_busDevices[data.initiator]->GetHandler()->GetTransmitRetries() + 1; |
2abe74eb LOK |
923 | } |
924 | ||
5de67222 | 925 | return m_communication->Write(data, iMaxTries, m_iStandardLineTimeout, m_iRetryLineTimeout) |
7cf8ba15 | 926 | == ADAPTER_MESSAGE_STATE_SENT_ACKED; |
825ddb96 | 927 | } |
abbca718 | 928 | |
22b4e74a | 929 | void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode, cec_abort_reason reason /* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */) |
abbca718 | 930 | { |
5477a250 | 931 | CLibCEC::AddLog(CEC_LOG_DEBUG, "<< transmitting abort message"); |
9dee1670 | 932 | |
06a1f7ce | 933 | cec_command command; |
f8513317 | 934 | // TODO |
dd18e809 | 935 | cec_command::Format(command, m_configuration.logicalAddresses.primary, address, CEC_OPCODE_FEATURE_ABORT); |
ab1469a0 LOK |
936 | command.parameters.PushBack((uint8_t)opcode); |
937 | command.parameters.PushBack((uint8_t)reason); | |
9dee1670 LOK |
938 | |
939 | Transmit(command); | |
abbca718 LOK |
940 | } |
941 | ||
b1f94db1 | 942 | void CCECProcessor::ParseCommand(const cec_command &command) |
abbca718 | 943 | { |
e9de9629 | 944 | CStdString dataStr; |
d297cbd4 LOK |
945 | dataStr.Format(">> %1x%1x", command.initiator, command.destination); |
946 | if (command.opcode_set == 1) | |
947 | dataStr.AppendFormat(":%02x", command.opcode); | |
e9de9629 LOK |
948 | for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) |
949 | dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]); | |
5477a250 | 950 | CLibCEC::AddLog(CEC_LOG_TRAFFIC, dataStr.c_str()); |
dc113aca | 951 | |
7871d66e | 952 | if (!m_bMonitor && command.initiator >= CECDEVICE_TV && command.initiator <= CECDEVICE_BROADCAST) |
e9de9629 | 953 | m_busDevices[(uint8_t)command.initiator]->HandleCommand(command); |
dc113aca LOK |
954 | } |
955 | ||
6d858ba4 LOK |
956 | cec_logical_addresses CCECProcessor::GetActiveDevices(void) |
957 | { | |
958 | cec_logical_addresses addresses; | |
988de7b9 | 959 | addresses.Clear(); |
6d858ba4 LOK |
960 | for (unsigned int iPtr = 0; iPtr < 15; iPtr++) |
961 | { | |
962 | if (m_busDevices[iPtr]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
963 | addresses.Set((cec_logical_address) iPtr); | |
964 | } | |
965 | return addresses; | |
966 | } | |
967 | ||
37b0c572 | 968 | bool CCECProcessor::IsPresentDevice(cec_logical_address address) |
6d858ba4 LOK |
969 | { |
970 | return m_busDevices[address]->GetStatus() == CEC_DEVICE_STATUS_PRESENT; | |
971 | } | |
972 | ||
37b0c572 | 973 | bool CCECProcessor::IsPresentDeviceType(cec_device_type type) |
6d858ba4 | 974 | { |
6d858ba4 | 975 | for (unsigned int iPtr = 0; iPtr < 15; iPtr++) |
2813bd07 LOK |
976 | { |
977 | if (m_busDevices[iPtr]->GetType() == type && m_busDevices[iPtr]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
6d858ba4 | 978 | return true; |
2813bd07 LOK |
979 | } |
980 | ||
6d858ba4 LOK |
981 | return false; |
982 | } | |
983 | ||
0f23c85c LOK |
984 | uint16_t CCECProcessor::GetPhysicalAddress(void) const |
985 | { | |
dd18e809 LOK |
986 | if (!m_configuration.logicalAddresses.IsEmpty() && m_busDevices[m_configuration.logicalAddresses.primary]) |
987 | return m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress(false); | |
cc60ab1c | 988 | return false; |
0f23c85c LOK |
989 | } |
990 | ||
06bfd4d7 LOK |
991 | bool CCECProcessor::SetAckMask(uint16_t iMask) |
992 | { | |
5dcf9f25 | 993 | return m_communication->SetAckMask(iMask); |
06bfd4d7 | 994 | } |
a33794d8 | 995 | |
4bec9d79 | 996 | bool CCECProcessor::TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = true */) |
a33794d8 | 997 | { |
86869f8f | 998 | return m_busDevices[iDestination]->TransmitKeypress(key, bWait); |
a33794d8 LOK |
999 | } |
1000 | ||
4bec9d79 | 1001 | bool CCECProcessor::TransmitKeyRelease(cec_logical_address iDestination, bool bWait /* = true */) |
a33794d8 | 1002 | { |
86869f8f | 1003 | return m_busDevices[iDestination]->TransmitKeyRelease(bWait); |
a33794d8 | 1004 | } |
7c63a480 | 1005 | |
8670c970 LOK |
1006 | bool CCECProcessor::EnablePhysicalAddressDetection(void) |
1007 | { | |
1008 | CLibCEC::AddLog(CEC_LOG_WARNING, "deprecated method %s called", __FUNCTION__); | |
1009 | uint16_t iPhysicalAddress = m_communication->GetPhysicalAddress(); | |
1010 | if (iPhysicalAddress != 0) | |
1011 | { | |
1012 | m_configuration.bAutodetectAddress = 1; | |
1013 | m_configuration.iPhysicalAddress = iPhysicalAddress; | |
1014 | m_configuration.baseDevice = CECDEVICE_UNKNOWN; | |
1015 | m_configuration.iHDMIPort = 0; | |
1016 | return SetPhysicalAddress(iPhysicalAddress); | |
1017 | } | |
1018 | return false; | |
1019 | } | |
1020 | ||
ca27e6cf LOK |
1021 | bool CCECProcessor::StandbyDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */) |
1022 | { | |
1023 | if (address == CECDEVICE_BROADCAST && m_configuration.clientVersion >= CEC_CLIENT_VERSION_1_5_0) | |
1024 | { | |
1025 | bool bReturn(true); | |
1026 | for (uint8_t iPtr = 0; iPtr <= 0xF; iPtr++) | |
1027 | { | |
1028 | if (m_configuration.powerOffDevices[iPtr]) | |
1029 | bReturn &= m_busDevices[iPtr]->Standby(); | |
1030 | } | |
1031 | return bReturn; | |
1032 | } | |
1033 | ||
1034 | return m_busDevices[address]->Standby(); | |
1035 | } | |
1036 | ||
1037 | bool CCECProcessor::PowerOnDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */) | |
1038 | { | |
1039 | if (address == CECDEVICE_BROADCAST && m_configuration.clientVersion >= CEC_CLIENT_VERSION_1_5_0) | |
1040 | { | |
1041 | bool bReturn(true); | |
1042 | for (uint8_t iPtr = 0; iPtr <= 0xF; iPtr++) | |
1043 | { | |
1044 | if (m_configuration.powerOffDevices[iPtr]) | |
1045 | bReturn &= m_busDevices[iPtr]->PowerOn(); | |
1046 | } | |
1047 | return bReturn; | |
1048 | } | |
1049 | ||
1050 | return m_busDevices[address]->PowerOn(); | |
1051 | } | |
1052 | ||
3e61b350 LOK |
1053 | const char *CCECProcessor::ToString(const cec_device_type type) |
1054 | { | |
1055 | switch (type) | |
1056 | { | |
1057 | case CEC_DEVICE_TYPE_AUDIO_SYSTEM: | |
1058 | return "audio system"; | |
1059 | case CEC_DEVICE_TYPE_PLAYBACK_DEVICE: | |
1060 | return "playback device"; | |
1061 | case CEC_DEVICE_TYPE_RECORDING_DEVICE: | |
1062 | return "recording device"; | |
1063 | case CEC_DEVICE_TYPE_RESERVED: | |
1064 | return "reserved"; | |
1065 | case CEC_DEVICE_TYPE_TUNER: | |
1066 | return "tuner"; | |
1067 | case CEC_DEVICE_TYPE_TV: | |
1068 | return "TV"; | |
1069 | default: | |
1070 | return "unknown"; | |
1071 | } | |
1072 | } | |
1073 | ||
03ae897d LOK |
1074 | const char *CCECProcessor::ToString(const cec_menu_state state) |
1075 | { | |
1076 | switch (state) | |
1077 | { | |
1078 | case CEC_MENU_STATE_ACTIVATED: | |
1079 | return "activated"; | |
1080 | case CEC_MENU_STATE_DEACTIVATED: | |
1081 | return "deactivated"; | |
1082 | default: | |
1083 | return "unknown"; | |
1084 | } | |
1085 | } | |
1086 | ||
1087 | const char *CCECProcessor::ToString(const cec_version version) | |
1088 | { | |
1089 | switch (version) | |
1090 | { | |
1091 | case CEC_VERSION_1_2: | |
1092 | return "1.2"; | |
1093 | case CEC_VERSION_1_2A: | |
1094 | return "1.2a"; | |
1095 | case CEC_VERSION_1_3: | |
1096 | return "1.3"; | |
1097 | case CEC_VERSION_1_3A: | |
1098 | return "1.3a"; | |
1099 | case CEC_VERSION_1_4: | |
1100 | return "1.4"; | |
1101 | default: | |
1102 | return "unknown"; | |
1103 | } | |
1104 | } | |
1105 | ||
1106 | const char *CCECProcessor::ToString(const cec_power_status status) | |
1107 | { | |
1108 | switch (status) | |
1109 | { | |
1110 | case CEC_POWER_STATUS_ON: | |
1111 | return "on"; | |
1112 | case CEC_POWER_STATUS_STANDBY: | |
1113 | return "standby"; | |
1114 | case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY: | |
1115 | return "in transition from on to standby"; | |
1116 | case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON: | |
1117 | return "in transition from standby to on"; | |
1118 | default: | |
1119 | return "unknown"; | |
1120 | } | |
1121 | } | |
1122 | ||
1123 | const char *CCECProcessor::ToString(const cec_logical_address address) | |
1124 | { | |
1125 | switch(address) | |
1126 | { | |
1127 | case CECDEVICE_AUDIOSYSTEM: | |
1128 | return "Audio"; | |
1129 | case CECDEVICE_BROADCAST: | |
1130 | return "Broadcast"; | |
1131 | case CECDEVICE_FREEUSE: | |
1132 | return "Free use"; | |
1133 | case CECDEVICE_PLAYBACKDEVICE1: | |
1134 | return "Playback 1"; | |
1135 | case CECDEVICE_PLAYBACKDEVICE2: | |
1136 | return "Playback 2"; | |
1137 | case CECDEVICE_PLAYBACKDEVICE3: | |
1138 | return "Playback 3"; | |
1139 | case CECDEVICE_RECORDINGDEVICE1: | |
1140 | return "Recorder 1"; | |
1141 | case CECDEVICE_RECORDINGDEVICE2: | |
1142 | return "Recorder 2"; | |
1143 | case CECDEVICE_RECORDINGDEVICE3: | |
1144 | return "Recorder 3"; | |
1145 | case CECDEVICE_RESERVED1: | |
1146 | return "Reserved 1"; | |
1147 | case CECDEVICE_RESERVED2: | |
1148 | return "Reserved 2"; | |
1149 | case CECDEVICE_TUNER1: | |
1150 | return "Tuner 1"; | |
1151 | case CECDEVICE_TUNER2: | |
1152 | return "Tuner 2"; | |
1153 | case CECDEVICE_TUNER3: | |
1154 | return "Tuner 3"; | |
1155 | case CECDEVICE_TUNER4: | |
1156 | return "Tuner 4"; | |
1157 | case CECDEVICE_TV: | |
1158 | return "TV"; | |
1159 | default: | |
1160 | return "unknown"; | |
1161 | } | |
1162 | } | |
1163 | ||
1164 | const char *CCECProcessor::ToString(const cec_deck_control_mode mode) | |
1165 | { | |
1166 | switch (mode) | |
1167 | { | |
1168 | case CEC_DECK_CONTROL_MODE_SKIP_FORWARD_WIND: | |
1169 | return "skip forward wind"; | |
1170 | case CEC_DECK_CONTROL_MODE_EJECT: | |
1171 | return "eject"; | |
1172 | case CEC_DECK_CONTROL_MODE_SKIP_REVERSE_REWIND: | |
1173 | return "reverse rewind"; | |
1174 | case CEC_DECK_CONTROL_MODE_STOP: | |
1175 | return "stop"; | |
1176 | default: | |
1177 | return "unknown"; | |
1178 | } | |
1179 | } | |
1180 | ||
1181 | const char *CCECProcessor::ToString(const cec_deck_info status) | |
1182 | { | |
1183 | switch (status) | |
1184 | { | |
1185 | case CEC_DECK_INFO_PLAY: | |
1186 | return "play"; | |
1187 | case CEC_DECK_INFO_RECORD: | |
1188 | return "record"; | |
1189 | case CEC_DECK_INFO_PLAY_REVERSE: | |
1190 | return "play reverse"; | |
1191 | case CEC_DECK_INFO_STILL: | |
1192 | return "still"; | |
1193 | case CEC_DECK_INFO_SLOW: | |
1194 | return "slow"; | |
1195 | case CEC_DECK_INFO_SLOW_REVERSE: | |
1196 | return "slow reverse"; | |
1197 | case CEC_DECK_INFO_FAST_FORWARD: | |
1198 | return "fast forward"; | |
1199 | case CEC_DECK_INFO_FAST_REVERSE: | |
1200 | return "fast reverse"; | |
1201 | case CEC_DECK_INFO_NO_MEDIA: | |
1202 | return "no media"; | |
1203 | case CEC_DECK_INFO_STOP: | |
1204 | return "stop"; | |
1205 | case CEC_DECK_INFO_SKIP_FORWARD_WIND: | |
1206 | return "info skip forward wind"; | |
1207 | case CEC_DECK_INFO_SKIP_REVERSE_REWIND: | |
1208 | return "info skip reverse rewind"; | |
1209 | case CEC_DECK_INFO_INDEX_SEARCH_FORWARD: | |
1210 | return "info index search forward"; | |
1211 | case CEC_DECK_INFO_INDEX_SEARCH_REVERSE: | |
1212 | return "info index search reverse"; | |
1213 | case CEC_DECK_INFO_OTHER_STATUS: | |
1214 | return "other"; | |
1215 | default: | |
1216 | return "unknown"; | |
1217 | } | |
1218 | } | |
1219 | ||
1220 | const char *CCECProcessor::ToString(const cec_opcode opcode) | |
1221 | { | |
1222 | switch (opcode) | |
1223 | { | |
1224 | case CEC_OPCODE_ACTIVE_SOURCE: | |
1225 | return "active source"; | |
1226 | case CEC_OPCODE_IMAGE_VIEW_ON: | |
1227 | return "image view on"; | |
1228 | case CEC_OPCODE_TEXT_VIEW_ON: | |
1229 | return "text view on"; | |
1230 | case CEC_OPCODE_INACTIVE_SOURCE: | |
1231 | return "inactive source"; | |
1232 | case CEC_OPCODE_REQUEST_ACTIVE_SOURCE: | |
1233 | return "request active source"; | |
1234 | case CEC_OPCODE_ROUTING_CHANGE: | |
1235 | return "routing change"; | |
1236 | case CEC_OPCODE_ROUTING_INFORMATION: | |
1237 | return "routing information"; | |
1238 | case CEC_OPCODE_SET_STREAM_PATH: | |
1239 | return "set stream path"; | |
1240 | case CEC_OPCODE_STANDBY: | |
1241 | return "standby"; | |
1242 | case CEC_OPCODE_RECORD_OFF: | |
1243 | return "record off"; | |
1244 | case CEC_OPCODE_RECORD_ON: | |
1245 | return "record on"; | |
1246 | case CEC_OPCODE_RECORD_STATUS: | |
1247 | return "record status"; | |
1248 | case CEC_OPCODE_RECORD_TV_SCREEN: | |
1249 | return "record tv screen"; | |
1250 | case CEC_OPCODE_CLEAR_ANALOGUE_TIMER: | |
1251 | return "clear analogue timer"; | |
1252 | case CEC_OPCODE_CLEAR_DIGITAL_TIMER: | |
1253 | return "clear digital timer"; | |
1254 | case CEC_OPCODE_CLEAR_EXTERNAL_TIMER: | |
1255 | return "clear external timer"; | |
1256 | case CEC_OPCODE_SET_ANALOGUE_TIMER: | |
1257 | return "set analogue timer"; | |
1258 | case CEC_OPCODE_SET_DIGITAL_TIMER: | |
1259 | return "set digital timer"; | |
1260 | case CEC_OPCODE_SET_EXTERNAL_TIMER: | |
1261 | return "set external timer"; | |
1262 | case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE: | |
1263 | return "set timer program title"; | |
1264 | case CEC_OPCODE_TIMER_CLEARED_STATUS: | |
1265 | return "timer cleared status"; | |
1266 | case CEC_OPCODE_TIMER_STATUS: | |
1267 | return "timer status"; | |
1268 | case CEC_OPCODE_CEC_VERSION: | |
1269 | return "cec version"; | |
1270 | case CEC_OPCODE_GET_CEC_VERSION: | |
1271 | return "get cec version"; | |
1272 | case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS: | |
1273 | return "give physical address"; | |
1274 | case CEC_OPCODE_GET_MENU_LANGUAGE: | |
1275 | return "get menu language"; | |
1276 | case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS: | |
1277 | return "report physical address"; | |
1278 | case CEC_OPCODE_SET_MENU_LANGUAGE: | |
1279 | return "set menu language"; | |
1280 | case CEC_OPCODE_DECK_CONTROL: | |
1281 | return "deck control"; | |
1282 | case CEC_OPCODE_DECK_STATUS: | |
1283 | return "deck status"; | |
1284 | case CEC_OPCODE_GIVE_DECK_STATUS: | |
1285 | return "give deck status"; | |
1286 | case CEC_OPCODE_PLAY: | |
1287 | return "play"; | |
1288 | case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS: | |
1289 | return "give tuner status"; | |
1290 | case CEC_OPCODE_SELECT_ANALOGUE_SERVICE: | |
1291 | return "select analogue service"; | |
1292 | case CEC_OPCODE_SELECT_DIGITAL_SERVICE: | |
1293 | return "set digital service"; | |
1294 | case CEC_OPCODE_TUNER_DEVICE_STATUS: | |
1295 | return "tuner device status"; | |
1296 | case CEC_OPCODE_TUNER_STEP_DECREMENT: | |
1297 | return "tuner step decrement"; | |
1298 | case CEC_OPCODE_TUNER_STEP_INCREMENT: | |
1299 | return "tuner step increment"; | |
1300 | case CEC_OPCODE_DEVICE_VENDOR_ID: | |
1301 | return "device vendor id"; | |
1302 | case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID: | |
1303 | return "give device vendor id"; | |
1304 | case CEC_OPCODE_VENDOR_COMMAND: | |
1305 | return "vendor command"; | |
1306 | case CEC_OPCODE_VENDOR_COMMAND_WITH_ID: | |
1307 | return "vendor command with id"; | |
1308 | case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN: | |
1309 | return "vendor remote button down"; | |
1310 | case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP: | |
1311 | return "vendor remote button up"; | |
1312 | case CEC_OPCODE_SET_OSD_STRING: | |
1313 | return "set osd string"; | |
1314 | case CEC_OPCODE_GIVE_OSD_NAME: | |
1315 | return "give osd name"; | |
1316 | case CEC_OPCODE_SET_OSD_NAME: | |
1317 | return "set osd name"; | |
1318 | case CEC_OPCODE_MENU_REQUEST: | |
1319 | return "menu request"; | |
1320 | case CEC_OPCODE_MENU_STATUS: | |
1321 | return "menu status"; | |
1322 | case CEC_OPCODE_USER_CONTROL_PRESSED: | |
1323 | return "user control pressed"; | |
1324 | case CEC_OPCODE_USER_CONTROL_RELEASE: | |
1325 | return "user control release"; | |
1326 | case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS: | |
1327 | return "give device power status"; | |
1328 | case CEC_OPCODE_REPORT_POWER_STATUS: | |
1329 | return "report power status"; | |
1330 | case CEC_OPCODE_FEATURE_ABORT: | |
1331 | return "feature abort"; | |
1332 | case CEC_OPCODE_ABORT: | |
1333 | return "abort"; | |
1334 | case CEC_OPCODE_GIVE_AUDIO_STATUS: | |
1335 | return "give audio status"; | |
1336 | case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS: | |
1337 | return "give audio mode status"; | |
1338 | case CEC_OPCODE_REPORT_AUDIO_STATUS: | |
1339 | return "report audio status"; | |
1340 | case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE: | |
1341 | return "set system audio mode"; | |
1342 | case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST: | |
1343 | return "system audio mode request"; | |
1344 | case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS: | |
1345 | return "system audio mode status"; | |
1346 | case CEC_OPCODE_SET_AUDIO_RATE: | |
1347 | return "set audio rate"; | |
24dd566c LOK |
1348 | case CEC_OPCODE_NONE: |
1349 | return "poll"; | |
03ae897d LOK |
1350 | default: |
1351 | return "UNKNOWN"; | |
1352 | } | |
1353 | } | |
1354 | ||
1355 | const char *CCECProcessor::ToString(const cec_system_audio_status mode) | |
1356 | { | |
1357 | switch(mode) | |
1358 | { | |
1359 | case CEC_SYSTEM_AUDIO_STATUS_ON: | |
1360 | return "on"; | |
1361 | case CEC_SYSTEM_AUDIO_STATUS_OFF: | |
1362 | return "off"; | |
1363 | default: | |
1364 | return "unknown"; | |
1365 | } | |
1366 | } | |
1367 | ||
1de6617c | 1368 | const char *CCECProcessor::ToString(const cec_audio_status UNUSED(status)) |
03ae897d LOK |
1369 | { |
1370 | // TODO this is a mask | |
1371 | return "TODO"; | |
1372 | } | |
1373 | ||
1374 | const char *CCECProcessor::ToString(const cec_vendor_id vendor) | |
1375 | { | |
1376 | switch (vendor) | |
1377 | { | |
1378 | case CEC_VENDOR_SAMSUNG: | |
1379 | return "Samsung"; | |
1380 | case CEC_VENDOR_LG: | |
1381 | return "LG"; | |
1382 | case CEC_VENDOR_PANASONIC: | |
1383 | return "Panasonic"; | |
1384 | case CEC_VENDOR_PIONEER: | |
1385 | return "Pioneer"; | |
1386 | case CEC_VENDOR_ONKYO: | |
1387 | return "Onkyo"; | |
1388 | case CEC_VENDOR_YAMAHA: | |
1389 | return "Yamaha"; | |
ec0deac1 LOK |
1390 | case CEC_VENDOR_PHILIPS: |
1391 | return "Philips"; | |
1a87cacc LOK |
1392 | case CEC_VENDOR_SONY: |
1393 | return "Sony"; | |
26555d6b LOK |
1394 | case CEC_VENDOR_TOSHIBA: |
1395 | return "Toshiba"; | |
03ae897d LOK |
1396 | default: |
1397 | return "Unknown"; | |
1398 | } | |
1399 | } | |
1400 | ||
caca2d81 LOK |
1401 | const char *CCECProcessor::ToString(const cec_client_version version) |
1402 | { | |
1403 | switch (version) | |
1404 | { | |
1405 | case CEC_CLIENT_VERSION_PRE_1_5: | |
1406 | return "pre-1.5"; | |
1407 | case CEC_CLIENT_VERSION_1_5_0: | |
1408 | return "1.5.0"; | |
41e3372a LOK |
1409 | case CEC_CLIENT_VERSION_1_5_1: |
1410 | return "1.5.1"; | |
2e82cff0 LOK |
1411 | case CEC_CLIENT_VERSION_1_5_2: |
1412 | return "1.5.2"; | |
e69d8f19 LOK |
1413 | case CEC_CLIENT_VERSION_1_5_3: |
1414 | return "1.5.3"; | |
1415 | case CEC_CLIENT_VERSION_1_6_0: | |
1416 | return "1.6.0"; | |
caca2d81 LOK |
1417 | default: |
1418 | return "Unknown"; | |
1419 | } | |
1420 | } | |
1421 | ||
3efda01a LOK |
1422 | const char *CCECProcessor::ToString(const cec_server_version version) |
1423 | { | |
1424 | switch (version) | |
1425 | { | |
1426 | case CEC_SERVER_VERSION_PRE_1_5: | |
1427 | return "pre-1.5"; | |
1428 | case CEC_SERVER_VERSION_1_5_0: | |
1429 | return "1.5.0"; | |
41e3372a | 1430 | case CEC_SERVER_VERSION_1_5_1: |
2e82cff0 LOK |
1431 | return "1.5.1"; |
1432 | case CEC_SERVER_VERSION_1_5_2: | |
1433 | return "1.5.2"; | |
e69d8f19 LOK |
1434 | case CEC_SERVER_VERSION_1_5_3: |
1435 | return "1.5.3"; | |
1436 | case CEC_SERVER_VERSION_1_6_0: | |
1437 | return "1.6.0"; | |
3efda01a LOK |
1438 | default: |
1439 | return "Unknown"; | |
1440 | } | |
1441 | } | |
1442 | ||
7c63a480 LOK |
1443 | void *CCECBusScan::Process(void) |
1444 | { | |
1445 | CCECBusDevice *device(NULL); | |
fe6f8e37 | 1446 | uint8_t iCounter(0); |
5f316715 | 1447 | |
5e5637c6 | 1448 | while (!IsStopped()) |
7c63a480 | 1449 | { |
bdb0f7f4 | 1450 | if (++iCounter < 10) |
fe6f8e37 LOK |
1451 | { |
1452 | Sleep(1000); | |
1453 | continue; | |
1454 | } | |
5f316715 | 1455 | for (unsigned int iPtr = 0; iPtr <= 11 && !IsStopped(); iPtr++) |
7c63a480 | 1456 | { |
5f316715 LOK |
1457 | device = m_processor->m_busDevices[iPtr]; |
1458 | WaitUntilIdle(); | |
1459 | if (device && device->GetStatus(true) == CEC_DEVICE_STATUS_PRESENT) | |
5e5637c6 | 1460 | { |
5f316715 LOK |
1461 | WaitUntilIdle(); |
1462 | if (!IsStopped()) | |
1463 | device->GetVendorId(); | |
1464 | ||
1465 | WaitUntilIdle(); | |
1466 | if (!IsStopped()) | |
1467 | device->GetPowerStatus(true); | |
5e5637c6 | 1468 | } |
7c63a480 LOK |
1469 | } |
1470 | } | |
5f316715 | 1471 | |
7c63a480 LOK |
1472 | return NULL; |
1473 | } | |
1113cb7d | 1474 | |
5f316715 LOK |
1475 | void CCECBusScan::WaitUntilIdle(void) |
1476 | { | |
1477 | if (IsStopped()) | |
1478 | return; | |
1479 | ||
701f753b | 1480 | int32_t iWaitTime = 3000 - (int32_t)(GetTimeMs() - m_processor->GetLastTransmission()); |
5f316715 LOK |
1481 | while (iWaitTime > 0) |
1482 | { | |
1483 | Sleep(iWaitTime); | |
701f753b | 1484 | iWaitTime = 3000 - (int32_t)(GetTimeMs() - m_processor->GetLastTransmission()); |
5f316715 LOK |
1485 | } |
1486 | } | |
1487 | ||
a2198e5e | 1488 | bool CCECProcessor::StartBootloader(const char *strPort /* = NULL */) |
1113cb7d | 1489 | { |
a2198e5e LOK |
1490 | if (!m_communication && strPort) |
1491 | { | |
1492 | bool bReturn(false); | |
1493 | IAdapterCommunication *comm = new CUSBCECAdapterCommunication(this, strPort); | |
1494 | CTimeout timeout(10000); | |
1495 | int iConnectTry(0); | |
3c5b4d05 | 1496 | while (timeout.TimeLeft() > 0 && (bReturn = comm->Open(timeout.TimeLeft() / CEC_CONNECT_TRIES, true)) == false) |
a2198e5e LOK |
1497 | { |
1498 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry); | |
1499 | comm->Close(); | |
1500 | Sleep(500); | |
1501 | } | |
1502 | if (comm->IsOpen()) | |
1503 | { | |
1504 | bReturn = comm->StartBootloader(); | |
1505 | delete comm; | |
1506 | } | |
1507 | return bReturn; | |
1508 | } | |
1509 | else | |
1510 | { | |
1511 | return m_communication->StartBootloader(); | |
1512 | } | |
1113cb7d LOK |
1513 | } |
1514 | ||
1515 | bool CCECProcessor::PingAdapter(void) | |
1516 | { | |
1517 | return m_communication->PingAdapter(); | |
1518 | } | |
6729ac71 LOK |
1519 | |
1520 | void CCECProcessor::HandlePoll(cec_logical_address initiator, cec_logical_address destination) | |
1521 | { | |
a75e3a5a LOK |
1522 | if (destination < CECDEVICE_BROADCAST) |
1523 | m_busDevices[destination]->HandlePollFrom(initiator); | |
6729ac71 LOK |
1524 | } |
1525 | ||
7bb4ed43 | 1526 | bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator) |
6729ac71 | 1527 | { |
0cfdeb5a | 1528 | return !m_busDevices[initiator]->HandleReceiveFailed(); |
6729ac71 | 1529 | } |
f42d3e0f LOK |
1530 | |
1531 | bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress) | |
1532 | { | |
1533 | // stream path changes are sent by the TV | |
1534 | return m_busDevices[CECDEVICE_TV]->GetHandler()->TransmitSetStreamPath(iPhysicalAddress); | |
1535 | } | |
d40928b5 | 1536 | |
30b4aac0 LOK |
1537 | bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration) |
1538 | { | |
30a09f32 | 1539 | bool bReinit(false); |
30b4aac0 | 1540 | CCECBusDevice *primary = IsRunning() ? GetPrimaryDevice() : NULL; |
30a09f32 | 1541 | cec_device_type oldPrimaryType = primary ? primary->GetType() : CEC_DEVICE_TYPE_RECORDING_DEVICE; |
f0154449 | 1542 | m_configuration.clientVersion = configuration->clientVersion; |
7c5c5bf4 | 1543 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using client version '%s'", __FUNCTION__, ToString((cec_client_version)configuration->clientVersion)); |
30b4aac0 LOK |
1544 | |
1545 | // client version 1.5.0 | |
1546 | ||
1547 | // device types | |
8670c970 | 1548 | bool bDeviceTypeChanged = IsRunning () && m_configuration.deviceTypes != configuration->deviceTypes; |
30b4aac0 | 1549 | m_configuration.deviceTypes = configuration->deviceTypes; |
7c5c5bf4 LOK |
1550 | if (bDeviceTypeChanged) |
1551 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using primary device type '%s'", __FUNCTION__, ToString(configuration->deviceTypes[0])); | |
30b4aac0 | 1552 | |
30a09f32 LOK |
1553 | bool bPhysicalAddressChanged(false); |
1554 | ||
8670c970 | 1555 | // autodetect address |
30a09f32 LOK |
1556 | bool bPhysicalAutodetected(false); |
1557 | if (IsRunning() && configuration->bAutodetectAddress == 1) | |
8670c970 | 1558 | { |
30a09f32 LOK |
1559 | uint16_t iPhysicalAddress = m_communication->GetPhysicalAddress(); |
1560 | if (iPhysicalAddress != 0) | |
1561 | { | |
1562 | if (IsRunning()) | |
1563 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - autodetected physical address '%4x'", __FUNCTION__, iPhysicalAddress); | |
7c5c5bf4 LOK |
1564 | else |
1565 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using physical address '%x'", __FUNCTION__, iPhysicalAddress); | |
30a09f32 LOK |
1566 | bPhysicalAddressChanged = (m_configuration.iPhysicalAddress != iPhysicalAddress); |
1567 | m_configuration.iPhysicalAddress = iPhysicalAddress; | |
1568 | m_configuration.iHDMIPort = 0; | |
1569 | m_configuration.baseDevice = CECDEVICE_UNKNOWN; | |
1570 | bPhysicalAutodetected = true; | |
1571 | } | |
8670c970 LOK |
1572 | } |
1573 | ||
30b4aac0 | 1574 | // physical address |
8670c970 LOK |
1575 | if (!bPhysicalAutodetected) |
1576 | { | |
30a09f32 LOK |
1577 | if (configuration->iPhysicalAddress != 0) |
1578 | bPhysicalAddressChanged = IsRunning() && m_configuration.iPhysicalAddress != configuration->iPhysicalAddress; | |
2270ce69 MK |
1579 | if (bPhysicalAddressChanged) |
1580 | { | |
7c5c5bf4 | 1581 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - physical address '%x'", __FUNCTION__, configuration->iPhysicalAddress); |
2270ce69 MK |
1582 | m_configuration.iPhysicalAddress = configuration->iPhysicalAddress; |
1583 | } | |
8670c970 | 1584 | } |
30b4aac0 | 1585 | |
8670c970 LOK |
1586 | bool bHdmiPortChanged(false); |
1587 | if (!bPhysicalAutodetected && !bPhysicalAddressChanged) | |
1588 | { | |
30a09f32 | 1589 | // base device |
8670c970 | 1590 | bHdmiPortChanged = IsRunning() && m_configuration.baseDevice != configuration->baseDevice; |
7c5c5bf4 | 1591 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using base device '%x'", __FUNCTION__, (int)configuration->baseDevice); |
8670c970 | 1592 | m_configuration.baseDevice = configuration->baseDevice; |
30b4aac0 | 1593 | |
30a09f32 | 1594 | // hdmi port |
8670c970 | 1595 | bHdmiPortChanged |= IsRunning() && m_configuration.iHDMIPort != configuration->iHDMIPort; |
7c5c5bf4 | 1596 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using HDMI port '%d'", __FUNCTION__, configuration->iHDMIPort); |
8670c970 LOK |
1597 | m_configuration.iHDMIPort = configuration->iHDMIPort; |
1598 | } | |
1599 | else | |
1600 | { | |
7c5c5bf4 | 1601 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - resetting HDMI port and base device to defaults", __FUNCTION__); |
30a09f32 LOK |
1602 | m_configuration.baseDevice = CECDEVICE_UNKNOWN; |
1603 | m_configuration.iHDMIPort = 0; | |
8670c970 | 1604 | } |
30b4aac0 | 1605 | |
30a09f32 | 1606 | bReinit = bPhysicalAddressChanged || bHdmiPortChanged || bDeviceTypeChanged; |
f0154449 | 1607 | |
30b4aac0 | 1608 | // device name |
7c5c5bf4 | 1609 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using OSD name '%s'", __FUNCTION__, configuration->strDeviceName); |
30b4aac0 LOK |
1610 | snprintf(m_configuration.strDeviceName, 13, "%s", configuration->strDeviceName); |
1611 | if (primary && !primary->GetOSDName().Equals(m_configuration.strDeviceName)) | |
1612 | { | |
1613 | primary->SetOSDName(m_configuration.strDeviceName); | |
f0154449 | 1614 | if (!bReinit && IsRunning()) |
30b4aac0 LOK |
1615 | primary->TransmitOSDName(CECDEVICE_TV); |
1616 | } | |
1617 | ||
1618 | // tv vendor id override | |
7c5c5bf4 | 1619 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - vendor id '%s'", __FUNCTION__, ToString((cec_vendor_id)configuration->tvVendor)); |
30b4aac0 LOK |
1620 | if (m_configuration.tvVendor != configuration->tvVendor) |
1621 | { | |
1622 | m_configuration.tvVendor= configuration->tvVendor; | |
1623 | m_busDevices[CECDEVICE_TV]->SetVendorId((uint64_t)m_configuration.tvVendor); | |
1624 | } | |
1625 | ||
1626 | // wake CEC devices | |
1627 | if (m_configuration.wakeDevices != configuration->wakeDevices) | |
1628 | { | |
1629 | m_configuration.wakeDevices = configuration->wakeDevices; | |
f0154449 | 1630 | if (!bReinit && IsRunning()) |
ca27e6cf | 1631 | PowerOnDevices(); |
30b4aac0 LOK |
1632 | } |
1633 | ||
1634 | // just copy these | |
4c42105f | 1635 | m_configuration.bUseTVMenuLanguage = configuration->bUseTVMenuLanguage; |
3efda01a | 1636 | m_configuration.bActivateSource = configuration->bActivateSource; |
30b4aac0 | 1637 | m_configuration.bGetSettingsFromROM = configuration->bGetSettingsFromROM; |
ca27e6cf | 1638 | m_configuration.powerOffDevices = configuration->powerOffDevices; |
30b4aac0 LOK |
1639 | m_configuration.bPowerOffScreensaver = configuration->bPowerOffScreensaver; |
1640 | m_configuration.bPowerOffOnStandby = configuration->bPowerOffOnStandby; | |
1641 | ||
41e3372a LOK |
1642 | // client version 1.5.1 |
1643 | if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1) | |
1644 | m_configuration.bSendInactiveSource = configuration->bSendInactiveSource; | |
1645 | ||
b98fc43d LOK |
1646 | // client version 1.6.0 |
1647 | if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_6_0) | |
fa4b80df | 1648 | { |
b98fc43d | 1649 | m_configuration.bPowerOffDevicesOnStandby = configuration->bPowerOffDevicesOnStandby; |
fa4b80df MK |
1650 | m_configuration.bShutdownOnStandby = configuration->bShutdownOnStandby; |
1651 | } | |
b98fc43d | 1652 | |
30b4aac0 LOK |
1653 | // ensure that there is at least 1 device type set |
1654 | if (m_configuration.deviceTypes.IsEmpty()) | |
1655 | m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); | |
1656 | ||
7c5c5bf4 LOK |
1657 | // persist the configuration |
1658 | if (IsRunning()) | |
1659 | m_communication->PersistConfiguration(&m_configuration); | |
1660 | ||
46dfe6c4 | 1661 | if (bReinit || m_configuration.logicalAddresses.IsEmpty()) |
30b4aac0 | 1662 | { |
44a1d92a LOK |
1663 | if (bDeviceTypeChanged) |
1664 | return ChangeDeviceType(oldPrimaryType, m_configuration.deviceTypes[0]); | |
1665 | else if (bPhysicalAddressChanged) | |
1666 | return SetPhysicalAddress(m_configuration.iPhysicalAddress); | |
8670c970 | 1667 | else |
f0154449 | 1668 | return SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort); |
30b4aac0 | 1669 | } |
dd18e809 | 1670 | else if (m_configuration.bActivateSource == 1 && IsRunning() && !IsActiveSource(m_configuration.logicalAddresses.primary)) |
c3c13157 LOK |
1671 | { |
1672 | // activate the source if we're not already the active source | |
1673 | SetActiveSource(m_configuration.deviceTypes.types[0]); | |
1674 | } | |
30b4aac0 LOK |
1675 | |
1676 | return true; | |
1677 | } | |
1678 | ||
d40928b5 LOK |
1679 | bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration) |
1680 | { | |
30b4aac0 | 1681 | // client version 1.5.0 |
30b4aac0 LOK |
1682 | snprintf(configuration->strDeviceName, 13, "%s", m_configuration.strDeviceName); |
1683 | configuration->deviceTypes = m_configuration.deviceTypes; | |
8670c970 | 1684 | configuration->bAutodetectAddress = m_configuration.bAutodetectAddress; |
30b4aac0 LOK |
1685 | configuration->iPhysicalAddress = m_configuration.iPhysicalAddress; |
1686 | configuration->baseDevice = m_configuration.baseDevice; | |
1687 | configuration->iHDMIPort = m_configuration.iHDMIPort; | |
3efda01a LOK |
1688 | configuration->clientVersion = m_configuration.clientVersion; |
1689 | configuration->serverVersion = m_configuration.serverVersion; | |
30b4aac0 | 1690 | configuration->tvVendor = m_configuration.tvVendor; |
3efda01a | 1691 | |
30b4aac0 | 1692 | configuration->bGetSettingsFromROM = m_configuration.bGetSettingsFromROM; |
3efda01a LOK |
1693 | configuration->bUseTVMenuLanguage = m_configuration.bUseTVMenuLanguage; |
1694 | configuration->bActivateSource = m_configuration.bActivateSource; | |
1695 | configuration->wakeDevices = m_configuration.wakeDevices; | |
ca27e6cf | 1696 | configuration->powerOffDevices = m_configuration.powerOffDevices; |
30b4aac0 LOK |
1697 | configuration->bPowerOffScreensaver = m_configuration.bPowerOffScreensaver; |
1698 | configuration->bPowerOffOnStandby = m_configuration.bPowerOffOnStandby; | |
1699 | ||
41e3372a LOK |
1700 | // client version 1.5.1 |
1701 | if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1) | |
1702 | configuration->bSendInactiveSource = m_configuration.bSendInactiveSource; | |
1703 | ||
dd18e809 LOK |
1704 | // client version 1.5.3 |
1705 | if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_3) | |
1706 | configuration->logicalAddresses = m_configuration.logicalAddresses; | |
1707 | ||
e69d8f19 | 1708 | // client version 1.6.0 |
b98fc43d LOK |
1709 | if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_6_0) |
1710 | { | |
1711 | configuration->iFirmwareVersion = m_configuration.iFirmwareVersion; | |
1712 | configuration->bPowerOffDevicesOnStandby = m_configuration.bPowerOffDevicesOnStandby; | |
fa4b80df | 1713 | configuration->bShutdownOnStandby = m_configuration.bShutdownOnStandby; |
b98fc43d | 1714 | } |
e69d8f19 | 1715 | |
d40928b5 LOK |
1716 | return true; |
1717 | } | |
224ea877 LOK |
1718 | |
1719 | bool CCECProcessor::CanPersistConfiguration(void) | |
1720 | { | |
1721 | return m_communication->GetFirmwareVersion() >= 2; | |
1722 | } | |
1723 | ||
1724 | bool CCECProcessor::PersistConfiguration(libcec_configuration *configuration) | |
1725 | { | |
1726 | return m_communication->PersistConfiguration(configuration); | |
1727 | } | |
3efda01a LOK |
1728 | |
1729 | void CCECProcessor::RescanActiveDevices(void) | |
1730 | { | |
1731 | for (unsigned int iPtr = 0; iPtr < 16; iPtr++) | |
1732 | m_busDevices[iPtr]->GetStatus(true); | |
1733 | } | |
f80cd208 LOK |
1734 | |
1735 | bool CCECProcessor::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = 10000 */) | |
1736 | { | |
1737 | if (!OpenConnection(strPort, 38400, iTimeoutMs, false)) | |
1738 | return false; | |
1739 | ||
1740 | config->iFirmwareVersion = m_communication->GetFirmwareVersion(); | |
1741 | config->iPhysicalAddress = m_communication->GetPhysicalAddress(); | |
1742 | ||
1743 | delete m_communication; | |
f3b6afa4 | 1744 | m_communication = NULL; |
f80cd208 LOK |
1745 | return true; |
1746 | } |