| 149 | } |
| 150 | |
| 151 | void Track::DoSetLinkType(LinkType linkType, bool completeList) |
| 152 | { |
| 153 | auto oldType = GetLinkType(); |
| 154 | if (linkType == oldType) |
| 155 | // No change |
| 156 | return; |
| 157 | |
| 158 | if (oldType == LinkType::None) { |
| 159 | // Becoming linked |
| 160 | |
| 161 | // First ensure that the previous does not link to this |
| 162 | if (auto partner = GetLinkedTrack()) |
| 163 | partner->mLinkType = LinkType::None; |
| 164 | assert(!GetLinkedTrack()); |
| 165 | |
| 166 | // Change my link type |
| 167 | mLinkType = linkType; |
| 168 | |
| 169 | // Keep link consistency, while still in un-zipped state |
| 170 | if (auto partner = GetLinkedTrack()) { |
| 171 | partner->mLinkType = LinkType::None; |
| 172 | partner->CopyGroupProperties(*this); |
| 173 | } |
| 174 | } |
| 175 | else if (linkType == LinkType::None) { |
| 176 | // Becoming unlinked |
| 177 | if (HasLinkedTrack()) { |
| 178 | if (auto partner = GetLinkedTrack()) { |
| 179 | // Make independent copy of group data in the partner, which should |
| 180 | // have had none |
| 181 | ChannelGroupAttachments &base = *partner; |
| 182 | // Intentional slice assignment deep-copies the attachment array: |
| 183 | base = *this; |
| 184 | partner->CopyGroupProperties(*this); |
| 185 | partner->mLinkType = LinkType::None; |
| 186 | } |
| 187 | } |
| 188 | mLinkType = LinkType::None; |
| 189 | } |
| 190 | else |
| 191 | // Remaining linked, changing the type |
| 192 | mLinkType = linkType; |
| 193 | |
| 194 | // Assertion checks only in a debug build, does not have side effects! |
| 195 | assert(!completeList || LinkConsistencyCheck()); |
| 196 | } |
| 197 | |
| 198 | Track *Track::GetLinkedTrack() const |
| 199 | { |
nothing calls this directly
no test coverage detected