From 5132a3058ac546990f560ed23880e89835bb5128 Mon Sep 17 00:00:00 2001 From: louis Date: Wed, 22 Jan 2014 17:43:53 +0100 Subject: [PATCH] fixed a possible deadlock when switching to a channel which is not available --- tvguideosd.c | 29 +++++++++++++++++------------ tvguideosd.h | 6 +++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/tvguideosd.c b/tvguideosd.c index 696b791..15f84bd 100644 --- a/tvguideosd.c +++ b/tvguideosd.c @@ -499,9 +499,9 @@ void cTvGuideOsd::processKeyYellow() { } } -eOSState cTvGuideOsd::processKeyBlue() { +eOSState cTvGuideOsd::processKeyBlue(bool *alreadyUnlocked) { if (tvguideConfig.blueKeyMode == eBlueKeySwitch) { - return ChannelSwitch(); + return ChannelSwitch(alreadyUnlocked); } else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) { DetailedEPG(); } else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) { @@ -510,22 +510,24 @@ eOSState cTvGuideOsd::processKeyBlue() { return osContinue; } -eOSState cTvGuideOsd::processKeyOk() { +eOSState cTvGuideOsd::processKeyOk(bool *alreadyUnlocked) { if (tvguideConfig.blueKeyMode == eBlueKeySwitch) { DetailedEPG(); } else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) { - return ChannelSwitch(); + return ChannelSwitch(alreadyUnlocked); } else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) { DetailedEPG(); } return osContinue; } -eOSState cTvGuideOsd::ChannelSwitch() { +eOSState cTvGuideOsd::ChannelSwitch(bool *alreadyUnlocked) { if (activeGrid == NULL) return osContinue; const cChannel *currentChannel = activeGrid->column->getChannel(); if (currentChannel) { + cPixmap::Unlock(); + *alreadyUnlocked = true; cDevice::PrimaryDevice()->SwitchChannel(currentChannel, true); if (tvguideConfig.closeOnSwitch) { if (detailView) { @@ -647,6 +649,7 @@ void cTvGuideOsd::SetTimers() { eOSState cTvGuideOsd::ProcessKey(eKeys Key) { eOSState state = osContinue; cPixmap::Lock(); + bool alreadyUnlocked = false; if (recMenuManager->isActive()) { state = recMenuManager->ProcessKey(Key); if (state == osEnd) { @@ -664,9 +667,9 @@ eOSState cTvGuideOsd::ProcessKey(eKeys Key) { delete detailView; detailView = NULL; detailViewActive = false; - if ((tvguideConfig.blueKeyMode == eBlueKeySwitch) || (tvguideConfig.blueKeyMode == eBlueKeyFavorites)) - state = ChannelSwitch(); - else { + if ((tvguideConfig.blueKeyMode == eBlueKeySwitch) || (tvguideConfig.blueKeyMode == eBlueKeyFavorites)) { + state = ChannelSwitch(&alreadyUnlocked); + } else { osdManager.flush(); state = osContinue; } @@ -674,7 +677,7 @@ eOSState cTvGuideOsd::ProcessKey(eKeys Key) { delete detailView; detailView = NULL; detailViewActive = false; - state = ChannelSwitch(); + state = ChannelSwitch(&alreadyUnlocked); } else { state = detailView->ProcessKey(Key); if (state == osEnd) { @@ -694,15 +697,17 @@ eOSState cTvGuideOsd::ProcessKey(eKeys Key) { case kRed: processKeyRed(); break; case kGreen: processKeyGreen(); break; case kYellow: processKeyYellow(); break; - case kBlue: state = processKeyBlue(); break; - case kOk: state = processKeyOk(); break; + case kBlue: state = processKeyBlue(&alreadyUnlocked); break; + case kOk: state = processKeyOk(&alreadyUnlocked); break; case kBack: state=osEnd; break; case k0 ... k9: processNumKey(Key - k0); break; case kNone: if (channelJumper) CheckTimeout(); break; default: break; } } - cPixmap::Unlock(); + if (!alreadyUnlocked) { + cPixmap::Unlock(); + } return state; } diff --git a/tvguideosd.h b/tvguideosd.h index cc266ef..1e6a990 100644 --- a/tvguideosd.h +++ b/tvguideosd.h @@ -38,8 +38,8 @@ private: void processKeyRed(); void processKeyGreen(); void processKeyYellow(); - eOSState processKeyBlue(); - eOSState processKeyOk(); + eOSState processKeyBlue(bool *alreadyUnlocked); + eOSState processKeyOk(bool *alreadyUnlocked); void processNumKey(int numKey); void TimeJump(int mode); void ChannelJump(int num); @@ -51,7 +51,7 @@ private: void timeBack(); void ScrollForward(); void ScrollBack(); - eOSState ChannelSwitch(); + eOSState ChannelSwitch(bool *alreadyUnlocked); void DetailedEPG(); void SetTimers(); void dump();