diff options
author | ksooo <3226626+ksooo@users.noreply.github.com> | 2023-10-15 10:14:16 +0200 |
---|---|---|
committer | ksooo <3226626+ksooo@users.noreply.github.com> | 2023-10-15 10:15:08 +0200 |
commit | 91ab7c60d93c0c060b37c115863df21d3f9e4262 (patch) | |
tree | 54581b2832795cba2a1c956e680570ca2eee47e5 | |
parent | 4e5909fa999402a36469d20d2107364bcdb8e0c7 (diff) | |
download | xbmc-91ab7c60d93c0c060b37c115863df21d3f9e4262.tar.xz |
[PVR] Fix 'switch to previous channel' not working if it is in another group than the currently playing channel.
-rw-r--r-- | xbmc/pvr/guilib/PVRGUIActionsChannels.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp b/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp index 0527c1ba65..fe1b652273 100644 --- a/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp +++ b/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp @@ -77,6 +77,32 @@ void CPVRChannelSwitchingInputHandler::OnInputDone() SwitchToChannel(channelNumber); } +namespace +{ +void UpdateActiveGroup(const std::shared_ptr<CPVRChannelGroupMember>& newChannel) +{ + const std::shared_ptr<CPVRPlaybackState> playbackState{ + CServiceBroker::GetPVRManager().PlaybackState()}; + const std::shared_ptr<CPVRChannelGroupsContainer> groups{ + CServiceBroker::GetPVRManager().ChannelGroups()}; + const std::shared_ptr<CPVRChannelGroup> group{ + groups->Get(newChannel->IsRadio())->GetById(newChannel->GroupID())}; + + // Switch group if new channel is not in the active group. + if (group && group != playbackState->GetActiveChannelGroup(newChannel->IsRadio())) + playbackState->SetActiveChannelGroup(group); +} + +void TriggerChannelSwitchAction(const CPVRChannelNumber& channelNumber) +{ + CServiceBroker::GetAppMessenger()->PostMsg( + TMSG_GUI_ACTION, WINDOW_INVALID, -1, + static_cast<void*>(new CAction(ACTION_CHANNEL_SWITCH, + static_cast<float>(channelNumber.GetChannelNumber()), + static_cast<float>(channelNumber.GetSubChannelNumber())))); +} +} // unnamed namespace + void CPVRChannelSwitchingInputHandler::SwitchToChannel(const CPVRChannelNumber& channelNumber) { if (channelNumber.IsValid() && CServiceBroker::GetPVRManager().PlaybackState()->IsPlaying()) @@ -115,11 +141,8 @@ void CPVRChannelSwitchingInputHandler::SwitchToChannel(const CPVRChannelNumber& if (groupMember) { - CServiceBroker::GetAppMessenger()->PostMsg( - TMSG_GUI_ACTION, WINDOW_INVALID, -1, - static_cast<void*>(new CAction( - ACTION_CHANNEL_SWITCH, static_cast<float>(channelNumber.GetChannelNumber()), - static_cast<float>(channelNumber.GetSubChannelNumber())))); + UpdateActiveGroup(groupMember); + TriggerChannelSwitchAction(channelNumber); } } } @@ -139,12 +162,8 @@ void CPVRChannelSwitchingInputHandler::SwitchToPreviousChannel() playbackState->GetPreviousToLastPlayedChannelGroupMember(playingChannel->IsRadio()); if (groupMember) { - const CPVRChannelNumber channelNumber = groupMember->ChannelNumber(); - CServiceBroker::GetAppMessenger()->SendMsg( - TMSG_GUI_ACTION, WINDOW_INVALID, -1, - static_cast<void*>(new CAction( - ACTION_CHANNEL_SWITCH, static_cast<float>(channelNumber.GetChannelNumber()), - static_cast<float>(channelNumber.GetSubChannelNumber())))); + UpdateActiveGroup(groupMember); + TriggerChannelSwitchAction(groupMember->ChannelNumber()); } } } |