Skip to content

Commit

Permalink
Configure Input Groups in mythtv-setup
Browse files Browse the repository at this point in the history
Capture cards can be configured so that only one capture card of a
group of capture cards can be used at any one time. This is done
by defining an Input Group and then assigning that group to all
capture cards that are to be part of the group.
Configuring this with mythtv-setup has always been possible but there
was a bug that allowed only one card to be configured as member of an
input group. This bug is now fixed.

Based on commit 973edd2 in master.

Refs #698
  • Loading branch information
kmdewaal committed Jan 21, 2023
1 parent e677dd3 commit 71d44af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 14 additions & 3 deletions mythtv/libs/libmythtv/cardutil.cpp
Expand Up @@ -2016,10 +2016,18 @@ bool CardUtil::LinkInputGroup(uint inputid, uint inputgroupid)
return false;
}

if (!query.next())
return false;
QString name;
while (query.next()) {
name = query.value(2).toString();
uint cardid = query.value(0).toUInt();
// Already linked
if (cardid == inputid)
return true;
}

const QString name = query.value(2).toString();
// Invalid group id
if (name.isEmpty())
return false;

query.prepare(
"INSERT INTO inputgroup "
Expand All @@ -2036,6 +2044,9 @@ bool CardUtil::LinkInputGroup(uint inputid, uint inputgroupid)
return false;
}

// Now that there is a proper linkage, unlink temporary cardid 0
UnlinkInputGroup(0, inputgroupid);

return true;
}

Expand Down
10 changes: 2 additions & 8 deletions mythtv/libs/libmythtv/videosource.cpp
Expand Up @@ -2913,14 +2913,11 @@ class InputGroup : public TransMythUIComboBoxSetting
uint inputid = m_cardInput.getInputID();
uint new_groupid = getValue().toUInt();

if (m_groupId)
if (m_groupId && (m_groupId != new_groupid))
CardUtil::UnlinkInputGroup(inputid, m_groupId);

if (new_groupid)
{
if (CardUtil::UnlinkInputGroup(inputid, new_groupid))
CardUtil::LinkInputGroup(inputid, new_groupid);
}
CardUtil::LinkInputGroup(inputid, new_groupid);
}

virtual void Save(const QString& /*destination*/) { Save(); }
Expand Down Expand Up @@ -3525,9 +3522,6 @@ void CardInput::Save(void)
{
CardUtil::CloneCard(cardid, 0);
}

// Delete any unused input groups
CardUtil::UnlinkInputGroup(0,0);
}

int CardInputDBStorage::getInputID(void) const
Expand Down

0 comments on commit 71d44af

Please sign in to comment.