Skip to content

Commit 67d444d

Browse files
committed
fixed: send an active source message when a routing change has been received with libCEC's address as new route and no active source message has been sent yet. issue Pulse-Eight#309 Pulse-Eight#205 Pulse-Eight#233
1 parent e1df683 commit 67d444d

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Diff for: src/libcec/devices/CECBusDevice.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi
153153
m_bAwaitingReceiveFailed(false),
154154
m_bVendorIdRequested (false),
155155
m_waitForResponse (new CWaitForResponse),
156-
m_bImageViewOnSent (false)
156+
m_bImageViewOnSent (false),
157+
m_bActiveSourceSent (false)
157158
{
158159
m_handler = new CCECCommandHandler(this);
159160
m_strDeviceName = ToString(m_iLogicalAddress);
@@ -685,6 +686,9 @@ void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
685686
m_iLastPowerStateUpdate = GetTimeMs();
686687
LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(powerStatus));
687688
m_powerStatus = powerStatus;
689+
690+
if (m_iLogicalAddress == CECDEVICE_TV)
691+
m_processor->GetDevices()->ResetActiveSourceSent();
688692
}
689693
}
690694

@@ -1141,6 +1145,7 @@ bool CCECBusDevice::TransmitActiveSource(bool bIsReply)
11411145
if (bSendActiveSource)
11421146
{
11431147
MarkBusy();
1148+
SetActiveSourceSent(true);
11441149
bActiveSourceSent = m_handler->TransmitActiveSource(m_iLogicalAddress, iPhysicalAddress, bIsReply);
11451150
MarkReady();
11461151
}
@@ -1215,7 +1220,7 @@ void CCECBusDevice::SetActiveRoute(uint16_t iRoute)
12151220
return;
12161221

12171222
CCECBusDevice* newRoute = m_processor->GetDeviceByPhysicalAddress(iRoute, true);
1218-
if (newRoute && newRoute->IsHandledByLibCEC() && !newRoute->IsActiveSource())
1223+
if (newRoute && newRoute->IsHandledByLibCEC() && (!ActiveSourceSent() || !newRoute->IsActiveSource()))
12191224
{
12201225
// we were made the active source, send notification
12211226
newRoute->ActivateSource();
@@ -1498,3 +1503,13 @@ bool CCECBusDevice::TransmitMuteAudio(const cec_logical_address source)
14981503
return TransmitKeypress(source, CEC_USER_CONTROL_CODE_MUTE) &&
14991504
TransmitKeyRelease(source);
15001505
}
1506+
1507+
void CCECBusDevice::SetActiveSourceSent(bool setto = true)
1508+
{
1509+
m_bActiveSource = setto;
1510+
}
1511+
1512+
bool CCECBusDevice::ActiveSourceSent(void) const
1513+
{
1514+
return m_bActiveSourceSent;
1515+
}

Diff for: src/libcec/devices/CECBusDevice.h

+4
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ namespace CEC
199199
void SignalOpcode(cec_opcode opcode);
200200
bool WaitForOpcode(cec_opcode opcode);
201201

202+
void SetActiveSourceSent(bool setto = true);
203+
bool ActiveSourceSent(void) const;
204+
202205
CCECAudioSystem * AsAudioSystem(void);
203206
static CCECAudioSystem * AsAudioSystem(CCECBusDevice *device);
204207
CCECPlaybackDevice * AsPlaybackDevice(void);
@@ -243,5 +246,6 @@ namespace CEC
243246
bool m_bVendorIdRequested;
244247
CWaitForResponse *m_waitForResponse;
245248
bool m_bImageViewOnSent;
249+
bool m_bActiveSourceSent;
246250
};
247251
};

Diff for: src/libcec/devices/CECDeviceMap.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ CCECBusDevice *CCECDeviceMap::GetActiveSource(void) const
212212
return NULL;
213213
}
214214

215+
void CCECDeviceMap::ResetActiveSourceSent(void)
216+
{
217+
for (CECDEVICEMAP::iterator it = m_busDevices.begin(); it != m_busDevices.end(); it++)
218+
it->second->SetActiveSourceSent(false);
219+
}
220+
215221
void CCECDeviceMap::FilterLibCECControlled(CECDEVICEVEC &devices)
216222
{
217223
CECDEVICEVEC newDevices;

Diff for: src/libcec/devices/CECDeviceMap.h

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace CEC
7171
void GetWakeDevices(const libcec_configuration &configuration, CECDEVICEVEC &devices) const;
7272

7373
CCECBusDevice *GetActiveSource(void) const;
74+
void ResetActiveSourceSent(void);
7475

7576
static void FilterLibCECControlled(CECDEVICEVEC &devices);
7677
static void FilterActive(CECDEVICEVEC &devices);

0 commit comments

Comments
 (0)